summaryrefslogtreecommitdiff
path: root/StardewModdingAPI
diff options
context:
space:
mode:
Diffstat (limited to 'StardewModdingAPI')
-rw-r--r--StardewModdingAPI/EventArgs.cs12
-rw-r--r--StardewModdingAPI/Events.cs7
-rw-r--r--StardewModdingAPI/Inheritance/SGame.cs8
3 files changed, 26 insertions, 1 deletions
diff --git a/StardewModdingAPI/EventArgs.cs b/StardewModdingAPI/EventArgs.cs
index c8119bf8..cb7324c9 100644
--- a/StardewModdingAPI/EventArgs.cs
+++ b/StardewModdingAPI/EventArgs.cs
@@ -1,4 +1,5 @@
-using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Input;
using StardewValley;
using StardewValley.Menus;
using System;
@@ -60,6 +61,15 @@ namespace StardewModdingAPI
public List<GameLocation> NewLocations { get; private set; }
}
+ public class EventArgsLocationObjectsChanged : EventArgs
+ {
+ public EventArgsLocationObjectsChanged(SerializableDictionary<Vector2, StardewValley.Object> newObjects)
+ {
+ NewObjects = newObjects;
+ }
+ public SerializableDictionary<Vector2, StardewValley.Object> NewObjects { get; private set; }
+ }
+
public class EventArgsCurrentLocationChanged : EventArgs
{
public EventArgsCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation)
diff --git a/StardewModdingAPI/Events.cs b/StardewModdingAPI/Events.cs
index 3ae861d9..de1c24bc 100644
--- a/StardewModdingAPI/Events.cs
+++ b/StardewModdingAPI/Events.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Microsoft.Xna.Framework.Input;
using StardewValley;
using StardewValley.Menus;
+using Microsoft.Xna.Framework;
namespace StardewModdingAPI
{
@@ -22,6 +23,7 @@ namespace StardewModdingAPI
public static event EventHandler<EventArgsMouseStateChanged> MouseChanged = delegate { };
public static event EventHandler<EventArgsClickableMenuChanged> MenuChanged = delegate { };
public static event EventHandler<EventArgsGameLocationsChanged> LocationsChanged = delegate { };
+ public static event EventHandler<EventArgsLocationObjectsChanged> LocationObjectsChanged = delegate { };
public static event EventHandler<EventArgsCurrentLocationChanged> CurrentLocationChanged = delegate { };
public static event EventHandler Resize = delegate { };
public static event EventHandler<EventArgsFarmerChanged> FarmerChanged = delegate { };
@@ -142,5 +144,10 @@ namespace StardewModdingAPI
{
SeasonOfYearChanged.Invoke(null, new EventArgsStringChanged(priorString, newString));
}
+
+ internal static void InvokeOnNewLocationObject(SerializableDictionary<Vector2, StardewValley.Object> newObjects)
+ {
+ LocationObjectsChanged.Invoke(null, new EventArgsLocationObjectsChanged(newObjects));
+ }
}
}
diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs
index 21fbea70..83f8e335 100644
--- a/StardewModdingAPI/Inheritance/SGame.cs
+++ b/StardewModdingAPI/Inheritance/SGame.cs
@@ -44,6 +44,8 @@ namespace StardewModdingAPI.Inheritance
}
public int PreviousGameLocations { get; private set; }
+ public int PreviousLocationObjects { get; private set; }
+
public GameLocation PreviousGameLocation { get; private set; }
public IClickableMenu PreviousActiveMenu { get; private set; }
@@ -261,6 +263,12 @@ namespace StardewModdingAPI.Inheritance
PreviousFarmer = player;
}
+ if(currentLocation != null && PreviousLocationObjects != currentLocation.objects.GetHash())
+ {
+ Events.InvokeOnNewLocationObject(currentLocation.objects);
+ PreviousLocationObjects = currentLocation.objects.GetHash();
+ }
+
if (timeOfDay != PreviousTimeOfDay)
{
Events.InvokeTimeOfDayChanged(PreviousTimeOfDay, timeOfDay);