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

@@ -1,8 +1,12 @@
using Content.Server.Buckle.Components; using Content.Server.Buckle.Components;
using Content.Server.Interaction; using Content.Server.Interaction;
using Content.Shared.Body.Components;
using Content.Shared.MobState.Components;
using Content.Shared.Storage;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
@@ -19,6 +23,14 @@ namespace Content.Server.Buckle.Systems
base.Initialize(); base.Initialize();
SubscribeLocalEvent<StrapComponent, GetInteractionVerbsEvent>(AddStrapVerbs); SubscribeLocalEvent<StrapComponent, GetInteractionVerbsEvent>(AddStrapVerbs);
SubscribeLocalEvent<StrapComponent, ContainerGettingInsertedAttemptEvent>(OnInsertAttempt);
}
private void OnInsertAttempt(EntityUid uid, StrapComponent component, ContainerGettingInsertedAttemptEvent args)
{
// If someone is attempting to put this item inside of a backpack, ensure that it has no entities strapped to it.
if (HasComp<SharedStorageComponent>(args.Container.Owner) && component.BuckledEntities.Count != 0)
args.Cancel();
} }
// TODO ECS BUCKLE/STRAP These 'Strap' verbs are an incestuous mess of buckle component and strap component // TODO ECS BUCKLE/STRAP These 'Strap' verbs are an incestuous mess of buckle component and strap component

View File

@@ -40,7 +40,7 @@ namespace Content.Server.Foldable
if (!Resolve(uid, ref fold)) if (!Resolve(uid, ref fold))
return false; return false;
// Can't un-fold in hands / inventory // Can't un-fold in any container (locker, hands, inventory, whatever).
if (_container.IsEntityInContainer(uid)) if (_container.IsEntityInContainer(uid))
return false; return false;

View File

@@ -1,6 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Content.Server.Interaction;
using Content.Server.Storage.Components; using Content.Server.Storage.Components;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Movement; using Content.Shared.Movement;

View File

@@ -9,8 +9,11 @@ using System;
namespace Content.Shared.Foldable; namespace Content.Shared.Foldable;
/// <summary> /// <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> /// </summary>
/// <remarks>
/// Wiill prevent any insertions into containers while this item is unfolded.
/// </remarks>
[RegisterComponent] [RegisterComponent]
[NetworkedComponent] [NetworkedComponent]
[Friend(typeof(SharedFoldableSystem))] [Friend(typeof(SharedFoldableSystem))]

View File

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