summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs')
-rw-r--r--src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs b/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs
new file mode 100644
index 00000000..1ee02842
--- /dev/null
+++ b/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using StardewValley;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="PlayerEvents.InventoryChanged"/> event.</summary>
+ public class EventArgsInventoryChanged : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The player's inventory.</summary>
+ public List<Item> Inventory { get; }
+
+ /// <summary>The added items.</summary>
+ public List<ItemStackChange> Added { get; }
+
+ /// <summary>The removed items.</summary>
+ public List<ItemStackChange> Removed { get; }
+
+ /// <summary>The items whose stack sizes changed.</summary>
+ public List<ItemStackChange> QuantityChanged { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="inventory">The player's inventory.</param>
+ /// <param name="changedItems">The inventory changes.</param>
+ public EventArgsInventoryChanged(List<Item> inventory, List<ItemStackChange> changedItems)
+ {
+ this.Inventory = inventory;
+ this.Added = changedItems.Where(n => n.ChangeType == ChangeType.Added).ToList();
+ this.Removed = changedItems.Where(n => n.ChangeType == ChangeType.Removed).ToList();
+ this.QuantityChanged = changedItems.Where(n => n.ChangeType == ChangeType.StackChange).ToList();
+ }
+ }
+}