From 6444f7b7c5eeed5d0ab2b0e7ce717bd4fbaf98e9 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Sun, 10 Dec 2023 23:51:45 -0800 Subject: [PATCH] Make pipes leak when destroyed (#20928) This plugs a meta where atmos techs were fireaxing pipes to remove them without leaking their contents. --- .../AtmosUnsafeUnanchorSystem.cs | 21 ++++++++- .../Structures/Piping/Atmospherics/pipes.yml | 44 +++++++++++++++++- .../Graphs/utilities/atmos_pipes.yml | 16 +++++++ .../Piping/Atmospherics/pipe.rsi/meta.json | 4 ++ .../Atmospherics/pipe.rsi/pipeBroken.png | Bin 0 -> 643 bytes 5 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 Resources/Textures/Structures/Piping/Atmospherics/pipe.rsi/pipeBroken.png diff --git a/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs b/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs index 84ac05a503..fcb3ccde68 100644 --- a/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs +++ b/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs @@ -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(OnBeforeUnanchored); SubscribeLocalEvent(OnUnanchorAttempt); + SubscribeLocalEvent(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); + } + + /// + /// Leak gas from the uid's NodeContainer into the tile atmosphere. + /// + public void LeakGas(EntityUid uid) + { + if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes)) return; if (_atmosphere.GetContainingMixture(uid, true, true) is not {} environment) diff --git a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/pipes.yml b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/pipes.yml index 1eda94ebf4..a312979507 100644 --- a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/pipes.yml +++ b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/pipes.yml @@ -21,12 +21,27 @@ - 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 @@ -149,3 +164,28 @@ - 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"] diff --git a/Resources/Prototypes/Recipes/Construction/Graphs/utilities/atmos_pipes.yml b/Resources/Prototypes/Recipes/Construction/Graphs/utilities/atmos_pipes.yml index 6c8439ff4e..771c63ebd5 100644 --- a/Resources/Prototypes/Recipes/Construction/Graphs/utilities/atmos_pipes.yml +++ b/Resources/Prototypes/Recipes/Construction/Graphs/utilities/atmos_pipes.yml @@ -113,3 +113,19 @@ 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 diff --git a/Resources/Textures/Structures/Piping/Atmospherics/pipe.rsi/meta.json b/Resources/Textures/Structures/Piping/Atmospherics/pipe.rsi/meta.json index ccf2bd69bc..ae4ff9b12d 100644 --- a/Resources/Textures/Structures/Piping/Atmospherics/pipe.rsi/meta.json +++ b/Resources/Textures/Structures/Piping/Atmospherics/pipe.rsi/meta.json @@ -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 index 0000000000000000000000000000000000000000..8a54fed66d7259ae7d9fd9675e27d01c02152388 GIT binary patch literal 643 zcmV-}0(||6P)EX>4Tx04R}tkv&MmKpe$iTSciA2U{rOkfA!+MMWHI6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfb#YR3krMxx6k5c1aNLh~_a1le0DrT}RI?`msG4PD zQb{3~UlsaZ5ySu@h$12}Q=b#XG(5-GJ$!t6^ClDu?Zdk+{#50?g z&Uv3W%*v8Nd`>)J&;^Mfxh}i>#<}FMpJ#@RY-XM~Oe~bTSngt0HdNwi;+Udpl<&{E ztZ?4qtXAu+eNX0S*p< z@e*aPd%U~9ySIPOwEO!3bhUD)-E{o~00006VoOIv0HOe-0HKTo5la97010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=L!oI94iU}+q?h(0DwtEK~z}7?bNXez#tHX;jEz| z;#f8oP9j(d?xRk3K?_M8LSFO!1^n=iyDr8UV=vNL3mgzaI0)z5zaV3b#2ELZtu=uG zdhY@Sj4?0(rPSVm1*o-R0P6?loRV|K0!k?uKuT$k00OYqo+X3;o_7Fph}H<8r`UUs d1u(|gm)&&