NetworkServer.OnCommandMessage: removed unnecessary GetComponent call and unnecessary .gameObject calls by using NetworkIdentity.spawned directly

This commit is contained in:
vis2k 2018-12-17 23:20:37 +01:00
parent 42ab1be224
commit 6f5ee57248

View File

@ -846,17 +846,11 @@ static void OnCommandMessage(NetworkMessage netMsg)
{ {
CommandMessage message = netMsg.ReadMessage<CommandMessage>(); CommandMessage message = netMsg.ReadMessage<CommandMessage>();
var cmdObject = FindLocalObject(message.netId); NetworkIdentity identity;
if (cmdObject == null) NetworkIdentity.spawned.TryGetValue(message.netId, out identity);
{
Debug.LogWarning("Instance not found when handling Command message [netId=" + message.netId + "]");
return;
}
NetworkIdentity identity = cmdObject.GetComponent<NetworkIdentity>();
if (identity == null) if (identity == null)
{ {
Debug.LogWarning("NetworkIdentity deleted when handling Command message [netId=" + message.netId + "]"); Debug.LogWarning("Spawned object not found when handling Command message [netId=" + message.netId + "]");
return; return;
} }