private void Scrub(GasVentScrubberComponent scrubber, AppearanceComponent?appearance, TileAtmosphere?tile, PipeNode outlet) { // Cannot scrub if tile is null or air-blocked. if (tile?.Air == null) { return; } // Cannot scrub if pressure too high. if (outlet.Air.Pressure >= 50 * Atmospherics.OneAtmosphere) { return; } if (scrubber.PumpDirection == ScrubberPumpDirection.Scrubbing) { appearance?.SetData(ScrubberVisuals.State, scrubber.WideNet ? ScrubberState.WideScrub : ScrubberState.Scrub); var transferMoles = MathF.Min(1f, (scrubber.VolumeRate / tile.Air.Volume) * tile.Air.TotalMoles); // Take a gas sample. var removed = tile.Air.Remove(transferMoles); // Nothing left to remove from the tile. if (MathHelper.CloseTo(removed.TotalMoles, 0f)) { return; } // TODO: Entity system dependency Get <AtmosphereSystem>().ScrubInto(removed, outlet.Air, scrubber.FilterGases); // Remix the gases. tile.AssumeAir(removed); } else if (scrubber.PumpDirection == ScrubberPumpDirection.Siphoning) { appearance?.SetData(ScrubberVisuals.State, ScrubberState.Siphon); var transferMoles = tile.Air.TotalMoles * (scrubber.VolumeRate / tile.Air.Volume); var removed = tile.Air.Remove(transferMoles); outlet.AssumeAir(removed); tile.Invalidate(); } }
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 || outlet.Air.Pressure >= 50 * Atmospherics.OneAtmosphere) // Cannot scrub if pressure too high. { appearance?.SetData(ScrubberVisuals.State, ScrubberState.Off); return; } if (scrubber.PumpDirection == ScrubberPumpDirection.Scrubbing) { appearance?.SetData(ScrubberVisuals.State, scrubber.WideNet ? ScrubberState.WideScrub : ScrubberState.Scrub); var transferMoles = MathF.Min(1f, (scrubber.VolumeRate / tile.Volume) * tile.TotalMoles); // Take a gas sample. var removed = tile.Remove(transferMoles); // Nothing left to remove from the tile. if (MathHelper.CloseTo(removed.TotalMoles, 0f)) { return; } atmosphereSystem.ScrubInto(removed, outlet.Air, scrubber.FilterGases); // Remix the gases. atmosphereSystem.Merge(tile, removed); } else if (scrubber.PumpDirection == ScrubberPumpDirection.Siphoning) { appearance?.SetData(ScrubberVisuals.State, ScrubberState.Siphon); var transferMoles = tile.TotalMoles * (scrubber.VolumeRate / tile.Volume); var removed = tile.Remove(transferMoles); outlet.AssumeAir(removed); } }