]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cancel CanBuckle before popup for foldable items (#24358)
authorKrunklehorn <42424291+Krunklehorn@users.noreply.github.com>
Sun, 21 Jan 2024 06:32:47 +0000 (01:32 -0500)
committerGitHub <noreply@github.com>
Sun, 21 Jan 2024 06:32:47 +0000 (17:32 +1100)
* Cancel CanBuckle before popup for foldable items

* Moved to FoldableSystem

Content.Shared/Foldable/FoldableSystem.cs

index 7bf00a5d243c8f8c771f41134e8e4fb2a26646e9..6f2e9f3ee5e9ceb78a7a1cd4b66ce41004fb9f6e 100644 (file)
@@ -1,4 +1,5 @@
 using Content.Shared.Buckle;
+using Content.Shared.Buckle.Components;
 using Content.Shared.Storage.Components;
 using Content.Shared.Verbs;
 using Robust.Shared.Containers;
@@ -26,6 +27,8 @@ public sealed class FoldableSystem : EntitySystem
         SubscribeLocalEvent<FoldableComponent, ContainerGettingInsertedAttemptEvent>(OnInsertEvent);
         SubscribeLocalEvent<FoldableComponent, StoreMobInItemContainerAttemptEvent>(OnStoreThisAttempt);
         SubscribeLocalEvent<FoldableComponent, StorageOpenAttemptEvent>(OnFoldableOpenAttempt);
+
+        SubscribeLocalEvent<FoldableComponent, BuckleAttemptEvent>(OnBuckleAttempt);
     }
 
     private void OnGetState(EntityUid uid, FoldableComponent component, ref ComponentGetState args)
@@ -61,6 +64,12 @@ public sealed class FoldableSystem : EntitySystem
             args.Cancelled = true;
     }
 
+    public void OnBuckleAttempt(EntityUid uid, FoldableComponent comp, ref BuckleAttemptEvent args)
+    {
+        if (args.Buckling && comp.IsFolded)
+            args.Cancelled = true;
+    }
+
     /// <summary>
     /// Returns false if the entity isn't foldable.
     /// </summary>