diff options
Diffstat (limited to 'src/SMAPI')
-rw-r--r-- | src/SMAPI/Framework/Events/ModEventsBase.cs | 28 | ||||
-rw-r--r-- | src/SMAPI/Framework/Events/ModWorldEvents.cs | 17 | ||||
-rw-r--r-- | src/SMAPI/StardewModdingAPI.csproj | 1 |
3 files changed, 31 insertions, 15 deletions
diff --git a/src/SMAPI/Framework/Events/ModEventsBase.cs b/src/SMAPI/Framework/Events/ModEventsBase.cs new file mode 100644 index 00000000..545c58a8 --- /dev/null +++ b/src/SMAPI/Framework/Events/ModEventsBase.cs @@ -0,0 +1,28 @@ +namespace StardewModdingAPI.Framework.Events +{ + /// <summary>An internal base class for event API classes.</summary> + internal abstract class ModEventsBase + { + /********* + ** Properties + *********/ + /// <summary>The underlying event manager.</summary> + protected readonly EventManager EventManager; + + /// <summary>The mod which uses this instance.</summary> + protected readonly IModMetadata Mod; + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="mod">The mod which uses this instance.</param> + /// <param name="eventManager">The underlying event manager.</param> + internal ModEventsBase(IModMetadata mod, EventManager eventManager) + { + this.Mod = mod; + this.EventManager = eventManager; + } + } +} diff --git a/src/SMAPI/Framework/Events/ModWorldEvents.cs b/src/SMAPI/Framework/Events/ModWorldEvents.cs index db03e447..e1a53e0c 100644 --- a/src/SMAPI/Framework/Events/ModWorldEvents.cs +++ b/src/SMAPI/Framework/Events/ModWorldEvents.cs @@ -4,19 +4,9 @@ using StardewModdingAPI.Events; namespace StardewModdingAPI.Framework.Events { /// <summary>Events raised when something changes in the world.</summary> - public class ModWorldEvents : IWorldEvents + internal class ModWorldEvents : ModEventsBase, IWorldEvents { /********* - ** Properties - *********/ - /// <summary>The underlying event manager.</summary> - private readonly EventManager EventManager; - - /// <summary>The mod which uses this instance.</summary> - private readonly IModMetadata Mod; - - - /********* ** Accessors *********/ /// <summary>Raised after a game location is added or removed.</summary> @@ -69,9 +59,6 @@ namespace StardewModdingAPI.Framework.Events /// <param name="mod">The mod which uses this instance.</param> /// <param name="eventManager">The underlying event manager.</param> internal ModWorldEvents(IModMetadata mod, EventManager eventManager) - { - this.Mod = mod; - this.EventManager = eventManager; - } + : base(mod, eventManager) { } } } diff --git a/src/SMAPI/StardewModdingAPI.csproj b/src/SMAPI/StardewModdingAPI.csproj index f9c93671..7b9629e2 100644 --- a/src/SMAPI/StardewModdingAPI.csproj +++ b/src/SMAPI/StardewModdingAPI.csproj @@ -98,6 +98,7 @@ <Compile Include="Framework\ContentManagers\GameContentManager.cs" /> <Compile Include="Framework\ContentManagers\IContentManager.cs" /> <Compile Include="Framework\ContentManagers\ModContentManager.cs" /> + <Compile Include="Framework\Events\ModEventsBase.cs" /> <Compile Include="Framework\Events\EventManager.cs" /> <Compile Include="Events\IModEvents.cs" /> <Compile Include="Framework\Events\ManagedEvent.cs" /> |