UnityEngine.Networking.NetworkServer.InternalAddPlayerForConnection C# (CSharp) Метод

InternalAddPlayerForConnection() приватный Метод

private InternalAddPlayerForConnection ( NetworkConnection conn, GameObject playerGameObject, short playerControllerId ) : bool
conn NetworkConnection
playerGameObject UnityEngine.GameObject
playerControllerId short
Результат bool
        internal bool InternalAddPlayerForConnection(NetworkConnection conn, GameObject playerGameObject, short playerControllerId)
        {
            NetworkIdentity identity;
            if (!GetNetworkIdentity(playerGameObject, out identity))
            {
                if (LogFilter.logError)
                {
                    Debug.Log("AddPlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to " + playerGameObject);
                }
                return false;
            }
            if (!CheckPlayerControllerIdForConnection(conn, playerControllerId))
            {
                return false;
            }
            PlayerController playerController = null;
            GameObject gameObject = null;
            if (conn.GetPlayerController(playerControllerId, out playerController))
            {
                gameObject = playerController.gameObject;
            }
            if (gameObject != null)
            {
                if (LogFilter.logError)
                {
                    Debug.Log("AddPlayer: player object already exists for playerControllerId of " + playerControllerId);
                }
                return false;
            }
            PlayerController player = new PlayerController(playerGameObject, playerControllerId);
            conn.SetPlayerController(player);
            identity.SetConnectionToClient(conn, player.playerControllerId);
            SetClientReady(conn);
            if (!this.SetupLocalPlayerForConnection(conn, identity, player))
            {
                if (LogFilter.logDebug)
                {
                    Debug.Log(string.Concat(new object[] { "Adding new playerGameObject object netId: ", playerGameObject.GetComponent<NetworkIdentity>().netId, " asset ID ", playerGameObject.GetComponent<NetworkIdentity>().assetId }));
                }
                FinishPlayerForConnection(conn, identity, playerGameObject);
                if (identity.localPlayerAuthority)
                {
                    identity.SetClientOwner(conn);
                }
            }
            return true;
        }