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>();
var cmdObject = FindLocalObject(message.netId);
if (cmdObject == null)
{
Debug.LogWarning("Instance not found when handling Command message [netId=" + message.netId + "]");
return;
}
NetworkIdentity identity = cmdObject.GetComponent<NetworkIdentity>();
NetworkIdentity identity;
NetworkIdentity.spawned.TryGetValue(message.netId, out identity);
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;
}