]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Deploy foldable (#30000)
authorShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Fri, 2 Aug 2024 07:05:12 +0000 (00:05 -0700)
committerGitHub <noreply@github.com>
Fri, 2 Aug 2024 07:05:12 +0000 (17:05 +1000)
* 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

Content.Shared/Foldable/DeployFoldableComponent.cs [new file with mode: 0644]
Content.Shared/Foldable/DeployFoldableSystem.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Objects/Specific/Medical/morgue.yml
Resources/Prototypes/Entities/Structures/Furniture/chairs.yml
Resources/Prototypes/Entities/Structures/Furniture/rollerbeds.yml
Resources/Prototypes/Entities/foldable.yml

diff --git a/Content.Shared/Foldable/DeployFoldableComponent.cs b/Content.Shared/Foldable/DeployFoldableComponent.cs
new file mode 100644 (file)
index 0000000..4ccca6b
--- /dev/null
@@ -0,0 +1,7 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Foldable;
+
+[RegisterComponent, NetworkedComponent]
+[Access(typeof(DeployFoldableSystem))]
+public sealed partial class DeployFoldableComponent : Component;
diff --git a/Content.Shared/Foldable/DeployFoldableSystem.cs b/Content.Shared/Foldable/DeployFoldableSystem.cs
new file mode 100644 (file)
index 0000000..fa2e3f8
--- /dev/null
@@ -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;
+    }
+}
index 065662146515e36746a620e04aae0136734ba0b6..578e0715871292bfb680f219d9fab167136e6d06 100644 (file)
@@ -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:
index ac5ec1e83e36724128b3663bf22b83dacfb5c20d..c1d767905c0111aaa8d6c81022242bb1bef3063e 100644 (file)
     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.
index b3cfe6ade3f011dcedd08097c4357a11049bbf32..f7b1be8ecdedd561c5b58e9749459c531fd36bf4 100644 (file)
@@ -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:
index a0843cd1250a2573bf69ae4eb9c5d73d556fb708..260cda799b432e2ef0af5a5c8eb4c9b1851193f5 100644 (file)
         unfoldedLayer:
           True: {visible: false}
           False: {visible: true}
+
+- type: entity
+  abstract: true
+  parent: BaseFoldable
+  id: BaseDeployFoldable
+  name: "deploy foldable"
+  components:
+  - type: DeployFoldable