GettingUsedAttemptEvent (#35450)

* init

* review

* doc

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

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
ScarKy0
2025-02-24 17:21:17 +01:00
committed by GitHub
parent f4fab85e34
commit c3784a3005
2 changed files with 19 additions and 3 deletions

View 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;
}

View File

@@ -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;
}