From 297baaca2324b57d93dc61d59e3a402886c0847f Mon Sep 17 00:00:00 2001
From: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Date: Sat, 20 Jul 2024 01:06:52 -0700
Subject: [PATCH] Add user to AttemptMeleeEvent, add ThrowItemAttemptEvent
(#30193)
* Add user to AttemptMeleeEvent, add ThrowItemAttemptEvent
* Add xmldoc
---
Content.Shared/ActionBlocker/ActionBlockerSystem.cs | 8 +++++++-
Content.Shared/Throwing/ThrowAttemptEvent.cs | 8 ++++++++
Content.Shared/Weapons/Melee/Events/AttemptMeleeEvent.cs | 2 +-
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs
index 005c7dc78e..afa1e19ead 100644
--- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs
+++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs
@@ -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)
diff --git a/Content.Shared/Throwing/ThrowAttemptEvent.cs b/Content.Shared/Throwing/ThrowAttemptEvent.cs
index bf8cad6c74..dfb3dca5c7 100644
--- a/Content.Shared/Throwing/ThrowAttemptEvent.cs
+++ b/Content.Shared/Throwing/ThrowAttemptEvent.cs
@@ -13,6 +13,14 @@
public EntityUid ItemUid { get; }
}
+ ///
+ /// Raised on the item entity that is thrown.
+ ///
+ /// The user that threw this entity.
+ /// Whether or not the throw should be cancelled.
+ [ByRefEvent]
+ public record struct ThrowItemAttemptEvent(EntityUid User, bool Cancelled = false);
+
///
/// Raised when we try to pushback an entity from throwing
///
diff --git a/Content.Shared/Weapons/Melee/Events/AttemptMeleeEvent.cs b/Content.Shared/Weapons/Melee/Events/AttemptMeleeEvent.cs
index 2800e3b34d..cbcadcd19f 100644
--- a/Content.Shared/Weapons/Melee/Events/AttemptMeleeEvent.cs
+++ b/Content.Shared/Weapons/Melee/Events/AttemptMeleeEvent.cs
@@ -4,4 +4,4 @@ namespace Content.Shared.Weapons.Melee.Events;
/// Raised directed on a weapon when attempt a melee attack.
///
[ByRefEvent]
-public record struct AttemptMeleeEvent(bool Cancelled, string? Message);
+public record struct AttemptMeleeEvent(EntityUid User, bool Cancelled = false, string? Message = null);