summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/SModHooks.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework/SModHooks.cs')
-rw-r--r--src/SMAPI/Framework/SModHooks.cs30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/SModHooks.cs b/src/SMAPI/Framework/SModHooks.cs
index 7dafc746..101e022a 100644
--- a/src/SMAPI/Framework/SModHooks.cs
+++ b/src/SMAPI/Framework/SModHooks.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading.Tasks;
using StardewValley;
namespace StardewModdingAPI.Framework
@@ -12,15 +13,20 @@ namespace StardewModdingAPI.Framework
/// <summary>A callback to invoke before <see cref="Game1.newDayAfterFade"/> runs.</summary>
private readonly Action BeforeNewDayAfterFade;
+ /// <summary>Writes messages to the console.</summary>
+ private readonly IMonitor Monitor;
+
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="beforeNewDayAfterFade">A callback to invoke before <see cref="Game1.newDayAfterFade"/> runs.</param>
- public SModHooks(Action beforeNewDayAfterFade)
+ /// <param name="monitor">Writes messages to the console.</param>
+ public SModHooks(Action beforeNewDayAfterFade, IMonitor monitor)
{
this.BeforeNewDayAfterFade = beforeNewDayAfterFade;
+ this.Monitor = monitor;
}
/// <summary>A hook invoked when <see cref="Game1.newDayAfterFade"/> is called.</summary>
@@ -30,5 +36,27 @@ namespace StardewModdingAPI.Framework
this.BeforeNewDayAfterFade?.Invoke();
action();
}
+
+ /// <summary>Start an asynchronous task for the game.</summary>
+ /// <param name="task">The task to start.</param>
+ /// <param name="id">A unique key which identifies the task.</param>
+ public override Task StartTask(Task task, string id)
+ {
+ this.Monitor.Log($"Synchronizing '{id}' task...");
+ task.RunSynchronously();
+ this.Monitor.Log(" task complete.");
+ return task;
+ }
+
+ /// <summary>Start an asynchronous task for the game.</summary>
+ /// <param name="task">The task to start.</param>
+ /// <param name="id">A unique key which identifies the task.</param>
+ public override Task<T> StartTask<T>(Task<T> task, string id)
+ {
+ this.Monitor.Log($"Synchronizing '{id}' task...");
+ task.RunSynchronously();
+ this.Monitor.Log(" task complete.");
+ return task;
+ }
}
}