From 63111621c9375ac2e9a68eefa73ffe1d817000dd Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 23 Dec 2020 19:11:41 -0500 Subject: fix world events not raised for volcano levels --- .../Framework/StateTracking/WorldLocationsTracker.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/SMAPI/Framework/StateTracking') diff --git a/src/SMAPI/Framework/StateTracking/WorldLocationsTracker.cs b/src/SMAPI/Framework/StateTracking/WorldLocationsTracker.cs index 303a4f3a..e968d79c 100644 --- a/src/SMAPI/Framework/StateTracking/WorldLocationsTracker.cs +++ b/src/SMAPI/Framework/StateTracking/WorldLocationsTracker.cs @@ -21,6 +21,9 @@ namespace StardewModdingAPI.Framework.StateTracking /// Tracks changes to the list of active mine locations. private readonly ICollectionWatcher MineLocationListWatcher; + /// Tracks changes to the list of active volcano locations. + private readonly ICollectionWatcher VolcanoLocationListWatcher; + /// A lookup of the tracked locations. private IDictionary LocationDict { get; } = new Dictionary(new ObjectReferenceComparer()); @@ -53,10 +56,12 @@ namespace StardewModdingAPI.Framework.StateTracking /// Construct an instance. /// The game's list of locations. /// The game's list of active mine locations. - public WorldLocationsTracker(ObservableCollection locations, IList activeMineLocations) + /// The game's list of active volcano locations. + public WorldLocationsTracker(ObservableCollection locations, IList activeMineLocations, IList activeVolcanoLocations) { this.LocationListWatcher = WatcherFactory.ForObservableCollection(locations); this.MineLocationListWatcher = WatcherFactory.ForReferenceList(activeMineLocations); + this.VolcanoLocationListWatcher = WatcherFactory.ForReferenceList(activeVolcanoLocations); } /// Update the current value if needed. @@ -65,6 +70,7 @@ namespace StardewModdingAPI.Framework.StateTracking // update watchers this.LocationListWatcher.Update(); this.MineLocationListWatcher.Update(); + this.VolcanoLocationListWatcher.Update(); foreach (LocationTracker watcher in this.Locations) watcher.Update(); @@ -79,6 +85,11 @@ namespace StardewModdingAPI.Framework.StateTracking this.Remove(this.MineLocationListWatcher.Removed); this.Add(this.MineLocationListWatcher.Added); } + if (this.VolcanoLocationListWatcher.IsChanged) + { + this.Remove(this.VolcanoLocationListWatcher.Removed); + this.Add(this.VolcanoLocationListWatcher.Added); + } // detect building changed foreach (LocationTracker watcher in this.Locations.Where(p => p.BuildingsWatcher.IsChanged).ToArray()) @@ -107,6 +118,7 @@ namespace StardewModdingAPI.Framework.StateTracking this.Added.Clear(); this.LocationListWatcher.Reset(); this.MineLocationListWatcher.Reset(); + this.VolcanoLocationListWatcher.Reset(); } /// Set the current value as the baseline. @@ -243,6 +255,7 @@ namespace StardewModdingAPI.Framework.StateTracking { yield return this.LocationListWatcher; yield return this.MineLocationListWatcher; + yield return this.VolcanoLocationListWatcher; foreach (LocationTracker watcher in this.Locations) yield return watcher; } -- cgit