summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Events/LocationEvents.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-11-21 22:09:02 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-11-21 22:09:02 -0500
commit9bf1ad71b43e41a3dfe645ccf66c6fb6b2e96242 (patch)
tree689b753b22702c1c3eb8c5fc2ccc4a068a581294 /src/StardewModdingAPI/Events/LocationEvents.cs
parent1a5eb12cc6877da6dd95bcae8814bc5d3fb87a9b (diff)
downloadSMAPI-9bf1ad71b43e41a3dfe645ccf66c6fb6b2e96242.tar.gz
SMAPI-9bf1ad71b43e41a3dfe645ccf66c6fb6b2e96242.tar.bz2
SMAPI-9bf1ad71b43e41a3dfe645ccf66c6fb6b2e96242.zip
intercept event handler exceptions (#179)
Diffstat (limited to 'src/StardewModdingAPI/Events/LocationEvents.cs')
-rw-r--r--src/StardewModdingAPI/Events/LocationEvents.cs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/StardewModdingAPI/Events/LocationEvents.cs b/src/StardewModdingAPI/Events/LocationEvents.cs
index 3c28f541..b834bc1c 100644
--- a/src/StardewModdingAPI/Events/LocationEvents.cs
+++ b/src/StardewModdingAPI/Events/LocationEvents.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
+using StardewModdingAPI.Framework;
using StardewValley;
using Object = StardewValley.Object;
@@ -26,25 +27,28 @@ namespace StardewModdingAPI.Events
** 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(GameLocation priorLocation, GameLocation newLocation)
+ internal static void InvokeCurrentLocationChanged(IMonitor monitor, GameLocation priorLocation, GameLocation newLocation)
{
- LocationEvents.CurrentLocationChanged?.Invoke(null, new EventArgsCurrentLocationChanged(priorLocation, 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(List<GameLocation> newLocations)
+ internal static void InvokeLocationsChanged(IMonitor monitor, List<GameLocation> newLocations)
{
- LocationEvents.LocationsChanged?.Invoke(null, new EventArgsGameLocationsChanged(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(SerializableDictionary<Vector2, Object> newObjects)
+ internal static void InvokeOnNewLocationObject(IMonitor monitor, SerializableDictionary<Vector2, Object> newObjects)
{
- LocationEvents.LocationObjectsChanged?.Invoke(null, new EventArgsLocationObjectsChanged(newObjects));
+ monitor.SafelyRaiseGenericEvent($"{nameof(LocationEvents)}.{nameof(LocationEvents.LocationObjectsChanged)}", LocationEvents.LocationObjectsChanged?.GetInvocationList(), null, new EventArgsLocationObjectsChanged(newObjects));
}
}
}