summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-01-01 18:57:05 -0500
committerGitHub <noreply@github.com>2020-01-01 18:57:05 -0500
commit00932a335c86be1303ff6443b38d1db629b444fc (patch)
tree8376207a89b08b4e72c1bcbd46ecd3946e516e5c /src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs
parentdca60f42b2048d6b0b27517b9e7686665e61e9c2 (diff)
parentb6aef499d3c9b82d33c75039e0ed58c22618c426 (diff)
downloadSMAPI-00932a335c86be1303ff6443b38d1db629b444fc.tar.gz
SMAPI-00932a335c86be1303ff6443b38d1db629b444fc.tar.bz2
SMAPI-00932a335c86be1303ff6443b38d1db629b444fc.zip
Merge pull request #686 from wartech0/chest-tracking
Add chest items changed event
Diffstat (limited to 'src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs')
-rw-r--r--src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs b/src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs
index 7bcd9f82..f0fb9485 100644
--- a/src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs
+++ b/src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs
@@ -11,6 +11,13 @@ namespace StardewModdingAPI.Framework.StateTracking.Snapshots
internal class PlayerSnapshot
{
/*********
+ ** Fields
+ *********/
+ /// <summary>An empty item list diff.</summary>
+ private readonly SnapshotItemListDiff EmptyItemListDiff = new SnapshotItemListDiff(new Item[0], new Item[0], new ItemStackSizeChange[0]);
+
+
+ /*********
** Accessors
*********/
/// <summary>The player being tracked.</summary>
@@ -27,7 +34,7 @@ namespace StardewModdingAPI.Framework.StateTracking.Snapshots
.ToDictionary(skill => skill, skill => new SnapshotDiff<int>());
/// <summary>Get a list of inventory changes.</summary>
- public IEnumerable<ItemStackChange> InventoryChanges { get; private set; }
+ public SnapshotItemListDiff Inventory { get; private set; }
/*********
@@ -47,7 +54,11 @@ namespace StardewModdingAPI.Framework.StateTracking.Snapshots
this.Location.Update(watcher.LocationWatcher);
foreach (var pair in this.Skills)
pair.Value.Update(watcher.SkillWatchers[pair.Key]);
- this.InventoryChanges = watcher.GetInventoryChanges().ToArray();
+
+ this.Inventory = watcher.TryGetInventoryChanges(out SnapshotItemListDiff itemChanges)
+ ? itemChanges
+ : this.EmptyItemListDiff;
+
}
}
}