mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
UpdateVarsMessage renamed to EntityStateMessage so it's more obvious. NetworkClient.OnEntityStateMessage can be reused for WorldState easier later.
This commit is contained in:
parent
0a6cd15bbd
commit
a43837e0d8
@ -87,7 +87,7 @@ public struct ObjectHideMessage : NetworkMessage
|
||||
public uint netId;
|
||||
}
|
||||
|
||||
public struct UpdateVarsMessage : NetworkMessage
|
||||
public struct EntityStateMessage : NetworkMessage
|
||||
{
|
||||
public uint netId;
|
||||
// the serialized component data
|
||||
|
@ -109,7 +109,7 @@ internal static void RegisterSystemHandlers(bool hostMode)
|
||||
// host mode doesn't need spawning
|
||||
RegisterHandler<ObjectSpawnFinishedMessage>(msg => {});
|
||||
// host mode doesn't need state updates
|
||||
RegisterHandler<UpdateVarsMessage>(msg => {});
|
||||
RegisterHandler<EntityStateMessage>(msg => {});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -119,7 +119,7 @@ internal static void RegisterSystemHandlers(bool hostMode)
|
||||
RegisterHandler<SpawnMessage>(OnSpawn);
|
||||
RegisterHandler<ObjectSpawnStartedMessage>(OnObjectSpawnStarted);
|
||||
RegisterHandler<ObjectSpawnFinishedMessage>(OnObjectSpawnFinished);
|
||||
RegisterHandler<UpdateVarsMessage>(OnUpdateVarsMessage);
|
||||
RegisterHandler<EntityStateMessage>(OnEntityStateMessage);
|
||||
}
|
||||
RegisterHandler<RpcMessage>(OnRPCMessage);
|
||||
}
|
||||
@ -1145,7 +1145,7 @@ internal static void OnHostClientSpawn(SpawnMessage message)
|
||||
}
|
||||
|
||||
// client-only mode callbacks //////////////////////////////////////////
|
||||
static void OnUpdateVarsMessage(UpdateVarsMessage message)
|
||||
static void OnEntityStateMessage(EntityStateMessage message)
|
||||
{
|
||||
// Debug.Log("NetworkClient.OnUpdateVarsMessage " + msg.netId);
|
||||
if (NetworkIdentity.spawned.TryGetValue(message.netId, out NetworkIdentity localObject) && localObject != null)
|
||||
|
@ -1510,7 +1510,7 @@ static void BroadcastToConnection(NetworkConnectionToClient connection)
|
||||
NetworkWriter serialization = GetEntitySerializationForConnection(identity, connection);
|
||||
if (serialization != null)
|
||||
{
|
||||
UpdateVarsMessage message = new UpdateVarsMessage
|
||||
EntityStateMessage message = new EntityStateMessage
|
||||
{
|
||||
netId = identity.netId,
|
||||
payload = serialization.ToArraySegment()
|
||||
|
@ -182,13 +182,13 @@ void DoTest(ulong testSceneId)
|
||||
public void UpdateVarsMessage()
|
||||
{
|
||||
// try setting value with constructor
|
||||
UpdateVarsMessage message = new UpdateVarsMessage
|
||||
EntityStateMessage message = new EntityStateMessage
|
||||
{
|
||||
netId = 42,
|
||||
payload = new ArraySegment<byte>(new byte[] { 0x01, 0x02 })
|
||||
};
|
||||
byte[] arr = MessagePackingTest.PackToByteArray(message);
|
||||
UpdateVarsMessage fresh = MessagePackingTest.UnpackFromByteArray<UpdateVarsMessage>(arr);
|
||||
EntityStateMessage fresh = MessagePackingTest.UnpackFromByteArray<EntityStateMessage>(arr);
|
||||
Assert.That(fresh.netId, Is.EqualTo(message.netId));
|
||||
Assert.That(fresh.payload.Count, Is.EqualTo(message.payload.Count));
|
||||
for (int i = 0; i < fresh.payload.Count; ++i)
|
||||
|
Loading…
Reference in New Issue
Block a user