From 1286a90ec2fb0dcf26bd59feec714544844e4398 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 29 Dec 2019 13:29:25 -0500 Subject: minor refactoring This commit... - removes key fields added to non-keyed types like NetListWatcher and SnapshotListDiff; - fixes existing chests not being watched; - fixes diffs not correctly updated for added/removed chests; - performs minor cleanup, adds missing docs, etc. --- src/SMAPI/Events/ChestInventoryChangedEventArgs.cs | 47 ++++++++++++++++++++++ src/SMAPI/Events/ChestItemChangedEventArgs.cs | 47 ---------------------- src/SMAPI/Events/IWorldEvents.cs | 4 +- 3 files changed, 49 insertions(+), 49 deletions(-) create mode 100644 src/SMAPI/Events/ChestInventoryChangedEventArgs.cs delete mode 100644 src/SMAPI/Events/ChestItemChangedEventArgs.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/ChestInventoryChangedEventArgs.cs b/src/SMAPI/Events/ChestInventoryChangedEventArgs.cs new file mode 100644 index 00000000..0b54e909 --- /dev/null +++ b/src/SMAPI/Events/ChestInventoryChangedEventArgs.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using StardewValley; + +namespace StardewModdingAPI.Events +{ + /// Event arguments for a event. + public class ChestInventoryChangedEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// The location containing the chest. + public GameLocation Location { get; } + + /// The tile position of the chest. + public Vector2 Tile { get; } + + /// The objects added to the location. + public IEnumerable Added { get; } + + /// The objects removed from the location. + public IEnumerable Removed { get; } + + /// Whether this is the location containing the local player. + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The location containing the chest. + /// The tile position of the chest. + /// The objects added to the location. + /// The objects removed from the location. + internal ChestInventoryChangedEventArgs(GameLocation location, Vector2 tile, IEnumerable added, IEnumerable removed) + { + this.Location = location; + this.Tile = tile; + this.Added = added.ToArray(); + this.Removed = removed.ToArray(); + } + } +} diff --git a/src/SMAPI/Events/ChestItemChangedEventArgs.cs b/src/SMAPI/Events/ChestItemChangedEventArgs.cs deleted file mode 100644 index 6b06487c..00000000 --- a/src/SMAPI/Events/ChestItemChangedEventArgs.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xna.Framework; -using StardewValley; -using Item = StardewValley.Item; - -namespace StardewModdingAPI.Events -{ - /// Event arguments for a event. - public class ChestItemChangedEventArgs : EventArgs - { - /********* - ** Accessors - *********/ - /// The location which changed. - public GameLocation Location { get; } - - /// The objects added to the location. - public IEnumerable Added { get; } - - /// The objects removed from the location. - public IEnumerable Removed { get; } - - /// The location of the chest from where the item was added or removed - public Vector2 LocationOfChest { get; } - - /// Whether this is the location containing the local player. - public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The location which changed. - /// The objects added to the location. - /// The objects removed from the location. - internal ChestItemChangedEventArgs(GameLocation location, IEnumerable added, IEnumerable 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 6f9b71a7..9569a57b 100644 --- a/src/SMAPI/Events/IWorldEvents.cs +++ b/src/SMAPI/Events/IWorldEvents.cs @@ -23,8 +23,8 @@ namespace StardewModdingAPI.Events /// Raised after objects are added or removed in a location. event EventHandler ObjectListChanged; - /// Raised after items are added or removed from a chest in a location. - event EventHandler ChestItemChanged; + /// Raised after items are added or removed from a chest. + event EventHandler ChestInventoryChanged; /// Raised after terrain features (like floors and trees) are added or removed in a location. event EventHandler TerrainFeatureListChanged; -- cgit