using System; using System.Threading.Tasks; using StardewModdingAPI.Utilities; using StardewValley; namespace StardewModdingAPI.Framework { /// Invokes callbacks for mod hooks provided by the game. internal class SModHooks : DelegatingModHooks { /********* ** Fields *********/ /// A callback to invoke before runs. private readonly Action BeforeNewDayAfterFade; /// Writes messages to the console. private readonly IMonitor Monitor; /********* ** Public methods *********/ /// Construct an instance. /// The underlying hooks to call by default. /// A callback to invoke before runs. /// Writes messages to the console. public SModHooks(ModHooks parent, Action beforeNewDayAfterFade, IMonitor monitor) : base(parent) { this.BeforeNewDayAfterFade = beforeNewDayAfterFade; this.Monitor = monitor; } /// public override void OnGame1_NewDayAfterFade(Action action) { this.BeforeNewDayAfterFade(); action(); } /// public override Task StartTask(Task task, string id) { this.Monitor.Log($"Synchronizing '{id}' task..."); task.RunSynchronously(); this.Monitor.Log(" task complete."); return task; } /// public override Task StartTask(Task task, string id) { this.Monitor.Log($"Synchronizing '{id}' task..."); task.RunSynchronously(); this.Monitor.Log(" task complete."); return task; } } }