Make pipes leak when destroyed (#20928)

This plugs a meta where atmos techs were fireaxing pipes to remove them without leaking their contents.
This commit is contained in:
Kevin Zheng
2023-12-10 23:51:45 -08:00
committed by GitHub
parent 76d64ac8c2
commit 6444f7b7c5
5 changed files with 82 additions and 3 deletions

View 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)