Reimplement anchor/unanchor delay (#11128)

This commit is contained in:
theashtronaut
2022-09-11 06:30:10 +00:00
committed by GitHub
parent b3c1a1aa19
commit 6f9065a1de
2 changed files with 22 additions and 17 deletions

View File

@@ -14,8 +14,8 @@ namespace Content.Server.Atmos.Piping.EntitySystems
[UsedImplicitly]
public sealed class AtmosUnsafeUnanchorSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly PopupSystem _popup = default!;
public override void Initialize()
{
@@ -28,17 +28,18 @@ namespace Content.Server.Atmos.Piping.EntitySystems
if (!component.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
return;
if (_atmosphereSystem.GetContainingMixture(uid, true) is not {} environment)
if (_atmosphere.GetContainingMixture(uid, true) is not {} environment)
return;
foreach (var node in nodes.Nodes.Values)
{
if (node is not PipeNode pipe) continue;
if (node is not PipeNode pipe)
continue;
if ((pipe.Air.Pressure - environment.Pressure) > 2 * Atmospherics.OneAtmosphere)
if (pipe.Air.Pressure - environment.Pressure > 2 * Atmospherics.OneAtmosphere)
{
args.Delay += 1.5f;
_popupSystem.PopupCursor(Loc.GetString("comp-atmos-unsafe-unanchor-warning"),
args.Delay += 2f;
_popup.PopupEntity(Loc.GetString("comp-atmos-unsafe-unanchor-warning"), pipe.Owner,
Filter.Entities(args.User), PopupType.MediumCaution);
return; // Show the warning only once.
}
@@ -50,7 +51,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
if (!component.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
return;
if (_atmosphereSystem.GetContainingMixture(uid, true, true) is not {} environment)
if (_atmosphere.GetContainingMixture(uid, true, true) is not {} environment)
environment = GasMixture.SpaceGas;
var lost = 0f;
@@ -58,7 +59,8 @@ namespace Content.Server.Atmos.Piping.EntitySystems
foreach (var node in nodes.Nodes.Values)
{
if (node is not PipeNode pipe) continue;
if (node is not PipeNode pipe)
continue;
var difference = pipe.Air.Pressure - environment.Pressure;
lost += difference * environment.Volume / (environment.Temperature * Atmospherics.R);
@@ -70,12 +72,13 @@ namespace Content.Server.Atmos.Piping.EntitySystems
foreach (var node in nodes.Nodes.Values)
{
if (node is not PipeNode pipe) continue;
if (node is not PipeNode pipe)
continue;
_atmosphereSystem.Merge(buffer, pipe.Air.Remove(sharedLoss));
_atmosphere.Merge(buffer, pipe.Air.Remove(sharedLoss));
}
_atmosphereSystem.Merge(environment, buffer);
_atmosphere.Merge(environment, buffer);
}
}
}