ECS Atmos Part 3: Removes AtmosHelpers, add many methods to AtmosphereSystem. (#4285)

* ECS Atmos Part 3: Removes AtmosHelpers, add many methods to AtmosphereSystem

* Adds API for adding/removing active tiles.

* Adds API for FixVacuum.

* Adds API for UpdateAdjacent.

* Adds API for IsTileAirBlocked.

* Re-organize hotspot code

* Adds API for IsTileSpace.

* RemoveGasCommand uses AtmosphereSystem

* AddGasCommand uses AtmosphereSystem.

* SetTemperatureCommand uses AtmosphereSystem.

* Adds API for IsSimulatedGrid.

* GasLeak uses AtmosphereSystem.

* Makes Spark method in GasLeak ALSO use AtmosphereSystem.

* GasPassiveVentSystem uses AtmosphereSystem.

* GasMinerSystem uses AtmosphereSystem.

* GasOutletInjectorSystem uses AtmosphereSystem.

* GasVentPumpSystem uses AtmosphereSystem.

* GasDualPortVentPumpSystem uses AtmosphereSystem.

* GasVolumePumpSystem uses AtmosphereSystem.

* GasAnalyzerComponent uses AtmosphereSystem.

* Add API for GetAdjacentTileMixtures.

* GasVentScrubberSystem uses AtmosphereSystem.

* AirtightComponent uses AtmosphereSystem.

* GasLeaks's TryFindRandomTile uses AtmosphereSystem.

* Adds API for GetAdjacentTiles.

* FirelockComponent's IsHoldingFire uses AtmosphereSystem.

* Adds API for GetAllTileMixtures.

* DeleteGasCommand uses AtmosphereSystem.

* FixGridAtmos uses AtmosphereSystem.

* FillGasCommand uses AtmosphereSystem.

* SetAtmosTemperatureCommand uses AtmosphereSystem.
This commit is contained in:
Vera Aguilera Puerto
2021-07-19 12:07:37 +02:00
committed by GitHub
parent 10ced26b0d
commit c8ba345cdc
34 changed files with 1214 additions and 483 deletions

View File

@@ -45,17 +45,17 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (!nodeContainer.TryGetNode(scrubber.OutletName, out PipeNode? outlet))
return;
var environment = args.Atmosphere.GetTile(scrubber.Owner.Transform.Coordinates)!;
var atmosphereSystem = Get<AtmosphereSystem>();
var environment = atmosphereSystem.GetTileMixture(scrubber.Owner.Transform.Coordinates, true);
Scrub(scrubber, appearance, environment, outlet);
Scrub(atmosphereSystem, scrubber, appearance, environment, outlet);
if (!scrubber.WideNet) return;
// Scrub adjacent tiles too.
foreach (var adjacent in environment.AdjacentTiles)
foreach (var adjacent in atmosphereSystem.GetAdjacentTileMixtures(scrubber.Owner.Transform.Coordinates, false, true))
{
// Pass null appearance, we don't need to set it there.
Scrub(scrubber, null, adjacent, outlet);
Scrub(atmosphereSystem, scrubber, null, adjacent, outlet);
}
}
@@ -67,10 +67,10 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
}
}
private void Scrub(GasVentScrubberComponent scrubber, AppearanceComponent? appearance, TileAtmosphere? tile, PipeNode outlet)
private void Scrub(AtmosphereSystem atmosphereSystem, GasVentScrubberComponent scrubber, AppearanceComponent? appearance, GasMixture? tile, PipeNode outlet)
{
// Cannot scrub if tile is null or air-blocked.
if (tile?.Air == null)
if (tile == null)
return;
// Cannot scrub if pressure too high.
@@ -80,30 +80,28 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
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);
var transferMoles = MathF.Min(1f, (scrubber.VolumeRate / tile.Volume) * tile.TotalMoles);
// Take a gas sample.
var removed = tile.Air.Remove(transferMoles);
var removed = tile.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);
atmosphereSystem.ScrubInto(removed, outlet.Air, scrubber.FilterGases);
// Remix the gases.
tile.AssumeAir(removed);
atmosphereSystem.Merge(tile, removed);
}
else if (scrubber.PumpDirection == ScrubberPumpDirection.Siphoning)
{
appearance?.SetData(ScrubberVisuals.State, ScrubberState.Siphon);
var transferMoles = tile.Air.TotalMoles * (scrubber.VolumeRate / tile.Air.Volume);
var transferMoles = tile.TotalMoles * (scrubber.VolumeRate / tile.Volume);
var removed = tile.Air.Remove(transferMoles);
var removed = tile.Remove(transferMoles);
outlet.AssumeAir(removed);
tile.Invalidate();
}
}
}