summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events
diff options
context:
space:
mode:
authorwartech0 <wartech0@hotmail.com>2019-12-29 08:06:02 -0600
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-12-31 16:19:43 -0500
commitaef1b8ac2898e147e6200fe257e8fdd82ee7fdbc (patch)
treede3026eeac70d90e729802b8213cbb4004f2dee9 /src/SMAPI/Events
parentdca60f42b2048d6b0b27517b9e7686665e61e9c2 (diff)
downloadSMAPI-aef1b8ac2898e147e6200fe257e8fdd82ee7fdbc.tar.gz
SMAPI-aef1b8ac2898e147e6200fe257e8fdd82ee7fdbc.tar.bz2
SMAPI-aef1b8ac2898e147e6200fe257e8fdd82ee7fdbc.zip
Added the new ChestItemChanged event.
Diffstat (limited to 'src/SMAPI/Events')
-rw-r--r--src/SMAPI/Events/ChestItemChangedEventArgs.cs47
-rw-r--r--src/SMAPI/Events/IWorldEvents.cs3
2 files changed, 50 insertions, 0 deletions
diff --git a/src/SMAPI/Events/ChestItemChangedEventArgs.cs b/src/SMAPI/Events/ChestItemChangedEventArgs.cs
new file mode 100644
index 00000000..6b06487c
--- /dev/null
+++ b/src/SMAPI/Events/ChestItemChangedEventArgs.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using StardewValley;
+using Item = StardewValley.Item;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="IWorldEvents.ChestItemChanged"/> event.</summary>
+ public class ChestItemChangedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The location which changed.</summary>
+ public GameLocation Location { get; }
+
+ /// <summary>The objects added to the location.</summary>
+ public IEnumerable<Item> Added { get; }
+
+ /// <summary>The objects removed from the location.</summary>
+ public IEnumerable<Item> Removed { get; }
+
+ /// <summary>The location of the chest from where the item was added or removed</summary>
+ public Vector2 LocationOfChest { get; }
+
+ /// <summary>Whether this is the location containing the local player.</summary>
+ public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation);
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="location">The location which changed.</param>
+ /// <param name="added">The objects added to the location.</param>
+ /// <param name="removed">The objects removed from the location.</param>
+ internal ChestItemChangedEventArgs(GameLocation location, IEnumerable<Item> added, IEnumerable<Item> removed, Vector2 locationOfChest)
+ {
+ this.Location = location;
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
+ this.LocationOfChest = locationOfChest;
+ }
+ }
+}
diff --git a/src/SMAPI/Events/IWorldEvents.cs b/src/SMAPI/Events/IWorldEvents.cs
index 0ceffcc1..6f9b71a7 100644
--- a/src/SMAPI/Events/IWorldEvents.cs
+++ b/src/SMAPI/Events/IWorldEvents.cs
@@ -23,6 +23,9 @@ namespace StardewModdingAPI.Events
/// <summary>Raised after objects are added or removed in a location.</summary>
event EventHandler<ObjectListChangedEventArgs> ObjectListChanged;
+ /// <summary>Raised after items are added or removed from a chest in a location.</summary>
+ event EventHandler<ChestItemChangedEventArgs> ChestItemChanged;
+
/// <summary>Raised after terrain features (like floors and trees) are added or removed in a location.</summary>
event EventHandler<TerrainFeatureListChangedEventArgs> TerrainFeatureListChanged;
}