]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add user to AttemptMeleeEvent, add ThrowItemAttemptEvent (#30193)
authorDrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Sat, 20 Jul 2024 08:06:52 +0000 (01:06 -0700)
committerGitHub <noreply@github.com>
Sat, 20 Jul 2024 08:06:52 +0000 (18:06 +1000)
* Add user to AttemptMeleeEvent, add ThrowItemAttemptEvent

* Add xmldoc

Content.Shared/ActionBlocker/ActionBlockerSystem.cs
Content.Shared/Throwing/ThrowAttemptEvent.cs
Content.Shared/Weapons/Melee/Events/AttemptMeleeEvent.cs

index 005c7dc78ec75ef55779c9192bf67803cbe7e06e..afa1e19eaded26f713f72ce6037aa75ea313ae5f 100644 (file)
@@ -120,7 +120,13 @@ namespace Content.Shared.ActionBlocker
             var ev = new ThrowAttemptEvent(user, itemUid);
             RaiseLocalEvent(user, ev);
 
-            return !ev.Cancelled;
+            if (ev.Cancelled)
+                return false;
+
+            var itemEv = new ThrowItemAttemptEvent(user);
+            RaiseLocalEvent(itemUid, ref itemEv);
+
+            return !itemEv.Cancelled;
         }
 
         public bool CanSpeak(EntityUid uid)
index bf8cad6c74628359f3d76da9c519db5cbf03d769..dfb3dca5c7d5489c036890f8d9d58d553b4da296 100644 (file)
         public EntityUid ItemUid { get; }
     }
 
+    /// <summary>
+    ///     Raised on the item entity that is thrown.
+    /// </summary>
+    /// <param name="User">The user that threw this entity.</param>
+    /// <param name="Cancelled">Whether or not the throw should be cancelled.</param>
+    [ByRefEvent]
+    public record struct ThrowItemAttemptEvent(EntityUid User, bool Cancelled = false);
+
     /// <summary>
     /// Raised when we try to pushback an entity from throwing
     /// </summary>
index 2800e3b34daebfb5415a2295c40956773b6bacfa..cbcadcd19f9639cdc03aa6c8b9c15667eb02fbac 100644 (file)
@@ -4,4 +4,4 @@ namespace Content.Shared.Weapons.Melee.Events;
 /// Raised directed on a weapon when attempt a melee attack.
 /// </summary>
 [ByRefEvent]
-public record struct AttemptMeleeEvent(bool Cancelled, string? Message);
+public record struct AttemptMeleeEvent(EntityUid User, bool Cancelled = false, string? Message = null);