From fc6563651389b54f2dca0090218430d774c8de38 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 20 May 2017 07:58:18 -0400 Subject: Document SaveSystem. --- ShiftOS_TheReturn/SaveSystem.cs | 65 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 948f95e..9c812c7 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -39,6 +39,7 @@ using static System.Net.Mime.MediaTypeNames; namespace ShiftOS.Engine { + [Obsolete("Use the servers.conf file instead.")] public class EngineConfig { public bool ConnectToMud = true; @@ -46,16 +47,34 @@ namespace ShiftOS.Engine public int MudDefaultPort = 13370; } + /// + /// Management class for the ShiftOS save system. + /// public static class SaveSystem { + /// + /// Boolean representing whether the system is shutting down. + /// public static bool ShuttingDown = false; + /// + /// Gets or sets the current logged in client-side user. + /// public static ClientSave CurrentUser { get; set; } + /// + /// Boolean representing whether the save system is ready to be used. + /// public static bool Ready = false; + /// + /// Occurs before the save system connects to the ShiftOS Digital Society. + /// public static event Action PreDigitalSocietyConnection; + /// + /// Gets or sets the current server-side save file. + /// public static Save CurrentSave { get; set; } /// @@ -182,7 +201,10 @@ namespace ShiftOS.Engine thread.Start(); } - public static void FinishBootstrap() + /// + /// Finish bootstrapping the engine. + /// + private static void FinishBootstrap() { KernelWatchdog.Log("mud_handshake", "handshake successful: kernel watchdog access code is \"" + ServerManager.thisGuid.ToString() + "\""); @@ -391,8 +413,14 @@ namespace ShiftOS.Engine GameReady?.Invoke(); } + /// + /// Delegate type for events with no caller objects or event arguments. You can use the () => {...} (C#) lambda expression with this delegate + /// public delegate void EmptyEventHandler(); + /// + /// Gets a list of all client-side users. + /// public static List Users { get @@ -401,20 +429,35 @@ namespace ShiftOS.Engine } } + /// + /// Occurs when the engine is loaded and the game can take over. + /// public static event EmptyEventHandler GameReady; + /// + /// Deducts a set amount of Codepoints from the save file... and sends them to a place where they'll never be seen again. + /// + /// The amount of Codepoints to deduct. public static void TransferCodepointsToVoid(long amount) { + if (amount < 0) + throw new ArgumentOutOfRangeException("We see what you did there. Trying to pull Codepoints from the void? That won't work."); CurrentSave.Codepoints -= amount; NotificationDaemon.AddNotification(NotificationType.CodepointsSent, amount); } + /// + /// Restarts the game. + /// public static void Restart() { TerminalBackend.InvokeCommand("sos.shutdown"); System.Windows.Forms.Application.Restart(); } + /// + /// Requests the save file from the server. If authentication fails, this will cause the user to be prompted for their website login and a new save will be created if none is associated with the login. + /// public static void ReadSave() { //Migrate old saves. @@ -458,6 +501,9 @@ namespace ShiftOS.Engine } + /// + /// Creates a new save, starting the Out Of Box Experience (OOBE). + /// public static void NewSave() { AppearanceManager.Invoke(new Action(() => @@ -470,6 +516,9 @@ namespace ShiftOS.Engine })); } + /// + /// Saves the game to the server, updating website stats if possible. + /// public static void SaveGame() { if(!Shiftorium.Silent) @@ -486,15 +535,29 @@ namespace ShiftOS.Engine System.IO.File.WriteAllText(Paths.SaveFile, Utils.ExportMount(0)); } + /// + /// Transfers codepoints from an arbitrary character to the save file. + /// + /// The character name + /// The amount of Codepoints. public static void TransferCodepointsFrom(string who, long amount) { + if (amount < 0) + throw new ArgumentOutOfRangeException("We see what you did there... You can't just give a fake character Codepoints like that. It's better if you transfer them to the void."); NotificationDaemon.AddNotification(NotificationType.CodepointsReceived, amount); CurrentSave.Codepoints += amount; } } + /// + /// Delegate for handling Terminal text input. + /// + /// The text inputted by the user (including prompt text). public delegate void TextSentEventHandler(string text); + /// + /// Denotes that this Terminal command or namespace is for developers. + /// public class DeveloperAttribute : Attribute { -- cgit v1.2.3