public override void updateBeforeSimulation() { if (m_NeedSettings) { try { m_NeedSettings = !m_MailMan.requestSettings(); } catch (Exception e) { log("Error" + e, "updateBeforeSimulation", Logger.severity.ERROR); } } if (m_CurrentFrame >= Constants.UpdateFrequency - 1) { if (m_Player.Controller.ControlledEntity is InGame.IMyShipController) { IMyCubeGrid currentControllerGrid = (m_Player.Controller.ControlledEntity as IMyCubeBlock).CubeGrid; IMyCubeBlock classifierBlock = currentControllerGrid.getFirstClassifierBlock(); if (classifierBlock != null && classifierBlock.OwnerId != m_Player.PlayerID && ConquestSettings.getInstance().SimpleOwnership) { MyAPIGateway.Utilities.ShowNotification("WARNING: Take control of the hull classifier or you may be tracked by the original owner!", 1250, MyFontEnum.Red); } } m_CurrentFrame = 0; } ++m_CurrentFrame; }
/// <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(); m_Player = MyAPIGateway.Session.Player; } // Subscribe events GridEnforcer.OnPlacementViolation += eventPlacementViolation; GridEnforcer.OnCleanupViolation += eventCleanupViolation; GridEnforcer.OnCleanupTimerStart += eventCleanupTimerStart; GridEnforcer.OnCleanupTimerEnd += eventCleanupTimerEnd; ControlPoint.OnRewardsDistributed += notifyPlayersOfCPResults; m_CurrentFrame = 0; m_Initialized = true; }