Added insertion blocking to Strap and Foldable components (#6151)

This commit is contained in:
Leon Friedrich
2022-01-14 04:09:42 +13:00
committed by GitHub
parent 291756b67c
commit 723e38f9ab
5 changed files with 20 additions and 5 deletions

View File

@@ -9,8 +9,11 @@ using System;
namespace Content.Shared.Foldable;
/// <summary>
/// Used to create "foldable structures" that you can pickup like an item when folded. Used for rollerbeds and wheelchairs
/// Used to create "foldable structures" that you can pickup like an item when folded. Used for rollerbeds and wheelchairs.
/// </summary>
/// <remarks>
/// Wiill prevent any insertions into containers while this item is unfolded.
/// </remarks>
[RegisterComponent]
[NetworkedComponent]
[Friend(typeof(SharedFoldableSystem))]

View File

@@ -1,5 +1,6 @@
using Content.Shared.Item;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
@@ -18,7 +19,7 @@ public abstract class SharedFoldableSystem : EntitySystem
SubscribeLocalEvent<FoldableComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<FoldableComponent, ComponentInit>(OnFoldableInit);
SubscribeLocalEvent<FoldableComponent, AttemptItemPickupEvent>(OnPickedUpAttempt);
SubscribeLocalEvent<FoldableComponent, ContainerGettingInsertedAttemptEvent>(OnInsertEvent);
}
private void OnGetState(EntityUid uid, FoldableComponent component, ref ComponentGetState args)
@@ -54,7 +55,7 @@ public abstract class SharedFoldableSystem : EntitySystem
appearance.SetData(FoldKey, folded);
}
private void OnPickedUpAttempt(EntityUid uid, FoldableComponent component, AttemptItemPickupEvent args)
private void OnInsertEvent(EntityUid uid, FoldableComponent component, ContainerGettingInsertedAttemptEvent args)
{
if (!component.IsFolded)
args.Cancel();