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;
{
SubscribeLocalEvent<AtmosUnsafeUnanchorComponent, BeforeUnanchoredEvent>(OnBeforeUnanchored);
SubscribeLocalEvent<AtmosUnsafeUnanchorComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
+ SubscribeLocalEvent<AtmosUnsafeUnanchorComponent, BreakageEventArgs>(OnBreak);
}
private void OnUnanchorAttempt(EntityUid uid, AtmosUnsafeUnanchorComponent component, UnanchorAttemptEvent args)
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)
- 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"]