Cancel CanBuckle before popup for foldable items (#24358)

* Cancel CanBuckle before popup for foldable items

* Moved to FoldableSystem

(cherry picked from commit b126aadd9cb867e9d64e10acce48d759385c1659)
This commit is contained in:
Krunklehorn 2024-01-21 01:32:47 -05:00 committed by Debug
parent 8e99c422f4
commit 5f2c241f9e
No known key found for this signature in database
GPG Key ID: 271270A74EF9C350
1 changed files with 9 additions and 0 deletions

View 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>