Exemplo n.º 1
0
        // OnClientAddedPlayer?
        static void OnOwnerMessage(NetworkMessage netMsg)
        {
            OwnerMessage msg = new OwnerMessage();

            netMsg.ReadMessage(msg);

            if (LogFilter.logDebug)
            {
                Debug.Log("ClientScene::OnOwnerMessage - connectionId=" + netMsg.conn.connectionId + " netId: " + msg.netId);
            }


            // is there already an owner that is a different object??
            if (netMsg.conn.playerController != null)
            {
                netMsg.conn.playerController.SetNotLocalPlayer();
            }

            NetworkIdentity localNetworkIdentity;

            if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localNetworkIdentity))
            {
                // this object already exists
                localNetworkIdentity.SetConnectionToServer(netMsg.conn);
                localNetworkIdentity.SetLocalPlayer();
                InternalAddPlayer(localNetworkIdentity);
            }
            else
            {
                s_PendingOwnerIds.Add(msg.netId);
            }
        }
Exemplo n.º 2
0
        // OnClientAddedPlayer?
        static void OnOwnerMessage(NetworkMessage netMsg)
        {
            OwnerMessage msg = netMsg.ReadMessage <OwnerMessage>();

            if (LogFilter.Debug)
            {
                Debug.Log("ClientScene::OnOwnerMessage - connectionId=" + netMsg.conn.connectionId + " netId: " + msg.netId);
            }

            // is there already an owner that is a different object??
            netMsg.conn.playerController?.SetNotLocalPlayer();

            NetworkIdentity localObject;

            if (NetworkIdentity.spawned.TryGetValue(msg.netId, out localObject) && localObject != null)
            {
                // this object already exists
                localObject.SetConnectionToServer(netMsg.conn);
                localObject.SetLocalPlayer();
                InternalAddPlayer(localObject);
            }
            else
            {
                s_PendingOwnerNetIds.Add(msg.netId);
            }
        }
Exemplo n.º 3
0
        static void FinishPlayerForConnection(NetworkConnection conn, NetworkIdentity uv, GameObject playerGameObject)
        {
            if (uv.netId == 0)
            {
                // it is allowed to provide an already spawned object as the new player object.
                // so dont spawn it again.
                Spawn(playerGameObject);
            }

            OwnerMessage owner = new OwnerMessage();

            owner.netId = uv.netId;
            conn.Send((short)MsgType.Owner, owner);
        }
Exemplo n.º 4
0
        static void FinishPlayerForConnection(NetworkConnection conn, NetworkIdentity identity, GameObject playerGameObject)
        {
            if (identity.netId == 0)
            {
                // it is allowed to provide an already spawned object as the new player object.
                // so dont spawn it again.
                Spawn(playerGameObject);
            }

            OwnerMessage owner = new OwnerMessage
            {
                netId = identity.netId
            };
            conn.Send(owner);
        }
Exemplo n.º 5
0
        // OnClientAddedPlayer?
        internal static void OnOwnerMessage(NetworkConnection conn, OwnerMessage msg)
        {
            if (LogFilter.Debug)
            {
                Debug.Log("ClientScene.OnOwnerMessage - connectionId=" + readyConnection.connectionId + " netId: " + msg.netId);
            }

            // is there already an owner that is a different object??
            readyConnection.playerController?.SetNotLocalPlayer();

            if (NetworkIdentity.spawned.TryGetValue(msg.netId, out NetworkIdentity localObject) && localObject != null)
            {
                // this object already exists
                localObject.connectionToServer = readyConnection;
                localObject.SetLocalPlayer();
                InternalAddPlayer(localObject);
            }
            else
            {
                pendingOwnerNetIds.Add(msg.netId);
            }
        }