diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-27 18:09:04 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-27 18:09:04 -0400 |
commit | 0209e70695b6d12692d4de554ce1fc9d65ca4715 (patch) | |
tree | 011867d845ee3cf2a88f306504a4bdd6fe414ed6 /src/SMAPI/Framework/StateTracking/LocationTracker.cs | |
parent | 2ab2182645179129997eac3fccb63f6f0683dbe1 (diff) | |
parent | e4cd7c8eb09fa50802ce4eb9dbe4683ce61f7a5d (diff) | |
download | SMAPI-0209e70695b6d12692d4de554ce1fc9d65ca4715.tar.gz SMAPI-0209e70695b6d12692d4de554ce1fc9d65ca4715.tar.bz2 SMAPI-0209e70695b6d12692d4de554ce1fc9d65ca4715.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/StateTracking/LocationTracker.cs')
-rw-r--r-- | src/SMAPI/Framework/StateTracking/LocationTracker.cs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/SMAPI/Framework/StateTracking/LocationTracker.cs b/src/SMAPI/Framework/StateTracking/LocationTracker.cs index ff72a19b..790c71dd 100644 --- a/src/SMAPI/Framework/StateTracking/LocationTracker.cs +++ b/src/SMAPI/Framework/StateTracking/LocationTracker.cs @@ -25,7 +25,10 @@ namespace StardewModdingAPI.Framework.StateTracking /********* ** Accessors *********/ - /// <summary>Whether the value changed since the last reset.</summary> + /// <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[] { @@ -88,7 +92,7 @@ namespace StardewModdingAPI.Framework.StateTracking this.UpdateChestWatcherList(added: location.Objects.Pairs, removed: Array.Empty<KeyValuePair<Vector2, SObject>>()); } - /// <summary>Update the current value if needed.</summary> + /// <inheritdoc /> public void Update() { foreach (IWatcher watcher in this.Watchers) @@ -100,7 +104,7 @@ namespace StardewModdingAPI.Framework.StateTracking watcher.Value.Update(); } - /// <summary>Set the current value as the baseline.</summary> + /// <inheritdoc /> public void Reset() { foreach (IWatcher watcher in this.Watchers) @@ -110,7 +114,7 @@ namespace StardewModdingAPI.Framework.StateTracking watcher.Value.Reset(); } - /// <summary>Stop watching the player fields and release all references.</summary> + /// <inheritdoc /> public void Dispose() { foreach (IWatcher watcher in this.Watchers) @@ -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)); } } } |