InternalAddPlayer() static private method

static private InternalAddPlayer ( NetworkIdentity view, short playerControllerId ) : void
view NetworkIdentity
playerControllerId short
return void
        private static void OnOwnerMessage(NetworkMessage netMsg)
        {
            netMsg.ReadMessage <OwnerMessage>(ClientScene.s_OwnerMessage);
            if (LogFilter.logDebug)
            {
                Debug.Log((object)("ClientScene::OnOwnerMessage - connectionId=" + (object)netMsg.conn.connectionId + " netId: " + (object)ClientScene.s_OwnerMessage.netId));
            }
            PlayerController playerController;

            if (netMsg.conn.GetPlayerController(ClientScene.s_OwnerMessage.playerControllerId, out playerController))
            {
                playerController.unetView.SetNotLocalPlayer();
            }
            NetworkIdentity uv;

            if (ClientScene.s_NetworkScene.GetNetworkIdentity(ClientScene.s_OwnerMessage.netId, out uv))
            {
                uv.SetConnectionToServer(netMsg.conn);
                uv.SetLocalPlayer(ClientScene.s_OwnerMessage.playerControllerId);
                ClientScene.InternalAddPlayer(uv, ClientScene.s_OwnerMessage.playerControllerId);
            }
            else
            {
                ClientScene.PendingOwner pendingOwner = new ClientScene.PendingOwner()
                {
                    netId = ClientScene.s_OwnerMessage.netId, playerControllerId = ClientScene.s_OwnerMessage.playerControllerId
                };
                ClientScene.s_PendingOwnerIds.Add(pendingOwner);
            }
        }
 private static void CheckForOwner(NetworkIdentity uv)
 {
     for (int index = 0; index < ClientScene.s_PendingOwnerIds.Count; ++index)
     {
         ClientScene.PendingOwner pendingOwnerId = ClientScene.s_PendingOwnerIds[index];
         if (pendingOwnerId.netId == uv.netId)
         {
             uv.SetConnectionToServer(ClientScene.s_ReadyConnection);
             uv.SetLocalPlayer(pendingOwnerId.playerControllerId);
             if (LogFilter.logDev)
             {
                 Debug.Log((object)("ClientScene::OnOwnerMessage - player=" + uv.gameObject.name));
             }
             if (ClientScene.s_ReadyConnection.connectionId < 0)
             {
                 if (!LogFilter.logError)
                 {
                     break;
                 }
                 Debug.LogError((object)"Owner message received on a local client.");
                 break;
             }
             ClientScene.InternalAddPlayer(uv, pendingOwnerId.playerControllerId);
             ClientScene.s_PendingOwnerIds.RemoveAt(index);
             break;
         }
     }
 }
Beispiel #3
0
        private static void CheckForOwner(NetworkIdentity uv)
        {
            int i = 0;

            while (i < ClientScene.s_PendingOwnerIds.Count)
            {
                ClientScene.PendingOwner pendingOwner = ClientScene.s_PendingOwnerIds[i];
                if (pendingOwner.netId == uv.netId)
                {
                    uv.SetConnectionToServer(ClientScene.s_ReadyConnection);
                    uv.SetLocalPlayer(pendingOwner.playerControllerId);
                    if (LogFilter.logDev)
                    {
                        Debug.Log("ClientScene::OnOwnerMessage - player=" + uv.gameObject.name);
                    }
                    if (ClientScene.s_ReadyConnection.connectionId < 0)
                    {
                        if (LogFilter.logError)
                        {
                            Debug.LogError("Owner message received on a local client.");
                        }
                        break;
                    }
                    ClientScene.InternalAddPlayer(uv, pendingOwner.playerControllerId);
                    ClientScene.s_PendingOwnerIds.RemoveAt(i);
                    break;
                }
                else
                {
                    i++;
                }
            }
        }
        internal void AddLocalPlayer(PlayerController localPlayer)
        {
            if (LogFilter.logDev)
            {
                Debug.Log((object)("Local client AddLocalPlayer " + localPlayer.gameObject.name + " conn=" + (object)this.m_Connection.connectionId));
            }
            this.m_Connection.isReady = true;
            this.m_Connection.SetPlayerController(localPlayer);
            NetworkIdentity unetView = localPlayer.unetView;

            if ((Object)unetView != (Object)null)
            {
                ClientScene.SetLocalObject(unetView.netId, localPlayer.gameObject);
                unetView.SetConnectionToServer(this.m_Connection);
            }
            ClientScene.InternalAddPlayer(unetView, localPlayer.playerControllerId);
        }
Beispiel #5
0
        internal void AddLocalPlayer(PlayerController localPlayer)
        {
            if (LogFilter.logDev)
            {
                Debug.Log(string.Concat(new object[] { "Local client AddLocalPlayer ", localPlayer.gameObject.name, " conn=", base.m_Connection.connectionId }));
            }
            base.m_Connection.isReady = true;
            base.m_Connection.SetPlayerController(localPlayer);
            NetworkIdentity unetView = localPlayer.unetView;

            if (unetView != null)
            {
                ClientScene.SetLocalObject(unetView.netId, localPlayer.gameObject);
                unetView.SetConnectionToServer(base.m_Connection);
            }
            ClientScene.InternalAddPlayer(unetView, localPlayer.playerControllerId);
        }
        // Called by the server to set the LocalClient's LocalPlayer object during NetworkServer.AddPlayer()
        internal void AddLocalPlayer(PlayerController localPlayer)
        {
            if (LogFilter.logDev)
            {
                Debug.Log("Local client AddLocalPlayer " + localPlayer.gameObject.name + " conn=" + m_Connection.connectionId);
            }
            m_Connection.isReady = true;
            m_Connection.SetPlayerController(localPlayer);
            var uv = localPlayer.unetView;

            if (uv != null)
            {
                ClientScene.SetLocalObject(uv.netId, localPlayer.gameObject);
                uv.SetConnectionToServer(m_Connection);
            }
            // there is no SystemOwnerMessage for local client. add to ClientScene here instead
            ClientScene.InternalAddPlayer(uv, localPlayer.playerControllerId);
        }
Beispiel #7
0
        private static void OnOwnerMessage(NetworkMessage netMsg)
        {
            netMsg.ReadMessage <OwnerMessage>(ClientScene.s_OwnerMessage);
            if (LogFilter.logDebug)
            {
                Debug.Log(string.Concat(new object[]
                {
                    "ClientScene::OnOwnerMessage - connectionId=",
                    netMsg.conn.connectionId,
                    " netId: ",
                    ClientScene.s_OwnerMessage.netId
                }));
            }
            PlayerController playerController;

            if (netMsg.conn.GetPlayerController(ClientScene.s_OwnerMessage.playerControllerId, out playerController))
            {
                playerController.unetView.SetNotLocalPlayer();
            }
            NetworkIdentity networkIdentity;

            if (ClientScene.s_NetworkScene.GetNetworkIdentity(ClientScene.s_OwnerMessage.netId, out networkIdentity))
            {
                networkIdentity.SetConnectionToServer(netMsg.conn);
                networkIdentity.SetLocalPlayer(ClientScene.s_OwnerMessage.playerControllerId);
                ClientScene.InternalAddPlayer(networkIdentity, ClientScene.s_OwnerMessage.playerControllerId);
            }
            else
            {
                ClientScene.PendingOwner item = new ClientScene.PendingOwner
                {
                    netId = ClientScene.s_OwnerMessage.netId,
                    playerControllerId = ClientScene.s_OwnerMessage.playerControllerId
                };
                ClientScene.s_PendingOwnerIds.Add(item);
            }
        }