]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
GettingUsedAttemptEvent (#35450)
authorScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Mon, 24 Feb 2025 16:21:17 +0000 (17:21 +0100)
committerGitHub <noreply@github.com>
Mon, 24 Feb 2025 16:21:17 +0000 (17:21 +0100)
* init

* review

* doc

* Update Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Shared/ActionBlocker/ActionBlockerSystem.cs
Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs [new file with mode: 0644]

index 6152699ccb1c4f9987ee89d8c566da402d3ee01b..08eac657c02e74a2eeb91b4c44659a2034c63582 100644 (file)
@@ -109,10 +109,16 @@ namespace Content.Shared.ActionBlocker
         /// </remarks>
         public bool CanUseHeldEntity(EntityUid user, EntityUid used)
         {
-            var ev = new UseAttemptEvent(user, used);
-            RaiseLocalEvent(user, ev);
+            var useEv = new UseAttemptEvent(user, used);
+            RaiseLocalEvent(user, useEv);
 
-            return !ev.Cancelled;
+            if (useEv.Cancelled)
+                return false;
+
+            var usedEv = new GettingUsedAttemptEvent(user);
+            RaiseLocalEvent(used, usedEv);
+
+            return !usedEv.Cancelled;
         }
 
 
diff --git a/Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs b/Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs
new file mode 100644 (file)
index 0000000..cd5f029
--- /dev/null
@@ -0,0 +1,10 @@
+namespace Content.Shared.Interaction.Events;
+
+/// <summary>
+/// Event raised on an item when attempting to use it in your hands. Cancelling it stops the interaction.
+/// </summary>
+/// <param name="user">The user of said item</param>
+public sealed class GettingUsedAttemptEvent(EntityUid user) : CancellableEntityEventArgs
+{
+    public EntityUid User = user;
+}