diff options
Diffstat (limited to 'src/SMAPI/Framework/Events')
-rw-r--r-- | src/SMAPI/Framework/Events/IManagedEvent.cs | 3 | ||||
-rw-r--r-- | src/SMAPI/Framework/Events/ManagedEvent.cs | 11 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/SMAPI/Framework/Events/IManagedEvent.cs b/src/SMAPI/Framework/Events/IManagedEvent.cs index 0ae8c55a..55994c04 100644 --- a/src/SMAPI/Framework/Events/IManagedEvent.cs +++ b/src/SMAPI/Framework/Events/IManagedEvent.cs @@ -8,5 +8,8 @@ namespace StardewModdingAPI.Framework.Events *********/ /// <summary>A human-readable name for the event.</summary> string EventName { get; } + + /// <summary>Whether any handlers are listening to the event.</summary> + bool HasListeners { get; } } } 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; } |