diff options
Diffstat (limited to 'src/SMAPI/Framework/StateTracking/LocationTracker.cs')
-rw-r--r-- | src/SMAPI/Framework/StateTracking/LocationTracker.cs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/SMAPI/Framework/StateTracking/LocationTracker.cs b/src/SMAPI/Framework/StateTracking/LocationTracker.cs index 036ed73a..790c71dd 100644 --- a/src/SMAPI/Framework/StateTracking/LocationTracker.cs +++ b/src/SMAPI/Framework/StateTracking/LocationTracker.cs @@ -26,6 +26,9 @@ namespace StardewModdingAPI.Framework.StateTracking ** Accessors *********/ /// <inheritdoc /> + public string Name { get; } + + /// <inheritdoc /> public bool IsChanged => this.Watchers.Any(p => p.IsChanged); /// <summary>The tracked location.</summary> @@ -63,16 +66,17 @@ namespace StardewModdingAPI.Framework.StateTracking /// <param name="location">The location to track.</param> public LocationTracker(GameLocation location) { + this.Name = $"Locations.{location.NameOrUniqueName}"; this.Location = location; // init watchers - this.BuildingsWatcher = location is BuildableGameLocation buildableLocation ? WatcherFactory.ForNetCollection(buildableLocation.buildings) : WatcherFactory.ForImmutableCollection<Building>(); - this.DebrisWatcher = WatcherFactory.ForNetCollection(location.debris); - this.LargeTerrainFeaturesWatcher = WatcherFactory.ForNetCollection(location.largeTerrainFeatures); - this.NpcsWatcher = WatcherFactory.ForNetCollection(location.characters); - this.ObjectsWatcher = WatcherFactory.ForNetDictionary(location.netObjects); - this.TerrainFeaturesWatcher = WatcherFactory.ForNetDictionary(location.terrainFeatures); - this.FurnitureWatcher = WatcherFactory.ForNetCollection(location.furniture); + this.BuildingsWatcher = location is BuildableGameLocation buildableLocation ? WatcherFactory.ForNetCollection($"{this.Name}.{nameof(buildableLocation.buildings)}", buildableLocation.buildings) : WatcherFactory.ForImmutableCollection<Building>(); + this.DebrisWatcher = WatcherFactory.ForNetCollection($"{this.Name}.{nameof(location.debris)}", location.debris); + this.LargeTerrainFeaturesWatcher = WatcherFactory.ForNetCollection($"{this.Name}.{nameof(location.largeTerrainFeatures)}", location.largeTerrainFeatures); + this.NpcsWatcher = WatcherFactory.ForNetCollection($"{this.Name}.{nameof(location.characters)}", location.characters); + this.ObjectsWatcher = WatcherFactory.ForNetDictionary($"{this.Name}.{nameof(location.netObjects)}", location.netObjects); + this.TerrainFeaturesWatcher = WatcherFactory.ForNetDictionary($"{this.Name}.{nameof(location.terrainFeatures)}", location.terrainFeatures); + this.FurnitureWatcher = WatcherFactory.ForNetCollection($"{this.Name}.{nameof(location.furniture)}", location.furniture); this.Watchers.AddRange(new IWatcher[] { @@ -143,7 +147,7 @@ namespace StardewModdingAPI.Framework.StateTracking foreach ((Vector2 tile, SObject? obj) in added) { if (obj is Chest chest && !this.ChestWatchers.ContainsKey(tile)) - this.ChestWatchers.Add(tile, new ChestTracker(chest)); + this.ChestWatchers.Add(tile, new ChestTracker($"{this.Name}.chest({tile})", chest)); } } } |