Skip to content
Snippets Groups Projects
Commit 733a633f authored by MaZiFAU's avatar MaZiFAU
Browse files

Fixed Bugs; Added PluginAssembly;

Fixed Bugs:
+multiple hits logic/highlight/remover

Added PluginAssembly:
+should help with compile time
parent cc85781e
No related branches found
No related tags found
No related merge requests found
{
"name": "PluginAssembly",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
\ No newline at end of file
fileFormatVersion: 2
guid: 4db3019411610f640ae53ea9ba8dab0a
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -493,7 +493,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -33793.79}
m_AnchoredPosition: {x: 0, y: -41183.812}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &8823539307371861913
......
......@@ -20,7 +20,7 @@ MonoBehaviour:
ButtonIndx: 1
LayerHitMask:
serializedVersion: 2
m_Bits: 1572913
m_Bits: 1581105
SecondaryLayerMask:
serializedVersion: 2
m_Bits: 0
......@@ -162,7 +162,7 @@ public void CoroutineCascadeForMeAndChildrenAllRenderer(Func<FactObject, Rendere
CascadeForMeAndChildren((FactObject fo) =>
fo.ForAllRenderer((Renderer ren) =>
StartCoroutine(func(fo, ren))
this.StartCoroutine(func(fo, ren))
));
}
}
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static CommunicationEvents;
......@@ -12,13 +13,17 @@ public class Remover : Gadget
public override void _Hit(RaycastHit[] hit)
{
// It's probably better to keep this only on the first hit and not multiple hits
string hid = hit[0].transform.GetComponent<FactObject>()?.URI;
if (hid == null)
return;
bool samestep = false;
foreach (string uri in hit.Select(h => h.transform.GetComponent<FactObject>()?.URI))
{
if(uri == null)
continue;
Workflow.Add(uri);
StageStatic.stage.factState.Remove(Workflow.Last(), samestep, gadget: this);
Workflow.Add(hid);
StageStatic.stage.factState.Remove(Workflow[0], samestep: false, gadget: this);
samestep = true;
}
ResetGadget();
}
......
......@@ -7,7 +7,7 @@ public class ShinyThings : MonoBehaviour
{
public WorldCursor Cursor;
//Attributes for Highlighting of Facts when Mouse-Over
private FactObject lastFactSelection;
private List<FactObject> LastFactSelection = new();
//Variables for Pushout-Highlighting
private static float timerDuration = 2.5f;
......@@ -34,10 +34,7 @@ private void Awake()
CommunicationEvents.AnimateExistingAsSolutionEvent.AddListener(HighlightWithFireworks);
rain = rain_wait = IEnumeratorExtensions.yield_break;
}
public void Start()
{
if (Cursor == null)
Cursor = GetComponent<WorldCursor>();
......@@ -49,30 +46,30 @@ public void Start()
public void Update()
{
foreach(var hit in Cursor.Hits)
HighlightCurserHit(hit);
if (Cursor?.Hits != null)
HighlightCurserHit(Cursor.Hits);
}
private void HighlightCurserHit(RaycastHit hit)
private void HighlightCurserHit(RaycastHit[] hits)
{
FactObject selected_fact_obj = hit.transform?.GetComponentInChildren<FactObject>();
//Set the last Fact unselected
if (this.lastFactSelection != null
&& (selected_fact_obj == null || this.lastFactSelection != selected_fact_obj))
{
ApplyMaterial(lastFactSelection, lastFactSelection.Default);
this.lastFactSelection = null;
}
//Set the Fact that was Hit as selected
if (selected_fact_obj != null && hit.transform != null
&& (hit.transform.CompareTag("Selectable") || hit.transform.CompareTag("SnapZone"))
&& (this.lastFactSelection == null || this.lastFactSelection != selected_fact_obj))
{
ApplyMaterial(selected_fact_obj, selected_fact_obj.Selected);
this.lastFactSelection = selected_fact_obj;
}
List<FactObject> selected_fact_objs = hits
.Select(h => h.transform?.GetComponentInChildren<FactObject>())
.Where(f => f != null)
.ToList();
//Set the last Facts unselected
foreach (var lastFact in LastFactSelection)
if (lastFact != null
&& !selected_fact_objs.Contains(lastFact))
ApplyMaterial(lastFact, lastFact.Default);
//Set the Facts that were Hit as selected
foreach (var fact_obj in selected_fact_objs)
if (!LastFactSelection.Contains(fact_obj))
ApplyMaterial(fact_obj, fact_obj.Selected);
LastFactSelection = selected_fact_objs;
return;
void ApplyMaterial(FactObject root, Material new_mat) =>
root.CoroutineCascadeForMeAndChildrenAllRenderer(
......
......@@ -11,7 +11,7 @@ public class WorldCursor : MonoBehaviour
// TODO experimentell for multiple hits
public RaycastHit[] Hits;
public float CollisionDistance = 0.1f;
public float IntersectionDistance = 0.1f;
public string deactivateSnapKey;
private Camera Cam;
......@@ -118,9 +118,15 @@ void Update()
break; // we had at least 1 succesfull case
}
if (i + 1 < Hits.Length
&& Hits[i + 1].distance - Hits[i + 0].distance < CollisionDistance)
{ // we have two objects intersecting
if (i == Hits.Length)
return; // no valid Hit
Hits = Hits.Skip(i)
.TakeWhile(h => h.distance - Hits[i].distance < IntersectionDistance)
.ToArray();
if (Hits.Length > 1)
{ // we have two or more objects intersecting
if (facts[i + 0] is RayFact rayFact1
&& facts[i + 1] is RayFact rayFact2)
{
......@@ -128,21 +134,14 @@ void Update()
, rayFact2.Point1.Point, rayFact2.Dir
, rayFact1.Point1.Point, rayFact1.Dir))
{
Hits[i].point = intersectionPoint;
Hits[i + 0].point = intersectionPoint;
Hits[i + 1].point = intersectionPoint;
}
}
//TODO: check for other types of intersection. Future Work
}
int nr_hits = Hits.Length - i;
if (i == Hits.Length)
{
i = 0;
nr_hits = 1;
}
Hits = Hits.Slice(i, nr_hits).ToArray();
transform.up = Hits[0].normal;
transform.position = Hits[0].point + .01f * Hits[0].normal;
......
......@@ -33,7 +33,7 @@ public void RevertMode()
/// <param name="select">Page to switch to</param>
public void SetMode(int select)
{
gameObject.SetActiveAllChildren(false);
Pages.SetActiveAllChildren(false);
mode_last = mode;
mode = select;
......
......@@ -30,10 +30,10 @@ EditorUserSettings:
value: 00540c020302515f0b0f5f2711265c44171519797e7c7463787d4d63e1b8303c
flags: 0
RecentlyUsedSceneGuid-8:
value: 57505505560608585a56557116730644404e4d7b7c7b7562787e4f66e4b1313e
value: 0709560454055c0d0c5e5c2444740b4413154a72792d22627c714963e0b6373d
flags: 0
RecentlyUsedSceneGuid-9:
value: 0709560454055c0d0c5e5c2444740b4413154a72792d22627c714963e0b6373d
value: 57505505560608585a56557116730644404e4d7b7c7b7562787e4f66e4b1313e
flags: 0
RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c681f041b1c39631c3435281e1221eee47a2decee22f0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment