ECS Atmos Part 2: Moves a lot of Gas Mixture methods to AtmosphereSystem. (#4218)

This commit is contained in:
Vera Aguilera Puerto
2021-06-23 11:35:30 +02:00
committed by GitHub
parent e16c23a747
commit 263c9ef974
34 changed files with 461 additions and 464 deletions

View File

@@ -1,6 +1,7 @@
#nullable enable
#nullable disable warnings
using System;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Respiratory;
using Content.Server.Explosion;
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
@@ -155,13 +156,6 @@ namespace Content.Server.Atmos.Components
DisconnectFromInternals();
}
public void Update()
{
Air?.React(this);
CheckStatus();
UpdateUserInterface();
}
public GasMixture? RemoveAir(float amount)
{
var gas = Air?.Remove(amount);
@@ -223,7 +217,7 @@ namespace Content.Server.Atmos.Components
UpdateUserInterface();
}
private void UpdateUserInterface(bool initialUpdate = false)
public void UpdateUserInterface(bool initialUpdate = false)
{
var internals = GetInternalsComponent();
_userInterface?.SetState(
@@ -279,15 +273,17 @@ namespace Content.Server.Atmos.Components
public void AssumeAir(GasMixture giver)
{
Air?.Merge(giver);
EntitySystem.Get<AtmosphereSystem>().Merge(Air, giver);
CheckStatus();
}
private void CheckStatus()
public void CheckStatus()
{
if (Air == null)
return;
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
var pressure = Air.Pressure;
if (pressure > TankFragmentPressure)
@@ -295,7 +291,7 @@ namespace Content.Server.Atmos.Components
// Give the gas a chance to build up more pressure.
for (var i = 0; i < 3; i++)
{
Air.React(this);
atmosphereSystem.React(Air, this);
}
pressure = Air.Pressure;