]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make pipes leak when destroyed (#20928)
authorKevin Zheng <kevinz5000@gmail.com>
Mon, 11 Dec 2023 07:51:45 +0000 (23:51 -0800)
committerGitHub <noreply@github.com>
Mon, 11 Dec 2023 07:51:45 +0000 (23:51 -0800)
This plugs a meta where atmos techs were fireaxing pipes to remove them without leaking their contents.

Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs
Resources/Prototypes/Entities/Structures/Piping/Atmospherics/pipes.yml
Resources/Prototypes/Recipes/Construction/Graphs/utilities/atmos_pipes.yml
Resources/Textures/Structures/Piping/Atmospherics/pipe.rsi/meta.json
Resources/Textures/Structures/Piping/Atmospherics/pipe.rsi/pipeBroken.png [new file with mode: 0644]

index 84ac05a5030430792a34b2a4c09729bf1efc17ad..fcb3ccde682fb96c3ffc8ecaa8cf9a86c791e1d7 100644 (file)
@@ -5,6 +5,7 @@ using Content.Server.NodeContainer.Nodes;
 using Content.Server.Popups;
 using Content.Shared.Atmos;
 using Content.Shared.Construction.Components;
+using Content.Shared.Destructible;
 using Content.Shared.Popups;
 using JetBrains.Annotations;
 using Robust.Shared.Player;
@@ -21,6 +22,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
         {
             SubscribeLocalEvent<AtmosUnsafeUnanchorComponent, BeforeUnanchoredEvent>(OnBeforeUnanchored);
             SubscribeLocalEvent<AtmosUnsafeUnanchorComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
+            SubscribeLocalEvent<AtmosUnsafeUnanchorComponent, BreakageEventArgs>(OnBreak);
         }
 
         private void OnUnanchorAttempt(EntityUid uid, AtmosUnsafeUnanchorComponent component, UnanchorAttemptEvent args)
@@ -48,7 +50,24 @@ namespace Content.Server.Atmos.Piping.EntitySystems
 
         private void OnBeforeUnanchored(EntityUid uid, AtmosUnsafeUnanchorComponent component, BeforeUnanchoredEvent args)
         {
-            if (!component.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
+            if (component.Enabled)
+                LeakGas(uid);
+        }
+
+        private void OnBreak(EntityUid uid, AtmosUnsafeUnanchorComponent component, BreakageEventArgs args)
+        {
+            LeakGas(uid);
+            // Can't use DoActsBehavior["Destruction"] in the same trigger because that would prevent us
+            // from leaking. So we make up for this by queueing deletion here.
+            QueueDel(uid);
+        }
+
+        /// <summary>
+        /// Leak gas from the uid's NodeContainer into the tile atmosphere.
+        /// </summary>
+        public void LeakGas(EntityUid uid)
+        {
+            if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
                 return;
 
             if (_atmosphere.GetContainingMixture(uid, true, true) is not {} environment)
index 1eda94ebf4250c881ec8d602db31c068d954c645..a312979507b781572fe1489e58bac3c7a3397a1f 100644 (file)
   - type: Rotatable
   - type: Destructible
     thresholds:
-    - trigger:
+    - trigger: # for nukes
         !type:DamageTrigger
-        damage: 100
+        damage: 200
       behaviors:
       - !type:DoActsBehavior
         acts: ["Destruction"]
+    - trigger: # regular damage trigger (replace with broken pipe)
+        !type:DamageTrigger
+        damage: 100
+      behaviors:
+      - !type:PlaySoundBehavior
+        sound:
+          path: /Audio/Effects/metalbreak.ogg
+      - !type:SpawnEntitiesBehavior
+        spawn:
+          GasPipeBroken:
+            min: 1
+            max: 1
+        offset: 0
+      - !type:DoActsBehavior
+        acts: ["Breakage"]
   - type: Sprite
     sprite: Structures/Piping/Atmospherics/pipe.rsi
     drawdepth: ThinPipe
   - type: Construction
     graph: GasPipe
     node: fourway
+
+- type: entity
+  id: GasPipeBroken
+  parent: GasPipeBase
+  name: broken pipe
+  description: It used to hold gas.
+  components:
+  - type: Sprite
+    sprite: Structures/Piping/Atmospherics/pipe.rsi
+    drawdepth: ThinPipe
+    state: pipeBroken
+    layers:
+      - state: pipeBroken
+        map: [ "enum.PipeVisualLayers.Pipe" ]
+  - type: Construction
+    graph: GasPipe
+    node: broken
+  - type: Destructible
+    thresholds: # override parent to avoid recursive destruction
+    - trigger:
+        !type:DamageTrigger
+        damage: 100
+      behaviors:
+      - !type:DoActsBehavior
+        acts: ["Destruction"]
index 6c8439ff4e464b76e0c853b28c97aa7a14d84c2b..771c63ebd5c4a6464fdeb125f9b935e3801e0a90 100644 (file)
       steps:
       - tool: Welding
         doAfter: 1
+
+  - node: broken
+    entity: GasPipeBroken
+    edges:
+    - to: start
+      conditions:
+      - !type:EntityAnchored
+        anchored: false
+      completed:
+      - !type:SpawnPrototype
+        prototype: SheetSteel1
+        amount: 1
+      - !type:DeleteEntity
+      steps:
+      - tool: Welding
+        doAfter: 1
index ccf2bd69bc57998d88813472a9ec5db6ad684445..ae4ff9b12d0d3e7c89bdd708785040a3b7cb4f4b 100644 (file)
@@ -7,6 +7,10 @@
    "license":"CC-BY-SA-3.0",
    "copyright":"pipeTrinaryConnectors made by Menshin for SS14 based on pipeTJunction, the rest is taken from https://github.com/tgstation/tgstation at commit 57cd1d59ca019dd0e7811ac451f295f818e573da",
    "states":[
+      {
+         "name":"pipeBroken",
+         "directions":1
+      },
       {
          "name":"pipeTJunction",
          "directions":4
diff --git a/Resources/Textures/Structures/Piping/Atmospherics/pipe.rsi/pipeBroken.png b/Resources/Textures/Structures/Piping/Atmospherics/pipe.rsi/pipeBroken.png
new file mode 100644 (file)
index 0000000..8a54fed
Binary files /dev/null and b/Resources/Textures/Structures/Piping/Atmospherics/pipe.rsi/pipeBroken.png differ