UnityEngine.Networking.NetworkLobbyManager.OnServerAddPlayer C# (CSharp) Method

OnServerAddPlayer() public method

public OnServerAddPlayer ( NetworkConnection conn, short playerControllerId ) : void
conn NetworkConnection
playerControllerId short
return void
        public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
        {
            if (Application.loadedLevelName == this.m_LobbyScene)
            {
                int num = 0;
                foreach (PlayerController controller in conn.playerControllers)
                {
                    if (controller.IsValid)
                    {
                        num++;
                    }
                }
                if (num >= this.maxPlayersPerConnection)
                {
                    if (LogFilter.logWarn)
                    {
                        Debug.LogWarning("NetworkLobbyManager no more players for this connection.");
                    }
                    EmptyMessage msg = new EmptyMessage();
                    conn.Send(0x2d, msg);
                }
                else
                {
                    byte index = this.FindSlot();
                    if (index == 0xff)
                    {
                        if (LogFilter.logWarn)
                        {
                            Debug.LogWarning("NetworkLobbyManager no space for more players");
                        }
                        EmptyMessage message2 = new EmptyMessage();
                        conn.Send(0x2d, message2);
                    }
                    else
                    {
                        GameObject obj2 = this.OnLobbyServerCreateLobbyPlayer(conn, playerControllerId);
                        if (obj2 == null)
                        {
                            obj2 = (GameObject) UnityEngine.Object.Instantiate(this.lobbyPlayerPrefab.gameObject, Vector3.zero, Quaternion.identity);
                        }
                        NetworkLobbyPlayer component = obj2.GetComponent<NetworkLobbyPlayer>();
                        component.slot = index;
                        this.lobbySlots[index] = component;
                        NetworkServer.AddPlayerForConnection(conn, obj2, playerControllerId);
                    }
                }
            }
        }