summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events/LocationEvents.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-10-07 23:20:36 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-10-07 23:20:36 -0400
commitd0dd2f7ba729de6be749d326a2fed78988ba9d7b (patch)
treea22127da6a8900e9f29bbb847bfd5d3347f6b952 /src/SMAPI/Events/LocationEvents.cs
parent7889676ea24cafc945899bf25608784e3f5bc9e0 (diff)
parent5928f5f86c4493ddb6b89bce0b7d0fb73a884c09 (diff)
downloadSMAPI-d0dd2f7ba729de6be749d326a2fed78988ba9d7b.tar.gz
SMAPI-d0dd2f7ba729de6be749d326a2fed78988ba9d7b.tar.bz2
SMAPI-d0dd2f7ba729de6be749d326a2fed78988ba9d7b.zip
Merge branch 'add-mod-build-config' into develop
Diffstat (limited to 'src/SMAPI/Events/LocationEvents.cs')
-rw-r--r--src/SMAPI/Events/LocationEvents.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/SMAPI/Events/LocationEvents.cs b/src/SMAPI/Events/LocationEvents.cs
new file mode 100644
index 00000000..b834bc1c
--- /dev/null
+++ b/src/SMAPI/Events/LocationEvents.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.Xna.Framework;
+using StardewModdingAPI.Framework;
+using StardewValley;
+using Object = StardewValley.Object;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Events raised when the player transitions between game locations, a location is added or removed, or the objects in the current location change.</summary>
+ public static class LocationEvents
+ {
+ /*********
+ ** Events
+ *********/
+ /// <summary>Raised after the player warps to a new location.</summary>
+ public static event EventHandler<EventArgsCurrentLocationChanged> CurrentLocationChanged;
+
+ /// <summary>Raised after a game location is added or removed.</summary>
+ public static event EventHandler<EventArgsGameLocationsChanged> LocationsChanged;
+
+ /// <summary>Raised after the list of objects in the current location changes (e.g. an object is added or removed).</summary>
+ public static event EventHandler<EventArgsLocationObjectsChanged> LocationObjectsChanged;
+
+
+ /*********
+ ** Internal methods
+ *********/
+ /// <summary>Raise a <see cref="CurrentLocationChanged"/> event.</summary>
+ /// <param name="monitor">Encapsulates monitoring and logging.</param>
+ /// <param name="priorLocation">The player's previous location.</param>
+ /// <param name="newLocation">The player's current location.</param>
+ internal static void InvokeCurrentLocationChanged(IMonitor monitor, GameLocation priorLocation, GameLocation newLocation)
+ {
+ monitor.SafelyRaiseGenericEvent($"{nameof(LocationEvents)}.{nameof(LocationEvents.CurrentLocationChanged)}", LocationEvents.CurrentLocationChanged?.GetInvocationList(), null, new EventArgsCurrentLocationChanged(priorLocation, newLocation));
+ }
+
+ /// <summary>Raise a <see cref="LocationsChanged"/> event.</summary>
+ /// <param name="monitor">Encapsulates monitoring and logging.</param>
+ /// <param name="newLocations">The current list of game locations.</param>
+ internal static void InvokeLocationsChanged(IMonitor monitor, List<GameLocation> newLocations)
+ {
+ monitor.SafelyRaiseGenericEvent($"{nameof(LocationEvents)}.{nameof(LocationEvents.LocationsChanged)}", LocationEvents.LocationsChanged?.GetInvocationList(), null, new EventArgsGameLocationsChanged(newLocations));
+ }
+
+ /// <summary>Raise a <see cref="LocationObjectsChanged"/> event.</summary>
+ /// <param name="monitor">Encapsulates monitoring and logging.</param>
+ /// <param name="newObjects">The current list of objects in the current location.</param>
+ internal static void InvokeOnNewLocationObject(IMonitor monitor, SerializableDictionary<Vector2, Object> newObjects)
+ {
+ monitor.SafelyRaiseGenericEvent($"{nameof(LocationEvents)}.{nameof(LocationEvents.LocationObjectsChanged)}", LocationEvents.LocationObjectsChanged?.GetInvocationList(), null, new EventArgsLocationObjectsChanged(newObjects));
+ }
+ }
+}