summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Events/ManagedEvent.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-11 19:29:57 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-11 19:29:57 -0400
commit077c897d53371d12c812be5145d917c59583d7cb (patch)
treecd2507cf7962720d4cf0844867f9ad62736b3b87 /src/SMAPI/Framework/Events/ManagedEvent.cs
parent05b39b7cd9a40f1660c2c53ef70b75a67f2fccc3 (diff)
downloadSMAPI-077c897d53371d12c812be5145d917c59583d7cb.tar.gz
SMAPI-077c897d53371d12c812be5145d917c59583d7cb.tar.bz2
SMAPI-077c897d53371d12c812be5145d917c59583d7cb.zip
replace event.HasListeners() with property
Diffstat (limited to 'src/SMAPI/Framework/Events/ManagedEvent.cs')
-rw-r--r--src/SMAPI/Framework/Events/ManagedEvent.cs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/SMAPI/Framework/Events/ManagedEvent.cs b/src/SMAPI/Framework/Events/ManagedEvent.cs
index a34106ce..8a3ca839 100644
--- a/src/SMAPI/Framework/Events/ManagedEvent.cs
+++ b/src/SMAPI/Framework/Events/ManagedEvent.cs
@@ -39,6 +39,9 @@ namespace StardewModdingAPI.Framework.Events
/// <inheritdoc />
public string EventName { get; }
+ /// <inheritdoc />
+ public bool HasListeners { get; private set; }
+
/*********
** Public methods
@@ -52,12 +55,6 @@ namespace StardewModdingAPI.Framework.Events
this.ModRegistry = modRegistry;
}
- /// <summary>Get whether anything is listening to the event.</summary>
- public bool HasListeners()
- {
- return this.Handlers.Count > 0;
- }
-
/// <summary>Add an event handler.</summary>
/// <param name="handler">The event handler.</param>
/// <param name="mod">The mod which added the event handler.</param>
@@ -70,6 +67,7 @@ namespace StardewModdingAPI.Framework.Events
this.Handlers.Add(managedHandler);
this.CachedHandlers = null;
+ this.HasListeners = true;
this.HasPriorities |= priority != EventPriority.Normal;
}
}
@@ -88,6 +86,7 @@ namespace StardewModdingAPI.Framework.Events
this.Handlers.RemoveAt(i);
this.CachedHandlers = null;
+ this.HasListeners = this.Handlers.Count != 0;
this.HasRemovedHandlers = true;
break;
}