Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GettingUsedAttemptEvent #35450

Merged
merged 4 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Content.Shared/ActionBlocker/ActionBlockerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,16 @@ public bool CanInteract(EntityUid user, EntityUid? target)
/// </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;
}


Expand Down
10 changes: 10 additions & 0 deletions Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs
Original file line number Diff line number Diff line change
@@ -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;
}
Loading