]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix some buckle interactions (#29293)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Fri, 21 Jun 2024 10:50:52 +0000 (22:50 +1200)
committerGitHub <noreply@github.com>
Fri, 21 Jun 2024 10:50:52 +0000 (03:50 -0700)
Content.Shared/Buckle/SharedBuckleSystem.Interaction.cs

index 8c2d0b8ee18127bbfddca53446ab77d9b601a2ee..463e0d5596233ea2950647df28444abfb10c8883 100644 (file)
@@ -13,10 +13,11 @@ public abstract partial class SharedBuckleSystem
     private void InitializeInteraction()
     {
         SubscribeLocalEvent<StrapComponent, GetVerbsEvent<InteractionVerb>>(AddStrapVerbs);
-        SubscribeLocalEvent<StrapComponent, InteractHandEvent>(OnStrapInteractHand);
+        SubscribeLocalEvent<StrapComponent, InteractHandEvent>(OnStrapInteractHand, after: [typeof(InteractionPopupSystem)]);
         SubscribeLocalEvent<StrapComponent, DragDropTargetEvent>(OnStrapDragDropTarget);
         SubscribeLocalEvent<StrapComponent, CanDropTargetEvent>(OnCanDropTarget);
 
+        SubscribeLocalEvent<BuckleComponent, InteractHandEvent>(OnBuckleInteractHand, after: [typeof(InteractionPopupSystem)]);
         SubscribeLocalEvent<BuckleComponent, GetVerbsEvent<InteractionVerb>>(AddUnbuckleVerb);
     }
 
@@ -58,6 +59,9 @@ public abstract partial class SharedBuckleSystem
         if (args.Handled)
             return;
 
+        if (!component.Enabled)
+            return;
+
         if (!TryComp(args.User, out BuckleComponent? buckle))
             return;
 
@@ -68,7 +72,20 @@ public abstract partial class SharedBuckleSystem
         else
             return;
 
-        args.Handled = true; // This generate popups on failure.
+        // TODO BUCKLE add out bool for whether a pop-up was generated or not.
+        args.Handled = true;
+    }
+
+    private void OnBuckleInteractHand(Entity<BuckleComponent> ent, ref InteractHandEvent args)
+    {
+        if (args.Handled)
+            return;
+
+        if (ent.Comp.BuckledTo != null)
+            TryUnbuckle(ent!, args.User, popup: true);
+
+        // TODO BUCKLE add out bool for whether a pop-up was generated or not.
+        args.Handled = true;
     }
 
     private void AddStrapVerbs(EntityUid uid, StrapComponent component, GetVerbsEvent<InteractionVerb> args)