]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix UI interaction priority (#27631)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Thu, 2 May 2024 23:37:20 +0000 (11:37 +1200)
committerGitHub <noreply@github.com>
Thu, 2 May 2024 23:37:20 +0000 (09:37 +1000)
Content.Shared/UserInterface/ActivatableUISystem.cs

index 5d408012bd0292d9f656e8c559d4f26e983cd33a..3ac8835dd02ed8ee783439b203956829ab403e09 100644 (file)
@@ -5,6 +5,7 @@ using Content.Shared.Hands;
 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;
@@ -27,6 +28,7 @@ public sealed partial class ActivatableUISystem : EntitySystem
     {
         base.Initialize();
 
+        SubscribeLocalEvent<ActivatableUIComponent, UseInHandEvent>(OnUseInHand);
         SubscribeLocalEvent<ActivatableUIComponent, ActivateInWorldEvent>(OnActivate);
         SubscribeLocalEvent<ActivatableUIComponent, InteractUsingEvent>(OnInteractUsing);
         SubscribeLocalEvent<ActivatableUIComponent, HandDeselectedEvent>(OnHandDeselected);
@@ -99,6 +101,9 @@ public sealed partial class ActivatableUISystem : EntitySystem
         if (!args.CanAccess)
             return false;
 
+        if (!component.RequiredItems?.IsValid(args.Using ?? default, EntityManager) ?? false)
+            return false;
+
         if (component.RequireHands)
         {
             if (args.Hands == null)
@@ -117,6 +122,20 @@ public sealed partial class ActivatableUISystem : EntitySystem
         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)