add base implementation for mod event classes (#310)

This commit is contained in:
Jesse Plamondon-Willard 2018-06-02 01:47:33 -04:00
parent a29e2c59d4
commit 97a2bdfdd4
3 changed files with 31 additions and 15 deletions

View File

@ -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;
}
}
}

View File

@ -4,18 +4,8 @@ using StardewModdingAPI.Events;
namespace StardewModdingAPI.Framework.Events namespace StardewModdingAPI.Framework.Events
{ {
/// <summary>Events raised when something changes in the world.</summary> /// <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 ** Accessors
*********/ *********/
@ -69,9 +59,6 @@ namespace StardewModdingAPI.Framework.Events
/// <param name="mod">The mod which uses this instance.</param> /// <param name="mod">The mod which uses this instance.</param>
/// <param name="eventManager">The underlying event manager.</param> /// <param name="eventManager">The underlying event manager.</param>
internal ModWorldEvents(IModMetadata mod, EventManager eventManager) internal ModWorldEvents(IModMetadata mod, EventManager eventManager)
{ : base(mod, eventManager) { }
this.Mod = mod;
this.EventManager = eventManager;
}
} }
} }

View File

@ -98,6 +98,7 @@
<Compile Include="Framework\ContentManagers\GameContentManager.cs" /> <Compile Include="Framework\ContentManagers\GameContentManager.cs" />
<Compile Include="Framework\ContentManagers\IContentManager.cs" /> <Compile Include="Framework\ContentManagers\IContentManager.cs" />
<Compile Include="Framework\ContentManagers\ModContentManager.cs" /> <Compile Include="Framework\ContentManagers\ModContentManager.cs" />
<Compile Include="Framework\Events\ModEventsBase.cs" />
<Compile Include="Framework\Events\EventManager.cs" /> <Compile Include="Framework\Events\EventManager.cs" />
<Compile Include="Events\IModEvents.cs" /> <Compile Include="Events\IModEvents.cs" />
<Compile Include="Framework\Events\ManagedEvent.cs" /> <Compile Include="Framework\Events\ManagedEvent.cs" />