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.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; /// /// This is our SSAir equivalent, if you need to interact with or query atmos in any way, go through this. /// [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 HashSet _entSet = new(); public override void Initialize() { base.Initialize(); UpdatesAfter.Add(typeof(NodeGroupSystem)); InitializeBreathTool(); InitializeGases(); InitializeCommands(); InitializeCVars(); InitializeGridAtmosphere(); InitializeMap(); SubscribeLocalEvent(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(); 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; } }