summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Events')
-rw-r--r--src/SMAPI/Events/EventArgsLocationObjectsChanged.cs26
-rw-r--r--src/SMAPI/Events/LocationEvents.cs8
2 files changed, 30 insertions, 4 deletions
diff --git a/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs b/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs
index de6bd365..a6138ddb 100644
--- a/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs
+++ b/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs
@@ -1,28 +1,46 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using Microsoft.Xna.Framework;
using Netcode;
-using Object = StardewValley.Object;
+using StardewValley;
+using SObject = StardewValley.Object;
namespace StardewModdingAPI.Events
{
- /// <summary>Event arguments for a <see cref="LocationEvents.LocationObjectsChanged"/> event.</summary>
+ /// <summary>Event arguments for a <see cref="LocationEvents.LocationObjectsChanged"/> or <see cref="LocationEvents.ObjectsChanged"/> event.</summary>
public class EventArgsLocationObjectsChanged : EventArgs
{
/*********
** Accessors
*********/
+ /// <summary>The location which changed.</summary>
+ public GameLocation Location { get; }
+
+ /// <summary>The objects added to the list.</summary>
+ public IEnumerable<KeyValuePair<Vector2, SObject>> Added { get; }
+
+ /// <summary>The objects removed from the list.</summary>
+ public IEnumerable<KeyValuePair<Vector2, SObject>> Removed { get; }
+
/// <summary>The current list of objects in the current location.</summary>
- public IDictionary<Vector2, NetRef<Object>> NewObjects { get; }
+ [Obsolete("Use " + nameof(EventArgsLocationObjectsChanged.Added))]
+ public IDictionary<Vector2, NetRef<SObject>> NewObjects { get; }
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
+ /// <param name="location">The location which changed.</param>
+ /// <param name="added">The objects added to the list.</param>
+ /// <param name="removed">The objects removed from the list.</param>
/// <param name="newObjects">The current list of objects in the current location.</param>
- public EventArgsLocationObjectsChanged(IDictionary<Vector2, NetRef<Object>> newObjects)
+ public EventArgsLocationObjectsChanged(GameLocation location, IEnumerable<KeyValuePair<Vector2, SObject>> added, IEnumerable<KeyValuePair<Vector2, SObject>> removed, IDictionary<Vector2, NetRef<SObject>> newObjects)
{
+ this.Location = location;
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
this.NewObjects = newObjects;
}
}
diff --git a/src/SMAPI/Events/LocationEvents.cs b/src/SMAPI/Events/LocationEvents.cs
index 81d13e9f..3ed09136 100644
--- a/src/SMAPI/Events/LocationEvents.cs
+++ b/src/SMAPI/Events/LocationEvents.cs
@@ -31,12 +31,20 @@ namespace StardewModdingAPI.Events
}
/// <summary>Raised after the list of objects in the current location changes (e.g. an object is added or removed).</summary>
+ [Obsolete("Use " + nameof(LocationEvents) + "." + nameof(LocationEvents.ObjectsChanged) + " instead")]
public static event EventHandler<EventArgsLocationObjectsChanged> LocationObjectsChanged
{
add => LocationEvents.EventManager.Location_LocationObjectsChanged.Add(value);
remove => LocationEvents.EventManager.Location_LocationObjectsChanged.Remove(value);
}
+ /// <summary>Raised after the list of objects in a location changes (e.g. an object is added or removed).</summary>
+ public static event EventHandler<EventArgsLocationObjectsChanged> ObjectsChanged
+ {
+ add => LocationEvents.EventManager.Location_ObjectsChanged.Add(value);
+ remove => LocationEvents.EventManager.Location_ObjectsChanged.Remove(value);
+ }
+
/*********
** Public methods