diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-05-05 01:31:06 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-05-05 01:31:06 -0400 |
commit | b8fd3aedfe884741bdda8c68398427f875585456 (patch) | |
tree | 12b6395923c930fa3155d4be2f38b1aa6e660217 /src/SMAPI/Events | |
parent | a65a49a62201cc897e73c265a0a808ef0baad002 (diff) | |
download | SMAPI-b8fd3aedfe884741bdda8c68398427f875585456.tar.gz SMAPI-b8fd3aedfe884741bdda8c68398427f875585456.tar.bz2 SMAPI-b8fd3aedfe884741bdda8c68398427f875585456.zip |
rewrite location events for multiplayer
Diffstat (limited to 'src/SMAPI/Events')
-rw-r--r-- | src/SMAPI/Events/EventArgsGameLocationsChanged.cs | 27 | ||||
-rw-r--r-- | src/SMAPI/Events/EventArgsIntChanged.cs | 3 | ||||
-rw-r--r-- | src/SMAPI/Events/EventArgsLocationBuildingsChanged.cs | 39 | ||||
-rw-r--r-- | src/SMAPI/Events/EventArgsLocationObjectsChanged.cs | 18 | ||||
-rw-r--r-- | src/SMAPI/Events/EventArgsLocationsChanged.cs | 33 | ||||
-rw-r--r-- | src/SMAPI/Events/EventArgsPlayerWarped.cs (renamed from src/SMAPI/Events/EventArgsCurrentLocationChanged.cs) | 13 | ||||
-rw-r--r-- | src/SMAPI/Events/LocationEvents.cs | 20 | ||||
-rw-r--r-- | src/SMAPI/Events/PlayerEvents.cs | 10 |
8 files changed, 102 insertions, 61 deletions
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/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/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 a6138ddb..410ef6e6 100644 --- a/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs +++ b/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs @@ -8,7 +8,7 @@ using SObject = StardewValley.Object; namespace StardewModdingAPI.Events { - /// <summary>Event arguments for a <see cref="LocationEvents.LocationObjectsChanged"/> or <see cref="LocationEvents.ObjectsChanged"/> event.</summary> + /// <summary>Event arguments for a <see cref="LocationEvents.ObjectsChanged"/> event.</summary> public class EventArgsLocationObjectsChanged : EventArgs { /********* @@ -17,31 +17,25 @@ namespace StardewModdingAPI.Events /// <summary>The location which changed.</summary> public GameLocation Location { get; } - /// <summary>The objects added to the list.</summary> + /// <summary>The objects added to the location.</summary> public IEnumerable<KeyValuePair<Vector2, SObject>> Added { get; } - /// <summary>The objects removed from the list.</summary> + /// <summary>The objects removed from the location.</summary> public IEnumerable<KeyValuePair<Vector2, SObject>> Removed { get; } - /// <summary>The current list of objects in the current location.</summary> - [Obsolete("Use " + nameof(EventArgsLocationObjectsChanged.Added))] - public IDictionary<Vector2, NetRef<SObject>> NewObjects { get; } - /********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="location">The location which changed.</param> - /// <param name="added">The objects added to the list.</param> - /// <param name="removed">The objects removed from the list.</param> - /// <param name="newObjects">The current list of objects in the current location.</param> - public EventArgsLocationObjectsChanged(GameLocation location, IEnumerable<KeyValuePair<Vector2, SObject>> added, IEnumerable<KeyValuePair<Vector2, SObject>> removed, IDictionary<Vector2, NetRef<SObject>> newObjects) + /// <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.Location = location; this.Added = added.ToArray(); this.Removed = removed.ToArray(); - this.NewObjects = newObjects; } } } 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/LocationEvents.cs b/src/SMAPI/Events/LocationEvents.cs index 3ed09136..ff75c619 100644 --- a/src/SMAPI/Events/LocationEvents.cs +++ b/src/SMAPI/Events/LocationEvents.cs @@ -16,29 +16,21 @@ namespace StardewModdingAPI.Events /********* ** Events *********/ - /// <summary>Raised after the player warps to a new location.</summary> - public static event EventHandler<EventArgsCurrentLocationChanged> CurrentLocationChanged - { - add => LocationEvents.EventManager.Location_CurrentLocationChanged.Add(value); - remove => LocationEvents.EventManager.Location_CurrentLocationChanged.Remove(value); - } - /// <summary>Raised after a game location is added or removed.</summary> - public static event EventHandler<EventArgsGameLocationsChanged> LocationsChanged + public static event EventHandler<EventArgsLocationsChanged> LocationsChanged { add => LocationEvents.EventManager.Location_LocationsChanged.Add(value); remove => LocationEvents.EventManager.Location_LocationsChanged.Remove(value); } - /// <summary>Raised after the list of objects in the current location changes (e.g. an object is added or removed).</summary> - [Obsolete("Use " + nameof(LocationEvents) + "." + nameof(LocationEvents.ObjectsChanged) + " instead")] - public static event EventHandler<EventArgsLocationObjectsChanged> LocationObjectsChanged + /// <summary>Raised after buildings are added or removed in a location.</summary> + public static event EventHandler<EventArgsLocationBuildingsChanged> BuildingsChanged { - add => LocationEvents.EventManager.Location_LocationObjectsChanged.Add(value); - remove => LocationEvents.EventManager.Location_LocationObjectsChanged.Remove(value); + add => LocationEvents.EventManager.Location_BuildingsChanged.Add(value); + remove => LocationEvents.EventManager.Location_BuildingsChanged.Remove(value); } - /// <summary>Raised after the list of objects in a location changes (e.g. an object is added or removed).</summary> + /// <summary>Raised after objects are added or removed in a location.</summary> public static event EventHandler<EventArgsLocationObjectsChanged> ObjectsChanged { add => LocationEvents.EventManager.Location_ObjectsChanged.Add(value); 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 |