fix world events not raised for volcano levels
This commit is contained in:
parent
bbf2c3b020
commit
63111621c9
|
@ -7,6 +7,10 @@
|
|||
* Migrated to Harmony 2.0 (see [_migrate to Harmony 2.0_](https://stardewvalleywiki.com/Modding:Migrate_to_Harmony_2.0) for more info).
|
||||
-->
|
||||
|
||||
## Upcoming release
|
||||
* For modders:
|
||||
* Fixed world events not raised for volcano levels.
|
||||
|
||||
## 3.8
|
||||
Released 21 December 2020 for Stardew Valley 1.5 or later. See [release highlights](https://www.patreon.com/posts/45294737).
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ namespace StardewModdingAPI.Framework.StateTracking
|
|||
/// <summary>Tracks changes to the list of active mine locations.</summary>
|
||||
private readonly ICollectionWatcher<MineShaft> MineLocationListWatcher;
|
||||
|
||||
/// <summary>Tracks changes to the list of active volcano locations.</summary>
|
||||
private readonly ICollectionWatcher<GameLocation> VolcanoLocationListWatcher;
|
||||
|
||||
/// <summary>A lookup of the tracked locations.</summary>
|
||||
private IDictionary<GameLocation, LocationTracker> LocationDict { get; } = new Dictionary<GameLocation, LocationTracker>(new ObjectReferenceComparer<GameLocation>());
|
||||
|
||||
|
@ -53,10 +56,12 @@ namespace StardewModdingAPI.Framework.StateTracking
|
|||
/// <summary>Construct an instance.</summary>
|
||||
/// <param name="locations">The game's list of locations.</param>
|
||||
/// <param name="activeMineLocations">The game's list of active mine locations.</param>
|
||||
public WorldLocationsTracker(ObservableCollection<GameLocation> locations, IList<MineShaft> activeMineLocations)
|
||||
/// <param name="activeVolcanoLocations">The game's list of active volcano locations.</param>
|
||||
public WorldLocationsTracker(ObservableCollection<GameLocation> locations, IList<MineShaft> activeMineLocations, IList<VolcanoDungeon> activeVolcanoLocations)
|
||||
{
|
||||
this.LocationListWatcher = WatcherFactory.ForObservableCollection(locations);
|
||||
this.MineLocationListWatcher = WatcherFactory.ForReferenceList(activeMineLocations);
|
||||
this.VolcanoLocationListWatcher = WatcherFactory.ForReferenceList(activeVolcanoLocations);
|
||||
}
|
||||
|
||||
/// <summary>Update the current value if needed.</summary>
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/// <summary>Set the current value as the baseline.</summary>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace StardewModdingAPI.Framework
|
|||
this.WindowSizeWatcher = WatcherFactory.ForEquatable(() => new Point(Game1.viewport.Width, Game1.viewport.Height));
|
||||
this.TimeWatcher = WatcherFactory.ForEquatable(() => Game1.timeOfDay);
|
||||
this.ActiveMenuWatcher = WatcherFactory.ForReference(() => Game1.activeClickableMenu);
|
||||
this.LocationsWatcher = new WorldLocationsTracker(gameLocations, MineShaft.activeMines);
|
||||
this.LocationsWatcher = new WorldLocationsTracker(gameLocations, MineShaft.activeMines, VolcanoDungeon.activeLevels);
|
||||
this.LocaleWatcher = WatcherFactory.ForGenericEquality(() => LocalizedContentManager.CurrentLanguageCode);
|
||||
this.Watchers.AddRange(new IWatcher[]
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue