summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events/TimeEvents.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-02-24 17:54:31 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-02-24 17:54:31 -0500
commit414cf5c197b5b59776d3dda914eb15710efb0868 (patch)
tree0393a95194ad78cf4440c68657b0488b7db6d68b /src/SMAPI/Events/TimeEvents.cs
parent5da8b707385b9851ff3f6442de58519125f5c96f (diff)
parentf2e8450706d1971d774f870081deffdb0c6b92eb (diff)
downloadSMAPI-414cf5c197b5b59776d3dda914eb15710efb0868.tar.gz
SMAPI-414cf5c197b5b59776d3dda914eb15710efb0868.tar.bz2
SMAPI-414cf5c197b5b59776d3dda914eb15710efb0868.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Events/TimeEvents.cs')
-rw-r--r--src/SMAPI/Events/TimeEvents.cs41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/SMAPI/Events/TimeEvents.cs b/src/SMAPI/Events/TimeEvents.cs
index 9aea5e04..f769fd08 100644
--- a/src/SMAPI/Events/TimeEvents.cs
+++ b/src/SMAPI/Events/TimeEvents.cs
@@ -1,5 +1,5 @@
using System;
-using StardewModdingAPI.Framework;
+using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
@@ -7,31 +7,38 @@ namespace StardewModdingAPI.Events
public static class TimeEvents
{
/*********
- ** Events
+ ** Properties
*********/
- /// <summary>Raised after the game begins a new day, including when loading a save.</summary>
- public static event EventHandler AfterDayStarted;
+ /// <summary>The core event manager.</summary>
+ private static EventManager EventManager;
- /// <summary>Raised after the in-game clock changes.</summary>
- public static event EventHandler<EventArgsIntChanged> TimeOfDayChanged;
/*********
- ** Internal methods
+ ** Events
*********/
- /// <summary>Raise an <see cref="AfterDayStarted"/> event.</summary>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- internal static void InvokeAfterDayStarted(IMonitor monitor)
+ /// <summary>Raised after the game begins a new day, including when loading a save.</summary>
+ public static event EventHandler AfterDayStarted
+ {
+ add => TimeEvents.EventManager.Time_AfterDayStarted.Add(value);
+ remove => TimeEvents.EventManager.Time_AfterDayStarted.Remove(value);
+ }
+
+ /// <summary>Raised after the in-game clock changes.</summary>
+ public static event EventHandler<EventArgsIntChanged> TimeOfDayChanged
{
- monitor.SafelyRaisePlainEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.AfterDayStarted)}", TimeEvents.AfterDayStarted?.GetInvocationList(), null, EventArgs.Empty);
+ add => TimeEvents.EventManager.Time_TimeOfDayChanged.Add(value);
+ remove => TimeEvents.EventManager.Time_TimeOfDayChanged.Remove(value);
}
- /// <summary>Raise a <see cref="TimeOfDayChanged"/> event.</summary>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- /// <param name="priorTime">The previous time in military time format (e.g. 6:00pm is 1800).</param>
- /// <param name="newTime">The current time in military time format (e.g. 6:10pm is 1810).</param>
- internal static void InvokeTimeOfDayChanged(IMonitor monitor, int priorTime, int newTime)
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Initialise the events.</summary>
+ /// <param name="eventManager">The core event manager.</param>
+ internal static void Init(EventManager eventManager)
{
- monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.TimeOfDayChanged)}", TimeEvents.TimeOfDayChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorTime, newTime));
+ TimeEvents.EventManager = eventManager;
}
}
}