summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events/EventArgsInventoryChanged.cs
blob: b85ae9dba9f5897b65cde35b1469f991c67a43bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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>
#if STARDEW_VALLEY_1_3
        public IList<Item> Inventory { get; }
#else
        public List<Item> Inventory { get; }
#endif

        /// <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(
#if STARDEW_VALLEY_1_3
            IList<Item> inventory,
#else
            List<Item> inventory,
#endif
            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();
        }
    }
}