Deploy foldable (#30000)
* Deploy foldable * Add NetworkedComponent and access to the component * Add handled to afterinteract * Use drop target location instead of setcoordinates * Put back in hand after failed deploy This prevents dropping the bed when clicking while inside a locker. * Created BaseDeployFoldable for folding chairs, body bags, and rollerbeds
This commit is contained in:
7
Content.Shared/Foldable/DeployFoldableComponent.cs
Normal file
7
Content.Shared/Foldable/DeployFoldableComponent.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Foldable;
|
||||
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[Access(typeof(DeployFoldableSystem))]
|
||||
public sealed partial class DeployFoldableComponent : Component;
|
||||
39
Content.Shared/Foldable/DeployFoldableSystem.cs
Normal file
39
Content.Shared/Foldable/DeployFoldableSystem.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
|
||||
namespace Content.Shared.Foldable;
|
||||
|
||||
public sealed class DeployFoldableSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||
[Dependency] private readonly FoldableSystem _foldable = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DeployFoldableComponent, AfterInteractEvent>(OnAfterInteract);
|
||||
}
|
||||
|
||||
private void OnAfterInteract(Entity<DeployFoldableComponent> ent, ref AfterInteractEvent args)
|
||||
{
|
||||
if (args.Handled || !args.CanReach)
|
||||
return;
|
||||
|
||||
if (!TryComp<FoldableComponent>(ent, out var foldable))
|
||||
return;
|
||||
|
||||
if (!TryComp(args.User, out HandsComponent? hands)
|
||||
|| !_hands.TryDrop(args.User, args.Used, targetDropLocation: args.ClickLocation, handsComp: hands))
|
||||
return;
|
||||
|
||||
if (!_foldable.TrySetFolded(ent, foldable, false))
|
||||
{
|
||||
_hands.TryPickup(args.User, args.Used, handsComp: hands);
|
||||
return;
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
- type: entity
|
||||
id: BodyBag
|
||||
parent: BaseFoldable
|
||||
parent: BaseDeployFoldable
|
||||
name: body bag
|
||||
description: A plastic bag designed for the storage and transportation of cadavers to stop body decomposition.
|
||||
components:
|
||||
|
||||
@@ -323,7 +323,7 @@
|
||||
node: chair
|
||||
|
||||
- type: entity
|
||||
parent: [SeatBase, BaseFoldable]
|
||||
parent: [SeatBase, BaseDeployFoldable]
|
||||
id: ChairFolding
|
||||
name: folding chair
|
||||
description: If you carry six of these you become the coolest kid at church.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
- type: entity
|
||||
id: RollerBed
|
||||
parent: [BaseItem, BaseFoldable]
|
||||
parent: [BaseItem, BaseDeployFoldable]
|
||||
name: rollerbed
|
||||
description: Used to carry patients around without damaging them.
|
||||
components:
|
||||
|
||||
@@ -13,3 +13,11 @@
|
||||
unfoldedLayer:
|
||||
True: {visible: false}
|
||||
False: {visible: true}
|
||||
|
||||
- type: entity
|
||||
abstract: true
|
||||
parent: BaseFoldable
|
||||
id: BaseDeployFoldable
|
||||
name: "deploy foldable"
|
||||
components:
|
||||
- type: DeployFoldable
|
||||
|
||||
Reference in New Issue
Block a user