ControlCore compatibility
This commit is contained in:
parent
11a0509ed3
commit
9a5d9544f9
@ -168,8 +168,8 @@ namespace Passer.Control {
|
||||
this.thingId = buffer[ix++];
|
||||
}
|
||||
|
||||
public static bool Send(Client client, byte thingId) {
|
||||
InvestigateMsg msg = new(client.networkId, thingId);
|
||||
public static bool Send(Client client, byte networkId, byte thingId) {
|
||||
InvestigateMsg msg = new(networkId, thingId);
|
||||
return SendMsg(client, msg);
|
||||
}
|
||||
public static async Task<bool> Receive(Stream dataStream, Client client, byte packetSize) {
|
||||
@ -406,7 +406,6 @@ namespace Passer.Control {
|
||||
return SendMsg(client, msg);
|
||||
}
|
||||
public static async Task<bool> Receive(Stream dataStream, Client client, byte packetSize) {
|
||||
UnityEngine.Debug.Log("Receive pose");
|
||||
if (packetSize != length)
|
||||
return false;
|
||||
|
||||
|
@ -128,6 +128,7 @@ namespace Passer.Humanoid {
|
||||
|
||||
public class HumanoidClient : Client {
|
||||
readonly HumanoidPlayer player;
|
||||
public List<Thing> allThings = new();
|
||||
|
||||
public HumanoidClient(UdpClient udpClient, string ipAddress, int port, HumanoidPlayer player) : base(udpClient, port) {
|
||||
this.player = player;
|
||||
@ -141,7 +142,12 @@ namespace Passer.Humanoid {
|
||||
player.ProcessNetworkId(this, msg);
|
||||
}
|
||||
|
||||
protected override void ProcessName(NameMsg msg) {
|
||||
Debug.Log($"Name [{msg.networkId}/{msg.thingId} {msg.name}]");
|
||||
}
|
||||
|
||||
protected override void ProcessModelUrl(ModelUrlMsg msg) {
|
||||
Debug.Log($"Model [{msg.networkId}/{msg.thingId} {msg.url}]");
|
||||
int ix = msg.url.LastIndexOf(".");
|
||||
if (ix < 0)
|
||||
return;
|
||||
@ -153,6 +159,16 @@ namespace Passer.Humanoid {
|
||||
player.ProcessGltfModel(msg);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ProcessPose(PoseMsg msg) {
|
||||
Debug.Log($"Pose [{msg.networkId}/{msg.thingId}]");
|
||||
Thing thing = allThings.Find(thing => thing.networkId == msg.networkId && thing.thingId == msg.thingId);
|
||||
if (thing == null) {
|
||||
Debug.Log($"Unknown thing [{msg.networkId}/{msg.thingId}]");
|
||||
thing = Thing.Create(player.gameObject, this, msg.thingId, 0);
|
||||
InvestigateMsg.Send(this, msg.networkId, msg.thingId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Awake() {
|
||||
|
44
Runtime/HumanoidControl/Scripts/Networking/Roboid/Thing.cs
Normal file
44
Runtime/HumanoidControl/Scripts/Networking/Roboid/Thing.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using Passer.Control;
|
||||
|
||||
public class Thing : MonoBehaviour {
|
||||
public Client client;
|
||||
public byte networkId;
|
||||
public byte thingId;
|
||||
public byte objectType;
|
||||
//protected Sensor sensor;
|
||||
|
||||
protected virtual void Init() {
|
||||
//if (this.objectType == 2) {
|
||||
// sensor = this.gameObject.AddComponent<DistanceSensor>();
|
||||
// sensor.thing = this;
|
||||
//}
|
||||
}
|
||||
|
||||
public static Thing Create(GameObject obj, Client client, byte objId, byte objType) {
|
||||
Thing thing = obj.AddComponent<Thing>();
|
||||
thing.client = client;
|
||||
thing.thingId = objId;
|
||||
thing.objectType = objType;
|
||||
thing.networkId = client.networkId;
|
||||
thing.Init();
|
||||
|
||||
return thing;
|
||||
}
|
||||
|
||||
public virtual Thing CopyTo(GameObject obj) {
|
||||
//Debug.Log($"copy {obj}");
|
||||
Thing foundThing = Thing.Create(obj, this.client, this.thingId, this.objectType);
|
||||
Destroy(this.gameObject);
|
||||
return foundThing;
|
||||
}
|
||||
|
||||
//public void ProcessBytes(byte[] bytes) {
|
||||
// if (sensor != null)
|
||||
// sensor.ProcessBytes(bytes);
|
||||
//}
|
||||
//public void Update() {
|
||||
// if (objectId == 0)
|
||||
// Debug.Log(this.transform.eulerAngles);
|
||||
//}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbfb00fc659e2d8489a48aafec5ddfc5
|
Loading…
x
Reference in New Issue
Block a user