Stardew_Valley_Mods/GeneralMods/MapEvents/EventSystem.cs

42 lines
1.5 KiB
C#
Raw Permalink Normal View History

using EventSystem.Framework;
using StardewModdingAPI;
2019-01-06 15:21:06 +08:00
using StardewModdingAPI.Events;
2018-02-24 05:55:51 +08:00
namespace EventSystem
{
// TODO: Make Bed/Sleep Event.
public class EventSystem : Mod
2018-02-24 05:55:51 +08:00
{
public static IModHelper ModHelper;
public static IMonitor ModMonitor;
public static EventManager eventManager;
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
2018-02-24 05:55:51 +08:00
public override void Entry(IModHelper helper)
{
ModHelper = this.Helper;
ModMonitor = this.Monitor;
2019-01-06 15:21:06 +08:00
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
2018-02-24 05:55:51 +08:00
}
2019-01-06 15:21:06 +08:00
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
2018-02-24 05:55:51 +08:00
{
eventManager = new EventManager();
}
2019-01-06 15:21:06 +08:00
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
2018-02-24 05:55:51 +08:00
{
eventManager?.update();
2018-02-24 05:55:51 +08:00
}
}
}