summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableWatcher.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableWatcher.cs')
-rw-r--r--src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableWatcher.cs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableWatcher.cs b/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableWatcher.cs
index 5f76fe0a..e2f6c7fd 100644
--- a/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableWatcher.cs
+++ b/src/SMAPI/Framework/StateTracking/FieldWatchers/ComparableWatcher.cs
@@ -20,13 +20,16 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers
/*********
** Accessors
*********/
- /// <summary>The field value at the last reset.</summary>
+ /// <inheritdoc />
+ public string Name { get; }
+
+ /// <inheritdoc />
public TValue PreviousValue { get; private set; }
- /// <summary>The latest value.</summary>
+ /// <inheritdoc />
public TValue CurrentValue { get; private set; }
- /// <summary>Whether the value changed since the last reset.</summary>
+ /// <inheritdoc />
public bool IsChanged { get; private set; }
@@ -34,31 +37,33 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers
** Public methods
*********/
/// <summary>Construct an instance.</summary>
+ /// <param name="name">A name which identifies what the watcher is watching, used for troubleshooting.</param>
/// <param name="getValue">Get the current value.</param>
/// <param name="comparer">The equality comparer which indicates whether two values are the same.</param>
- public ComparableWatcher(Func<TValue> getValue, IEqualityComparer<TValue> comparer)
+ public ComparableWatcher(string name, Func<TValue> getValue, IEqualityComparer<TValue> comparer)
{
+ this.Name = name;
this.GetValue = getValue;
this.Comparer = comparer;
this.CurrentValue = getValue();
this.PreviousValue = this.CurrentValue;
}
- /// <summary>Update the current value if needed.</summary>
+ /// <inheritdoc />
public void Update()
{
this.CurrentValue = this.GetValue();
this.IsChanged = !this.Comparer.Equals(this.PreviousValue, this.CurrentValue);
}
- /// <summary>Set the current value as the baseline.</summary>
+ /// <inheritdoc />
public void Reset()
{
this.PreviousValue = this.CurrentValue;
this.IsChanged = false;
}
- /// <summary>Release any references if needed when the field is no longer needed.</summary>
+ /// <inheritdoc />
public void Dispose() { }
}
}