mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkScene.GetNetworkIdentity replaced with NetworkIdentity.spawned.TryGetValue
This commit is contained in:
parent
ab3770cf4f
commit
77ea4dff21
@ -323,7 +323,7 @@ static void OnSpawnPrefab(NetworkMessage netMsg)
|
||||
if (LogFilter.Debug) { Debug.Log("Client spawn handler instantiating [netId:" + msg.netId + " asset ID:" + msg.assetId + " pos:" + msg.position + "]"); }
|
||||
|
||||
NetworkIdentity localNetworkIdentity;
|
||||
if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localNetworkIdentity))
|
||||
if (NetworkIdentity.spawned.TryGetValue(msg.netId, out localNetworkIdentity) && localNetworkIdentity != null)
|
||||
{
|
||||
// this object already exists (was in the scene), just apply the update to existing object
|
||||
localNetworkIdentity.Reset();
|
||||
@ -382,7 +382,7 @@ static void OnSpawnSceneObject(NetworkMessage netMsg)
|
||||
if (LogFilter.Debug) { Debug.Log("Client spawn scene handler instantiating [netId:" + msg.netId + " sceneId:" + msg.sceneId + " pos:" + msg.position); }
|
||||
|
||||
NetworkIdentity localNetworkIdentity;
|
||||
if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localNetworkIdentity))
|
||||
if (NetworkIdentity.spawned.TryGetValue(msg.netId, out localNetworkIdentity) && localNetworkIdentity != null)
|
||||
{
|
||||
// this object already exists (was in the scene)
|
||||
localNetworkIdentity.Reset();
|
||||
@ -437,7 +437,7 @@ static void OnObjectDestroy(NetworkMessage netMsg)
|
||||
if (LogFilter.Debug) { Debug.Log("ClientScene::OnObjDestroy netId:" + msg.netId); }
|
||||
|
||||
NetworkIdentity localObject;
|
||||
if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localObject))
|
||||
if (NetworkIdentity.spawned.TryGetValue(msg.netId, out localObject) && localObject != null)
|
||||
{
|
||||
localObject.OnNetworkDestroy();
|
||||
|
||||
@ -478,7 +478,7 @@ static void OnLocalClientObjectHide(NetworkMessage netMsg)
|
||||
if (LogFilter.Debug) { Debug.Log("ClientScene::OnLocalObjectObjHide netId:" + msg.netId); }
|
||||
|
||||
NetworkIdentity localObject;
|
||||
if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localObject))
|
||||
if (NetworkIdentity.spawned.TryGetValue(msg.netId, out localObject) && localObject != null)
|
||||
{
|
||||
localObject.OnSetLocalVisibility(false);
|
||||
}
|
||||
@ -489,7 +489,7 @@ static void OnLocalClientSpawnPrefab(NetworkMessage netMsg)
|
||||
SpawnPrefabMessage msg = netMsg.ReadMessage<SpawnPrefabMessage>();
|
||||
|
||||
NetworkIdentity localObject;
|
||||
if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localObject))
|
||||
if (NetworkIdentity.spawned.TryGetValue(msg.netId, out localObject) && localObject != null)
|
||||
{
|
||||
localObject.OnSetLocalVisibility(true);
|
||||
}
|
||||
@ -500,7 +500,7 @@ static void OnLocalClientSpawnSceneObject(NetworkMessage netMsg)
|
||||
SpawnSceneObjectMessage msg = netMsg.ReadMessage<SpawnSceneObjectMessage>();
|
||||
|
||||
NetworkIdentity localObject;
|
||||
if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localObject))
|
||||
if (NetworkIdentity.spawned.TryGetValue(msg.netId, out localObject) && localObject != null)
|
||||
{
|
||||
localObject.OnSetLocalVisibility(true);
|
||||
}
|
||||
@ -513,7 +513,7 @@ static void OnUpdateVarsMessage(NetworkMessage netMsg)
|
||||
if (LogFilter.Debug) { Debug.Log("ClientScene::OnUpdateVarsMessage " + message.netId); }
|
||||
|
||||
NetworkIdentity localObject;
|
||||
if (s_NetworkScene.GetNetworkIdentity(message.netId, out localObject))
|
||||
if (NetworkIdentity.spawned.TryGetValue(message.netId, out localObject) && localObject != null)
|
||||
{
|
||||
localObject.OnUpdateVars(new NetworkReader(message.payload), false);
|
||||
}
|
||||
@ -530,7 +530,7 @@ static void OnRPCMessage(NetworkMessage netMsg)
|
||||
if (LogFilter.Debug) { Debug.Log("ClientScene::OnRPCMessage hash:" + message.rpcHash + " netId:" + message.netId); }
|
||||
|
||||
NetworkIdentity uv;
|
||||
if (s_NetworkScene.GetNetworkIdentity(message.netId, out uv))
|
||||
if (NetworkIdentity.spawned.TryGetValue(message.netId, out uv) && uv != null)
|
||||
{
|
||||
uv.HandleRPC(message.componentIndex, message.rpcHash, new NetworkReader(message.payload));
|
||||
}
|
||||
@ -548,7 +548,7 @@ static void OnSyncEventMessage(NetworkMessage netMsg)
|
||||
if (LogFilter.Debug) { Debug.Log("ClientScene::OnSyncEventMessage " + message.netId); }
|
||||
|
||||
NetworkIdentity uv;
|
||||
if (s_NetworkScene.GetNetworkIdentity(message.netId, out uv))
|
||||
if (NetworkIdentity.spawned.TryGetValue(message.netId, out uv) && uv != null)
|
||||
{
|
||||
uv.HandleSyncEvent(message.componentIndex, message.eventHash, new NetworkReader(message.payload));
|
||||
}
|
||||
@ -565,7 +565,7 @@ static void OnClientAuthority(NetworkMessage netMsg)
|
||||
if (LogFilter.Debug) { Debug.Log("ClientScene::OnClientAuthority for connectionId=" + netMsg.conn.connectionId + " netId: " + msg.netId); }
|
||||
|
||||
NetworkIdentity uv;
|
||||
if (s_NetworkScene.GetNetworkIdentity(msg.netId, out uv))
|
||||
if (NetworkIdentity.spawned.TryGetValue(msg.netId, out uv) && uv != null)
|
||||
{
|
||||
uv.HandleClientAuthority(msg.authority);
|
||||
}
|
||||
@ -585,7 +585,7 @@ static void OnOwnerMessage(NetworkMessage netMsg)
|
||||
}
|
||||
|
||||
NetworkIdentity localNetworkIdentity;
|
||||
if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localNetworkIdentity))
|
||||
if (NetworkIdentity.spawned.TryGetValue(msg.netId, out localNetworkIdentity) && localNetworkIdentity != null)
|
||||
{
|
||||
// this object already exists
|
||||
localNetworkIdentity.SetConnectionToServer(netMsg.conn);
|
||||
|
@ -46,18 +46,13 @@ internal void SetLocalObject(uint netId, GameObject obj, bool isClient, bool isS
|
||||
internal GameObject FindLocalObject(uint netId)
|
||||
{
|
||||
NetworkIdentity identity;
|
||||
if (GetNetworkIdentity(netId, out identity))
|
||||
if (NetworkIdentity.spawned.TryGetValue(netId, out identity) && identity != null)
|
||||
{
|
||||
return identity.gameObject;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal bool GetNetworkIdentity(uint netId, out NetworkIdentity uv)
|
||||
{
|
||||
return NetworkIdentity.spawned.TryGetValue(netId, out uv) && uv != null;
|
||||
}
|
||||
|
||||
internal static void RegisterPrefab(GameObject prefab, Guid newAssetId)
|
||||
{
|
||||
NetworkIdentity view = prefab.GetComponent<NetworkIdentity>();
|
||||
|
Loading…
Reference in New Issue
Block a user