From: Kevin Zheng Date: Mon, 11 Dec 2023 07:51:45 +0000 (-0800) Subject: Make pipes leak when destroyed (#20928) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=6444f7b7c5eeed5d0ab2b0e7ce717bd4fbaf98e9;p=space-station-14.git Make pipes leak when destroyed (#20928) This plugs a meta where atmos techs were fireaxing pipes to remove them without leaking their contents. --- 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 0000000000..8a54fed66d Binary files /dev/null and b/Resources/Textures/Structures/Piping/Atmospherics/pipe.rsi/pipeBroken.png differ