summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Events')
-rw-r--r--src/SMAPI/Events/ControlEvents.cs36
-rw-r--r--src/SMAPI/Events/EventArgsGameLocationsChanged.cs27
-rw-r--r--src/SMAPI/Events/EventArgsInput.cs125
-rw-r--r--src/SMAPI/Events/EventArgsIntChanged.cs3
-rw-r--r--src/SMAPI/Events/EventArgsInventoryChanged.cs12
-rw-r--r--src/SMAPI/Events/EventArgsLocationBuildingsChanged.cs39
-rw-r--r--src/SMAPI/Events/EventArgsLocationObjectsChanged.cs41
-rw-r--r--src/SMAPI/Events/EventArgsLocationsChanged.cs33
-rw-r--r--src/SMAPI/Events/EventArgsPlayerWarped.cs (renamed from src/SMAPI/Events/EventArgsCurrentLocationChanged.cs)13
-rw-r--r--src/SMAPI/Events/GameLoopLaunchedEventArgs.cs7
-rw-r--r--src/SMAPI/Events/GameLoopUpdatedEventArgs.cs36
-rw-r--r--src/SMAPI/Events/GameLoopUpdatingEventArgs.cs36
-rw-r--r--src/SMAPI/Events/IGameLoopEvents.cs17
-rw-r--r--src/SMAPI/Events/IInputEvents.cs20
-rw-r--r--src/SMAPI/Events/IModEvents.cs15
-rw-r--r--src/SMAPI/Events/IWorldEvents.cs29
-rw-r--r--src/SMAPI/Events/InputButtonPressedEventArgs.cs60
-rw-r--r--src/SMAPI/Events/InputButtonReleasedEventArgs.cs60
-rw-r--r--src/SMAPI/Events/InputCursorMovedEventArgs.cs30
-rw-r--r--src/SMAPI/Events/InputEvents.cs8
-rw-r--r--src/SMAPI/Events/InputMouseWheelScrolledEventArgs.cs38
-rw-r--r--src/SMAPI/Events/LocationEvents.cs24
-rw-r--r--src/SMAPI/Events/MultiplayerEvents.cs58
-rw-r--r--src/SMAPI/Events/PlayerEvents.cs10
-rw-r--r--src/SMAPI/Events/WorldBuildingListChangedEventArgs.cs39
-rw-r--r--src/SMAPI/Events/WorldDebrisListChangedEventArgs.cs38
-rw-r--r--src/SMAPI/Events/WorldLargeTerrainFeatureListChangedEventArgs.cs39
-rw-r--r--src/SMAPI/Events/WorldLocationListChangedEventArgs.cs33
-rw-r--r--src/SMAPI/Events/WorldNpcListChangedEventArgs.cs38
-rw-r--r--src/SMAPI/Events/WorldObjectListChangedEventArgs.cs40
-rw-r--r--src/SMAPI/Events/WorldTerrainFeatureListChangedEventArgs.cs40
31 files changed, 833 insertions, 211 deletions
diff --git a/src/SMAPI/Events/ControlEvents.cs b/src/SMAPI/Events/ControlEvents.cs
index 973bb245..a3994d1d 100644
--- a/src/SMAPI/Events/ControlEvents.cs
+++ b/src/SMAPI/Events/ControlEvents.cs
@@ -20,57 +20,57 @@ namespace StardewModdingAPI.Events
/// <summary>Raised when the <see cref="KeyboardState"/> changes. That happens when the player presses or releases a key.</summary>
public static event EventHandler<EventArgsKeyboardStateChanged> KeyboardChanged
{
- add => ControlEvents.EventManager.Control_KeyboardChanged.Add(value);
- remove => ControlEvents.EventManager.Control_KeyboardChanged.Remove(value);
+ add => ControlEvents.EventManager.Legacy_Control_KeyboardChanged.Add(value);
+ remove => ControlEvents.EventManager.Legacy_Control_KeyboardChanged.Remove(value);
}
- /// <summary>Raised when the player presses a keyboard key.</summary>
+ /// <summary>Raised after the player presses a keyboard key.</summary>
public static event EventHandler<EventArgsKeyPressed> KeyPressed
{
- add => ControlEvents.EventManager.Control_KeyPressed.Add(value);
- remove => ControlEvents.EventManager.Control_KeyPressed.Remove(value);
+ add => ControlEvents.EventManager.Legacy_Control_KeyPressed.Add(value);
+ remove => ControlEvents.EventManager.Legacy_Control_KeyPressed.Remove(value);
}
- /// <summary>Raised when the player releases a keyboard key.</summary>
+ /// <summary>Raised after the player releases a keyboard key.</summary>
public static event EventHandler<EventArgsKeyPressed> KeyReleased
{
- add => ControlEvents.EventManager.Control_KeyReleased.Add(value);
- remove => ControlEvents.EventManager.Control_KeyReleased.Remove(value);
+ add => ControlEvents.EventManager.Legacy_Control_KeyReleased.Add(value);
+ remove => ControlEvents.EventManager.Legacy_Control_KeyReleased.Remove(value);
}
/// <summary>Raised when the <see cref="MouseState"/> changes. That happens when the player moves the mouse, scrolls the mouse wheel, or presses/releases a button.</summary>
public static event EventHandler<EventArgsMouseStateChanged> MouseChanged
{
- add => ControlEvents.EventManager.Control_MouseChanged.Add(value);
- remove => ControlEvents.EventManager.Control_MouseChanged.Remove(value);
+ add => ControlEvents.EventManager.Legacy_Control_MouseChanged.Add(value);
+ remove => ControlEvents.EventManager.Legacy_Control_MouseChanged.Remove(value);
}
/// <summary>The player pressed a controller button. This event isn't raised for trigger buttons.</summary>
public static event EventHandler<EventArgsControllerButtonPressed> ControllerButtonPressed
{
- add => ControlEvents.EventManager.Control_ControllerButtonPressed.Add(value);
- remove => ControlEvents.EventManager.Control_ControllerButtonPressed.Remove(value);
+ add => ControlEvents.EventManager.Legacy_Control_ControllerButtonPressed.Add(value);
+ remove => ControlEvents.EventManager.Legacy_Control_ControllerButtonPressed.Remove(value);
}
/// <summary>The player released a controller button. This event isn't raised for trigger buttons.</summary>
public static event EventHandler<EventArgsControllerButtonReleased> ControllerButtonReleased
{
- add => ControlEvents.EventManager.Control_ControllerButtonReleased.Add(value);
- remove => ControlEvents.EventManager.Control_ControllerButtonReleased.Remove(value);
+ add => ControlEvents.EventManager.Legacy_Control_ControllerButtonReleased.Add(value);
+ remove => ControlEvents.EventManager.Legacy_Control_ControllerButtonReleased.Remove(value);
}
/// <summary>The player pressed a controller trigger button.</summary>
public static event EventHandler<EventArgsControllerTriggerPressed> ControllerTriggerPressed
{
- add => ControlEvents.EventManager.Control_ControllerTriggerPressed.Add(value);
- remove => ControlEvents.EventManager.Control_ControllerTriggerPressed.Remove(value);
+ add => ControlEvents.EventManager.Legacy_Control_ControllerTriggerPressed.Add(value);
+ remove => ControlEvents.EventManager.Legacy_Control_ControllerTriggerPressed.Remove(value);
}
/// <summary>The player released a controller trigger button.</summary>
public static event EventHandler<EventArgsControllerTriggerReleased> ControllerTriggerReleased
{
- add => ControlEvents.EventManager.Control_ControllerTriggerReleased.Add(value);
- remove => ControlEvents.EventManager.Control_ControllerTriggerReleased.Remove(value);
+ add => ControlEvents.EventManager.Legacy_Control_ControllerTriggerReleased.Add(value);
+ remove => ControlEvents.EventManager.Legacy_Control_ControllerTriggerReleased.Remove(value);
}
diff --git a/src/SMAPI/Events/EventArgsGameLocationsChanged.cs b/src/SMAPI/Events/EventArgsGameLocationsChanged.cs
deleted file mode 100644
index 78ba38fa..00000000
--- a/src/SMAPI/Events/EventArgsGameLocationsChanged.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using StardewValley;
-
-namespace StardewModdingAPI.Events
-{
- /// <summary>Event arguments for a <see cref="LocationEvents.LocationsChanged"/> event.</summary>
- public class EventArgsGameLocationsChanged : EventArgs
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The current list of game locations.</summary>
- public IList<GameLocation> NewLocations { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="newLocations">The current list of game locations.</param>
- public EventArgsGameLocationsChanged(IList<GameLocation> newLocations)
- {
- this.NewLocations = newLocations;
- }
- }
-}
diff --git a/src/SMAPI/Events/EventArgsInput.cs b/src/SMAPI/Events/EventArgsInput.cs
index 75b9b8cd..0cafdba5 100644
--- a/src/SMAPI/Events/EventArgsInput.cs
+++ b/src/SMAPI/Events/EventArgsInput.cs
@@ -1,8 +1,5 @@
using System;
-using System.Linq;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Input;
-using StardewValley;
+using System.Collections.Generic;
namespace StardewModdingAPI.Events
{
@@ -10,6 +7,13 @@ namespace StardewModdingAPI.Events
public class EventArgsInput : EventArgs
{
/*********
+ ** Properties
+ *********/
+ /// <summary>The buttons to suppress.</summary>
+ private readonly HashSet<SButton> SuppressButtons;
+
+
+ /*********
** Accessors
*********/
/// <summary>The button on the controller, keyboard, or mouse.</summary>
@@ -18,20 +22,14 @@ namespace StardewModdingAPI.Events
/// <summary>The current cursor position.</summary>
public ICursorPosition Cursor { get; }
-#if !STARDEW_VALLEY_1_3
- /// <summary>Whether the input is considered a 'click' by the game for enabling action.</summary>
- [Obsolete("Use " + nameof(EventArgsInput.IsActionButton) + " or " + nameof(EventArgsInput.IsUseToolButton) + " instead")] // deprecated in SMAPI 2.1
- public bool IsClick => this.IsActionButton;
-#endif
-
/// <summary>Whether the input should trigger actions on the affected tile.</summary>
- public bool IsActionButton { get; }
+ public bool IsActionButton => this.Button.IsActionButton();
/// <summary>Whether the input should use tools on the affected tile.</summary>
- public bool IsUseToolButton { get; }
+ public bool IsUseToolButton => this.Button.IsUseToolButton();
/// <summary>Whether a mod has indicated the key was already handled.</summary>
- public bool IsSuppressed { get; private set; }
+ public bool IsSuppressed => this.SuppressButtons.Contains(this.Button);
/*********
@@ -40,17 +38,15 @@ namespace StardewModdingAPI.Events
/// <summary>Construct an instance.</summary>
/// <param name="button">The button on the controller, keyboard, or mouse.</param>
/// <param name="cursor">The cursor position.</param>
- /// <param name="isActionButton">Whether the input should trigger actions on the affected tile.</param>
- /// <param name="isUseToolButton">Whether the input should use tools on the affected tile.</param>
- public EventArgsInput(SButton button, ICursorPosition cursor, bool isActionButton, bool isUseToolButton)
+ /// <param name="suppressButtons">The buttons to suppress.</param>
+ public EventArgsInput(SButton button, ICursorPosition cursor, HashSet<SButton> suppressButtons)
{
this.Button = button;
this.Cursor = cursor;
- this.IsActionButton = isActionButton;
- this.IsUseToolButton = isUseToolButton;
+ this.SuppressButtons = suppressButtons;
}
- /// <summary>Prevent the game from handling the vurrent button press. This doesn't prevent other mods from receiving the event.</summary>
+ /// <summary>Prevent the game from handling the current button press. This doesn't prevent other mods from receiving the event.</summary>
public void SuppressButton()
{
this.SuppressButton(this.Button);
@@ -60,96 +56,7 @@ namespace StardewModdingAPI.Events
/// <param name="button">The button to suppress.</param>
public void SuppressButton(SButton button)
{
- if (button == this.Button)
- this.IsSuppressed = true;
-
- // keyboard
- if (button.TryGetKeyboard(out Keys key))
- Game1.oldKBState = new KeyboardState(Game1.oldKBState.GetPressedKeys().Union(new[] { key }).ToArray());
-
- // controller
- else if (button.TryGetController(out Buttons controllerButton))
- {
- var newState = GamePad.GetState(PlayerIndex.One);
- var thumbsticks = Game1.oldPadState.ThumbSticks;
- var triggers = Game1.oldPadState.Triggers;
- var buttons = Game1.oldPadState.Buttons;
- var dpad = Game1.oldPadState.DPad;
-
- switch (controllerButton)
- {
- // d-pad
- case Buttons.DPadDown:
- dpad = new GamePadDPad(dpad.Up, newState.DPad.Down, dpad.Left, dpad.Right);
- break;
- case Buttons.DPadLeft:
- dpad = new GamePadDPad(dpad.Up, dpad.Down, newState.DPad.Left, dpad.Right);
- break;
- case Buttons.DPadRight:
- dpad = new GamePadDPad(dpad.Up, dpad.Down, dpad.Left, newState.DPad.Right);
- break;
- case Buttons.DPadUp:
- dpad = new GamePadDPad(newState.DPad.Up, dpad.Down, dpad.Left, dpad.Right);
- break;
-
- // trigger
- case Buttons.LeftTrigger:
- triggers = new GamePadTriggers(newState.Triggers.Left, triggers.Right);
- break;
- case Buttons.RightTrigger:
- triggers = new GamePadTriggers(triggers.Left, newState.Triggers.Right);
- break;
-
- // thumbstick
- case Buttons.LeftThumbstickDown:
- case Buttons.LeftThumbstickLeft:
- case Buttons.LeftThumbstickRight:
- case Buttons.LeftThumbstickUp:
- thumbsticks = new GamePadThumbSticks(newState.ThumbSticks.Left, thumbsticks.Right);
- break;
- case Buttons.RightThumbstickDown:
- case Buttons.RightThumbstickLeft:
- case Buttons.RightThumbstickRight:
- case Buttons.RightThumbstickUp:
- thumbsticks = new GamePadThumbSticks(newState.ThumbSticks.Right, thumbsticks.Left);
- break;
-
- // buttons
- default:
- var mask =
- (buttons.A == ButtonState.Pressed ? Buttons.A : 0)
- | (buttons.B == ButtonState.Pressed ? Buttons.B : 0)
- | (buttons.Back == ButtonState.Pressed ? Buttons.Back : 0)
- | (buttons.BigButton == ButtonState.Pressed ? Buttons.BigButton : 0)
- | (buttons.LeftShoulder == ButtonState.Pressed ? Buttons.LeftShoulder : 0)
- | (buttons.LeftStick == ButtonState.Pressed ? Buttons.LeftStick : 0)
- | (buttons.RightShoulder == ButtonState.Pressed ? Buttons.RightShoulder : 0)
- | (buttons.RightStick == ButtonState.Pressed ? Buttons.RightStick : 0)
- | (buttons.Start == ButtonState.Pressed ? Buttons.Start : 0)
- | (buttons.X == ButtonState.Pressed ? Buttons.X : 0)
- | (buttons.Y == ButtonState.Pressed ? Buttons.Y : 0);
- mask = mask ^ controllerButton;
- buttons = new GamePadButtons(mask);
- break;
- }
-
- Game1.oldPadState = new GamePadState(thumbsticks, triggers, buttons, dpad);
- }
-
- // mouse
- else if (button == SButton.MouseLeft || button == SButton.MouseMiddle || button == SButton.MouseRight || button == SButton.MouseX1 || button == SButton.MouseX2)
- {
- Game1.oldMouseState = new MouseState(
- x: Game1.oldMouseState.X,
- y: Game1.oldMouseState.Y,
- scrollWheel: Game1.oldMouseState.ScrollWheelValue,
- leftButton: button == SButton.MouseLeft ? ButtonState.Pressed : Game1.oldMouseState.LeftButton,
- middleButton: button == SButton.MouseMiddle ? ButtonState.Pressed : Game1.oldMouseState.MiddleButton,
- rightButton: button == SButton.MouseRight ? ButtonState.Pressed : Game1.oldMouseState.RightButton,
- xButton1: button == SButton.MouseX1 ? ButtonState.Pressed : Game1.oldMouseState.XButton1,
- xButton2: button == SButton.MouseX2 ? ButtonState.Pressed : Game1.oldMouseState.XButton2
- );
- }
+ this.SuppressButtons.Add(button);
}
}
}
diff --git a/src/SMAPI/Events/EventArgsIntChanged.cs b/src/SMAPI/Events/EventArgsIntChanged.cs
index 0c742d12..a018695c 100644
--- a/src/SMAPI/Events/EventArgsIntChanged.cs
+++ b/src/SMAPI/Events/EventArgsIntChanged.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace StardewModdingAPI.Events
{
@@ -14,6 +14,7 @@ namespace StardewModdingAPI.Events
/// <summary>The current value.</summary>
public int NewInt { get; }
+
/*********
** Public methods
*********/
diff --git a/src/SMAPI/Events/EventArgsInventoryChanged.cs b/src/SMAPI/Events/EventArgsInventoryChanged.cs
index b85ae9db..1fdca834 100644
--- a/src/SMAPI/Events/EventArgsInventoryChanged.cs
+++ b/src/SMAPI/Events/EventArgsInventoryChanged.cs
@@ -12,11 +12,7 @@ namespace StardewModdingAPI.Events
** Accessors
*********/
/// <summary>The player's inventory.</summary>
-#if STARDEW_VALLEY_1_3
public IList<Item> Inventory { get; }
-#else
- public List<Item> Inventory { get; }
-#endif
/// <summary>The added items.</summary>
public List<ItemStackChange> Added { get; }
@@ -34,13 +30,7 @@ namespace StardewModdingAPI.Events
/// <summary>Construct an instance.</summary>
/// <param name="inventory">The player's inventory.</param>
/// <param name="changedItems">The inventory changes.</param>
- public EventArgsInventoryChanged(
-#if STARDEW_VALLEY_1_3
- IList<Item> inventory,
-#else
- List<Item> inventory,
-#endif
- List<ItemStackChange> changedItems)
+ public EventArgsInventoryChanged(IList<Item> inventory, List<ItemStackChange> changedItems)
{
this.Inventory = inventory;
this.Added = changedItems.Where(n => n.ChangeType == ChangeType.Added).ToList();
diff --git a/src/SMAPI/Events/EventArgsLocationBuildingsChanged.cs b/src/SMAPI/Events/EventArgsLocationBuildingsChanged.cs
new file mode 100644
index 00000000..e8184ebe
--- /dev/null
+++ b/src/SMAPI/Events/EventArgsLocationBuildingsChanged.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using StardewValley;
+using StardewValley.Buildings;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="LocationEvents.BuildingsChanged"/> event.</summary>
+ public class EventArgsLocationBuildingsChanged : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The location which changed.</summary>
+ public GameLocation Location { get; }
+
+ /// <summary>The buildings added to the location.</summary>
+ public IEnumerable<Building> Added { get; }
+
+ /// <summary>The buildings removed from the location.</summary>
+ public IEnumerable<Building> Removed { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="location">The location which changed.</param>
+ /// <param name="added">The buildings added to the location.</param>
+ /// <param name="removed">The buildings removed from the location.</param>
+ public EventArgsLocationBuildingsChanged(GameLocation location, IEnumerable<Building> added, IEnumerable<Building> removed)
+ {
+ this.Location = location;
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
+ }
+ }
+}
diff --git a/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs b/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs
index 180e9d78..3bb387d5 100644
--- a/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs
+++ b/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs
@@ -1,43 +1,40 @@
using System;
-using Microsoft.Xna.Framework;
-#if STARDEW_VALLEY_1_3
using System.Collections.Generic;
-using Netcode;
-#else
+using System.Linq;
+using Microsoft.Xna.Framework;
using StardewValley;
-#endif
-using Object = StardewValley.Object;
+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.ObjectsChanged"/> event.</summary>
public class EventArgsLocationObjectsChanged : EventArgs
{
/*********
** Accessors
*********/
- /// <summary>The current list of objects in the current location.</summary>
-#if STARDEW_VALLEY_1_3
- public IDictionary<Vector2, NetRef<Object>> NewObjects { get; }
-#else
- public SerializableDictionary<Vector2, Object> NewObjects { get; }
-#endif
+ /// <summary>The location which changed.</summary>
+ public GameLocation Location { get; }
+
+ /// <summary>The objects added to the location.</summary>
+ public IEnumerable<KeyValuePair<Vector2, SObject>> Added { get; }
+
+ /// <summary>The objects removed from the location.</summary>
+ public IEnumerable<KeyValuePair<Vector2, SObject>> Removed { get; }
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
- /// <param name="newObjects">The current list of objects in the current location.</param>
- public EventArgsLocationObjectsChanged(
-#if STARDEW_VALLEY_1_3
- IDictionary<Vector2, NetRef<Object>> newObjects
-#else
- SerializableDictionary<Vector2, Object> newObjects
-#endif
- )
+ /// <param name="location">The location which changed.</param>
+ /// <param name="added">The objects added to the location.</param>
+ /// <param name="removed">The objects removed from the location.</param>
+ public EventArgsLocationObjectsChanged(GameLocation location, IEnumerable<KeyValuePair<Vector2, SObject>> added, IEnumerable<KeyValuePair<Vector2, SObject>> removed)
{
- this.NewObjects = newObjects;
+ this.Location = location;
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
}
}
}
diff --git a/src/SMAPI/Events/EventArgsLocationsChanged.cs b/src/SMAPI/Events/EventArgsLocationsChanged.cs
new file mode 100644
index 00000000..20984f45
--- /dev/null
+++ b/src/SMAPI/Events/EventArgsLocationsChanged.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using StardewValley;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="LocationEvents.LocationsChanged"/> event.</summary>
+ public class EventArgsLocationsChanged : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The added locations.</summary>
+ public IEnumerable<GameLocation> Added { get; }
+
+ /// <summary>The removed locations.</summary>
+ public IEnumerable<GameLocation> Removed { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="added">The added locations.</param>
+ /// <param name="removed">The removed locations.</param>
+ public EventArgsLocationsChanged(IEnumerable<GameLocation> added, IEnumerable<GameLocation> removed)
+ {
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
+ }
+ }
+}
diff --git a/src/SMAPI/Events/EventArgsCurrentLocationChanged.cs b/src/SMAPI/Events/EventArgsPlayerWarped.cs
index 25d3ebf3..93026aea 100644
--- a/src/SMAPI/Events/EventArgsCurrentLocationChanged.cs
+++ b/src/SMAPI/Events/EventArgsPlayerWarped.cs
@@ -1,19 +1,20 @@
-using System;
+using System;
using StardewValley;
namespace StardewModdingAPI.Events
{
- /// <summary>Event arguments for a <see cref="LocationEvents.CurrentLocationChanged"/> event.</summary>
- public class EventArgsCurrentLocationChanged : EventArgs
+ /// <summary>Event arguments for a <see cref="PlayerEvents.Warped"/> event.</summary>
+ public class EventArgsPlayerWarped : EventArgs
{
/*********
** Accessors
*********/
+ /// <summary>The player's previous location.</summary>
+ public GameLocation PriorLocation { get; }
+
/// <summary>The player's current location.</summary>
public GameLocation NewLocation { get; }
- /// <summary>The player's previous location.</summary>
- public GameLocation PriorLocation { get; }
/*********
@@ -22,7 +23,7 @@ namespace StardewModdingAPI.Events
/// <summary>Construct an instance.</summary>
/// <param name="priorLocation">The player's previous location.</param>
/// <param name="newLocation">The player's current location.</param>
- public EventArgsCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation)
+ public EventArgsPlayerWarped(GameLocation priorLocation, GameLocation newLocation)
{
this.NewLocation = newLocation;
this.PriorLocation = priorLocation;
diff --git a/src/SMAPI/Events/GameLoopLaunchedEventArgs.cs b/src/SMAPI/Events/GameLoopLaunchedEventArgs.cs
new file mode 100644
index 00000000..6a42e4f9
--- /dev/null
+++ b/src/SMAPI/Events/GameLoopLaunchedEventArgs.cs
@@ -0,0 +1,7 @@
+using System;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for an <see cref="IGameLoopEvents.Launched"/> event.</summary>
+ public class GameLoopLaunchedEventArgs : EventArgs { }
+}
diff --git a/src/SMAPI/Events/GameLoopUpdatedEventArgs.cs b/src/SMAPI/Events/GameLoopUpdatedEventArgs.cs
new file mode 100644
index 00000000..3ad34b69
--- /dev/null
+++ b/src/SMAPI/Events/GameLoopUpdatedEventArgs.cs
@@ -0,0 +1,36 @@
+using System;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for an <see cref="IGameLoopEvents.Updated"/> event.</summary>
+ public class GameLoopUpdatedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The number of ticks elapsed since the game started, including the current tick.</summary>
+ public uint Ticks { get; }
+
+ /// <summary>Whether <see cref="Ticks"/> is a multiple of 60, which happens approximately once per second.</summary>
+ public bool IsOneSecond { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="ticks">The number of ticks elapsed since the game started, including the current tick.</param>
+ public GameLoopUpdatedEventArgs(uint ticks)
+ {
+ this.Ticks = ticks;
+ this.IsOneSecond = this.IsMultipleOf(60);
+ }
+
+ /// <summary>Get whether <see cref="Ticks"/> is a multiple of the given <paramref name="number"/>. This is mainly useful if you want to run logic intermittently (e.g. <code>e.IsMultipleOf(30)</code> for every half-second).</summary>
+ /// <param name="number">The factor to check.</param>
+ public bool IsMultipleOf(uint number)
+ {
+ return this.Ticks % number == 0;
+ }
+ }
+}
diff --git a/src/SMAPI/Events/GameLoopUpdatingEventArgs.cs b/src/SMAPI/Events/GameLoopUpdatingEventArgs.cs
new file mode 100644
index 00000000..d6a8b5c2
--- /dev/null
+++ b/src/SMAPI/Events/GameLoopUpdatingEventArgs.cs
@@ -0,0 +1,36 @@
+using System;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for an <see cref="IGameLoopEvents.Updating"/> event.</summary>
+ public class GameLoopUpdatingEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The number of ticks elapsed since the game started, including the current tick.</summary>
+ public uint Ticks { get; }
+
+ /// <summary>Whether <see cref="Ticks"/> is a multiple of 60, which happens approximately once per second.</summary>
+ public bool IsOneSecond { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="ticks">The number of ticks elapsed since the game started, including the current tick.</param>
+ public GameLoopUpdatingEventArgs(uint ticks)
+ {
+ this.Ticks = ticks;
+ this.IsOneSecond = this.IsMultipleOf(60);
+ }
+
+ /// <summary>Get whether <see cref="Ticks"/> is a multiple of the given <paramref name="number"/>. This is mainly useful if you want to run logic intermittently (e.g. <code>e.IsMultipleOf(30)</code> for every half-second).</summary>
+ /// <param name="number">The factor to check.</param>
+ public bool IsMultipleOf(uint number)
+ {
+ return this.Ticks % number == 0;
+ }
+ }
+}
diff --git a/src/SMAPI/Events/IGameLoopEvents.cs b/src/SMAPI/Events/IGameLoopEvents.cs
new file mode 100644
index 00000000..a56b3de3
--- /dev/null
+++ b/src/SMAPI/Events/IGameLoopEvents.cs
@@ -0,0 +1,17 @@
+using System;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Events linked to the game's update loop. The update loop runs roughly ≈60 times/second to run game logic like state changes, action handling, etc. These can be useful, but you should consider more semantic events like <see cref="IInputEvents"/> if possible.</summary>
+ public interface IGameLoopEvents
+ {
+ /// <summary>Raised after the game is launched, right before the first update tick. This happens once per game session (unrelated to loading saves). All mods are loaded and initialised at this point, so this is a good time to set up mod integrations.</summary>
+ event EventHandler<GameLoopLaunchedEventArgs> Launched;
+
+ /// <summary>Raised before the game performs its overall update tick (≈60 times per second).</summary>
+ event EventHandler<GameLoopUpdatingEventArgs> Updating;
+
+ /// <summary>Raised after the game performs its overall update tick (≈60 times per second).</summary>
+ event EventHandler<GameLoopUpdatedEventArgs> Updated;
+ }
+}
diff --git a/src/SMAPI/Events/IInputEvents.cs b/src/SMAPI/Events/IInputEvents.cs
new file mode 100644
index 00000000..8e2ef406
--- /dev/null
+++ b/src/SMAPI/Events/IInputEvents.cs
@@ -0,0 +1,20 @@
+using System;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Events raised when the player provides input using a controller, keyboard, or mouse.</summary>
+ public interface IInputEvents
+ {
+ /// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
+ event EventHandler<InputButtonPressedEventArgs> ButtonPressed;
+
+ /// <summary>Raised after the player releases a button on the keyboard, controller, or mouse.</summary>
+ event EventHandler<InputButtonReleasedEventArgs> ButtonReleased;
+
+ /// <summary>Raised after the player moves the in-game cursor.</summary>
+ event EventHandler<InputCursorMovedEventArgs> CursorMoved;
+
+ /// <summary>Raised after the player scrolls the mouse wheel.</summary>
+ event EventHandler<InputMouseWheelScrolledEventArgs> MouseWheelScrolled;
+ }
+}
diff --git a/src/SMAPI/Events/IModEvents.cs b/src/SMAPI/Events/IModEvents.cs
new file mode 100644
index 00000000..cf2f8cb8
--- /dev/null
+++ b/src/SMAPI/Events/IModEvents.cs
@@ -0,0 +1,15 @@
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Manages access to events raised by SMAPI.</summary>
+ public interface IModEvents
+ {
+ /// <summary>Events linked to the game's update loop. The update loop runs roughly ≈60 times/second to run game logic like state changes, action handling, etc. These can be useful, but you should consider more semantic events like <see cref="Input"/> if possible.</summary>
+ IGameLoopEvents GameLoop { get; }
+
+ /// <summary>Events raised when the player provides input using a controller, keyboard, or mouse.</summary>
+ IInputEvents Input { get; }
+
+ /// <summary>Events raised when something changes in the world.</summary>
+ IWorldEvents World { get; }
+ }
+}
diff --git a/src/SMAPI/Events/IWorldEvents.cs b/src/SMAPI/Events/IWorldEvents.cs
new file mode 100644
index 00000000..d4efb53b
--- /dev/null
+++ b/src/SMAPI/Events/IWorldEvents.cs
@@ -0,0 +1,29 @@
+using System;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Events raised when something changes in the world.</summary>
+ public interface IWorldEvents
+ {
+ /// <summary>Raised after a game location is added or removed.</summary>
+ event EventHandler<WorldLocationListChangedEventArgs> LocationListChanged;
+
+ /// <summary>Raised after buildings are added or removed in a location.</summary>
+ event EventHandler<WorldBuildingListChangedEventArgs> BuildingListChanged;
+
+ /// <summary>Raised after debris are added or removed in a location.</summary>
+ event EventHandler<WorldDebrisListChangedEventArgs> DebrisListChanged;
+
+ /// <summary>Raised after large terrain features (like bushes) are added or removed in a location.</summary>
+ event EventHandler<WorldLargeTerrainFeatureListChangedEventArgs> LargeTerrainFeatureListChanged;
+
+ /// <summary>Raised after NPCs are added or removed in a location.</summary>
+ event EventHandler<WorldNpcListChangedEventArgs> NpcListChanged;
+
+ /// <summary>Raised after objects are added or removed in a location.</summary>
+ event EventHandler<WorldObjectListChangedEventArgs> ObjectListChanged;
+
+ /// <summary>Raised after terrain features (like floors and trees) are added or removed in a location.</summary>
+ event EventHandler<WorldTerrainFeatureListChangedEventArgs> TerrainFeatureListChanged;
+ }
+}
diff --git a/src/SMAPI/Events/InputButtonPressedEventArgs.cs b/src/SMAPI/Events/InputButtonPressedEventArgs.cs
new file mode 100644
index 00000000..8c6844dd
--- /dev/null
+++ b/src/SMAPI/Events/InputButtonPressedEventArgs.cs
@@ -0,0 +1,60 @@
+using System;
+using StardewModdingAPI.Framework.Input;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments when a button is pressed.</summary>
+ public class InputButtonPressedEventArgs : EventArgs
+ {
+ /*********
+ ** Properties
+ *********/
+ /// <summary>The game's current input state.</summary>
+ private readonly SInputState InputState;
+
+
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The button on the controller, keyboard, or mouse.</summary>
+ public SButton Button { get; }
+
+ /// <summary>The current cursor position.</summary>
+ public ICursorPosition Cursor { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="button">The button on the controller, keyboard, or mouse.</param>
+ /// <param name="cursor">The cursor position.</param>
+ /// <param name="inputState">The game's current input state.</param>
+ internal InputButtonPressedEventArgs(SButton button, ICursorPosition cursor, SInputState inputState)
+ {
+ this.Button = button;
+ this.Cursor = cursor;
+ this.InputState = inputState;
+ }
+
+ /// <summary>Whether a mod has indicated the key was already handled, so the game should handle it.</summary>
+ public bool IsSuppressed()
+ {
+ return this.IsSuppressed(this.Button);
+ }
+
+ /// <summary>Whether a mod has indicated the key was already handled, so the game should handle it.</summary>
+ /// <param name="button">The button to check.</param>
+ public bool IsSuppressed(SButton button)
+ {
+ return this.InputState.SuppressButtons.Contains(button);
+ }
+
+ /// <summary>Get whether a given button was pressed or held.</summary>
+ /// <param name="button">The button to check.</param>
+ public bool IsDown(SButton button)
+ {
+ return this.InputState.IsDown(button);
+ }
+ }
+}
diff --git a/src/SMAPI/Events/InputButtonReleasedEventArgs.cs b/src/SMAPI/Events/InputButtonReleasedEventArgs.cs
new file mode 100644
index 00000000..4b0bc326
--- /dev/null
+++ b/src/SMAPI/Events/InputButtonReleasedEventArgs.cs
@@ -0,0 +1,60 @@
+using System;
+using StardewModdingAPI.Framework.Input;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments when a button is released.</summary>
+ public class InputButtonReleasedEventArgs : EventArgs
+ {
+ /*********
+ ** Properties
+ *********/
+ /// <summary>The game's current input state.</summary>
+ private readonly SInputState InputState;
+
+
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The button on the controller, keyboard, or mouse.</summary>
+ public SButton Button { get; }
+
+ /// <summary>The current cursor position.</summary>
+ public ICursorPosition Cursor { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="button">The button on the controller, keyboard, or mouse.</param>
+ /// <param name="cursor">The cursor position.</param>
+ /// <param name="inputState">The game's current input state.</param>
+ internal InputButtonReleasedEventArgs(SButton button, ICursorPosition cursor, SInputState inputState)
+ {
+ this.Button = button;
+ this.Cursor = cursor;
+ this.InputState = inputState;
+ }
+
+ /// <summary>Whether a mod has indicated the key was already handled, so the game should handle it.</summary>
+ public bool IsSuppressed()
+ {
+ return this.IsSuppressed(this.Button);
+ }
+
+ /// <summary>Whether a mod has indicated the key was already handled, so the game should handle it.</summary>
+ /// <param name="button">The button to check.</param>
+ public bool IsSuppressed(SButton button)
+ {
+ return this.InputState.SuppressButtons.Contains(button);
+ }
+
+ /// <summary>Get whether a given button was pressed or held.</summary>
+ /// <param name="button">The button to check.</param>
+ public bool IsDown(SButton button)
+ {
+ return this.InputState.IsDown(button);
+ }
+ }
+}
diff --git a/src/SMAPI/Events/InputCursorMovedEventArgs.cs b/src/SMAPI/Events/InputCursorMovedEventArgs.cs
new file mode 100644
index 00000000..53aac5b3
--- /dev/null
+++ b/src/SMAPI/Events/InputCursorMovedEventArgs.cs
@@ -0,0 +1,30 @@
+using System;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments when the in-game cursor is moved.</summary>
+ public class InputCursorMovedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The previous cursor position.</summary>
+ public ICursorPosition OldPosition { get; }
+
+ /// <summary>The current cursor position.</summary>
+ public ICursorPosition NewPosition { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="oldPosition">The previous cursor position.</param>
+ /// <param name="newPosition">The new cursor position.</param>
+ public InputCursorMovedEventArgs(ICursorPosition oldPosition, ICursorPosition newPosition)
+ {
+ this.OldPosition = oldPosition;
+ this.NewPosition = newPosition;
+ }
+ }
+}
diff --git a/src/SMAPI/Events/InputEvents.cs b/src/SMAPI/Events/InputEvents.cs
index 84d7ce5d..e62d6ee6 100644
--- a/src/SMAPI/Events/InputEvents.cs
+++ b/src/SMAPI/Events/InputEvents.cs
@@ -19,15 +19,15 @@ namespace StardewModdingAPI.Events
/// <summary>Raised when the player presses a button on the keyboard, controller, or mouse.</summary>
public static event EventHandler<EventArgsInput> ButtonPressed
{
- add => InputEvents.EventManager.Input_ButtonPressed.Add(value);
- remove => InputEvents.EventManager.Input_ButtonPressed.Remove(value);
+ add => InputEvents.EventManager.Legacy_Input_ButtonPressed.Add(value);
+ remove => InputEvents.EventManager.Legacy_Input_ButtonPressed.Remove(value);
}
/// <summary>Raised when the player releases a keyboard key on the keyboard, controller, or mouse.</summary>
public static event EventHandler<EventArgsInput> ButtonReleased
{
- add => InputEvents.EventManager.Input_ButtonReleased.Add(value);
- remove => InputEvents.EventManager.Input_ButtonReleased.Remove(value);
+ add => InputEvents.EventManager.Legacy_Input_ButtonReleased.Add(value);
+ remove => InputEvents.EventManager.Legacy_Input_ButtonReleased.Remove(value);
}
diff --git a/src/SMAPI/Events/InputMouseWheelScrolledEventArgs.cs b/src/SMAPI/Events/InputMouseWheelScrolledEventArgs.cs
new file mode 100644
index 00000000..9afab9cc
--- /dev/null
+++ b/src/SMAPI/Events/InputMouseWheelScrolledEventArgs.cs
@@ -0,0 +1,38 @@
+using System;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments when the player scrolls the mouse wheel.</summary>
+ public class InputMouseWheelScrolledEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The cursor position.</summary>
+ public ICursorPosition Position { get; }
+
+ /// <summary>The old scroll value.</summary>
+ public int OldValue { get; }
+
+ /// <summary>The new scroll value.</summary>
+ public int NewValue { get; }
+
+ /// <summary>The amount by which the scroll value changed.</summary>
+ public int Delta => this.NewValue - this.OldValue;
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="position">The cursor position.</param>
+ /// <param name="oldValue">The old scroll value.</param>
+ /// <param name="newValue">The new scroll value.</param>
+ public InputMouseWheelScrolledEventArgs(ICursorPosition position, int oldValue, int newValue)
+ {
+ this.Position = position;
+ this.OldValue = oldValue;
+ this.NewValue = newValue;
+ }
+ }
+}
diff --git a/src/SMAPI/Events/LocationEvents.cs b/src/SMAPI/Events/LocationEvents.cs
index 81d13e9f..e2108de0 100644
--- a/src/SMAPI/Events/LocationEvents.cs
+++ b/src/SMAPI/Events/LocationEvents.cs
@@ -16,25 +16,25 @@ namespace StardewModdingAPI.Events
/*********
** 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<EventArgsLocationsChanged> LocationsChanged
{
- add => LocationEvents.EventManager.Location_CurrentLocationChanged.Add(value);
- remove => LocationEvents.EventManager.Location_CurrentLocationChanged.Remove(value);
+ add => LocationEvents.EventManager.Legacy_Location_LocationsChanged.Add(value);
+ remove => LocationEvents.EventManager.Legacy_Location_LocationsChanged.Remove(value);
}
- /// <summary>Raised after a game location is added or removed.</summary>
- public static event EventHandler<EventArgsGameLocationsChanged> LocationsChanged
+ /// <summary>Raised after buildings are added or removed in a location.</summary>
+ public static event EventHandler<EventArgsLocationBuildingsChanged> BuildingsChanged
{
- add => LocationEvents.EventManager.Location_LocationsChanged.Add(value);
- remove => LocationEvents.EventManager.Location_LocationsChanged.Remove(value);
+ add => LocationEvents.EventManager.Legacy_Location_BuildingsChanged.Add(value);
+ remove => LocationEvents.EventManager.Legacy_Location_BuildingsChanged.Remove(value);
}
- /// <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
+ /// <summary>Raised after objects are added or removed in a location.</summary>
+ public static event EventHandler<EventArgsLocationObjectsChanged> ObjectsChanged
{
- add => LocationEvents.EventManager.Location_LocationObjectsChanged.Add(value);
- remove => LocationEvents.EventManager.Location_LocationObjectsChanged.Remove(value);
+ add => LocationEvents.EventManager.Legacy_Location_ObjectsChanged.Add(value);
+ remove => LocationEvents.EventManager.Legacy_Location_ObjectsChanged.Remove(value);
}
diff --git a/src/SMAPI/Events/MultiplayerEvents.cs b/src/SMAPI/Events/MultiplayerEvents.cs
new file mode 100644
index 00000000..f96ecba5
--- /dev/null
+++ b/src/SMAPI/Events/MultiplayerEvents.cs
@@ -0,0 +1,58 @@
+using System;
+using StardewModdingAPI.Framework.Events;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Events raised during the multiplayer sync process.</summary>
+ public static class MultiplayerEvents
+ {
+ /*********
+ ** Properties
+ *********/
+ /// <summary>The core event manager.</summary>
+ private static EventManager EventManager;
+
+
+ /*********
+ ** Events
+ *********/
+ /// <summary>Raised before the game syncs changes from other players.</summary>
+ public static event EventHandler BeforeMainSync
+ {
+ add => MultiplayerEvents.EventManager.Multiplayer_BeforeMainSync.Add(value);
+ remove => MultiplayerEvents.EventManager.Multiplayer_BeforeMainSync.Remove(value);
+ }
+
+ /// <summary>Raised after the game syncs changes from other players.</summary>
+ public static event EventHandler AfterMainSync
+ {
+ add => MultiplayerEvents.EventManager.Multiplayer_AfterMainSync.Add(value);
+ remove => MultiplayerEvents.EventManager.Multiplayer_AfterMainSync.Remove(value);
+ }
+
+ /// <summary>Raised before the game broadcasts changes to other players.</summary>
+ public static event EventHandler BeforeMainBroadcast
+ {
+ add => MultiplayerEvents.EventManager.Multiplayer_BeforeMainBroadcast.Add(value);
+ remove => MultiplayerEvents.EventManager.Multiplayer_BeforeMainBroadcast.Remove(value);
+ }
+
+ /// <summary>Raised after the game broadcasts changes to other players.</summary>
+ public static event EventHandler AfterMainBroadcast
+ {
+ add => MultiplayerEvents.EventManager.Multiplayer_AfterMainBroadcast.Add(value);
+ remove => MultiplayerEvents.EventManager.Multiplayer_AfterMainBroadcast.Remove(value);
+ }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Initialise the events.</summary>
+ /// <param name="eventManager">The core event manager.</param>
+ internal static void Init(EventManager eventManager)
+ {
+ MultiplayerEvents.EventManager = eventManager;
+ }
+ }
+}
diff --git a/src/SMAPI/Events/PlayerEvents.cs b/src/SMAPI/Events/PlayerEvents.cs
index 84a7ff63..6e7050e3 100644
--- a/src/SMAPI/Events/PlayerEvents.cs
+++ b/src/SMAPI/Events/PlayerEvents.cs
@@ -23,13 +23,21 @@ namespace StardewModdingAPI.Events
remove => PlayerEvents.EventManager.Player_InventoryChanged.Remove(value);
}
- /// <summary> Raised after the player levels up a skill. This happens as soon as they level up, not when the game notifies the player after their character goes to bed.</summary>
+ /// <summary>Raised after the player levels up a skill. This happens as soon as they level up, not when the game notifies the player after their character goes to bed.</summary>
public static event EventHandler<EventArgsLevelUp> LeveledUp
{
add => PlayerEvents.EventManager.Player_LeveledUp.Add(value);
remove => PlayerEvents.EventManager.Player_LeveledUp.Remove(value);
}
+ /// <summary>Raised after the player warps to a new location.</summary>
+ public static event EventHandler<EventArgsPlayerWarped> Warped
+ {
+ add => PlayerEvents.EventManager.Player_Warped.Add(value);
+ remove => PlayerEvents.EventManager.Player_Warped.Remove(value);
+ }
+
+
/*********
** Public methods
diff --git a/src/SMAPI/Events/WorldBuildingListChangedEventArgs.cs b/src/SMAPI/Events/WorldBuildingListChangedEventArgs.cs
new file mode 100644
index 00000000..e73b9396
--- /dev/null
+++ b/src/SMAPI/Events/WorldBuildingListChangedEventArgs.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using StardewValley;
+using StardewValley.Buildings;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="IWorldEvents.BuildingListChanged"/> event.</summary>
+ public class WorldBuildingListChangedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The location which changed.</summary>
+ public GameLocation Location { get; }
+
+ /// <summary>The buildings added to the location.</summary>
+ public IEnumerable<Building> Added { get; }
+
+ /// <summary>The buildings removed from the location.</summary>
+ public IEnumerable<Building> Removed { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="location">The location which changed.</param>
+ /// <param name="added">The buildings added to the location.</param>
+ /// <param name="removed">The buildings removed from the location.</param>
+ public WorldBuildingListChangedEventArgs(GameLocation location, IEnumerable<Building> added, IEnumerable<Building> removed)
+ {
+ this.Location = location;
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
+ }
+ }
+}
diff --git a/src/SMAPI/Events/WorldDebrisListChangedEventArgs.cs b/src/SMAPI/Events/WorldDebrisListChangedEventArgs.cs
new file mode 100644
index 00000000..aad9c24d
--- /dev/null
+++ b/src/SMAPI/Events/WorldDebrisListChangedEventArgs.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using StardewValley;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="IWorldEvents.DebrisListChanged"/> event.</summary>
+ public class WorldDebrisListChangedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The location which changed.</summary>
+ public GameLocation Location { get; }
+
+ /// <summary>The debris added to the location.</summary>
+ public IEnumerable<Debris> Added { get; }
+
+ /// <summary>The debris removed from the location.</summary>
+ public IEnumerable<Debris> Removed { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="location">The location which changed.</param>
+ /// <param name="added">The debris added to the location.</param>
+ /// <param name="removed">The debris removed from the location.</param>
+ public WorldDebrisListChangedEventArgs(GameLocation location, IEnumerable<Debris> added, IEnumerable<Debris> removed)
+ {
+ this.Location = location;
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
+ }
+ }
+}
diff --git a/src/SMAPI/Events/WorldLargeTerrainFeatureListChangedEventArgs.cs b/src/SMAPI/Events/WorldLargeTerrainFeatureListChangedEventArgs.cs
new file mode 100644
index 00000000..053a0e41
--- /dev/null
+++ b/src/SMAPI/Events/WorldLargeTerrainFeatureListChangedEventArgs.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using StardewValley;
+using StardewValley.TerrainFeatures;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="IWorldEvents.LargeTerrainFeatureListChanged"/> event.</summary>
+ public class WorldLargeTerrainFeatureListChangedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The location which changed.</summary>
+ public GameLocation Location { get; }
+
+ /// <summary>The large terrain features added to the location.</summary>
+ public IEnumerable<LargeTerrainFeature> Added { get; }
+
+ /// <summary>The large terrain features removed from the location.</summary>
+ public IEnumerable<LargeTerrainFeature> Removed { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="location">The location which changed.</param>
+ /// <param name="added">The large terrain features added to the location.</param>
+ /// <param name="removed">The large terrain features removed from the location.</param>
+ public WorldLargeTerrainFeatureListChangedEventArgs(GameLocation location, IEnumerable<LargeTerrainFeature> added, IEnumerable<LargeTerrainFeature> removed)
+ {
+ this.Location = location;
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
+ }
+ }
+}
diff --git a/src/SMAPI/Events/WorldLocationListChangedEventArgs.cs b/src/SMAPI/Events/WorldLocationListChangedEventArgs.cs
new file mode 100644
index 00000000..8bc26a43
--- /dev/null
+++ b/src/SMAPI/Events/WorldLocationListChangedEventArgs.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using StardewValley;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="IWorldEvents.LocationListChanged"/> event.</summary>
+ public class WorldLocationListChangedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The added locations.</summary>
+ public IEnumerable<GameLocation> Added { get; }
+
+ /// <summary>The removed locations.</summary>
+ public IEnumerable<GameLocation> Removed { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="added">The added locations.</param>
+ /// <param name="removed">The removed locations.</param>
+ public WorldLocationListChangedEventArgs(IEnumerable<GameLocation> added, IEnumerable<GameLocation> removed)
+ {
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
+ }
+ }
+}
diff --git a/src/SMAPI/Events/WorldNpcListChangedEventArgs.cs b/src/SMAPI/Events/WorldNpcListChangedEventArgs.cs
new file mode 100644
index 00000000..e251f894
--- /dev/null
+++ b/src/SMAPI/Events/WorldNpcListChangedEventArgs.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using StardewValley;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="IWorldEvents.NpcListChanged"/> event.</summary>
+ public class WorldNpcListChangedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The location which changed.</summary>
+ public GameLocation Location { get; }
+
+ /// <summary>The NPCs added to the location.</summary>
+ public IEnumerable<NPC> Added { get; }
+
+ /// <summary>The NPCs removed from the location.</summary>
+ public IEnumerable<NPC> Removed { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="location">The location which changed.</param>
+ /// <param name="added">The NPCs added to the location.</param>
+ /// <param name="removed">The NPCs removed from the location.</param>
+ public WorldNpcListChangedEventArgs(GameLocation location, IEnumerable<NPC> added, IEnumerable<NPC> removed)
+ {
+ this.Location = location;
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
+ }
+ }
+}
diff --git a/src/SMAPI/Events/WorldObjectListChangedEventArgs.cs b/src/SMAPI/Events/WorldObjectListChangedEventArgs.cs
new file mode 100644
index 00000000..5623a49b
--- /dev/null
+++ b/src/SMAPI/Events/WorldObjectListChangedEventArgs.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using StardewValley;
+using Object = StardewValley.Object;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="IWorldEvents.ObjectListChanged"/> event.</summary>
+ public class WorldObjectListChangedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The location which changed.</summary>
+ public GameLocation Location { get; }
+
+ /// <summary>The objects added to the location.</summary>
+ public IEnumerable<KeyValuePair<Vector2, Object>> Added { get; }
+
+ /// <summary>The objects removed from the location.</summary>
+ public IEnumerable<KeyValuePair<Vector2, Object>> Removed { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="location">The location which changed.</param>
+ /// <param name="added">The objects added to the location.</param>
+ /// <param name="removed">The objects removed from the location.</param>
+ public WorldObjectListChangedEventArgs(GameLocation location, IEnumerable<KeyValuePair<Vector2, Object>> added, IEnumerable<KeyValuePair<Vector2, Object>> removed)
+ {
+ this.Location = location;
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
+ }
+ }
+}
diff --git a/src/SMAPI/Events/WorldTerrainFeatureListChangedEventArgs.cs b/src/SMAPI/Events/WorldTerrainFeatureListChangedEventArgs.cs
new file mode 100644
index 00000000..cb089811
--- /dev/null
+++ b/src/SMAPI/Events/WorldTerrainFeatureListChangedEventArgs.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using StardewValley;
+using StardewValley.TerrainFeatures;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for a <see cref="IWorldEvents.TerrainFeatureListChanged"/> event.</summary>
+ public class WorldTerrainFeatureListChangedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The location which changed.</summary>
+ public GameLocation Location { get; }
+
+ /// <summary>The terrain features added to the location.</summary>
+ public IEnumerable<KeyValuePair<Vector2, TerrainFeature>> Added { get; }
+
+ /// <summary>The terrain features removed from the location.</summary>
+ public IEnumerable<KeyValuePair<Vector2, TerrainFeature>> Removed { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="location">The location which changed.</param>
+ /// <param name="added">The terrain features added to the location.</param>
+ /// <param name="removed">The terrain features removed from the location.</param>
+ public WorldTerrainFeatureListChangedEventArgs(GameLocation location, IEnumerable<KeyValuePair<Vector2, TerrainFeature>> added, IEnumerable<KeyValuePair<Vector2, TerrainFeature>> removed)
+ {
+ this.Location = location;
+ this.Added = added.ToArray();
+ this.Removed = removed.ToArray();
+ }
+ }
+}