Fix many RemoteParticipants in Unity
This commit is contained in:
parent
7f063e0434
commit
ad8e587f65
@ -49,14 +49,13 @@ namespace RoboidControl.Unity {
|
|||||||
Participant participant = remoteParticipant.AddComponent<Participant>();
|
Participant participant = remoteParticipant.AddComponent<Participant>();
|
||||||
participant.coreParticipant = e.participant;
|
participant.coreParticipant = e.participant;
|
||||||
participant.coreParticipant.component = participant;
|
participant.coreParticipant.component = participant;
|
||||||
ParticipantUDP participantUDP = participant.coreParticipant as ParticipantUDP;
|
if (participant.coreParticipant is ParticipantUDP participantUDP) {
|
||||||
if (participantUDP != null) {
|
|
||||||
participant.ipAddress = participantUDP.ipAddress;
|
participant.ipAddress = participantUDP.ipAddress;
|
||||||
participant.port = participantUDP.port;
|
participant.port = participantUDP.port;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (RoboidControl.Thing thing in this.site.things)
|
foreach (RoboidControl.Thing thing in this.site.things)
|
||||||
participant.coreParticipant.SendThingInfo(thing);
|
participant.coreParticipant.SendThingInfo(thing);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ThingMsg.id:
|
case ThingMsg.id:
|
||||||
|
@ -120,7 +120,7 @@ namespace RoboidControl {
|
|||||||
public override byte Serialize(ref byte[] buffer) {
|
public override byte Serialize(ref byte[] buffer) {
|
||||||
if (poseType == 0)
|
if (poseType == 0)
|
||||||
return 0;
|
return 0;
|
||||||
#if DEBUG
|
#if DEBUG2
|
||||||
System.Console.WriteLine($"Send PoseMsg [{this.networkId}/{this.thingId}] {this.poseType}");
|
System.Console.WriteLine($"Send PoseMsg [{this.networkId}/{this.thingId}] {this.poseType}");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -325,12 +325,13 @@ namespace RoboidControl {
|
|||||||
if (sender == null) {
|
if (sender == null) {
|
||||||
sender = AddParticipant(ipAddress, endPoint.Port, this);
|
sender = AddParticipant(ipAddress, endPoint.Port, this);
|
||||||
sender.isRemote = true;
|
sender.isRemote = true;
|
||||||
}
|
|
||||||
|
|
||||||
UpdateEvent e = new() {
|
|
||||||
messageId = NetworkIdMsg.Id,
|
UpdateEvent e = new() {
|
||||||
participant = sender
|
messageId = NetworkIdMsg.Id,
|
||||||
};
|
participant = sender
|
||||||
|
};
|
||||||
|
}
|
||||||
this.updateQueue.Enqueue(e);
|
this.updateQueue.Enqueue(e);
|
||||||
|
|
||||||
ReceiveData(data, sender);
|
ReceiveData(data, sender);
|
||||||
@ -457,6 +458,7 @@ namespace RoboidControl {
|
|||||||
// Console.Write($"Dropped {thing.id}");
|
// Console.Write($"Dropped {thing.id}");
|
||||||
thing.parent = null;
|
thing.parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ForwardMessage(sender, msg);
|
ForwardMessage(sender, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,6 +481,8 @@ namespace RoboidControl {
|
|||||||
Thing thing = sender.Get(msg.thingId);
|
Thing thing = sender.Get(msg.thingId);
|
||||||
if (thing != null)
|
if (thing != null)
|
||||||
thing.name = msg.name;
|
thing.name = msg.name;
|
||||||
|
|
||||||
|
ForwardMessage(sender, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Process(Participant sender, ModelUrlMsg msg) {
|
protected virtual void Process(Participant sender, ModelUrlMsg msg) {
|
||||||
@ -489,6 +493,8 @@ namespace RoboidControl {
|
|||||||
Thing thing = sender.Get(msg.thingId);
|
Thing thing = sender.Get(msg.thingId);
|
||||||
if (thing != null)
|
if (thing != null)
|
||||||
thing.modelUrl = msg.url;
|
thing.modelUrl = msg.url;
|
||||||
|
|
||||||
|
ForwardMessage(sender, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Process(Participant sender, PoseMsg msg) {
|
protected virtual void Process(Participant sender, PoseMsg msg) {
|
||||||
@ -511,6 +517,8 @@ namespace RoboidControl {
|
|||||||
thing.linearVelocity = msg.linearVelocity;
|
thing.linearVelocity = msg.linearVelocity;
|
||||||
if ((msg.poseType & PoseMsg.Pose_AngularVelocity) != 0)
|
if ((msg.poseType & PoseMsg.Pose_AngularVelocity) != 0)
|
||||||
thing.angularVelocity = msg.angularVelocity;
|
thing.angularVelocity = msg.angularVelocity;
|
||||||
|
|
||||||
|
ForwardMessage(sender, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Process(Participant sender, BinaryMsg msg) {
|
protected virtual void Process(Participant sender, BinaryMsg msg) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user