From 077c897d53371d12c812be5145d917c59583d7cb Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 11 May 2022 19:29:57 -0400 Subject: replace event.HasListeners() with property --- src/SMAPI/Framework/Events/ManagedEvent.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/SMAPI/Framework/Events/ManagedEvent.cs') 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 /// public string EventName { get; } + /// + public bool HasListeners { get; private set; } + /********* ** Public methods @@ -52,12 +55,6 @@ namespace StardewModdingAPI.Framework.Events this.ModRegistry = modRegistry; } - /// Get whether anything is listening to the event. - public bool HasListeners() - { - return this.Handlers.Count > 0; - } - /// Add an event handler. /// The event handler. /// The mod which added the event handler. @@ -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; } -- cgit