MsgType.ObjectSpawn renamed to SpawnPrefab, ObjectSpawnScene renamed to SpawnSceneObject. Messages.ObjectSpawnMessage renamed to SpawnPrefabMessage, etc. to make it perfectly clear what the messages do in order to avoid any confusion.

This commit is contained in:
vis2k 2018-07-20 16:37:05 +02:00
parent e0a2a373ed
commit 2dd907fb28
4 changed files with 27 additions and 27 deletions

View File

@ -248,15 +248,15 @@ static internal void RegisterSystemHandlers(NetworkClient client, bool localClie
{ {
client.RegisterHandler((short)MsgType.ObjectDestroy, OnLocalClientObjectDestroy); client.RegisterHandler((short)MsgType.ObjectDestroy, OnLocalClientObjectDestroy);
client.RegisterHandler((short)MsgType.ObjectHide, OnLocalClientObjectHide); client.RegisterHandler((short)MsgType.ObjectHide, OnLocalClientObjectHide);
client.RegisterHandler((short)MsgType.ObjectSpawn, OnLocalClientObjectSpawn); client.RegisterHandler((short)MsgType.SpawnPrefab, OnLocalClientSpawnPrefab);
client.RegisterHandler((short)MsgType.ObjectSpawnScene, OnLocalClientObjectSpawnScene); client.RegisterHandler((short)MsgType.SpawnSceneObject, OnLocalClientSpawnSceneObject);
client.RegisterHandler((short)MsgType.LocalClientAuthority, OnClientAuthority); client.RegisterHandler((short)MsgType.LocalClientAuthority, OnClientAuthority);
} }
else else
{ {
// LocalClient shares the sim/scene with the server, no need for these events // LocalClient shares the sim/scene with the server, no need for these events
client.RegisterHandler((short)MsgType.ObjectSpawn, OnObjectSpawn); client.RegisterHandler((short)MsgType.SpawnPrefab, OnSpawnPrefab);
client.RegisterHandler((short)MsgType.ObjectSpawnScene, OnObjectSpawnScene); client.RegisterHandler((short)MsgType.SpawnSceneObject, OnSpawnSceneObject);
client.RegisterHandler((short)MsgType.SpawnFinished, OnObjectSpawnFinished); client.RegisterHandler((short)MsgType.SpawnFinished, OnObjectSpawnFinished);
client.RegisterHandler((short)MsgType.ObjectDestroy, OnObjectDestroy); client.RegisterHandler((short)MsgType.ObjectDestroy, OnObjectDestroy);
client.RegisterHandler((short)MsgType.ObjectHide, OnObjectDestroy); client.RegisterHandler((short)MsgType.ObjectHide, OnObjectDestroy);
@ -373,9 +373,9 @@ static void ApplySpawnPayload(NetworkIdentity uv, Vector3 position, byte[] paylo
} }
} }
static void OnObjectSpawn(NetworkMessage netMsg) static void OnSpawnPrefab(NetworkMessage netMsg)
{ {
ObjectSpawnMessage msg = new ObjectSpawnMessage(); SpawnPrefabMessage msg = new SpawnPrefabMessage();
netMsg.ReadMessage(msg); netMsg.ReadMessage(msg);
if (!msg.assetId.IsValid()) if (!msg.assetId.IsValid())
@ -388,7 +388,7 @@ static void OnObjectSpawn(NetworkMessage netMsg)
#if UNITY_EDITOR #if UNITY_EDITOR
UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.IncrementStat(
UnityEditor.NetworkDetailStats.NetworkDirection.Incoming, UnityEditor.NetworkDetailStats.NetworkDirection.Incoming,
(short)MsgType.ObjectSpawn, GetStringForAssetId(msg.assetId), 1); (short)MsgType.SpawnPrefab, GetStringForAssetId(msg.assetId), 1);
#endif #endif
NetworkIdentity localNetworkIdentity; NetworkIdentity localNetworkIdentity;
@ -444,9 +444,9 @@ static void OnObjectSpawn(NetworkMessage netMsg)
} }
} }
static void OnObjectSpawnScene(NetworkMessage netMsg) static void OnSpawnSceneObject(NetworkMessage netMsg)
{ {
ObjectSpawnSceneMessage msg = new ObjectSpawnSceneMessage(); SpawnSceneObjectMessage msg = new SpawnSceneObjectMessage();
netMsg.ReadMessage(msg); netMsg.ReadMessage(msg);
if (LogFilter.logDebug) { Debug.Log("Client spawn scene handler instantiating [netId:" + msg.netId + " sceneId:" + msg.sceneId + " pos:" + msg.position); } if (LogFilter.logDebug) { Debug.Log("Client spawn scene handler instantiating [netId:" + msg.netId + " sceneId:" + msg.sceneId + " pos:" + msg.position); }
@ -455,7 +455,7 @@ static void OnObjectSpawnScene(NetworkMessage netMsg)
#if UNITY_EDITOR #if UNITY_EDITOR
UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.IncrementStat(
UnityEditor.NetworkDetailStats.NetworkDirection.Incoming, UnityEditor.NetworkDetailStats.NetworkDirection.Incoming,
(short)MsgType.ObjectSpawnScene, "sceneId", 1); (short)MsgType.SpawnSceneObject, "sceneId", 1);
#endif #endif
NetworkIdentity localNetworkIdentity; NetworkIdentity localNetworkIdentity;
@ -570,9 +570,9 @@ static void OnLocalClientObjectHide(NetworkMessage netMsg)
} }
} }
static void OnLocalClientObjectSpawn(NetworkMessage netMsg) static void OnLocalClientSpawnPrefab(NetworkMessage netMsg)
{ {
ObjectSpawnMessage msg = new ObjectSpawnMessage(); SpawnPrefabMessage msg = new SpawnPrefabMessage();
netMsg.ReadMessage(msg); netMsg.ReadMessage(msg);
NetworkIdentity localObject; NetworkIdentity localObject;
@ -582,9 +582,9 @@ static void OnLocalClientObjectSpawn(NetworkMessage netMsg)
} }
} }
static void OnLocalClientObjectSpawnScene(NetworkMessage netMsg) static void OnLocalClientSpawnSceneObject(NetworkMessage netMsg)
{ {
ObjectSpawnSceneMessage msg = new ObjectSpawnSceneMessage(); SpawnSceneObjectMessage msg = new SpawnSceneObjectMessage();
netMsg.ReadMessage(msg); netMsg.ReadMessage(msg);
NetworkIdentity localObject; NetworkIdentity localObject;

View File

@ -173,7 +173,7 @@ internal class SyncListMessage<T> where T: struct
// ---------- Internal System Messages ------------------- // ---------- Internal System Messages -------------------
class ObjectSpawnMessage : MessageBase class SpawnPrefabMessage : MessageBase
{ {
public NetworkInstanceId netId; public NetworkInstanceId netId;
public NetworkHash128 assetId; public NetworkHash128 assetId;
@ -200,7 +200,7 @@ public override void Serialize(NetworkWriter writer)
} }
} }
class ObjectSpawnSceneMessage : MessageBase class SpawnSceneObjectMessage : MessageBase
{ {
public NetworkInstanceId netId; public NetworkInstanceId netId;
public NetworkSceneId sceneId; public NetworkSceneId sceneId;

View File

@ -1151,7 +1151,7 @@ static internal void SendSpawnMessage(NetworkIdentity uv, NetworkConnection conn
// 'uv' is a prefab that should be spawned // 'uv' is a prefab that should be spawned
if (uv.sceneId.IsEmpty()) if (uv.sceneId.IsEmpty())
{ {
ObjectSpawnMessage msg = new ObjectSpawnMessage(); SpawnPrefabMessage msg = new SpawnPrefabMessage();
msg.netId = uv.netId; msg.netId = uv.netId;
msg.assetId = uv.assetId; msg.assetId = uv.assetId;
msg.position = uv.transform.position; msg.position = uv.transform.position;
@ -1165,24 +1165,24 @@ static internal void SendSpawnMessage(NetworkIdentity uv, NetworkConnection conn
// conn is != null when spawning it for a client // conn is != null when spawning it for a client
if (conn != null) if (conn != null)
{ {
conn.Send((short)MsgType.ObjectSpawn, msg); conn.Send((short)MsgType.SpawnPrefab, msg);
} }
// conn is == null when spawning it for the local player // conn is == null when spawning it for the local player
else else
{ {
SendToReady(uv.gameObject, (short)MsgType.ObjectSpawn, msg); SendToReady(uv.gameObject, (short)MsgType.SpawnPrefab, msg);
} }
#if UNITY_EDITOR #if UNITY_EDITOR
UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.IncrementStat(
UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing, UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing,
(short)MsgType.ObjectSpawn, uv.assetId.ToString(), 1); (short)MsgType.SpawnPrefab, uv.assetId.ToString(), 1);
#endif #endif
} }
// 'uv' is a scene object that should be spawned again // 'uv' is a scene object that should be spawned again
else else
{ {
ObjectSpawnSceneMessage msg = new ObjectSpawnSceneMessage(); SpawnSceneObjectMessage msg = new SpawnSceneObjectMessage();
msg.netId = uv.netId; msg.netId = uv.netId;
msg.sceneId = uv.sceneId; msg.sceneId = uv.sceneId;
msg.position = uv.transform.position; msg.position = uv.transform.position;
@ -1195,18 +1195,18 @@ static internal void SendSpawnMessage(NetworkIdentity uv, NetworkConnection conn
// conn is != null when spawning it for a client // conn is != null when spawning it for a client
if (conn != null) if (conn != null)
{ {
conn.Send((short)MsgType.ObjectSpawnScene, msg); conn.Send((short)MsgType.SpawnSceneObject, msg);
} }
// conn is == null when spawning it for the local player // conn is == null when spawning it for the local player
else else
{ {
SendToReady(uv.gameObject, (short)MsgType.ObjectSpawnScene, msg); SendToReady(uv.gameObject, (short)MsgType.SpawnSceneObject, msg);
} }
#if UNITY_EDITOR #if UNITY_EDITOR
UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.IncrementStat(
UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing, UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing,
(short)MsgType.ObjectSpawnScene, "sceneId", 1); (short)MsgType.SpawnSceneObject, "sceneId", 1);
#endif #endif
} }
} }

View File

@ -22,14 +22,14 @@ public enum MsgType : short
// internal system messages - cannot be replaced by user code // internal system messages - cannot be replaced by user code
ObjectDestroy = 1, ObjectDestroy = 1,
Rpc = 2, Rpc = 2,
ObjectSpawn = 3,
Owner = 4, Owner = 4,
Command = 5, Command = 5,
LocalPlayerTransform = 6, LocalPlayerTransform = 6,
SyncEvent = 7, SyncEvent = 7,
UpdateVars = 8, UpdateVars = 8,
SyncList = 9, SyncList = 9,
ObjectSpawnScene = 10, SpawnPrefab = 3,
SpawnSceneObject = 10,
SpawnFinished = 12, SpawnFinished = 12,
ObjectHide = 13, ObjectHide = 13,
LocalClientAuthority = 15, LocalClientAuthority = 15,