diff --git a/Participant.cs b/Participant.cs index ffecf5d..40f71ed 100644 --- a/Participant.cs +++ b/Participant.cs @@ -134,7 +134,9 @@ namespace Passer.Control.Core { this.nextPublishMe = currentTimeMS + this.publishInterval; } - foreach (Thing thing in this.things) { + int n = this.things.Count; + for (int ix = 0; ix < n; ix++) { + Thing thing = this.things[ix]; if (thing != null && thing.parent == null) // update only root things thing.Update(currentTimeMS); } diff --git a/RemoteParticipant.cs b/RemoteParticipant.cs index 500bc41..cc3c0ce 100644 --- a/RemoteParticipant.cs +++ b/RemoteParticipant.cs @@ -31,13 +31,17 @@ namespace Passer.Control.Core { Thing foundThing = Get(thing.networkId, thing.id); if (foundThing == null) { - // if (thing.id == 0) - // thing.id = (byte)(things.Count + 1); things.Add(thing); if (invokeEvent) Thing.InvokeNewThing(thing); // Console.Write($"Add thing {ipAddress}:{port}[{networkId}/{thing.id}]"); + } else { + if (thing != foundThing) { + // should be: find first non-existing id... + thing.id = (byte)this.things.Count; + things.Add(thing); + } } } diff --git a/Unity/DistanceSensor.cs b/Unity/DistanceSensor.cs index c623c15..6dc1fdf 100644 --- a/Unity/DistanceSensor.cs +++ b/Unity/DistanceSensor.cs @@ -22,7 +22,7 @@ namespace Passer.Control.Unity { GameObject distanceObj = new("Distance sensor"); DistanceSensor component = distanceObj.AddComponent(); if (parent != null && parent.component != null) - distanceObj.transform.SetParent(parent.component.transform); + distanceObj.transform.SetParent(parent.component.transform, false); return component; } diff --git a/Unity/SiteServer.cs b/Unity/SiteServer.cs index 628ab09..6431eb3 100644 --- a/Unity/SiteServer.cs +++ b/Unity/SiteServer.cs @@ -22,6 +22,7 @@ namespace Passer.Control.Unity { } public void HandleNewThing(Core.Thing thing) { + site.Add(thing, false); thingQueue.Enqueue(thing); } @@ -31,7 +32,6 @@ namespace Passer.Control.Unity { thing.CreateComponent(); } } - } }