public void TryToAddPlayer()
{
if (!NetworkClient.active)
{
if (LogFilter.logDebug)
{
Debug.Log("NetworkLobbyManager NetworkClient not active!");
}
}
else
{
short playerControllerId = -1;
List<PlayerController> playerControllers = NetworkClient.allClients[0].connection.playerControllers;
if (playerControllers.Count < this.maxPlayers)
{
playerControllerId = (short) playerControllers.Count;
}
else
{
for (short i = 0; i < this.maxPlayers; i = (short) (i + 1))
{
if (!playerControllers[i].IsValid)
{
playerControllerId = i;
break;
}
}
}
if (LogFilter.logDebug)
{
Debug.Log(string.Concat(new object[] { "NetworkLobbyManager TryToAddPlayer controllerId ", playerControllerId, " ready:", ClientScene.ready }));
}
if (playerControllerId == -1)
{
if (LogFilter.logDebug)
{
Debug.Log("NetworkLobbyManager No Space!");
}
}
else if (ClientScene.ready)
{
ClientScene.AddPlayer(playerControllerId);
}
else
{
ClientScene.AddPlayer(NetworkClient.allClients[0].connection, playerControllerId);
}
}
}