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

@ -221,7 +221,7 @@ internal static void PrepareToSpawnSceneObjects()
{
var uv = uvs[i];
// not spawned yet etc.?
if (!uv.gameObject.activeSelf &&
if (!uv.gameObject.activeSelf &&
uv.gameObject.hideFlags != HideFlags.NotEditable && uv.gameObject.hideFlags != HideFlags.HideAndDontSave &&
!uv.sceneId.IsEmpty())
{
@ -248,15 +248,15 @@ static internal void RegisterSystemHandlers(NetworkClient client, bool localClie
{
client.RegisterHandler((short)MsgType.ObjectDestroy, OnLocalClientObjectDestroy);
client.RegisterHandler((short)MsgType.ObjectHide, OnLocalClientObjectHide);
client.RegisterHandler((short)MsgType.ObjectSpawn, OnLocalClientObjectSpawn);
client.RegisterHandler((short)MsgType.ObjectSpawnScene, OnLocalClientObjectSpawnScene);
client.RegisterHandler((short)MsgType.SpawnPrefab, OnLocalClientSpawnPrefab);
client.RegisterHandler((short)MsgType.SpawnSceneObject, OnLocalClientSpawnSceneObject);
client.RegisterHandler((short)MsgType.LocalClientAuthority, OnClientAuthority);
}
else
{
// LocalClient shares the sim/scene with the server, no need for these events
client.RegisterHandler((short)MsgType.ObjectSpawn, OnObjectSpawn);
client.RegisterHandler((short)MsgType.ObjectSpawnScene, OnObjectSpawnScene);
client.RegisterHandler((short)MsgType.SpawnPrefab, OnSpawnPrefab);
client.RegisterHandler((short)MsgType.SpawnSceneObject, OnSpawnSceneObject);
client.RegisterHandler((short)MsgType.SpawnFinished, OnObjectSpawnFinished);
client.RegisterHandler((short)MsgType.ObjectDestroy, 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);
if (!msg.assetId.IsValid())
@ -388,7 +388,7 @@ static void OnObjectSpawn(NetworkMessage netMsg)
#if UNITY_EDITOR
UnityEditor.NetworkDetailStats.IncrementStat(
UnityEditor.NetworkDetailStats.NetworkDirection.Incoming,
(short)MsgType.ObjectSpawn, GetStringForAssetId(msg.assetId), 1);
(short)MsgType.SpawnPrefab, GetStringForAssetId(msg.assetId), 1);
#endif
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);
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
UnityEditor.NetworkDetailStats.IncrementStat(
UnityEditor.NetworkDetailStats.NetworkDirection.Incoming,
(short)MsgType.ObjectSpawnScene, "sceneId", 1);
(short)MsgType.SpawnSceneObject, "sceneId", 1);
#endif
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);
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);
NetworkIdentity localObject;

View File

@ -173,7 +173,7 @@ internal class SyncListMessage<T> where T: struct
// ---------- Internal System Messages -------------------
class ObjectSpawnMessage : MessageBase
class SpawnPrefabMessage : MessageBase
{
public NetworkInstanceId netId;
public NetworkHash128 assetId;
@ -200,7 +200,7 @@ public override void Serialize(NetworkWriter writer)
}
}
class ObjectSpawnSceneMessage : MessageBase
class SpawnSceneObjectMessage : MessageBase
{
public NetworkInstanceId netId;
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
if (uv.sceneId.IsEmpty())
{
ObjectSpawnMessage msg = new ObjectSpawnMessage();
SpawnPrefabMessage msg = new SpawnPrefabMessage();
msg.netId = uv.netId;
msg.assetId = uv.assetId;
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
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
else
{
SendToReady(uv.gameObject, (short)MsgType.ObjectSpawn, msg);
SendToReady(uv.gameObject, (short)MsgType.SpawnPrefab, msg);
}
#if UNITY_EDITOR
UnityEditor.NetworkDetailStats.IncrementStat(
UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing,
(short)MsgType.ObjectSpawn, uv.assetId.ToString(), 1);
(short)MsgType.SpawnPrefab, uv.assetId.ToString(), 1);
#endif
}
// 'uv' is a scene object that should be spawned again
else
{
ObjectSpawnSceneMessage msg = new ObjectSpawnSceneMessage();
SpawnSceneObjectMessage msg = new SpawnSceneObjectMessage();
msg.netId = uv.netId;
msg.sceneId = uv.sceneId;
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
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
else
{
SendToReady(uv.gameObject, (short)MsgType.ObjectSpawnScene, msg);
SendToReady(uv.gameObject, (short)MsgType.SpawnSceneObject, msg);
}
#if UNITY_EDITOR
UnityEditor.NetworkDetailStats.IncrementStat(
UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing,
(short)MsgType.ObjectSpawnScene, "sceneId", 1);
(short)MsgType.SpawnSceneObject, "sceneId", 1);
#endif
}
}

View File

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