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

Fix UI interaction priority #27631

Merged
merged 1 commit into from
May 2, 2024
Merged
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
19 changes: 19 additions & 0 deletions Content.Shared/UserInterface/ActivatableUISystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Popups;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
Expand All @@ -27,6 +28,7 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ActivatableUIComponent, UseInHandEvent>(OnUseInHand);
SubscribeLocalEvent<ActivatableUIComponent, ActivateInWorldEvent>(OnActivate);
SubscribeLocalEvent<ActivatableUIComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<ActivatableUIComponent, HandDeselectedEvent>(OnHandDeselected);
Expand Down Expand Up @@ -99,6 +101,9 @@ private bool ShouldAddVerb<T>(EntityUid uid, ActivatableUIComponent component, G
if (!args.CanAccess)
return false;

if (!component.RequiredItems?.IsValid(args.Using ?? default, EntityManager) ?? false)
return false;

if (component.RequireHands)
{
if (args.Hands == null)
Expand All @@ -117,6 +122,20 @@ private bool ShouldAddVerb<T>(EntityUid uid, ActivatableUIComponent component, G
return args.CanInteract || component.AllowSpectator && HasComp<GhostComponent>(args.User);
}

private void OnUseInHand(EntityUid uid, ActivatableUIComponent component, UseInHandEvent args)
{
if (args.Handled)
return;

if (component.VerbOnly)
return;

if (component.RequiredItems != null)
return;

args.Handled = InteractUI(args.User, uid, component);
}

private void OnActivate(EntityUid uid, ActivatableUIComponent component, ActivateInWorldEvent args)
{
if (args.Handled)
Expand Down
Loading