Beispiel #1
0
        /// <summary>
        /// Echo the mission information to the console
        /// </summary>
        /// <param name="mission"></param>
        public static void dumpLoadInfo()
        {
            Torque3D.LevelInfo theLevelInfo = Sim.FindObject <Torque3D.LevelInfo>("theLevelInfo");

            Global.echo("Level Name: " + theLevelInfo.Name);
            Global.echo("Level Description:");

            for (int i = 0; !string.IsNullOrEmpty(theLevelInfo.getFieldValue($"desc[{i}]")); i++)
            {
                Global.echo("   " + theLevelInfo.getFieldValue($"desc[{i}]"));
            }
        }
        /// <summary>
        /// This function is called when a client drops for any reason
        /// </summary>
        /// <param name="reason"></param>
        public void onDrop(string reason)
        {
            Torque3D.LevelInfo theLevelInfo = Sim.FindObject <Torque3D.LevelInfo>("TheLevelInfo");
            if (Globals.GetBool("missionRunning"))
            {
                theLevelInfo.call("onClientLeaveGame");
            }

            Server.removeFromServerGuidList(Guid);

            Globals.Decrement("Server::PlayerCount");
        }
Beispiel #3
0
        /// <summary>
        /// Sends mission description to the client
        /// </summary>
        /// <param name="client"></param>
        public static void sendLoadInfoToClient(GameConnectionToClient client)
        {
            Torque3D.LevelInfo theLevelInfo = Sim.FindObject <Torque3D.LevelInfo>("theLevelInfo");
            Message.messageClient(client, Global.addTaggedString("MsgLoadInfo"), "", theLevelInfo.getFieldValue("levelName"));

            for (int i = 0; !string.IsNullOrEmpty(theLevelInfo.getFieldValue($"desc[{i}]")); i++)
            {
                Message.messageClient(client, Global.addTaggedString("MsgLoadDescription"), "", theLevelInfo.getFieldValue(
                                          $"desc[{i}]"));
            }

            Message.messageClient(client, Global.addTaggedString("MsgLoadInfoDone"), "");
        }
Beispiel #4
0
        public static void resetMission()
        {
            Global.echo("*** MISSION RESET");

            SimGroup MissionCleanup = Sim.FindObject <SimGroup>("MissionCleanup");

            // Remove any temporary mission objects
            MissionCleanup.delete();
            Globals.SetString("instantGroup", "ServerGroup");

            MissionCleanup = new SimGroup("MissionCleanup", true);
            Globals.SetString("instantGroup", "MissionCleanup");

            Global.clearServerPaths();
            //
            Torque3D.LevelInfo TheLevelInfo = Sim.FindObject <Torque3D.LevelInfo>("TheLevelInfo");
            //todo onMissionReset
            TheLevelInfo.call("onMissionReset");
        }
Beispiel #5
0
        public static void serverCmdMissionStartPhase3Ack(string client, string seq)
        {
            GameConnectionToClient clientConnection = Sim.FindObject <GameConnectionToClient>(client);

            // Make sure to ignore calls from a previous mission load
            if (!seq.Equals(Globals.GetString("missionSequence")) || !Globals.GetBool("MissionRunning") || clientConnection.CurrentPhase != "2")
            {
                return;
            }

            clientConnection.CurrentPhase = "3";

            // Server is ready to drop into the game

            Torque3D.LevelInfo TheLevelInfo = Sim.FindObject <Torque3D.LevelInfo>("TheLevelInfo");

            //Have any special game-play handling here
            TheLevelInfo.call("onClientEnterGame", client);

            clientConnection.startMission();
        }
        //----------------------------------------------------------------------------
        // Phase 1
        //----------------------------------------------------------------------------
        public void loadMission()
        {
            // Send over the information that will display the server info
            // when we learn it got there, we'll send the data blocks
            CurrentPhase = "0";

            if (isAIControlled())
            {
                Torque3D.LevelInfo TheLevelInfo = Sim.FindObject <Torque3D.LevelInfo>("TheLevelInfo");
                // Cut to the chase...
                TheLevelInfo.call("onEnterGame");
            }
            else
            {
                Global.commandToClient(this,
                                       "MissionStartPhase1".Tag(),
                                       Globals.GetString("missionSequence"),
                                       Globals.GetString("Server::MissionFile"),
                                       Sim.FindObject <SimGroup>("MissionGroup").getFieldValue("musicTrack")
                                       );
                Global.echo("*** Sending mission load to client: " + Globals.GetString("Server::MissionFile"));
            }
        }
Beispiel #7
0
        public static void onServerDestroyed()
        {
            Global.physicsStopSimulation("server");

            if (!Global.isObject("MissionGroup"))
            {
                return;
            }

            Global.echo("*** ENDING MISSION");

            // Inform the game code we're done.
            Torque3D.LevelInfo TheLevelInfo = Sim.FindObject <Torque3D.LevelInfo>("TheLevelInfo");
            //todo onMissionEnded
            TheLevelInfo.call("onMissionEnded");

            SimGroup ClientGroup = Sim.FindObject <SimGroup>("ClientGroup");

            // Inform the clients
            for (uint clientIndex = 0; clientIndex < ClientGroup.getCount(); clientIndex++)
            {
                // clear ghosts and paths from all clients
                GameConnectionToClient cl = ClientGroup.getObject(clientIndex).As <GameConnectionToClient>();
                cl.endMission();
                cl.resetGhosting();
                cl.clearPaths();
            }

            SimGroup MissionGroup   = Sim.FindObject <SimGroup>("MissionGroup");
            SimGroup MissionCleanup = Sim.FindObject <SimGroup>("MissionCleanup");

            // Delete everything
            MissionGroup.delete();
            MissionCleanup.delete();

            Global.clearServerPaths();
        }
Beispiel #8
0
        public static void loadMissionStage2()
        {
            Global.echo("*** Stage 2 load");

            // Create the mission group off the ServerGroup
            Globals.SetString("instantGroup", "ServerGroup");

            // Make sure the mission exists
            string file = Globals.GetString("Server::MissionFile");

            if (!Global.isFile(file))
            {
                Globals.SetString("Server::LoadFailMsg", "Could not find mission \"" + file + "\"");
            }
            else
            {
                // Calculate the mission CRC.  The CRC is used by the clients
                // to caching mission lighting.
                Globals.SetInt("missionCRC", Global.getFileCRC(file));

                // Exec the mission.  The MissionGroup (loaded components) is added to the ServerGroup
                Global.exec(file);

                if (!Global.isObject("MissionGroup"))
                {
                    Globals.SetString("Server::LoadFailMsg", "No 'MissionGroup' found in mission \"" + file + "\".");
                }
            }

            SimSet ClientGroup = Sim.FindObject <SimSet>("ClientGroup");

            if (Globals.GetString("Server::LoadFailMsg") != "")
            {
                // Inform clients that are already connected
                for (uint clientIndex = 0; clientIndex < ClientGroup.getCount(); clientIndex++)
                {
                    Message.messageClient(ClientGroup.getObject(clientIndex).As <GameConnectionToClient>(), "MsgLoadFailed".Tag(), Globals.GetString("Server::LoadFailMsg"));
                }
                return;
            }

            Torque3D.LevelInfo TheLevelInfo = Sim.FindObject <Torque3D.LevelInfo>("TheLevelInfo");

            // Set mission name.
            if (Global.isObject("TheLevelInfo"))
            {
                Globals.SetString("Server::MissionName", TheLevelInfo.getFieldValue("levelName"));
            }

            // Mission cleanup group.  This is where run time components will reside.  The MissionCleanup
            // group will be added to the ServerGroup.
            SimGroup MissionCleanup = new SimGroup("MissionCleanup", true);

            // Make the MissionCleanup group the place where all new objects will automatically be added.
            Globals.SetInt("instantGroup", MissionCleanup.getId());

            // Construct MOD paths
            Global.pathOnMissionLoadDone();

            // Mission loading done...
            Global.echo("*** Mission loaded");

            // Start all the clients in the mission
            Globals.SetBool("missionRunning", true);
            for (uint clientIndex = 0; clientIndex < ClientGroup.getCount(); clientIndex++)
            {
                ClientGroup.getObject(clientIndex).As <GameConnectionToClient>().loadMission();
            }

            // Go ahead and launch the game
            //todo onMissionStart
            TheLevelInfo.call("onMissionStart");
        }