using System; using System.Collections.Generic; using Microsoft.Xna.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. /// The player's previous location. /// The player's current location. internal static void InvokeCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) { LocationEvents.CurrentLocationChanged?.Invoke(null, new EventArgsCurrentLocationChanged(priorLocation, newLocation)); } /// Raise a event. /// The current list of game locations. internal static void InvokeLocationsChanged(List newLocations) { LocationEvents.LocationsChanged?.Invoke(null, new EventArgsGameLocationsChanged(newLocations)); } /// Raise a event. /// The current list of objects in the current location. internal static void InvokeOnNewLocationObject(SerializableDictionary newObjects) { LocationEvents.LocationObjectsChanged?.Invoke(null, new EventArgsLocationObjectsChanged(newObjects)); } } }