Example #1
0
        public override void initialize()
        {
            if (s_Logger == null)
                s_Logger = new Logger("Conquest Core", "Client");

            m_MailMan = new ResponseProcessor();

            m_CmdProc = new CommandProcessor(m_MailMan);
            m_CmdProc.initialize();
        }
Example #2
0
        public override void unloadData()
        {
            log("Unloading", "unloadData");

            GridEnforcer.OnPlacementViolation -= eventPlacementViolation;
            GridEnforcer.OnCleanupViolation -= eventCleanupViolation;
            GridEnforcer.OnCleanupTimerStart -= eventCleanupTimerStart;
            GridEnforcer.OnCleanupTimerEnd -= eventCleanupTimerEnd;
            ControlPoint.OnRewardsDistributed -= notifyPlayersOfCPResults;

            if (m_LocalReceiver != null) {
                m_MailMan.localMsgSent -= m_LocalReceiver.incomming;
                m_LocalReceiver.unload();
                m_LocalReceiver = null;
            }

            m_MailMan.unload();

            if (!MyAPIGateway.Utilities.IsDedicated) m_CmdProc.shutdown();

            m_RoundTimer.Dispose();
            m_RoundTimer = null;
            m_SaveTimer.Dispose();
            m_SaveTimer = null;

            s_Logger = null;
        }
Example #3
0
        /// <summary>
        /// Starts up the core on the server
        /// </summary>
        public override void initialize()
        {
            if (MyAPIGateway.Session == null || m_Initialized)
                return;

            if (s_Logger == null)
                s_Logger = new Logger("Conquest Core", "Server");
            log("Conquest core (Server) started");

            s_Settings = ConquestSettings.getInstance();
            s_DelayedSettingWrite = s_Settings.WriteFailed;
            // Start round timer
            m_RoundTimer = new MyTimer(s_Settings.CPPeriod * 1000, roundEnd);
            m_RoundTimer.Start();
            log("Round timer started with " + s_Settings.CPPeriod + " seconds");

            // Start save timer
            m_SaveTimer = new MyTimer(Constants.SaveInterval * 1000, saveTimer);
            m_SaveTimer.Start();
            log("Save timer started");

            m_MailMan = new RequestProcessor();

            // If the server is a player (non-dedicated) they also need to receive notifications
            if (!MyAPIGateway.Utilities.IsDedicated) {
                m_LocalReceiver = new ResponseProcessor(false);
                m_MailMan.localMsgSent += m_LocalReceiver.incomming;
                m_CmdProc = new CommandProcessor(m_LocalReceiver);
                m_CmdProc.initialize();
                m_LocalReceiver.requestSettings();
            }

            // Subscribe events
            GridEnforcer.OnPlacementViolation += eventPlacementViolation;
            GridEnforcer.OnCleanupViolation += eventCleanupViolation;
            GridEnforcer.OnCleanupTimerStart += eventCleanupTimerStart;
            GridEnforcer.OnCleanupTimerEnd += eventCleanupTimerEnd;
            ControlPoint.OnRewardsDistributed += notifyPlayersOfCPResults;

            m_Initialized = true;
        }
 public CommandProcessor(ResponseProcessor mailMan)
 {
     log("Started", "CommandProcessor");
     m_MailMan = mailMan;
 }
Example #5
0
        public override void unloadData()
        {
            log("Unloading", "unloadData");

            GridEnforcer.OnPlacementViolation -= eventPlacementViolation;
            GridEnforcer.OnCleanupViolation -= eventCleanupViolation;
            GridEnforcer.OnCleanupTimerStart -= eventCleanupTimerStart;
            GridEnforcer.OnCleanupTimerEnd -= eventCleanupTimerEnd;

            if (m_LocalReceiver != null) {
                m_MailMan.localMsgSent -= m_LocalReceiver.incomming;
                m_LocalReceiver.unload();
                m_LocalReceiver = null;
            }

            m_MailMan.unload();

            if (!MyAPIGateway.Utilities.IsDedicated) m_CmdProc.shutdown();

            s_Logger = null;
        }
Example #6
0
        /// <summary>
        /// Starts up the core on the server
        /// </summary>
        public override void initialize()
        {
            if (MyAPIGateway.Session == null || m_Initialized)
                return;

            if (s_Logger == null)
                s_Logger = new Logger("Conquest Core", "Server");
            log("Conquest core (Server) started");

            s_TokenBuilder = new MyObjectBuilder_Component() { SubtypeName = "ShipLicense" };
            s_TokenDef = new VRage.ObjectBuilders.SerializableDefinitionId(
                typeof(MyObjectBuilder_InventoryItem), "ShipLicense");
            s_Sorter = new GridSorter();

            s_Settings = ConquestSettings.getInstance();
            s_DelayedSettingWrite = s_Settings.WriteFailed;
            // Start round timer
            m_RoundTimer = new MyTimer(s_Settings.CPPeriod * 1000, roundEnd);
            m_RoundTimer.Start();
            log("Round timer started");

            // Start save timer
            m_SaveTimer = new MyTimer(Constants.SaveInterval * 1000, saveTimer);
            m_SaveTimer.Start();
            log("Save timer started");

            m_MailMan = new RequestProcessor();

            // If the server is a player (non-dedicated) they also need to receive notifications
            if (!MyAPIGateway.Utilities.IsDedicated) {
                m_LocalReceiver = new ResponseProcessor(false);
                m_MailMan.localMsgSent += m_LocalReceiver.incomming;
                m_CmdProc = new CommandProcessor(m_LocalReceiver);
                m_CmdProc.initialize();
                m_LocalReceiver.requestSettings();
            }

            // Subscribe events
            GridEnforcer.OnPlacementViolation += eventPlacementViolation;
            GridEnforcer.OnCleanupViolation += eventCleanupViolation;
            GridEnforcer.OnCleanupTimerStart += eventCleanupTimerStart;
            GridEnforcer.OnCleanupTimerEnd += eventCleanupTimerEnd;

            m_Initialized = true;
        }