예제 #1
0
        private void FireOnUnityMessageReceived(UnityEngine.Networking.NetworkMessage netMsg)
        {
            NetworkMessage message = netMsg.ReadMessage <NetworkMessage>();
            Packet         packet  = message.Data.ToPacket();

            if (packet.Type != PacketType.None)
            {
                byte[] bytes = this.Append(packet);

                if (bytes != null)
                {
                    FireOnMessageReceivedSuccess(this, bytes);
                    if (_messages.Count > 0)
                    {
                        ProcessSend(_messages.Dequeue());
                    }
                }
                else
                {
                    this.Send(new Packet(
                                  PacketType.None, new byte[] { 0 }));
                }
            }
            else
            {
                this.Send(this.PopPacket());
            }
        }
예제 #2
0
        private void FireOnUnityError(UnityEngine.Networking.NetworkMessage netMsg)
        {
            ErrorMessage error = netMsg.ReadMessage <ErrorMessage>();

            DebugHelper.PrintError(
                new NetworkInfoException("Error:" + error.errorCode));
        }
        static void OnObjectSpawn(NetworkMessage netMsg)
        {
            netMsg.ReadMessage(s_ObjectSpawnMessage);

            if (!s_ObjectSpawnMessage.assetId.IsValid())
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("OnObjSpawn netId: " + s_ObjectSpawnMessage.netId + " has invalid asset Id");
                }
                return;
            }
            if (LogFilter.logDebug)
            {
                Debug.Log("Client spawn handler instantiating [netId:" + s_ObjectSpawnMessage.netId + " asset ID:" + s_ObjectSpawnMessage.assetId + " pos:" + s_ObjectSpawnMessage.position + "]");
            }

#if UNITY_EDITOR
            UnityEditor.NetworkDetailStats.IncrementStat(
                UnityEditor.NetworkDetailStats.NetworkDirection.Incoming,
                MsgType.ObjectSpawn, GetStringForAssetId(s_ObjectSpawnMessage.assetId), 1);
#endif

            NetworkIdentity localNetworkIdentity;
            if (s_NetworkScene.GetNetworkIdentity(s_ObjectSpawnMessage.netId, out localNetworkIdentity))
            {
                // this object already exists (was in the scene), just apply the update to existing object
                ApplySpawnPayload(localNetworkIdentity, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.payload, s_ObjectSpawnMessage.netId, null, s_ObjectSpawnMessage.data);
                return;
            }

            GameObject      prefab;
            SpawnDelegate   handler;
            SpawnExDelegate exHandler;
            if (NetworkScene.GetPrefab(s_ObjectSpawnMessage.assetId, out prefab))
            {
                var obj = (GameObject)Object.Instantiate(prefab, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.rotation);
                if (LogFilter.logDebug)
                {
                    Debug.Log("Client spawn handler instantiating [netId:" + s_ObjectSpawnMessage.netId + " asset ID:" + s_ObjectSpawnMessage.assetId + " pos:" + s_ObjectSpawnMessage.position + " rotation: " + s_ObjectSpawnMessage.rotation + "]");
                }

                localNetworkIdentity = obj.GetComponent <NetworkIdentity>();
                if (localNetworkIdentity == null)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Client object spawned for " + s_ObjectSpawnMessage.assetId + " does not have a NetworkIdentity");
                    }
                    return;
                }
                localNetworkIdentity.Reset();
                ApplySpawnPayload(localNetworkIdentity, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.payload, s_ObjectSpawnMessage.netId, obj);
            }
            // lookup registered factory for type:
            else if (NetworkScene.GetSpawnHandler(s_ObjectSpawnMessage.assetId, out handler))
            {
                GameObject obj = handler(s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.assetId);
                if (obj == null)
                {
                    if (LogFilter.logWarn)
                    {
                        Debug.LogWarning("Client spawn handler for " + s_ObjectSpawnMessage.assetId + " returned null");
                    }
                    return;
                }
                localNetworkIdentity = obj.GetComponent <NetworkIdentity>();
                if (localNetworkIdentity == null)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Client object spawned for " + s_ObjectSpawnMessage.assetId + " does not have a network identity");
                    }
                    return;
                }
                localNetworkIdentity.Reset();
                localNetworkIdentity.SetDynamicAssetId(s_ObjectSpawnMessage.assetId);
                ApplySpawnPayload(localNetworkIdentity, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.payload, s_ObjectSpawnMessage.netId, obj);
            }
            else if (NetworkScene.GetSpawnHandler(s_ObjectSpawnMessage.assetId, out exHandler))
            {
                GameObject obj = exHandler(s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.assetId, s_ObjectSpawnMessage.data);
                if (obj == null)
                {
                    if (LogFilter.logWarn)
                    {
                        Debug.LogWarning("Client spawn handler for " + s_ObjectSpawnMessage.assetId + " returned null");
                    }
                    return;
                }
                localNetworkIdentity = obj.GetComponent <NetworkIdentity>();
                if (localNetworkIdentity == null)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Client object spawned for " + s_ObjectSpawnMessage.assetId + " does not have a network identity");
                    }
                    return;
                }
                localNetworkIdentity.Reset();
                localNetworkIdentity.SetDynamicAssetId(s_ObjectSpawnMessage.assetId);
                ApplySpawnPayload(localNetworkIdentity, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.payload, s_ObjectSpawnMessage.netId, obj, s_ObjectSpawnMessage.data);
            }
            else
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Failed to spawn server object, did you forget to add it to the NetworkManager? assetId=" + s_ObjectSpawnMessage.assetId + " netId=" + s_ObjectSpawnMessage.netId);
                }
            }
        }
예제 #4
0
 void OnCRC(NetworkMessage netMsg)
 {
     netMsg.ReadMessage(s_CRCMessage);
     NetworkCRC.Validate(s_CRCMessage.scripts, numChannels);
 }
        private void OnServerReconnectPlayerMessage(NetworkMessage netMsg)
        {
            ReconnectMessage reconnectMessage = netMsg.ReadMessage <ReconnectMessage>();

            if (LogFilter.logDev)
            {
                Debug.Log(string.Concat(new object[]
                {
                    "OnReconnectMessage: connId=",
                    reconnectMessage.oldConnectionId,
                    " playerControllerId:",
                    reconnectMessage.playerControllerId,
                    " netId:",
                    reconnectMessage.netId
                }));
            }
            GameObject gameObject = this.FindPendingPlayer(reconnectMessage.oldConnectionId, reconnectMessage.netId, reconnectMessage.playerControllerId);

            if (gameObject == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError(string.Concat(new object[]
                    {
                        "OnReconnectMessage connId=",
                        reconnectMessage.oldConnectionId,
                        " player null for netId:",
                        reconnectMessage.netId,
                        " msg.playerControllerId:",
                        reconnectMessage.playerControllerId
                    }));
                }
            }
            else if (gameObject.activeSelf)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("OnReconnectMessage connId=" + reconnectMessage.oldConnectionId + " player already active?");
                }
            }
            else
            {
                if (LogFilter.logDebug)
                {
                    Debug.Log("OnReconnectMessage: player=" + gameObject);
                }
                NetworkReader networkReader = null;
                if (reconnectMessage.msgSize != 0)
                {
                    networkReader = new NetworkReader(reconnectMessage.msgData);
                }
                if (reconnectMessage.playerControllerId != -1)
                {
                    if (networkReader == null)
                    {
                        this.OnServerReconnectPlayer(netMsg.conn, gameObject, reconnectMessage.oldConnectionId, reconnectMessage.playerControllerId);
                    }
                    else
                    {
                        this.OnServerReconnectPlayer(netMsg.conn, gameObject, reconnectMessage.oldConnectionId, reconnectMessage.playerControllerId, networkReader);
                    }
                }
                else
                {
                    this.OnServerReconnectObject(netMsg.conn, gameObject, reconnectMessage.oldConnectionId);
                }
            }
        }
예제 #6
0
 private void OnCRC(NetworkMessage netMsg)
 {
     netMsg.ReadMessage <CRCMessage>(s_CRCMessage);
     NetworkCRC.Validate(s_CRCMessage.scripts, this.numChannels);
 }
예제 #7
0
        private static void OnObjectSpawn(NetworkMessage netMsg)
        {
            netMsg.ReadMessage(s_ObjectSpawnMessage);
            if (!s_ObjectSpawnMessage.assetId.IsValid())
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("OnObjSpawn netId: " + s_ObjectSpawnMessage.netId + " has invalid asset Id");
                }
                return;
            }
            if (LogFilter.logDebug)
            {
                Debug.Log("Client spawn handler instantiating [netId:" + s_ObjectSpawnMessage.netId + " asset ID:" + s_ObjectSpawnMessage.assetId + " pos:" + s_ObjectSpawnMessage.position + "]");
            }
            GameObject    prefab;
            SpawnDelegate handler;

            if (s_NetworkScene.GetNetworkIdentity(s_ObjectSpawnMessage.netId, out NetworkIdentity uv))
            {
                ApplySpawnPayload(uv, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.payload, s_ObjectSpawnMessage.netId, null);
            }
            else if (NetworkScene.GetPrefab(s_ObjectSpawnMessage.assetId, out prefab))
            {
                GameObject gameObject = (GameObject)Object.Instantiate(prefab, s_ObjectSpawnMessage.position, Quaternion.identity);
                uv = gameObject.GetComponent <NetworkIdentity>();
                if (uv == null)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Client object spawned for " + s_ObjectSpawnMessage.assetId + " does not have a NetworkIdentity");
                    }
                }
                else
                {
                    ApplySpawnPayload(uv, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.payload, s_ObjectSpawnMessage.netId, gameObject);
                }
            }
            else if (NetworkScene.GetSpawnHandler(s_ObjectSpawnMessage.assetId, out handler))
            {
                GameObject gameObject2 = handler(s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.assetId);
                if (gameObject2 == null)
                {
                    if (LogFilter.logWarn)
                    {
                        Debug.LogWarning("Client spawn handler for " + s_ObjectSpawnMessage.assetId + " returned null");
                    }
                    return;
                }
                uv = gameObject2.GetComponent <NetworkIdentity>();
                if (uv == null)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Client object spawned for " + s_ObjectSpawnMessage.assetId + " does not have a network identity");
                    }
                }
                else
                {
                    uv.SetDynamicAssetId(s_ObjectSpawnMessage.assetId);
                    ApplySpawnPayload(uv, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.payload, s_ObjectSpawnMessage.netId, gameObject2);
                }
            }
            else if (LogFilter.logError)
            {
                Debug.LogError("Failed to spawn server object, assetId=" + s_ObjectSpawnMessage.assetId + " netId=" + s_ObjectSpawnMessage.netId);
            }
        }
예제 #8
0
        // received on both host and clients
        void OnPeerClientAuthority(NetworkMessage netMsg)
        {
            var msg = netMsg.ReadMessage <PeerAuthorityMessage>();

            if (LogFilter.logDebug)
            {
                Debug.Log("OnPeerClientAuthority for netId:" + msg.netId);
            }

            if (m_Peers == null)
            {
                // havent received peers yet. just ignore this. the peer list will contain this data.
                return;
            }

            // find the peer for connId
            foreach (var p in m_Peers)
            {
                if (p.connectionId == msg.connectionId)
                {
                    if (p.playerIds == null)
                    {
                        p.playerIds = new PeerInfoPlayer[0];
                    }

                    if (msg.authorityState)
                    {
                        foreach (var playerId in p.playerIds)
                        {
                            if (playerId.netId == msg.netId)
                            {
                                // already in list
                                return;
                            }
                        }
                        var newPlayerId = new PeerInfoPlayer();
                        newPlayerId.netId = msg.netId;
                        newPlayerId.playerControllerId = -1;

                        var pl = new List <PeerInfoPlayer>(p.playerIds);
                        pl.Add(newPlayerId);
                        p.playerIds = pl.ToArray();
                    }
                    else
                    {
                        for (int i = 0; i < p.playerIds.Length; i++)
                        {
                            if (p.playerIds[i].netId == msg.netId)
                            {
                                var pl = new List <PeerInfoPlayer>(p.playerIds);
                                pl.RemoveAt(i);
                                p.playerIds = pl.ToArray();
                                break;
                            }
                        }
                    }
                }
            }

            var foundObj = ClientScene.FindLocalObject(msg.netId);

            OnAuthorityUpdated(foundObj, msg.connectionId, msg.authorityState);
        }
예제 #9
0
 private static void OnObjectSpawn(NetworkMessage netMsg)
 {
     netMsg.ReadMessage <ObjectSpawnMessage>(s_ObjectSpawnMessage);
     if (!s_ObjectSpawnMessage.assetId.IsValid())
     {
         if (LogFilter.logError)
         {
             Debug.LogError("OnObjSpawn netId: " + s_ObjectSpawnMessage.netId + " has invalid asset Id");
         }
     }
     else
     {
         NetworkIdentity component;
         if (LogFilter.logDebug)
         {
             Debug.Log(string.Concat(new object[] { "Client spawn handler instantiating [netId:", s_ObjectSpawnMessage.netId, " asset ID:", s_ObjectSpawnMessage.assetId, " pos:", s_ObjectSpawnMessage.position, "]" }));
         }
         NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, 3, GetStringForAssetId(s_ObjectSpawnMessage.assetId), 1);
         if (s_NetworkScene.GetNetworkIdentity(s_ObjectSpawnMessage.netId, out component))
         {
             ApplySpawnPayload(component, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.payload, s_ObjectSpawnMessage.netId, null);
         }
         else
         {
             GameObject obj2;
             if (NetworkScene.GetPrefab(s_ObjectSpawnMessage.assetId, out obj2))
             {
                 GameObject newGameObject = UnityEngine.Object.Instantiate <GameObject>(obj2, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.rotation);
                 if (LogFilter.logDebug)
                 {
                     Debug.Log(string.Concat(new object[] { "Client spawn handler instantiating [netId:", s_ObjectSpawnMessage.netId, " asset ID:", s_ObjectSpawnMessage.assetId, " pos:", s_ObjectSpawnMessage.position, " rotation: ", s_ObjectSpawnMessage.rotation, "]" }));
                 }
                 component = newGameObject.GetComponent <NetworkIdentity>();
                 if (component == null)
                 {
                     if (LogFilter.logError)
                     {
                         Debug.LogError("Client object spawned for " + s_ObjectSpawnMessage.assetId + " does not have a NetworkIdentity");
                     }
                 }
                 else
                 {
                     component.Reset();
                     ApplySpawnPayload(component, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.payload, s_ObjectSpawnMessage.netId, newGameObject);
                 }
             }
             else
             {
                 SpawnDelegate delegate2;
                 if (NetworkScene.GetSpawnHandler(s_ObjectSpawnMessage.assetId, out delegate2))
                 {
                     GameObject obj4 = delegate2(s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.assetId);
                     if (obj4 == null)
                     {
                         if (LogFilter.logWarn)
                         {
                             Debug.LogWarning("Client spawn handler for " + s_ObjectSpawnMessage.assetId + " returned null");
                         }
                     }
                     else
                     {
                         component = obj4.GetComponent <NetworkIdentity>();
                         if (component == null)
                         {
                             if (LogFilter.logError)
                             {
                                 Debug.LogError("Client object spawned for " + s_ObjectSpawnMessage.assetId + " does not have a network identity");
                             }
                         }
                         else
                         {
                             component.Reset();
                             component.SetDynamicAssetId(s_ObjectSpawnMessage.assetId);
                             ApplySpawnPayload(component, s_ObjectSpawnMessage.position, s_ObjectSpawnMessage.payload, s_ObjectSpawnMessage.netId, obj4);
                         }
                     }
                 }
                 else if (LogFilter.logError)
                 {
                     Debug.LogError(string.Concat(new object[] { "Failed to spawn server object, assetId=", s_ObjectSpawnMessage.assetId, " netId=", s_ObjectSpawnMessage.netId }));
                 }
             }
         }
     }
 }
예제 #10
0
    private void __onMove(UnityEngine.Networking.NetworkMessage netMsg)
    {
        Message.Move move = netMsg.ReadMessage <Message.Move>();

        GetPlayerObj(move.playerId).transform.Translate(move.direction * move.speed);
    }
예제 #11
0
        static internal void HandleChildTransform(NetworkMessage netMsg)
        {
            LocalChildTransformMessage message = netMsg.ReadMessage <LocalChildTransformMessage>();

#if UNITY_EDITOR
            UnityEditor.NetworkDetailStats.IncrementStat(
                UnityEditor.NetworkDetailStats.NetworkDirection.Incoming,
                (short)MsgType.LocalChildTransform, "16:LocalChildTransform", 1);
#endif

            GameObject foundObj = NetworkServer.FindLocalObject(message.netId);
            if (foundObj == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Received NetworkTransformChild data for GameObject that doesn't exist");
                }
                return;
            }
            var children = foundObj.GetComponents <NetworkTransformChild>();
            if (children == null || children.Length == 0)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleChildTransform no children");
                }
                return;
            }
            if (message.childIndex >= children.Length)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleChildTransform childIndex invalid");
                }
                return;
            }

            NetworkTransformChild foundSync = children[message.childIndex];
            if (foundSync == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleChildTransform null target");
                }
                return;
            }
            if (!foundSync.localPlayerAuthority)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleChildTransform no localPlayerAuthority");
                }
                return;
            }

            if (!netMsg.conn.clientOwnedObjects.Contains(message.netId))
            {
                if (LogFilter.logWarn)
                {
                    Debug.LogWarning("NetworkTransformChild netId:" + message.netId + " is not for a valid player");
                }
                return;
            }

            foundSync.UnserializeModeTransform(new NetworkReader(message.payload), false);
            foundSync.m_LastClientSyncTime = Time.time;

            if (!foundSync.isClient)
            {
                // dedicated server wont interpolate, so snap.
                foundSync.m_Target.localPosition = foundSync.m_TargetSyncPosition;
                foundSync.m_Target.localRotation = foundSync.m_TargetSyncRotation3D;
            }
        }
예제 #12
0
 private static void OnObjectSpawn(NetworkMessage netMsg)
 {
     netMsg.ReadMessage <ObjectSpawnMessage>(ClientScene.s_ObjectSpawnMessage);
     if (!ClientScene.s_ObjectSpawnMessage.assetId.IsValid())
     {
         if (!LogFilter.logError)
         {
             return;
         }
         Debug.LogError((object)("OnObjSpawn netId: " + (object)ClientScene.s_ObjectSpawnMessage.netId + " has invalid asset Id"));
     }
     else
     {
         if (LogFilter.logDebug)
         {
             Debug.Log((object)("Client spawn handler instantiating [netId:" + (object)ClientScene.s_ObjectSpawnMessage.netId + " asset ID:" + (object)ClientScene.s_ObjectSpawnMessage.assetId + " pos:" + (object)ClientScene.s_ObjectSpawnMessage.position + "]"));
         }
         NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, (short)3, ClientScene.GetStringForAssetId(ClientScene.s_ObjectSpawnMessage.assetId), 1);
         NetworkIdentity uv;
         if (ClientScene.s_NetworkScene.GetNetworkIdentity(ClientScene.s_ObjectSpawnMessage.netId, out uv))
         {
             ClientScene.ApplySpawnPayload(uv, ClientScene.s_ObjectSpawnMessage.position, ClientScene.s_ObjectSpawnMessage.payload, ClientScene.s_ObjectSpawnMessage.netId, (GameObject)null);
         }
         else
         {
             GameObject prefab;
             if (NetworkScene.GetPrefab(ClientScene.s_ObjectSpawnMessage.assetId, out prefab))
             {
                 GameObject newGameObject = (GameObject)Object.Instantiate((Object)prefab, ClientScene.s_ObjectSpawnMessage.position, Quaternion.identity);
                 uv = newGameObject.GetComponent <NetworkIdentity>();
                 if ((Object)uv == (Object)null)
                 {
                     if (!LogFilter.logError)
                     {
                         return;
                     }
                     Debug.LogError((object)("Client object spawned for " + (object)ClientScene.s_ObjectSpawnMessage.assetId + " does not have a NetworkIdentity"));
                 }
                 else
                 {
                     ClientScene.ApplySpawnPayload(uv, ClientScene.s_ObjectSpawnMessage.position, ClientScene.s_ObjectSpawnMessage.payload, ClientScene.s_ObjectSpawnMessage.netId, newGameObject);
                 }
             }
             else
             {
                 SpawnDelegate handler;
                 if (NetworkScene.GetSpawnHandler(ClientScene.s_ObjectSpawnMessage.assetId, out handler))
                 {
                     GameObject newGameObject = handler(ClientScene.s_ObjectSpawnMessage.position, ClientScene.s_ObjectSpawnMessage.assetId);
                     if ((Object)newGameObject == (Object)null)
                     {
                         if (!LogFilter.logWarn)
                         {
                             return;
                         }
                         Debug.LogWarning((object)("Client spawn handler for " + (object)ClientScene.s_ObjectSpawnMessage.assetId + " returned null"));
                     }
                     else
                     {
                         uv = newGameObject.GetComponent <NetworkIdentity>();
                         if ((Object)uv == (Object)null)
                         {
                             if (!LogFilter.logError)
                             {
                                 return;
                             }
                             Debug.LogError((object)("Client object spawned for " + (object)ClientScene.s_ObjectSpawnMessage.assetId + " does not have a network identity"));
                         }
                         else
                         {
                             uv.SetDynamicAssetId(ClientScene.s_ObjectSpawnMessage.assetId);
                             ClientScene.ApplySpawnPayload(uv, ClientScene.s_ObjectSpawnMessage.position, ClientScene.s_ObjectSpawnMessage.payload, ClientScene.s_ObjectSpawnMessage.netId, newGameObject);
                         }
                     }
                 }
                 else
                 {
                     if (!LogFilter.logError)
                     {
                         return;
                     }
                     Debug.LogError((object)("Failed to spawn server object, assetId=" + (object)ClientScene.s_ObjectSpawnMessage.assetId + " netId=" + (object)ClientScene.s_ObjectSpawnMessage.netId));
                 }
             }
         }
     }
 }
예제 #13
0
 private static void OnObjectSpawn(NetworkMessage netMsg)
 {
     netMsg.ReadMessage <ObjectSpawnMessage>(ClientScene.s_ObjectSpawnMessage);
     if (!ClientScene.s_ObjectSpawnMessage.assetId.IsValid())
     {
         if (LogFilter.logError)
         {
             Debug.LogError("OnObjSpawn netId: " + ClientScene.s_ObjectSpawnMessage.netId + " has invalid asset Id");
         }
     }
     else
     {
         if (LogFilter.logDebug)
         {
             Debug.Log(string.Concat(new object[]
             {
                 "Client spawn handler instantiating [netId:",
                 ClientScene.s_ObjectSpawnMessage.netId,
                 " asset ID:",
                 ClientScene.s_ObjectSpawnMessage.assetId,
                 " pos:",
                 ClientScene.s_ObjectSpawnMessage.position,
                 "]"
             }));
         }
         NetworkIdentity component;
         GameObject      original;
         SpawnDelegate   spawnDelegate;
         if (ClientScene.s_NetworkScene.GetNetworkIdentity(ClientScene.s_ObjectSpawnMessage.netId, out component))
         {
             ClientScene.ApplySpawnPayload(component, ClientScene.s_ObjectSpawnMessage.position, ClientScene.s_ObjectSpawnMessage.payload, ClientScene.s_ObjectSpawnMessage.netId, null);
         }
         else if (NetworkScene.GetPrefab(ClientScene.s_ObjectSpawnMessage.assetId, out original))
         {
             GameObject gameObject = Object.Instantiate <GameObject>(original, ClientScene.s_ObjectSpawnMessage.position, ClientScene.s_ObjectSpawnMessage.rotation);
             if (LogFilter.logDebug)
             {
                 Debug.Log(string.Concat(new object[]
                 {
                     "Client spawn handler instantiating [netId:",
                     ClientScene.s_ObjectSpawnMessage.netId,
                     " asset ID:",
                     ClientScene.s_ObjectSpawnMessage.assetId,
                     " pos:",
                     ClientScene.s_ObjectSpawnMessage.position,
                     " rotation: ",
                     ClientScene.s_ObjectSpawnMessage.rotation,
                     "]"
                 }));
             }
             component = gameObject.GetComponent <NetworkIdentity>();
             if (component == null)
             {
                 if (LogFilter.logError)
                 {
                     Debug.LogError("Client object spawned for " + ClientScene.s_ObjectSpawnMessage.assetId + " does not have a NetworkIdentity");
                 }
             }
             else
             {
                 component.Reset();
                 ClientScene.ApplySpawnPayload(component, ClientScene.s_ObjectSpawnMessage.position, ClientScene.s_ObjectSpawnMessage.payload, ClientScene.s_ObjectSpawnMessage.netId, gameObject);
             }
         }
         else if (NetworkScene.GetSpawnHandler(ClientScene.s_ObjectSpawnMessage.assetId, out spawnDelegate))
         {
             GameObject gameObject2 = spawnDelegate(ClientScene.s_ObjectSpawnMessage.position, ClientScene.s_ObjectSpawnMessage.assetId);
             if (gameObject2 == null)
             {
                 if (LogFilter.logWarn)
                 {
                     Debug.LogWarning("Client spawn handler for " + ClientScene.s_ObjectSpawnMessage.assetId + " returned null");
                 }
             }
             else
             {
                 component = gameObject2.GetComponent <NetworkIdentity>();
                 if (component == null)
                 {
                     if (LogFilter.logError)
                     {
                         Debug.LogError("Client object spawned for " + ClientScene.s_ObjectSpawnMessage.assetId + " does not have a network identity");
                     }
                 }
                 else
                 {
                     component.Reset();
                     component.SetDynamicAssetId(ClientScene.s_ObjectSpawnMessage.assetId);
                     ClientScene.ApplySpawnPayload(component, ClientScene.s_ObjectSpawnMessage.position, ClientScene.s_ObjectSpawnMessage.payload, ClientScene.s_ObjectSpawnMessage.netId, gameObject2);
                 }
             }
         }
         else if (LogFilter.logError)
         {
             Debug.LogError(string.Concat(new object[]
             {
                 "Failed to spawn server object, did you forget to add it to the NetworkManager? assetId=",
                 ClientScene.s_ObjectSpawnMessage.assetId,
                 " netId=",
                 ClientScene.s_ObjectSpawnMessage.netId
             }));
         }
     }
 }