Skip to content

Commit

Permalink
Fix UI interaction priority (#27631)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroJr authored May 2, 2024
1 parent 8a7f709 commit 3c3c2da
Showing 1 changed file with 19 additions and 0 deletions.
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

0 comments on commit 3c3c2da

Please sign in to comment.