using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using StardewModdingAPI.Framework;
using StardewValley;
using Object = StardewValley.Object;
namespace StardewModdingAPI.Events
{
/// Events raised when the player transitions between game locations, a location is added or removed, or the objects in the current location change.
public static class LocationEvents
{
/*********
** Events
*********/
/// Raised after the player warps to a new location.
public static event EventHandler CurrentLocationChanged;
/// Raised after a game location is added or removed.
public static event EventHandler LocationsChanged;
/// Raised after the list of objects in the current location changes (e.g. an object is added or removed).
public static event EventHandler LocationObjectsChanged;
/*********
** Internal methods
*********/
/// Raise a event.
/// Encapsulates monitoring and logging.
/// The player's previous location.
/// The player's current location.
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));
}
/// Raise a event.
/// Encapsulates monitoring and logging.
/// The current list of game locations.
internal static void InvokeLocationsChanged(IMonitor monitor, List newLocations)
{
monitor.SafelyRaiseGenericEvent($"{nameof(LocationEvents)}.{nameof(LocationEvents.LocationsChanged)}", LocationEvents.LocationsChanged?.GetInvocationList(), null, new EventArgsGameLocationsChanged(newLocations));
}
/// Raise a event.
/// Encapsulates monitoring and logging.
/// The current list of objects in the current location.
internal static void InvokeOnNewLocationObject(IMonitor monitor, SerializableDictionary newObjects)
{
monitor.SafelyRaiseGenericEvent($"{nameof(LocationEvents)}.{nameof(LocationEvents.LocationObjectsChanged)}", LocationEvents.LocationObjectsChanged?.GetInvocationList(), null, new EventArgsLocationObjectsChanged(newObjects));
}
}
}