From: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:21:17 +0000 (+0100) Subject: GettingUsedAttemptEvent (#35450) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=c3784a3005cea9cf04baab53587da5009b4986cf;p=space-station-14.git GettingUsedAttemptEvent (#35450) * init * review * doc * Update Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --- diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index 6152699ccb..08eac657c0 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -109,10 +109,16 @@ namespace Content.Shared.ActionBlocker /// 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 index 0000000000..cd5f029346 --- /dev/null +++ b/Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs @@ -0,0 +1,10 @@ +namespace Content.Shared.Interaction.Events; + +/// +/// Event raised on an item when attempting to use it in your hands. Cancelling it stops the interaction. +/// +/// The user of said item +public sealed class GettingUsedAttemptEvent(EntityUid user) : CancellableEntityEventArgs +{ + public EntityUid User = user; +}