Ejemplo n.º 1
0
        static void OnObjectSpawnFinished(NetworkMessage netMsg)
        {
            ObjectSpawnFinishedMessage msg = new ObjectSpawnFinishedMessage();

            netMsg.ReadMessage(msg);
            if (LogFilter.logDebug)
            {
                Debug.Log("SpawnFinished:" + msg.state);
            }

            if (msg.state == 0)
            {
                PrepareToSpawnSceneObjects();
                s_IsSpawnFinished = false;
                return;
            }

            foreach (var uv in objects.Values)
            {
                if (!uv.isClient)
                {
                    uv.OnStartClient();
                    CheckForOwner(uv);
                }
            }
            s_IsSpawnFinished = true;
        }
Ejemplo n.º 2
0
        static void OnObjectSpawnFinished(NetworkMessage netMsg)
        {
            ObjectSpawnFinishedMessage msg = netMsg.ReadMessage <ObjectSpawnFinishedMessage>();

            if (LogFilter.Debug)
            {
                Debug.Log("SpawnFinished:" + msg.state);
            }

            if (msg.state == 0)
            {
                PrepareToSpawnSceneObjects();
                s_IsSpawnFinished = false;
                return;
            }

            // paul: Initialize the objects in the same order as they were initialized
            // in the server.   This is important if spawned objects
            // use data from scene objects
            foreach (NetworkIdentity identity in NetworkIdentity.spawned.Values.OrderBy(uv => uv.netId))
            {
                if (!identity.isClient)
                {
                    identity.OnStartClient();
                    CheckForOwner(identity);
                }
            }
            s_IsSpawnFinished = true;
        }
Ejemplo n.º 3
0
        internal static void OnObjectSpawnFinished(ObjectSpawnFinishedMessage _)
        {
            logger.Log("SpawnFinished");

            // paul: Initialize the objects in the same order as they were initialized
            // in the server.   This is important if spawned objects
            // use data from scene objects
            foreach (NetworkIdentity identity in NetworkIdentity.spawned.Values.OrderBy(uv => uv.netId))
            {
                identity.NotifyAuthority();
                identity.OnStartClient();
                CheckForLocalPlayer(identity);
            }
            isSpawnFinished = true;
        }
Ejemplo n.º 4
0
        internal static void OnObjectSpawnFinished(NetworkConnection _, ObjectSpawnFinishedMessage msg)
        {
            if (LogFilter.Debug)
            {
                Debug.Log("SpawnFinished");
            }

            // paul: Initialize the objects in the same order as they were initialized
            // in the server.   This is important if spawned objects
            // use data from scene objects
            foreach (NetworkIdentity identity in NetworkIdentity.spawned.Values.OrderBy(uv => uv.netId))
            {
                if (!identity.isClient)
                {
                    identity.OnStartClient();
                    CheckForLocalPlayer(identity);
                }
            }
            isSpawnFinished = true;
        }
Ejemplo n.º 5
0
        internal static void OnObjectSpawnFinished(ObjectSpawnFinishedMessage _)
        {
            if (LogFilter.Debug)
            {
                Debug.Log("SpawnFinished");
            }

            // paul: Initialize the objects in the same order as they were initialized
            // in the server.   This is important if spawned objects
            // use data from scene objects
            foreach (NetworkIdentity identity in NetworkIdentity.spawned.Values.OrderBy(uv => uv.netId))
            {
                identity.hasAuthority = identity.pendingAuthority;
                if (!identity.isClient)
                {
                    identity.OnStartClient();
                }
            }
            if (localPlayer != null)
            {
                OnSpawnMessageForLocalPlayer(localPlayer);
            }
            isSpawnFinished = true;
        }
Ejemplo n.º 6
0
        internal static void SetClientReadyInternal(NetworkConnection conn)
        {
            if (LogFilter.Debug)
            {
                Debug.Log("SetClientReadyInternal for conn:" + conn.connectionId);
            }

            if (conn.isReady)
            {
                if (LogFilter.Debug)
                {
                    Debug.Log("SetClientReady conn " + conn.connectionId + " already ready");
                }
                return;
            }

            if (conn.playerController == null)
            {
                // this is now allowed
                if (LogFilter.Debug)
                {
                    Debug.LogWarning("Ready with no player object");
                }
            }

            conn.isReady = true;

            var localConnection = conn as ULocalConnectionToClient;

            if (localConnection != null)
            {
                if (LogFilter.Debug)
                {
                    Debug.Log("NetworkServer Ready handling ULocalConnectionToClient");
                }

                // Setup spawned objects for local player
                // Only handle the local objects for the first player (no need to redo it when doing more local players)
                // and don't handle player objects here, they were done above
                foreach (NetworkIdentity uv in objects.Values)
                {
                    // Need to call OnStartClient directly here, as it's already been added to the local object dictionary
                    // in the above SetLocalPlayer call
                    if (uv != null && uv.gameObject != null)
                    {
                        var vis = uv.OnCheckObserver(conn);
                        if (vis)
                        {
                            uv.AddObserver(conn);
                        }
                        if (!uv.isClient)
                        {
                            if (LogFilter.Debug)
                            {
                                Debug.Log("LocalClient.SetSpawnObject calling OnStartClient");
                            }
                            uv.OnStartClient();
                        }
                    }
                }
                return;
            }

            // Spawn/update all current server objects
            if (LogFilter.Debug)
            {
                Debug.Log("Spawning " + objects.Count + " objects for conn " + conn.connectionId);
            }

            ObjectSpawnFinishedMessage msg = new ObjectSpawnFinishedMessage();

            msg.state = 0;
            conn.Send((short)MsgType.SpawnFinished, msg);

            foreach (NetworkIdentity uv in objects.Values)
            {
                if (uv == null)
                {
                    Debug.LogWarning("Invalid object found in server local object list (null NetworkIdentity).");
                    continue;
                }
                if (!uv.gameObject.activeSelf)
                {
                    continue;
                }

                if (LogFilter.Debug)
                {
                    Debug.Log("Sending spawn message for current server objects name='" + uv.gameObject.name + "' netId=" + uv.netId);
                }

                var vis = uv.OnCheckObserver(conn);
                if (vis)
                {
                    uv.AddObserver(conn);
                }
            }

            msg.state = 1;
            conn.Send((short)MsgType.SpawnFinished, msg);
        }