Cancel CanBuckle before popup for foldable items (#24358)

* Cancel CanBuckle before popup for foldable items

* Moved to FoldableSystem
This commit is contained in:
Krunklehorn 2024-01-21 01:32:47 -05:00 committed by GitHub
parent 8f1d67014c
commit b126aadd9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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>