summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Events/ManagedEvent.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-23 01:06:11 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-23 01:06:11 -0400
commit584725bb8e554e314843315facca1fd15868bee4 (patch)
treefdb4ecc4a9f190e7e4018fc3334ad8a4bec53e6d /src/SMAPI/Framework/Events/ManagedEvent.cs
parentb07d2340a9a6da22ee0fd95f2c6ccca3939cb7ab (diff)
downloadSMAPI-584725bb8e554e314843315facca1fd15868bee4.tar.gz
SMAPI-584725bb8e554e314843315facca1fd15868bee4.tar.bz2
SMAPI-584725bb8e554e314843315facca1fd15868bee4.zip
add initial AssetRequested content event (#766)
Diffstat (limited to 'src/SMAPI/Framework/Events/ManagedEvent.cs')
-rw-r--r--src/SMAPI/Framework/Events/ManagedEvent.cs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/Events/ManagedEvent.cs b/src/SMAPI/Framework/Events/ManagedEvent.cs
index a200393d..154ef659 100644
--- a/src/SMAPI/Framework/Events/ManagedEvent.cs
+++ b/src/SMAPI/Framework/Events/ManagedEvent.cs
@@ -100,6 +100,14 @@ namespace StardewModdingAPI.Framework.Events
/// <param name="match">A lambda which returns true if the event should be raised for the given mod.</param>
public void Raise(TEventArgs args, Func<IModMetadata, bool> match = null)
{
+ this.Raise((_, invoke) => invoke(args), match);
+ }
+
+ /// <summary>Raise the event and notify all handlers.</summary>
+ /// <param name="invoke">Invoke an event handler. This receives the mod which registered the handler, and should invoke the callback with the event arguments to pass it.</param>
+ /// <param name="match">A lambda which returns true if the event should be raised for the given mod.</param>
+ public void Raise(Action<IModMetadata, Action<TEventArgs>> invoke, Func<IModMetadata, bool> match = null)
+ {
// skip if no handlers
if (this.Handlers.Count == 0)
return;
@@ -128,7 +136,7 @@ namespace StardewModdingAPI.Framework.Events
try
{
- handler.Handler.Invoke(null, args);
+ invoke(handler.SourceMod, args => handler.Handler.Invoke(null, args));
}
catch (Exception ex)
{