Compliency fixes

This commit is contained in:
Pascal Serrarens 2025-06-05 11:37:29 +02:00
parent a5664dea9d
commit f3b863692b
7 changed files with 14 additions and 10 deletions

View File

@ -44,10 +44,10 @@ namespace RoboidControl.Unity {
// before we can create the wheel reliably
break;
case RoboidControl.Thing coreThing:
Debug.Log("Handle Thing");
// Debug.Log("Handle Thing");
if (coreThing.component == null) {
Thing[] things = FindObjectsByType<Thing>(FindObjectsSortMode.None);
Debug.Log(things.Length);
// Debug.Log(things.Length);
Thing thing = things.FirstOrDefault(t => t.core != null && t.core.id == coreThing.id);
if (thing == null)
thing = Thing.Create(coreThing);

View File

@ -30,7 +30,7 @@ namespace RoboidControl.Unity {
while (site.updateQueue.TryDequeue(out RoboidControl.Participant.UpdateEvent e))
HandleUpdateEvent(e);
site.Update((ulong)(Time.time * 1000));
site.Update();
// while (thingQueue.TryDequeue(out RoboidControl.Thing thing))
// thing.CreateComponent();
}

View File

@ -212,9 +212,8 @@ namespace RoboidControl.Unity {
}
}
}
else {
ScanForThings(parentTransform);
}
else
ScanForThings(parentTransform);
}
else {
this.transform.localScale = Vector3.one * 1;
@ -230,7 +229,7 @@ namespace RoboidControl.Unity {
for (int thingIx = 0; thingIx < thingArray.Length; thingIx++) {
RoboidControl.Thing thing = thingArray[thingIx];
GameObject foundObj = FindThingByName(thing, rootTransform);
if (foundObj != null && foundObj != thing.component.gameObject) {
if (foundObj != null && (thing.component != null && foundObj != thing.component.gameObject)) {
Thing foundThing = foundObj.GetComponent<Thing>();
if (foundThing == null) {
Debug.Log($"move thing [{thing.owner.networkId}/{thing.id}] to {foundObj.name}");
@ -242,6 +241,9 @@ namespace RoboidControl.Unity {
Destroy(thing.component.gameObject);
thing.component = foundThing;
}
else {
Debug.LogWarning($"Could not find [{thing.owner.networkId}/{thing.id}]");
}
}
}
}

View File

@ -58,7 +58,7 @@ namespace RoboidControl {
float horizontal = ReceiveAngle8(data, ref ix);
float vertical = ReceiveAngle8(data, ref ix);
float twist = ReceiveAngle8(data, ref ix);
System.Console.Write($"receive st: {horizontal} {vertical} {twist}");
// System.Console.Write($"receive st: {horizontal} {vertical} {twist}");
SwingTwist r = SwingTwist.Degrees(horizontal, vertical, twist);
return r;

View File

@ -163,6 +163,7 @@ namespace RoboidControl {
/// The thing relevant fo the event
/// </summary>
public Thing thing;
public Participant participant;
}
/// <summary>
/// Queue containing events happened to this participant

View File

@ -401,7 +401,7 @@ namespace RoboidControl {
protected virtual void Process(Participant sender, PoseMsg msg) {
#if DEBUG
Console.WriteLine($"{this.name}: Process PoseMsg [{msg.networkId}/{msg.thingId}] {msg.poseType}");
// Console.WriteLine($"{this.name}: Process PoseMsg [{msg.networkId}/{msg.thingId}] {msg.poseType}");
#endif
Participant owner = Participant.GetParticipant(msg.networkId);
if (owner == null)

View File

@ -104,7 +104,8 @@ namespace RoboidControl {
// this.Send(sender, new NetworkIdMsg(sender.networkId));
sender.Send(new NetworkIdMsg(sender.networkId));
UpdateEvent e = new() {
messageId = ParticipantMsg.Id
messageId = ParticipantMsg.Id,
participant = sender
};
this.updateQueue.Enqueue(e);
}