summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-27 18:09:04 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-27 18:09:04 -0400
commit0209e70695b6d12692d4de554ce1fc9d65ca4715 (patch)
tree011867d845ee3cf2a88f306504a4bdd6fe414ed6 /src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs
parent2ab2182645179129997eac3fccb63f6f0683dbe1 (diff)
parente4cd7c8eb09fa50802ce4eb9dbe4683ce61f7a5d (diff)
downloadSMAPI-0209e70695b6d12692d4de554ce1fc9d65ca4715.tar.gz
SMAPI-0209e70695b6d12692d4de554ce1fc9d65ca4715.tar.bz2
SMAPI-0209e70695b6d12692d4de554ce1fc9d65ca4715.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs')
-rw-r--r--src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs b/src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs
index 0b4d3030..5b6a3e1f 100644
--- a/src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs
+++ b/src/SMAPI/Framework/StateTracking/FieldWatchers/NetListWatcher.cs
@@ -25,13 +25,16 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers
/*********
** Accessors
*********/
- /// <summary>Whether the collection changed since the last reset.</summary>
+ /// <inheritdoc />
+ public string Name { get; }
+
+ /// <inheritdoc />
public bool IsChanged => this.AddedImpl.Count > 0 || this.RemovedImpl.Count > 0;
- /// <summary>The values added since the last reset.</summary>
+ /// <inheritdoc />
public IEnumerable<TValue> Added => this.AddedImpl;
- /// <summary>The values removed since the last reset.</summary>
+ /// <inheritdoc />
public IEnumerable<TValue> Removed => this.RemovedImpl;
@@ -39,28 +42,30 @@ 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="field">The field to watch.</param>
- public NetListWatcher(NetList<TValue, NetRef<TValue>> field)
+ public NetListWatcher(string name, NetList<TValue, NetRef<TValue>> field)
{
+ this.Name = name;
this.Field = field;
field.OnElementChanged += this.OnElementChanged;
field.OnArrayReplaced += this.OnArrayReplaced;
}
- /// <summary>Set the current value as the baseline.</summary>
+ /// <inheritdoc />
public void Reset()
{
this.AddedImpl.Clear();
this.RemovedImpl.Clear();
}
- /// <summary>Update the current value if needed.</summary>
+ /// <inheritdoc />
public void Update()
{
this.AssertNotDisposed();
}
- /// <summary>Stop watching the field and release all references.</summary>
+ /// <inheritdoc />
public override void Dispose()
{
if (!this.IsDisposed)
@@ -102,7 +107,7 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers
/// <param name="index">The list index which changed.</param>
/// <param name="oldValue">The previous value.</param>
/// <param name="newValue">The new value.</param>
- private void OnElementChanged(NetList<TValue, NetRef<TValue>> list, int index, TValue oldValue, TValue newValue)
+ private void OnElementChanged(NetList<TValue, NetRef<TValue>> list, int index, TValue? oldValue, TValue? newValue)
{
this.Remove(oldValue);
this.Add(newValue);
@@ -110,7 +115,7 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers
/// <summary>Track an added item.</summary>
/// <param name="value">The value that was added.</param>
- private void Add(TValue value)
+ private void Add(TValue? value)
{
if (value == null)
return;
@@ -126,7 +131,7 @@ namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers
/// <summary>Track a removed item.</summary>
/// <param name="value">The value that was removed.</param>
- private void Remove(TValue value)
+ private void Remove(TValue? value)
{
if (value == null)
return;