From dae12c16e5ecb88e8043272c9d8ffdc88bc351ca Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 29 Dec 2018 18:31:23 -0500 Subject: add IsCurrentLocation event arg to World events --- src/SMAPI/Events/BuildingListChangedEventArgs.cs | 3 +++ src/SMAPI/Events/DebrisListChangedEventArgs.cs | 3 +++ src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs | 3 +++ src/SMAPI/Events/NpcListChangedEventArgs.cs | 3 +++ src/SMAPI/Events/ObjectListChangedEventArgs.cs | 3 +++ src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs | 3 +++ 6 files changed, 18 insertions(+) (limited to 'src') diff --git a/src/SMAPI/Events/BuildingListChangedEventArgs.cs b/src/SMAPI/Events/BuildingListChangedEventArgs.cs index 0237342f..74f37710 100644 --- a/src/SMAPI/Events/BuildingListChangedEventArgs.cs +++ b/src/SMAPI/Events/BuildingListChangedEventArgs.cs @@ -21,6 +21,9 @@ namespace StardewModdingAPI.Events /// The buildings 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 diff --git a/src/SMAPI/Events/DebrisListChangedEventArgs.cs b/src/SMAPI/Events/DebrisListChangedEventArgs.cs index 68328885..61b7590a 100644 --- a/src/SMAPI/Events/DebrisListChangedEventArgs.cs +++ b/src/SMAPI/Events/DebrisListChangedEventArgs.cs @@ -20,6 +20,9 @@ namespace StardewModdingAPI.Events /// The debris 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 diff --git a/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs b/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs index c7d55bf8..59d79f0f 100644 --- a/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs +++ b/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs @@ -21,6 +21,9 @@ namespace StardewModdingAPI.Events /// The large terrain features 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 diff --git a/src/SMAPI/Events/NpcListChangedEventArgs.cs b/src/SMAPI/Events/NpcListChangedEventArgs.cs index a9ec2a3b..3a37f1e7 100644 --- a/src/SMAPI/Events/NpcListChangedEventArgs.cs +++ b/src/SMAPI/Events/NpcListChangedEventArgs.cs @@ -20,6 +20,9 @@ namespace StardewModdingAPI.Events /// The NPCs 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 diff --git a/src/SMAPI/Events/ObjectListChangedEventArgs.cs b/src/SMAPI/Events/ObjectListChangedEventArgs.cs index d0cf9e7b..b21d2867 100644 --- a/src/SMAPI/Events/ObjectListChangedEventArgs.cs +++ b/src/SMAPI/Events/ObjectListChangedEventArgs.cs @@ -22,6 +22,9 @@ namespace StardewModdingAPI.Events /// 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 diff --git a/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs b/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs index 0992633e..cdf1e6dc 100644 --- a/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs +++ b/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs @@ -22,6 +22,9 @@ namespace StardewModdingAPI.Events /// The terrain features 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 -- cgit