summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Events')
-rw-r--r--src/SMAPI/Events/EventPriority.cs15
-rw-r--r--src/SMAPI/Events/EventPriorityAttribute.cs26
-rw-r--r--src/SMAPI/Events/IMultiplayerEvents.cs5
-rw-r--r--src/SMAPI/Events/PeerConnectedEventArgs.cs25
4 files changed, 70 insertions, 1 deletions
diff --git a/src/SMAPI/Events/EventPriority.cs b/src/SMAPI/Events/EventPriority.cs
new file mode 100644
index 00000000..1efb4e2a
--- /dev/null
+++ b/src/SMAPI/Events/EventPriority.cs
@@ -0,0 +1,15 @@
+namespace StardewModdingAPI.Events
+{
+ /// <summary>The event priorities for method handlers.</summary>
+ public enum EventPriority
+ {
+ /// <summary>Low priority.</summary>
+ Low = -1000,
+
+ /// <summary>The default priority.</summary>
+ Normal = 0,
+
+ /// <summary>High priority.</summary>
+ High = 1000
+ }
+}
diff --git a/src/SMAPI/Events/EventPriorityAttribute.cs b/src/SMAPI/Events/EventPriorityAttribute.cs
new file mode 100644
index 00000000..207e7862
--- /dev/null
+++ b/src/SMAPI/Events/EventPriorityAttribute.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>An attribute which specifies the priority for an event handler.</summary>
+ [AttributeUsage(AttributeTargets.Method)]
+ public class EventPriorityAttribute : Attribute
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The event handler priority, relative to other handlers across all mods registered for this event.</summary>
+ internal EventPriority Priority { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="priority">The event handler priority, relative to other handlers across all mods registered for this event. Higher-priority handlers are notified before lower-priority handlers.</param>
+ public EventPriorityAttribute(EventPriority priority)
+ {
+ this.Priority = priority;
+ }
+ }
+}
diff --git a/src/SMAPI/Events/IMultiplayerEvents.cs b/src/SMAPI/Events/IMultiplayerEvents.cs
index 4a31f48e..af9b5f17 100644
--- a/src/SMAPI/Events/IMultiplayerEvents.cs
+++ b/src/SMAPI/Events/IMultiplayerEvents.cs
@@ -5,9 +5,12 @@ namespace StardewModdingAPI.Events
/// <summary>Events raised for multiplayer messages and connections.</summary>
public interface IMultiplayerEvents
{
- /// <summary>Raised after the mod context for a peer is received. This happens before the game approves the connection, so the player doesn't yet exist in the game. This is the earliest point where messages can be sent to the peer via SMAPI.</summary>
+ /// <summary>Raised after the mod context for a peer is received. This happens before the game approves the connection (<see cref="PeerConnected"/>), so the player doesn't yet exist in the game. This is the earliest point where messages can be sent to the peer via SMAPI.</summary>
event EventHandler<PeerContextReceivedEventArgs> PeerContextReceived;
+ /// <summary>Raised after a peer connection is approved by the game.</summary>
+ event EventHandler<PeerConnectedEventArgs> PeerConnected;
+
/// <summary>Raised after a mod message is received over the network.</summary>
event EventHandler<ModMessageReceivedEventArgs> ModMessageReceived;
diff --git a/src/SMAPI/Events/PeerConnectedEventArgs.cs b/src/SMAPI/Events/PeerConnectedEventArgs.cs
new file mode 100644
index 00000000..bfaa2bd3
--- /dev/null
+++ b/src/SMAPI/Events/PeerConnectedEventArgs.cs
@@ -0,0 +1,25 @@
+using System;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments for an <see cref="IMultiplayerEvents.PeerConnected"/> event.</summary>
+ public class PeerConnectedEventArgs : EventArgs
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The peer whose metadata was received.</summary>
+ public IMultiplayerPeer Peer { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="peer">The peer whose metadata was received.</param>
+ internal PeerConnectedEventArgs(IMultiplayerPeer peer)
+ {
+ this.Peer = peer;
+ }
+ }
+}