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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
10
Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs
Normal file
10
Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user