From 5675f9fcebfdeb03510c347712df8e9934b362c6 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 23 May 2022 12:57:33 -0400 Subject: [PATCH] add watcher names to simplify troubleshooting --- .../Framework/StateTracking/ChestTracker.cs | 5 ++- .../FieldWatchers/ComparableListWatcher.cs | 7 ++- .../FieldWatchers/ComparableWatcher.cs | 7 ++- .../ImmutableCollectionWatcher.cs | 3 ++ .../FieldWatchers/NetCollectionWatcher.cs | 7 ++- .../FieldWatchers/NetDictionaryWatcher.cs | 7 ++- .../FieldWatchers/NetListWatcher.cs | 7 ++- .../FieldWatchers/NetValueWatcher.cs | 7 ++- .../ObservableCollectionWatcher.cs | 7 ++- .../FieldWatchers/WatcherFactory.cs | 45 +++++++++++-------- src/SMAPI/Framework/StateTracking/IWatcher.cs | 3 ++ .../StateTracking/LocationTracker.cs | 20 +++++---- .../Framework/StateTracking/PlayerTracker.cs | 14 +++--- .../StateTracking/WorldLocationsTracker.cs | 9 ++-- src/SMAPI/Framework/WatcherCore.cs | 14 +++--- 15 files changed, 110 insertions(+), 52 deletions(-) diff --git a/src/SMAPI/Framework/StateTracking/ChestTracker.cs b/src/SMAPI/Framework/StateTracking/ChestTracker.cs index c33a7498..2796ad54 100644 --- a/src/SMAPI/Framework/StateTracking/ChestTracker.cs +++ b/src/SMAPI/Framework/StateTracking/ChestTracker.cs @@ -39,11 +39,12 @@ namespace StardewModdingAPI.Framework.StateTracking ** Public methods *********/ /// Construct an instance. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The chest being tracked. - public ChestTracker(Chest chest) + public ChestTracker(string name, Chest chest) { this.Chest = chest; - this.InventoryWatcher = WatcherFactory.ForNetList(chest.items); + this.InventoryWatcher = WatcherFactory.ForNetList($"{name}.{nameof(chest.items)}", chest.items); this.StackSizes = this.Chest.items .Where(n => n != null) diff --git a/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableListWatcher.cs b/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableListWatcher.cs index 3d178a36..0b13434a 100644 --- a/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableListWatcher.cs +++ b/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableListWatcher.cs @@ -26,6 +26,9 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers /********* ** Accessors *********/ + /// + public string Name { get; } + /// public bool IsChanged => this.AddedImpl.Count > 0 || this.RemovedImpl.Count > 0; @@ -40,10 +43,12 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers ** Public methods *********/ /// Construct an instance. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The collection to watch. /// The equality comparer which indicates whether two values are the same. - public ComparableListWatcher(ICollection values, IEqualityComparer comparer) + public ComparableListWatcher(string name, ICollection values, IEqualityComparer comparer) { + this.Name = name; this.CurrentValues = values; this.LastValues = new HashSet(comparer); } diff --git a/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableWatcher.cs b/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableWatcher.cs index e51c46c1..e2f6c7fd 100644 --- a/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableWatcher.cs +++ b/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableWatcher.cs @@ -20,6 +20,9 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers /********* ** Accessors *********/ + /// + public string Name { get; } + /// public TValue PreviousValue { get; private set; } @@ -34,10 +37,12 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers ** Public methods *********/ /// Construct an instance. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// Get the current value. /// The equality comparer which indicates whether two values are the same. - public ComparableWatcher(Func getValue, IEqualityComparer comparer) + public ComparableWatcher(string name, Func getValue, IEqualityComparer comparer) { + this.Name = name; this.GetValue = getValue; this.Comparer = comparer; this.CurrentValue = getValue(); diff --git a/src/SMAPI/Framework/StateTracking/FieldWatchers/ImmutableCollectionWatcher.cs b/src/SMAPI/Framework/StateTracking/FieldWatchers/ImmutableCollectionWatcher.cs index b46e0b24..9c2ba9bc 100644 --- a/src/SMAPI/Framework/StateTracking/FieldWatchers/ImmutableCollectionWatcher.cs +++ b/src/SMAPI/Framework/StateTracking/FieldWatchers/ImmutableCollectionWatcher.cs @@ -13,6 +13,9 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers /// A singleton collection watcher instance. public static ImmutableCollectionWatcher Instance { get; } = new(); + /// + public string Name => nameof(ImmutableCollectionWatcher); + /// public bool IsChanged { get; } = false; diff --git a/src/SMAPI/Framework/StateTracking/FieldWatchers/NetCollectionWatcher.cs b/src/SMAPI/Framework/StateTracking/FieldWatchers/NetCollectionWatcher.cs index e278fa99..1d5e4851 100644 --- a/src/SMAPI/Framework/StateTracking/FieldWatchers/NetCollectionWatcher.cs +++ b/src/SMAPI/Framework/StateTracking/FieldWatchers/NetCollectionWatcher.cs @@ -24,6 +24,9 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers /********* ** Accessors *********/ + /// + public string Name { get; } + /// public bool IsChanged => this.AddedImpl.Count > 0 || this.RemovedImpl.Count > 0; @@ -38,9 +41,11 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers ** Public methods *********/ /// Construct an instance. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The field to watch. - public NetCollectionWatcher(NetCollection field) + public NetCollectionWatcher(string name, NetCollection field) { + this.Name = name; this.Field = field; field.OnValueAdded += this.OnValueAdded; field.OnValueRemoved += this.OnValueRemoved; diff --git a/src/SMAPI/Framework/StateTracking/FieldWatchers/NetDictionaryWatcher.cs b/src/SMAPI/Framework/StateTracking/FieldWatchers/NetDictionaryWatcher.cs index a0fcc236..3bd8e09d 100644 --- a/src/SMAPI/Framework/StateTracking/FieldWatchers/NetDictionaryWatcher.cs +++ b/src/SMAPI/Framework/StateTracking/FieldWatchers/NetDictionaryWatcher.cs @@ -31,6 +31,9 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers /********* ** Accessors *********/ + /// + public string Name { get; } + /// public bool IsChanged => this.PairsAdded.Count > 0 || this.PairsRemoved.Count > 0; @@ -45,9 +48,11 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers ** Public methods *********/ /// Construct an instance. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The field to watch. - public NetDictionaryWatcher(NetDictionary field) + public NetDictionaryWatcher(string name, NetDictionary field) { + this.Name = name; this.Field = field; field.OnValueAdded += this.OnValueAdded; diff --git a/src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs b/src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs index 3badb533..5b6a3e1f 100644 --- a/src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs +++ b/src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs @@ -25,6 +25,9 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers /********* ** Accessors *********/ + /// + public string Name { get; } + /// public bool IsChanged => this.AddedImpl.Count > 0 || this.RemovedImpl.Count > 0; @@ -39,9 +42,11 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers ** Public methods *********/ /// Construct an instance. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The field to watch. - public NetListWatcher(NetList> field) + public NetListWatcher(string name, NetList> field) { + this.Name = name; this.Field = field; field.OnElementChanged += this.OnElementChanged; field.OnArrayReplaced += this.OnArrayReplaced; diff --git a/src/SMAPI/Framework/StateTracking/FieldWatchers/NetValueWatcher.cs b/src/SMAPI/Framework/StateTracking/FieldWatchers/NetValueWatcher.cs index d00f4582..e4219dda 100644 --- a/src/SMAPI/Framework/StateTracking/FieldWatchers/NetValueWatcher.cs +++ b/src/SMAPI/Framework/StateTracking/FieldWatchers/NetValueWatcher.cs @@ -17,6 +17,9 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers /********* ** Accessors *********/ + /// + public string Name { get; } + /// public bool IsChanged { get; private set; } @@ -31,9 +34,11 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers ** Public methods *********/ /// Construct an instance. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The field to watch. - public NetValueWatcher(NetFieldBase field) + public NetValueWatcher(string name, NetFieldBase field) { + this.Name = name; this.Field = field; this.PreviousValue = field.Value; this.CurrentValue = field.Value; diff --git a/src/SMAPI/Framework/StateTracking/FieldWatchers/ObservableCollectionWatcher.cs b/src/SMAPI/Framework/StateTracking/FieldWatchers/ObservableCollectionWatcher.cs index f503c47f..1f95ac89 100644 --- a/src/SMAPI/Framework/StateTracking/FieldWatchers/ObservableCollectionWatcher.cs +++ b/src/SMAPI/Framework/StateTracking/FieldWatchers/ObservableCollectionWatcher.cs @@ -28,6 +28,9 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers /********* ** Accessors *********/ + /// + public string Name { get; } + /// public bool IsChanged => this.AddedImpl.Count > 0 || this.RemovedImpl.Count > 0; @@ -42,9 +45,11 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers ** Public methods *********/ /// Construct an instance. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The field to watch. - public ObservableCollectionWatcher(ObservableCollection field) + public ObservableCollectionWatcher(string name, ObservableCollection field) { + this.Name = name; this.Field = field; field.CollectionChanged += this.OnCollectionChanged; } diff --git a/src/SMAPI/Framework/StateTracking/FieldWatchers/WatcherFactory.cs b/src/SMAPI/Framework/StateTracking/FieldWatchers/WatcherFactory.cs index c4a4d0b9..c31be1fc 100644 --- a/src/SMAPI/Framework/StateTracking/FieldWatchers/WatcherFactory.cs +++ b/src/SMAPI/Framework/StateTracking/FieldWatchers/WatcherFactory.cs @@ -17,37 +17,41 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers ****/ /// Get a watcher which compares values using their method. This method should only be used when won't work, since this doesn't validate whether they're comparable. /// The value type. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// Get the current value. - public static IValueWatcher ForGenericEquality(Func getValue) + public static IValueWatcher ForGenericEquality(string name, Func getValue) where T : struct { - return new ComparableWatcher(getValue, new GenericEqualsComparer()); + return new ComparableWatcher(name, getValue, new GenericEqualsComparer()); } /// Get a watcher for an value. /// The value type. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// Get the current value. - public static IValueWatcher ForEquatable(Func getValue) + public static IValueWatcher ForEquatable(string name, Func getValue) where T : IEquatable { - return new ComparableWatcher(getValue, new EquatableComparer()); + return new ComparableWatcher(name, getValue, new EquatableComparer()); } /// Get a watcher which detects when an object reference changes. /// The value type. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// Get the current value. - public static IValueWatcher ForReference(Func getValue) + public static IValueWatcher ForReference(string name, Func getValue) { - return new ComparableWatcher(getValue, new ObjectReferenceComparer()); + return new ComparableWatcher(name, getValue, new ObjectReferenceComparer()); } /// Get a watcher for a net collection. /// The value type. /// The net field instance type. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The net collection. - public static IValueWatcher ForNetValue(NetFieldBase field) where TSelf : NetFieldBase + public static IValueWatcher ForNetValue(string name, NetFieldBase field) where TSelf : NetFieldBase { - return new NetValueWatcher(field); + return new NetValueWatcher(name, field); } /**** @@ -55,18 +59,20 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers ****/ /// Get a watcher which detects when an object reference in a collection changes. /// The value type. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The observable collection. - public static ICollectionWatcher ForReferenceList(ICollection collection) + public static ICollectionWatcher ForReferenceList(string name, ICollection collection) { - return new ComparableListWatcher(collection, new ObjectReferenceComparer()); + return new ComparableListWatcher(name, collection, new ObjectReferenceComparer()); } /// Get a watcher for an observable collection. /// The value type. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The observable collection. - public static ICollectionWatcher ForObservableCollection(ObservableCollection collection) + public static ICollectionWatcher ForObservableCollection(string name, ObservableCollection collection) { - return new ObservableCollectionWatcher(collection); + return new ObservableCollectionWatcher(name, collection); } /// Get a watcher for a collection that never changes. @@ -78,36 +84,39 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers /// Get a watcher for a net collection. /// The value type. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The net collection. - public static ICollectionWatcher ForNetCollection(NetCollection collection) + public static ICollectionWatcher ForNetCollection(string name, NetCollection collection) where T : class, INetObject { - return new NetCollectionWatcher(collection); + return new NetCollectionWatcher(name, collection); } /// Get a watcher for a net list. /// The value type. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The net list. - public static ICollectionWatcher ForNetList(NetList> collection) + public static ICollectionWatcher ForNetList(string name, NetList> collection) where T : class, INetObject { - return new NetListWatcher(collection); + return new NetListWatcher(name, collection); } /// Get a watcher for a net dictionary. + /// A name which identifies what the watcher is watching, used for troubleshooting. /// The dictionary key type. /// The dictionary value type. /// The net type equivalent to . /// The serializable dictionary type that can store the keys and values. /// The net field instance type. /// The net field. - public static NetDictionaryWatcher ForNetDictionary(NetDictionary field) + public static NetDictionaryWatcher ForNetDictionary(string name, NetDictionary field) where TKey : notnull where TField : class, INetObject, new() where TSerialDict : IDictionary, new() where TSelf : NetDictionary { - return new NetDictionaryWatcher(field); + return new NetDictionaryWatcher(name, field); } } } diff --git a/src/SMAPI/Framework/StateTracking/IWatcher.cs b/src/SMAPI/Framework/StateTracking/IWatcher.cs index 8c7fa51c..4a0e3998 100644 --- a/src/SMAPI/Framework/StateTracking/IWatcher.cs +++ b/src/SMAPI/Framework/StateTracking/IWatcher.cs @@ -8,6 +8,9 @@ namespace StardewModdingAPI.Framework.StateTracking /********* ** Accessors *********/ + /// A name which identifies what the watcher is watching, used for troubleshooting. + string Name { get; } + /// Whether the value changed since the last reset. bool IsChanged { get; } 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 @@ -25,6 +25,9 @@ namespace StardewModdingAPI.Framework.StateTracking /********* ** Accessors *********/ + /// + public string Name { get; } + /// public bool IsChanged => this.Watchers.Any(p => p.IsChanged); @@ -63,16 +66,17 @@ namespace StardewModdingAPI.Framework.StateTracking /// The location to track. 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(); - 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(); + 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)); } } } diff --git a/src/SMAPI/Framework/StateTracking/PlayerTracker.cs b/src/SMAPI/Framework/StateTracking/PlayerTracker.cs index 5433ac8e..fae90678 100644 --- a/src/SMAPI/Framework/StateTracking/PlayerTracker.cs +++ b/src/SMAPI/Framework/StateTracking/PlayerTracker.cs @@ -54,15 +54,15 @@ namespace StardewModdingAPI.Framework.StateTracking this.PreviousInventory = new Dictionary(this.CurrentInventory); // init trackers - this.LocationWatcher = WatcherFactory.ForReference(this.GetCurrentLocation); + this.LocationWatcher = WatcherFactory.ForReference($"player.{nameof(player.currentLocation)}", this.GetCurrentLocation); this.SkillWatchers = new Dictionary> { - [SkillType.Combat] = WatcherFactory.ForNetValue(player.combatLevel), - [SkillType.Farming] = WatcherFactory.ForNetValue(player.farmingLevel), - [SkillType.Fishing] = WatcherFactory.ForNetValue(player.fishingLevel), - [SkillType.Foraging] = WatcherFactory.ForNetValue(player.foragingLevel), - [SkillType.Luck] = WatcherFactory.ForNetValue(player.luckLevel), - [SkillType.Mining] = WatcherFactory.ForNetValue(player.miningLevel) + [SkillType.Combat] = WatcherFactory.ForNetValue($"player.{nameof(player.combatLevel)}", player.combatLevel), + [SkillType.Farming] = WatcherFactory.ForNetValue($"player.{nameof(player.farmingLevel)}", player.farmingLevel), + [SkillType.Fishing] = WatcherFactory.ForNetValue($"player.{nameof(player.fishingLevel)}", player.fishingLevel), + [SkillType.Foraging] = WatcherFactory.ForNetValue($"player.{nameof(player.foragingLevel)}", player.foragingLevel), + [SkillType.Luck] = WatcherFactory.ForNetValue($"player.{nameof(player.luckLevel)}", player.luckLevel), + [SkillType.Mining] = WatcherFactory.ForNetValue($"player.{nameof(player.miningLevel)}", player.miningLevel) }; // track watchers for convenience diff --git a/src/SMAPI/Framework/StateTracking/WorldLocationsTracker.cs b/src/SMAPI/Framework/StateTracking/WorldLocationsTracker.cs index f328d659..ca6988ad 100644 --- a/src/SMAPI/Framework/StateTracking/WorldLocationsTracker.cs +++ b/src/SMAPI/Framework/StateTracking/WorldLocationsTracker.cs @@ -34,6 +34,9 @@ namespace StardewModdingAPI.Framework.StateTracking /********* ** Accessors *********/ + /// + public string Name => nameof(WorldLocationsTracker); + /// Whether locations were added or removed since the last reset. public bool IsLocationListChanged => this.Added.Any() || this.Removed.Any(); @@ -59,9 +62,9 @@ namespace StardewModdingAPI.Framework.StateTracking /// 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); + this.LocationListWatcher = WatcherFactory.ForObservableCollection($"{this.Name}.{nameof(locations)}", locations); + this.MineLocationListWatcher = WatcherFactory.ForReferenceList($"{this.Name}.{nameof(activeMineLocations)}", activeMineLocations); + this.VolcanoLocationListWatcher = WatcherFactory.ForReferenceList($"{this.Name}.{nameof(activeVolcanoLocations)}", activeVolcanoLocations); } /// diff --git a/src/SMAPI/Framework/WatcherCore.cs b/src/SMAPI/Framework/WatcherCore.cs index 5e20ac7b..35f27cc7 100644 --- a/src/SMAPI/Framework/WatcherCore.cs +++ b/src/SMAPI/Framework/WatcherCore.cs @@ -60,14 +60,14 @@ namespace StardewModdingAPI.Framework public WatcherCore(SInputState inputState, ObservableCollection gameLocations) { // init watchers - this.CursorWatcher = WatcherFactory.ForEquatable(() => inputState.CursorPosition); - this.MouseWheelScrollWatcher = WatcherFactory.ForEquatable(() => inputState.MouseState.ScrollWheelValue); - this.SaveIdWatcher = WatcherFactory.ForEquatable(() => Game1.hasLoadedGame ? Game1.uniqueIDForThisGame : 0); - 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.CursorWatcher = WatcherFactory.ForEquatable(nameof(inputState.CursorPosition), () => inputState.CursorPosition); + this.MouseWheelScrollWatcher = WatcherFactory.ForEquatable(nameof(inputState.MouseState.ScrollWheelValue), () => inputState.MouseState.ScrollWheelValue); + this.SaveIdWatcher = WatcherFactory.ForEquatable(nameof(Game1.uniqueIDForThisGame), () => Game1.hasLoadedGame ? Game1.uniqueIDForThisGame : 0); + this.WindowSizeWatcher = WatcherFactory.ForEquatable(nameof(Game1.viewport), () => new Point(Game1.viewport.Width, Game1.viewport.Height)); + this.TimeWatcher = WatcherFactory.ForEquatable(nameof(Game1.timeOfDay), () => Game1.timeOfDay); + this.ActiveMenuWatcher = WatcherFactory.ForReference(nameof(Game1.activeClickableMenu), () => Game1.activeClickableMenu); this.LocationsWatcher = new WorldLocationsTracker(gameLocations, MineShaft.activeMines, VolcanoDungeon.activeLevels); - this.LocaleWatcher = WatcherFactory.ForGenericEquality(() => LocalizedContentManager.CurrentLanguageCode); + this.LocaleWatcher = WatcherFactory.ForGenericEquality(nameof(LocalizedContentManager.CurrentLanguageCode), () => LocalizedContentManager.CurrentLanguageCode); this.Watchers.AddRange(new IWatcher[] { this.CursorWatcher,