Fix event order handling for diff.drive
This commit is contained in:
parent
9bfa288465
commit
66c494ad60
@ -50,10 +50,14 @@ namespace RoboidControl.Unity {
|
||||
coreDrive.component = differentialDrive;
|
||||
break;
|
||||
case RoboidControl.Motor coreMotor:
|
||||
if (coreMotor.component == null) {
|
||||
Motor wheel = Motor.Create(coreMotor);
|
||||
coreMotor.component = wheel;
|
||||
// We need to know the details (though a binary msg)
|
||||
// before we can create the wheel reliably
|
||||
}
|
||||
else // Update the component from the core
|
||||
coreMotor.component.Init(coreMotor);
|
||||
break;
|
||||
case RoboidControl.Thing coreThing:
|
||||
if (coreThing.component == null) {
|
||||
@ -69,6 +73,8 @@ namespace RoboidControl.Unity {
|
||||
thing = Thing.Create(coreThing);
|
||||
coreThing.component = thing;
|
||||
}
|
||||
else // Update the component from the core
|
||||
coreThing.component.Init(coreThing);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ namespace RoboidControl.Unity {
|
||||
/// </summary>
|
||||
/// <param name="core">The core of the thing</param>
|
||||
/// This affects the parent and pose of the thing
|
||||
protected void Init(RoboidControl.Thing core) {
|
||||
public void Init(RoboidControl.Thing core) {
|
||||
this.core = core;
|
||||
this.core.component = this;
|
||||
// This is wrong, it should get the owner, which is not the siteserver
|
||||
|
@ -111,9 +111,8 @@ namespace RoboidControl {
|
||||
aThing.owner.networkId == networkId &&
|
||||
aThing.id == thingId
|
||||
);
|
||||
//Thing thing = things.Find(aThing => Thing.IsThing(aThing, networkId, thingId));
|
||||
if (thing == null)
|
||||
Console.WriteLine($"Unknown Thing {this.networkId} [{networkId}/{thingId}]");
|
||||
// if (thing == null)
|
||||
// Console.WriteLine($"Unknown Thing {this.networkId} [{networkId}/{thingId}]");
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
@ -465,15 +465,16 @@ namespace RoboidControl {
|
||||
}
|
||||
|
||||
Thing thing = owner.Get(msg.networkId, msg.thingId);
|
||||
if (sender.networkId != owner.networkId) {
|
||||
// Sender forwarded this thing msg
|
||||
// So this is a remote thing
|
||||
thing ??= ProcessNewThing(owner, msg, true);
|
||||
if (thing != null) {
|
||||
UpdateEvent e = new() {
|
||||
messageId = ThingMsg.id,
|
||||
thing = thing
|
||||
};
|
||||
owner.updateQueue.Enqueue(e);
|
||||
}
|
||||
else {
|
||||
// Sender is the owner of the thing
|
||||
// So this is a simulated thing
|
||||
thing ??= ProcessNewThing(owner, msg, false);
|
||||
bool isRemote = sender.networkId != owner.networkId;
|
||||
thing = ProcessNewThing(owner, msg, isRemote);
|
||||
}
|
||||
|
||||
if (msg.parentId != 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user