private GameObject NetworkCreatePlayer(int connectionID, Vector3 position, Vector3 eulerAngles)
        {
            if (!ServerValidateInstantiate(Settings.m_PlayerObject))
            {
                return(null);
            }

            CreateRegisteredObject(Settings.m_PlayerObject, position, eulerAngles, NetworkController.Instance.GetConnection(connectionID), out GameObject inst, out NetworkIdentity instIdentity);

            NetworkWriter writer = GetCreatePlayerWriter(connectionID, inst, instIdentity);

            NetworkController.Instance.SendToAll(NetworkController.ReliableSequencedChannel, CreatePlayerMsg, writer.ToArray());

            if (PlayerObjects == null)
            {
                PlayerObjects = new List <NetworkPlayerObject>();
            }

            if (m_PlayerObjectCache == null)
            {
                m_PlayerObjectCache = new Dictionary <int, NetworkPlayerObject>();
            }

            NetworkPlayerObject netPlayer = new NetworkPlayerObject(connectionID, inst);

            PlayerObjects.Add(netPlayer);

            m_PlayerObjectCache[connectionID] = netPlayer;

            return(inst);
        }
        private void OnNetworkSpawnPlayer(NetworkWriter writer)
        {
            if (IsServer)
            {
                return;
            }

            ReadInstantiationMessage(writer, out int connectionID, out int netID, out Vector3 position, out Quaternion rotation, out GameObject prefab, out _, out _);

            NetworkConnection conn = NetworkController.Instance.GetConnection(connectionID);

            if (conn == null || !NetworkController.Instance.IsOnlineScene)
            {
                if (m_BufferedPlayersCreations == null)
                {
                    m_BufferedPlayersCreations = new Dictionary <int, NetworkWriter>();
                }

                m_BufferedPlayersCreations[connectionID] = new NetworkWriter(writer.ToArray());
                return;
            }

            GameObject inst = ClientInstantiateServerObject(netID, position, rotation, prefab, conn, null);

            inst.name += " [Connection " + connectionID + "]";

            if (PlayerObjects == null)
            {
                PlayerObjects = new List <NetworkPlayerObject>();
            }

            if (m_PlayerObjectCache == null)
            {
                m_PlayerObjectCache = new Dictionary <int, NetworkPlayerObject>();
            }

            NetworkPlayerObject netPlayer = new NetworkPlayerObject(connectionID, inst);

            PlayerObjects.Add(netPlayer);

            m_PlayerObjectCache[connectionID] = netPlayer;
        }