public bool EndSession() { var mymod = ResetModeMod.Instance; if (Main.netMode == 1) { throw new Exception("Clients cannot call this."); } // Already ended? if (!this.Data.IsRunning) { LogHelpers.Alert("Already stopped."); return(false); } if (mymod.Config.DebugModeInfo) { string worldId = WorldHelpers.GetUniqueIdForCurrentWorld(true); LogHelpers.Alert("Sets ALL session data to defaults, stops all TimeLimit \"reset\" commands (world id: " + worldId + ")"); } this.IsExiting = false; this.Data.ResetAll(); this.Save(); if (Main.netMode == 2) { SessionProtocol.SyncToClients(); } this.ResetCurrentWorldForSession(); return(true); }
public bool StartSession() { var mymod = ResetModeMod.Instance; if (Main.netMode == 1) { throw new Exception("Clients cannot call this."); } //this.IsExiting = false; // Careful! // Already running? if (this.Data.IsRunning) { LogHelpers.Warn("Session already running"); return(false); } if (mymod.Config.DebugModeInfo) { LogHelpers.Alert(); } this.Data.IsRunning = true; this.Save(); if (Main.netMode == 2) { SessionProtocol.SyncToClients(); } return(true); }
public void ExpireCurrentWorldInSession(ResetModeMod mymod) { if (mymod.Config.DebugModeInfo) { LogHelpers.Alert("Sets AwaitingNextWorld=true, CurrentSessionedWorldId=\"\", PlayersValidated.Clear()"); } this.Data.AwaitingNextWorld = true; this.Data.CurrentSessionedWorldId = ""; this.Data.PlayersValidated.Clear(); if (Main.netMode != 1) { this.Save(); } if (Main.netMode == 2) { SessionProtocol.SyncToClients(); } if (Main.netMode != 1) { this.GoodExit(); } }