Refactors the AtmosphereSystem public-facing API to allow for multiple atmos backends. (#8134)
* Refactors the entirety of the AtmosphereSystem public-facing API to allow for multiple atmos backends. * actually compiles * Remove commented out code * funny bracket * Move archived moles, temperature from GasMixture to TileAtmosphere. * WIP customizable map default mixture still VERY buggy * broken mess aaaaaaaaaaaaa * Fix lattice, etc not being considered space * visualization for "IsSpace" * help * Update Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs Co-authored-by: Moony <moonheart08@users.noreply.github.com> * Holy SHIT it compiles AGAIN * Fix AtmosDeviceSystem crash at shutdown * Fix immutable tiles on map blueprints not being fixed by fixgridatmos/revalidate. * Use space instead of gasmixture immutable for heat capacity calculations * Remove all LINDA-specific code from GasMixture, move it to TileAtmosphere/AtmosphereSystem instead. * Fix roundstart tiles not processing * Update Content.Server/Atmos/Commands/SetTemperatureCommand.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs Changed Files tab is so large I can't commit both suggestions at once mfw Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Moony <moonheart08@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
43216a000f
commit
aa9281d667
@@ -4,90 +4,84 @@ using Content.Server.NodeContainer.EntitySystems;
|
||||
using Content.Shared.Atmos.EntitySystems;
|
||||
using Content.Shared.Maps;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Atmos.EntitySystems
|
||||
namespace Content.Server.Atmos.EntitySystems;
|
||||
|
||||
/// <summary>
|
||||
/// This is our SSAir equivalent, if you need to interact with or query atmos in any way, go through this.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public sealed partial class AtmosphereSystem : SharedAtmosphereSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// This is our SSAir equivalent, if you need to interact with or query atmos in any way, go through this.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public sealed partial class AtmosphereSystem : SharedAtmosphereSystem
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLog = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containers = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly GasTileOverlaySystem _gasTileOverlaySystem = default!;
|
||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||
|
||||
|
||||
private const float ExposedUpdateDelay = 1f;
|
||||
private float _exposedTimer = 0f;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containers = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
base.Initialize();
|
||||
|
||||
UpdatesAfter.Add(typeof(NodeGroupSystem));
|
||||
|
||||
InitializeGases();
|
||||
InitializeCommands();
|
||||
InitializeCVars();
|
||||
InitializeGridAtmosphere();
|
||||
InitializeMap();
|
||||
|
||||
|
||||
private const float ExposedUpdateDelay = 1f;
|
||||
private float _exposedTimer = 0f;
|
||||
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged);
|
||||
|
||||
public override void Initialize()
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
ShutdownCommands();
|
||||
}
|
||||
|
||||
private void OnTileChanged(TileChangedEvent ev)
|
||||
{
|
||||
InvalidateTile(ev.NewTile.GridUid, ev.NewTile.GridIndices);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
UpdateProcessing(frameTime);
|
||||
UpdateHighPressure(frameTime);
|
||||
|
||||
_exposedTimer += frameTime;
|
||||
|
||||
if (_exposedTimer < ExposedUpdateDelay)
|
||||
return;
|
||||
|
||||
foreach (var (exposed, transform) in EntityManager.EntityQuery<AtmosExposedComponent, TransformComponent>())
|
||||
{
|
||||
base.Initialize();
|
||||
var air = GetContainingMixture(exposed.Owner, transform:transform);
|
||||
|
||||
UpdatesAfter.Add(typeof(NodeGroupSystem));
|
||||
|
||||
InitializeGases();
|
||||
InitializeCommands();
|
||||
InitializeCVars();
|
||||
InitializeGrid();
|
||||
|
||||
|
||||
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged);
|
||||
if (air == null)
|
||||
continue;
|
||||
|
||||
var updateEvent = new AtmosExposedUpdateEvent(transform.Coordinates, air, transform);
|
||||
RaiseLocalEvent(exposed.Owner, ref updateEvent);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
ShutdownCommands();
|
||||
}
|
||||
|
||||
private void OnTileChanged(TileChangedEvent ev)
|
||||
{
|
||||
// When a tile changes, we want to update it only if it's gone from
|
||||
// space -> not space or vice versa. So if the old tile is the
|
||||
// same as the new tile in terms of space-ness, ignore the change
|
||||
|
||||
if (ev.NewTile.IsSpace(_tileDefinitionManager) == ev.OldTile.IsSpace(_tileDefinitionManager))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InvalidateTile(ev.NewTile.GridUid, ev.NewTile.GridIndices);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
UpdateProcessing(frameTime);
|
||||
UpdateHighPressure(frameTime);
|
||||
|
||||
_exposedTimer += frameTime;
|
||||
|
||||
if (_exposedTimer < ExposedUpdateDelay)
|
||||
return;
|
||||
|
||||
foreach (var (exposed, transform) in EntityManager.EntityQuery<AtmosExposedComponent, TransformComponent>())
|
||||
{
|
||||
// Used for things like disposals/cryo to change which air people are exposed to.
|
||||
var airEvent = new AtmosExposedGetAirEvent();
|
||||
RaiseLocalEvent(exposed.Owner, ref airEvent, false);
|
||||
|
||||
airEvent.Gas ??= GetTileMixture(transform.Coordinates);
|
||||
if (airEvent.Gas == null)
|
||||
continue;
|
||||
|
||||
var updateEvent = new AtmosExposedUpdateEvent(transform.Coordinates, airEvent.Gas);
|
||||
RaiseLocalEvent(exposed.Owner, ref updateEvent, true);
|
||||
}
|
||||
|
||||
_exposedTimer -= ExposedUpdateDelay;
|
||||
}
|
||||
_exposedTimer -= ExposedUpdateDelay;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user