diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-10-14 11:44:02 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-10-14 11:44:02 -0400 |
commit | 79118316065a01322d8ea12a14589ec016794c32 (patch) | |
tree | 7a26668a66ea0630a2b9367ac820fe7a6d99ac77 /src/SMAPI/Mod.cs | |
parent | af1a2bde8219c5d4b8660b13702725626a4a5647 (diff) | |
parent | 8aec1eff99858716afe7b8604b512181f78c214f (diff) | |
download | SMAPI-79118316065a01322d8ea12a14589ec016794c32.tar.gz SMAPI-79118316065a01322d8ea12a14589ec016794c32.tar.bz2 SMAPI-79118316065a01322d8ea12a14589ec016794c32.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Mod.cs')
-rw-r--r-- | src/SMAPI/Mod.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/SMAPI/Mod.cs b/src/SMAPI/Mod.cs new file mode 100644 index 00000000..ee75ba54 --- /dev/null +++ b/src/SMAPI/Mod.cs @@ -0,0 +1,50 @@ +using System; + +namespace StardewModdingAPI +{ + /// <summary>The base class for a mod.</summary> + public abstract class Mod : IMod, IDisposable + { + /********* + ** Accessors + *********/ + /// <summary>Provides simplified APIs for writing mods.</summary> + public IModHelper Helper { get; internal set; } + + /// <summary>Writes messages to the console and log file.</summary> + public IMonitor Monitor { get; internal set; } + + /// <summary>The mod's manifest.</summary> + public IManifest ModManifest { get; internal set; } + + + /********* + ** Public methods + *********/ + /// <summary>The mod entry point, called after the mod is first loaded.</summary> + /// <param name="helper">Provides simplified APIs for writing mods.</param> + public abstract void Entry(IModHelper helper); + + /// <summary>Release or reset unmanaged resources.</summary> + public void Dispose() + { + (this.Helper as IDisposable)?.Dispose(); // deliberate do this outside overridable dispose method so mods don't accidentally suppress it + this.Dispose(true); + GC.SuppressFinalize(this); + } + + + /********* + ** Private methods + *********/ + /// <summary>Release or reset unmanaged resources when the game exits. There's no guarantee this will be called on every exit.</summary> + /// <param name="disposing">Whether the instance is being disposed explicitly rather than finalised. If this is false, the instance shouldn't dispose other objects since they may already be finalised.</param> + protected virtual void Dispose(bool disposing) { } + + /// <summary>Destruct the instance.</summary> + ~Mod() + { + this.Dispose(false); + } + } +} |