Optimize atmos devices' appearance updating.

This commit is contained in:
Vera Aguilera Puerto
2021-07-30 14:00:14 +02:00
parent f4769c00d7
commit e256cb7bb0
5 changed files with 44 additions and 48 deletions

View File

@@ -37,16 +37,13 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
return;
}
appearance?.SetData(ScrubberVisuals.State, ScrubberState.Off);
if (!scrubber.Enabled)
return;
if (!ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
return;
if (!nodeContainer.TryGetNode(scrubber.OutletName, out PipeNode? outlet))
if (!scrubber.Enabled
|| !ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
|| !nodeContainer.TryGetNode(scrubber.OutletName, out PipeNode? outlet))
{
appearance?.SetData(ScrubberVisuals.State, ScrubberState.Off);
return;
}
var environment = _atmosphereSystem.GetTileMixture(scrubber.Owner.Transform.Coordinates, true);
@@ -72,12 +69,12 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void Scrub(AtmosphereSystem atmosphereSystem, GasVentScrubberComponent scrubber, AppearanceComponent? appearance, GasMixture? tile, PipeNode outlet)
{
// Cannot scrub if tile is null or air-blocked.
if (tile == null)
return;
// Cannot scrub if pressure too high.
if (outlet.Air.Pressure >= 50 * Atmospherics.OneAtmosphere)
if (tile == null
|| outlet.Air.Pressure >= 50 * Atmospherics.OneAtmosphere) // Cannot scrub if pressure too high.
{
appearance?.SetData(ScrubberVisuals.State, ScrubberState.Off);
return;
}
if (scrubber.PumpDirection == ScrubberPumpDirection.Scrubbing)
{