* Reduce atmos component queries * Remove method events * Cache airtight data * Make MolesArchived nullable * Fix airtight cache * only get tile def once * Immutable mixtures * firelock queries * misc * misc cleanup * Trim disconnected tiles * Fix merge issues and bugs * Why does the PR keep increasing in scope * debug overlay * Fix bugs * Fix test, remove unused events * Add setmapatmos command * Fix overlays * Add map check * A * Resolve conflicts with #26102 * Remove some obsolete methods
109 lines
3.7 KiB
C#
109 lines
3.7 KiB
C#
using Content.Server.Administration.Logs;
|
|
using Content.Server.Atmos.Components;
|
|
using Content.Server.Body.Systems;
|
|
using Content.Server.Fluids.EntitySystems;
|
|
using Content.Server.NodeContainer.EntitySystems;
|
|
using Content.Shared.Atmos.EntitySystems;
|
|
using Content.Shared.Doors.Components;
|
|
using Content.Shared.Maps;
|
|
using JetBrains.Annotations;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Physics.Systems;
|
|
using Robust.Shared.Random;
|
|
|
|
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
|
|
{
|
|
[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 EntityLookupSystem _lookup = default!;
|
|
[Dependency] private readonly InternalsSystem _internals = default!;
|
|
[Dependency] private readonly SharedContainerSystem _containers = default!;
|
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
|
[Dependency] private readonly GasTileOverlaySystem _gasTileOverlaySystem = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
|
|
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
|
[Dependency] private readonly TileSystem _tile = default!;
|
|
[Dependency] private readonly MapSystem _map = default!;
|
|
[Dependency] public readonly PuddleSystem Puddle = default!;
|
|
|
|
private const float ExposedUpdateDelay = 1f;
|
|
private float _exposedTimer = 0f;
|
|
|
|
private EntityQuery<GridAtmosphereComponent> _atmosQuery;
|
|
private EntityQuery<AirtightComponent> _airtightQuery;
|
|
private EntityQuery<FirelockComponent> _firelockQuery;
|
|
private HashSet<EntityUid> _entSet = new();
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
UpdatesAfter.Add(typeof(NodeGroupSystem));
|
|
|
|
InitializeBreathTool();
|
|
InitializeGases();
|
|
InitializeCommands();
|
|
InitializeCVars();
|
|
InitializeGridAtmosphere();
|
|
InitializeMap();
|
|
|
|
_atmosQuery = GetEntityQuery<GridAtmosphereComponent>();
|
|
_airtightQuery = GetEntityQuery<AirtightComponent>();
|
|
_firelockQuery = GetEntityQuery<FirelockComponent>();
|
|
|
|
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged);
|
|
|
|
}
|
|
|
|
public override void Shutdown()
|
|
{
|
|
base.Shutdown();
|
|
|
|
ShutdownCommands();
|
|
}
|
|
|
|
private void OnTileChanged(ref 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;
|
|
|
|
var query = EntityQueryEnumerator<AtmosExposedComponent, TransformComponent>();
|
|
while (query.MoveNext(out var uid, out _, out var transform))
|
|
{
|
|
var air = GetContainingMixture(uid, transform:transform);
|
|
|
|
if (air == null)
|
|
continue;
|
|
|
|
var updateEvent = new AtmosExposedUpdateEvent(transform.Coordinates, air, transform);
|
|
RaiseLocalEvent(uid, ref updateEvent);
|
|
}
|
|
|
|
_exposedTimer -= ExposedUpdateDelay;
|
|
}
|
|
}
|