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:
committed by
GitHub
parent
10ced26b0d
commit
c8ba345cdc
@@ -1,17 +1,12 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.NodeContainer.EntitySystems;
|
||||
using Content.Shared.Atmos.EntitySystems;
|
||||
using Content.Shared.Maps;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Atmos.EntitySystems
|
||||
{
|
||||
@@ -20,16 +15,11 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IPauseManager _pauseManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
private GridTileLookupSystem? _gridTileLookup = null;
|
||||
|
||||
private const float ExposedUpdateDelay = 1f;
|
||||
private float _exposedTimer = 0f;
|
||||
|
||||
public GridTileLookupSystem GridTileLookupSystem => _gridTileLookup ??= Get<GridTileLookupSystem>();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -81,73 +71,6 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
map.AddComponent<SpaceGridAtmosphereComponent>();
|
||||
}
|
||||
|
||||
#region Helper Methods
|
||||
public IGridAtmosphereComponent? GetGridAtmosphere(GridId gridId)
|
||||
{
|
||||
if (!gridId.IsValid())
|
||||
return null;
|
||||
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
return null;
|
||||
|
||||
return ComponentManager.TryGetComponent(grid.GridEntityId, out IGridAtmosphereComponent? gridAtmosphere)
|
||||
? gridAtmosphere : null;
|
||||
}
|
||||
|
||||
public IGridAtmosphereComponent GetGridAtmosphere(EntityCoordinates coordinates)
|
||||
{
|
||||
return GetGridAtmosphere(coordinates.ToMap(EntityManager));
|
||||
}
|
||||
|
||||
public IGridAtmosphereComponent GetGridAtmosphere(MapCoordinates coordinates)
|
||||
{
|
||||
if (coordinates.MapId == MapId.Nullspace)
|
||||
{
|
||||
throw new ArgumentException($"Coordinates cannot be in nullspace!", nameof(coordinates));
|
||||
}
|
||||
|
||||
if (_mapManager.TryFindGridAt(coordinates, out var grid))
|
||||
{
|
||||
if (ComponentManager.TryGetComponent(grid.GridEntityId, out IGridAtmosphereComponent? atmos))
|
||||
{
|
||||
return atmos;
|
||||
}
|
||||
}
|
||||
|
||||
return _mapManager.GetMapEntity(coordinates.MapId).GetComponent<IGridAtmosphereComponent>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unlike <see cref="GetGridAtmosphere"/>, this doesn't return space grid when not found.
|
||||
/// </summary>
|
||||
public bool TryGetSimulatedGridAtmosphere(MapCoordinates coordinates, [NotNullWhen(true)] out IGridAtmosphereComponent? atmosphere)
|
||||
{
|
||||
if (coordinates.MapId == MapId.Nullspace)
|
||||
{
|
||||
atmosphere = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_mapManager.TryFindGridAt(coordinates, out var mapGrid)
|
||||
&& ComponentManager.TryGetComponent(mapGrid.GridEntityId, out IGridAtmosphereComponent? atmosGrid)
|
||||
&& atmosGrid.Simulated)
|
||||
{
|
||||
atmosphere = atmosGrid;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_mapManager.GetMapEntity(coordinates.MapId).TryGetComponent(out IGridAtmosphereComponent? atmosMap)
|
||||
&& atmosMap.Simulated)
|
||||
{
|
||||
atmosphere = atmosMap;
|
||||
return true;
|
||||
}
|
||||
|
||||
atmosphere = null;
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
@@ -158,9 +81,11 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
if (_exposedTimer >= ExposedUpdateDelay)
|
||||
{
|
||||
foreach (var exposed in EntityManager.ComponentManager.EntityQuery<AtmosExposedComponent>(true))
|
||||
foreach (var exposed in EntityManager.ComponentManager.EntityQuery<AtmosExposedComponent>())
|
||||
{
|
||||
var tile = exposed.Owner.Transform.Coordinates.GetTileAtmosphere();
|
||||
// TODO ATMOS: Kill this with fire.
|
||||
var atmos = GetGridAtmosphere(exposed.Owner.Transform.Coordinates);
|
||||
var tile = atmos.GetTile(exposed.Owner.Transform.Coordinates);
|
||||
if (tile == null) continue;
|
||||
exposed.Update(tile, _exposedTimer, this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user