summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events
diff options
context:
space:
mode:
authorDiscipleOfEris <discipleoferis1@gmail.com>2021-05-26 11:50:49 -0700
committerDiscipleOfEris <discipleoferis1@gmail.com>2021-05-26 11:50:49 -0700
commitb149e11338ba2dbaf030a70783d28b6be21ccf1e (patch)
tree4081de50a7af24d5892329167083f4de96ca6b4d /src/SMAPI/Events
parent112b505118e65d2741a5cfebce44abd02742dd2f (diff)
downloadSMAPI-b149e11338ba2dbaf030a70783d28b6be21ccf1e.tar.gz
SMAPI-b149e11338ba2dbaf030a70783d28b6be21ccf1e.tar.bz2
SMAPI-b149e11338ba2dbaf030a70783d28b6be21ccf1e.zip
Add `World.FurnitureListChanged` event
Create a new event available to SMAPI mods to track furniture changes. To facilitate the event, a `FurnitureListChangedEventArgs` class is added as well. Fixes #778
Diffstat (limited to 'src/SMAPI/Events')
-rw-r--r--src/SMAPI/Events/FurnitureListChangedEventArgs.cs44
-rw-r--r--src/SMAPI/Events/IWorldEvents.cs3
2 files changed, 47 insertions, 0 deletions
diff --git a/src/SMAPI/Events/FurnitureListChangedEventArgs.cs b/src/SMAPI/Events/FurnitureListChangedEventArgs.cs
new file mode 100644
index 00000000..04fcf9ff
--- /dev/null
+++ b/src/SMAPI/Events/FurnitureListChangedEventArgs.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using StardewValley;
+using StardewValley.Objects;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="IWorldEvents.FurnitureListChanged"/> event.</summary>
+ public class FurnitureListChangedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The location which changed.</summary>
+ public GameLocation Location { get; }
+
+ /// <summary>The furniture added to the location.</summary>
+ public IEnumerable<Furniture> Added { get; }
+
+ /// <summary>The furniture removed from the location.</summary>
+ public IEnumerable<Furniture> Removed { 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 furniture added to the location.</param>
+ /// <param name="removed">The furniture removed from the location.</param>
+ internal FurnitureListChangedEventArgs(GameLocation location, IEnumerable<Furniture> added, IEnumerable<Furniture> removed)
+ {
+ this.Location = location;
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
+ }
+ }
+}
diff --git a/src/SMAPI/Events/IWorldEvents.cs b/src/SMAPI/Events/IWorldEvents.cs
index 9569a57b..c023e1f0 100644
--- a/src/SMAPI/Events/IWorldEvents.cs
+++ b/src/SMAPI/Events/IWorldEvents.cs
@@ -28,5 +28,8 @@ namespace StardewModdingAPI.Events
/// <summary>Raised after terrain features (like floors and trees) are added or removed in a location.</summary>
event EventHandler<TerrainFeatureListChangedEventArgs> TerrainFeatureListChanged;
+
+ /// <summary>Raised after furniture are added or removed in a location.</summary>
+ event EventHandler<FurnitureListChangedEventArgs> FurnitureListChanged;
}
}