Esempio n. 1
0
        public static void SceneChanged(byte fromClient, Packet packet)
        {
            string sceneName = packet.ReadString();

            Server.clients[fromClient].player.activeScene = sceneName;

            for (byte i = 1; i <= Server.MaxPlayers; i++)
            {
                if (Server.clients[i].player != null && i != fromClient)
                {
                    if (Server.clients[i].player.activeScene == sceneName)
                    {
                        Log("Same Scene, Spawning Players Subsequent Pass");
                        Player iPlayer    = Server.clients[i].player;
                        Player fromPlayer = Server.clients[fromClient].player;
                        ServerSend.SpawnPlayer(fromClient, iPlayer);
                        ServerSend.SpawnPlayer(i, fromPlayer);
                    }
                    else
                    {
                        Log("Different Scene, Destroying Players");
                        ServerSend.DestroyPlayer(i, fromClient);
                        //ServerSend.DestroyPlayer(fromClient, i);
                    }
                }
            }
        }
 /// <summary>Initial scene load when joining the server for the first time.</summary>
 /// <param name="fromClient">The ID of the client who joined the server</param>
 /// <param name="sceneName">The name of the client's active scene when joining the server</param>
 public static void SceneChanged(byte fromClient, string sceneName, bool other)
 {
     Server.clients[fromClient].player.activeScene         = sceneName;
     Server.clients[fromClient].player.CurrentRoomSyncHost = !other;
     if (!other)
     {
         ServerSend.StartEnemySync(fromClient, true);
     }
     for (byte i = 1; i <= Server.MaxPlayers; i++)
     {
         if (Server.clients[i].player != null && i != fromClient)
         {
             if (Server.clients[i].player.activeScene == sceneName)
             {
                 Log("Same Scene, Spawning Players First Pass");
                 ServerSend.SpawnPlayer(fromClient, Server.clients[i].player);
                 ServerSend.SpawnPlayer(Server.clients[i].player.id, Server.clients[fromClient].player);
                 Player iPlayer    = Server.clients[i].player;
                 Player fromPlayer = Server.clients[fromClient].player;
                 ServerSend.SpawnPlayer(fromClient, iPlayer);
                 ServerSend.SpawnPlayer(i, fromPlayer);
             }
         }
     }
 }
Esempio n. 3
0
        /// <summary>Initial scene load when joining the server for the first time.</summary>
        /// <param name="fromClient">The ID of the client who joined the server</param>
        /// <param name="sceneName">The name of the client's active scene when joining the server</param>
        public static void SceneChanged(byte fromClient, string sceneName)
        {
            Server.clients[fromClient].player.activeScene = sceneName;

            for (byte i = 1; i <= Server.MaxPlayers; i++)
            {
                if (Server.clients[i].player != null && i != fromClient)
                {
                    if (Server.clients[i].player.activeScene == sceneName)
                    {
                        Log("Same Scene, Spawning Players First Pass");
                        ServerSend.SpawnPlayer(fromClient, Server.clients[i].player);
                        ServerSend.SpawnPlayer(Server.clients[i].player.id, Server.clients[fromClient].player);
                    }

                    Player iPlayer    = Server.clients[i].player;
                    Player fromPlayer = Server.clients[fromClient].player;
                    ServerSend.SpawnPlayer(fromClient, iPlayer);
                    ServerSend.SpawnPlayer(i, fromPlayer);

                    // CustomKnight integration
                    if (ServerSettings.CustomKnightIntegration)
                    {
                        Log("Checking Hashes");
                        ServerSend.CheckHashes(i);
                        ServerSend.CheckHashes(fromClient);
                    }
                }
            }
        }
        public static void SceneChanged(byte fromClient, Packet packet)
        {
            string sceneName = packet.ReadString();
            bool   host      = Server.clients[fromClient].player.CurrentRoomSyncHost;
            string oldscene  = Server.clients[fromClient].player.activeScene;

            Server.clients[fromClient].player.activeScene = sceneName;
            bool first       = true;
            bool otherplayer = false;

            for (byte i = 1; i <= Server.MaxPlayers; i++)
            {
                if (Server.clients[i].player != null && i != fromClient)
                {
                    if (Server.clients[i].player.activeScene == sceneName)
                    {
                        Log("Same Scene, Spawning Players Subsequent Pass");
                        Player iPlayer    = Server.clients[i].player;
                        Player fromPlayer = Server.clients[fromClient].player;
                        ServerSend.SpawnPlayer(fromClient, iPlayer);
                        ServerSend.SpawnPlayer(i, fromPlayer);
                        otherplayer = true;
                    }
                    else
                    {
                        if (first && Server.clients[i].player.activeScene == oldscene && host)
                        {
                            Log("Different Scene, Destroying Players And Changing room host");
                            ServerSend.DestroyPlayer(i, fromClient, true);
                            first = false;
                        }
                        else
                        {
                            Log("Different Scene, Destroying Players");
                            ServerSend.DestroyPlayer(i, fromClient, false);
                        }
                        //ServerSend.DestroyPlayer(fromClient, i);
                    }
                }
            }
            if (!otherplayer && !host)
            {
                ServerSend.StartEnemySync(fromClient, true);
            }
            Server.clients[fromClient].player.CurrentRoomSyncHost = !otherplayer;
        }
Esempio n. 5
0
        /// <summary>Initial scene load when joining the server for the first time.</summary>
        /// <param name="fromClient">The ID of the client who joined the server</param>
        /// <param name="sceneName">The name of the client's active scene when joining the server</param>
        public static void SceneChanged(byte fromClient, string sceneName)
        {
            Server.clients[fromClient].player.activeScene = sceneName;

            for (byte i = 1; i <= Server.MaxPlayers; i++)
            {
                if (Server.clients[i].player != null && i != fromClient)
                {
                    if (Server.clients[i].player.activeScene == sceneName)
                    {
                        Log("Same Scene, Spawning Players First Pass");
                        ServerSend.SpawnPlayer(fromClient, Server.clients[i].player);
                        ServerSend.SpawnPlayer(Server.clients[i].player.id, Server.clients[fromClient].player);
                        Player iPlayer    = Server.clients[i].player;
                        Player fromPlayer = Server.clients[fromClient].player;
                        ServerSend.SpawnPlayer(fromClient, iPlayer);
                        ServerSend.SpawnPlayer(i, fromPlayer);
                    }
                }
            }
        }