Multiple ant support

This commit is contained in:
Pascal Serrarens 2025-02-14 09:08:08 +01:00
parent 3e5da90f47
commit 78aed40a9b
4 changed files with 11 additions and 5 deletions

View File

@ -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);
}

View File

@ -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);
}
}
}

View File

@ -22,7 +22,7 @@ namespace Passer.Control.Unity {
GameObject distanceObj = new("Distance sensor");
DistanceSensor component = distanceObj.AddComponent<DistanceSensor>();
if (parent != null && parent.component != null)
distanceObj.transform.SetParent(parent.component.transform);
distanceObj.transform.SetParent(parent.component.transform, false);
return component;
}

View File

@ -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();
}
}
}
}