diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-01-16 16:10:57 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-01-16 16:10:57 -0500 |
commit | 6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f (patch) | |
tree | faa9155fae99533110853567003325486f208937 /src/StardewModdingAPI/Events/SaveEvents.cs | |
parent | e8825947ca82c8f28ad9bc8a225fb4fb749814cb (diff) | |
parent | 1f3d3c8c93c7a427486b60cf649b86cef140e88b (diff) | |
download | SMAPI-6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f.tar.gz SMAPI-6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f.tar.bz2 SMAPI-6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Events/SaveEvents.cs')
-rw-r--r-- | src/StardewModdingAPI/Events/SaveEvents.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Events/SaveEvents.cs b/src/StardewModdingAPI/Events/SaveEvents.cs new file mode 100644 index 00000000..2921003a --- /dev/null +++ b/src/StardewModdingAPI/Events/SaveEvents.cs @@ -0,0 +1,46 @@ +using System; +using StardewModdingAPI.Framework; + +namespace StardewModdingAPI.Events +{ + /// <summary>Events raised before and after the player saves/loads the game.</summary> + public static class SaveEvents + { + /********* + ** Events + *********/ + /// <summary>Raised before the game begins writes data to the save file.</summary> + public static event EventHandler BeforeSave; + + /// <summary>Raised after the game finishes writing data to the save file.</summary> + public static event EventHandler AfterSave; + + /// <summary>Raised after the player loads a save slot.</summary> + public static event EventHandler AfterLoad; + + + /********* + ** Internal methods + *********/ + /// <summary>Raise a <see cref="BeforeSave"/> event.</summary> + /// <param name="monitor">Encapsulates monitoring and logging.</param> + internal static void InvokeBeforeSave(IMonitor monitor) + { + monitor.SafelyRaisePlainEvent($"{nameof(SaveEvents)}.{nameof(SaveEvents.BeforeSave)}", SaveEvents.BeforeSave?.GetInvocationList(), null, EventArgs.Empty); + } + + /// <summary>Raise a <see cref="AfterSave"/> event.</summary> + /// <param name="monitor">Encapsulates monitoring and logging.</param> + internal static void InvokeAfterSave(IMonitor monitor) + { + monitor.SafelyRaisePlainEvent($"{nameof(SaveEvents)}.{nameof(SaveEvents.AfterSave)}", SaveEvents.AfterSave?.GetInvocationList(), null, EventArgs.Empty); + } + + /// <summary>Raise a <see cref="AfterLoad"/> event.</summary> + /// <param name="monitor">Encapsulates monitoring and logging.</param> + internal static void InvokeAfterLoad(IMonitor monitor) + { + monitor.SafelyRaisePlainEvent($"{nameof(SaveEvents)}.{nameof(SaveEvents.AfterLoad)}", SaveEvents.AfterLoad?.GetInvocationList(), null, EventArgs.Empty); + } + } +} |