using System.Collections.Concurrent; using Content.Shared.Atmos.EntitySystems; using Content.Shared.Atmos.Serialization; using Content.Shared.NodeContainer.NodeGroups; namespace Content.Shared.Atmos.Components; /// /// Internal class for storing all grid data. /// If you need to access this data, use the API methods in the /server /// instead of trying to scour this component or others for the data you need. /// [RegisterComponent, Serializable, Access(typeof(SharedAtmosphereSystem), typeof(SharedGasTileOverlaySystem), typeof(SharedAtmosDebugOverlaySystem))] public sealed partial class GridAtmosphereComponent : Component { /// /// Whether the grid is being updated by Atmospherics. /// [ViewVariables(VVAccess.ReadWrite)] public bool Simulated = true; /// /// Indicator for if Atmospherics has delegated the processing of this /// grid to another tick due to the time budget running out. /// /// If true, Atmospherics is not finished /// processing the current stage and has yielded processing /// to the next tick. [ViewVariables] public bool ProcessingPaused; /// /// Timer used to delay processing for every AtmosTick. /// No, Atmospherics cannot tick every frame. /// /// TODO: Replace with TimeSpan please. [ViewVariables] public float Timer; /// /// Integer that is incremented every time the grid is processed by Atmospherics. /// Used in multiple subsystems to prevent double-copy/processing of data. /// /// Do not set to zero by default. /// You will break roundstart atmos otherwise. [ViewVariables] public int UpdateCounter = 1; [ViewVariables] [IncludeDataField(customTypeSerializer:typeof(TileAtmosCollectionSerializer))] public Dictionary Tiles = new(1000); [ViewVariables] public HashSet MapTiles = new(1000); [ViewVariables] public readonly HashSet ActiveTiles = new(1000); [ViewVariables] public int ActiveTilesCount => ActiveTiles.Count; [ViewVariables] public readonly HashSet ExcitedGroups = new(1000); [ViewVariables] public int ExcitedGroupCount => ExcitedGroups.Count; [ViewVariables] public readonly HashSet HotspotTiles = new(1000); [ViewVariables] public int HotspotTilesCount => HotspotTiles.Count; [ViewVariables] public readonly HashSet SuperconductivityTiles = new(1000); [ViewVariables] public int SuperconductivityTilesCount => SuperconductivityTiles.Count; [ViewVariables] public HashSet HighPressureDelta = new(1000); [ViewVariables] public int HighPressureDeltaCount => HighPressureDelta.Count; /// /// A list of entities that have a and are to /// be processed by the , if enabled. /// /// To prevent massive bookkeeping overhead, this list is processed in-place, /// with add/remove/find operations helped via a dict. /// /// If you want to add/remove/find entities in this list, /// use the API methods in the Atmospherics API. [ViewVariables] public readonly List> DeltaPressureEntities = new(SharedAtmosphereSystem.DeltaPressurePreAllocateLength); /// /// An index lookup for the list. /// Used for add/remove/find operations to speed up processing. /// public readonly Dictionary DeltaPressureEntityLookup = new(SharedAtmosphereSystem.DeltaPressurePreAllocateLength); /// /// Integer that indicates the current position in the /// list that is being processed. /// [ViewVariables(VVAccess.ReadOnly)] public int DeltaPressureCursor; /// /// Queue of entities that need to have damage applied to them. /// [ViewVariables] public readonly ConcurrentQueue DeltaPressureDamageResults = new(); [ViewVariables] public readonly HashSet PipeNets = new(); [ViewVariables] public readonly HashSet> AtmosDevices = new(); [ViewVariables] public readonly Queue CurrentRunTiles = new(); [ViewVariables] public readonly Queue CurrentRunExcitedGroups = new(); [ViewVariables] public readonly Queue CurrentRunPipeNet = new(); [ViewVariables] public readonly Queue> CurrentRunAtmosDevices = new(); [ViewVariables] public readonly HashSet InvalidatedCoords = new(1000); [ViewVariables] public readonly Queue CurrentRunInvalidatedTiles = new(); [ViewVariables] public readonly List PossiblyDisconnectedTiles = new(100); [ViewVariables] public int InvalidatedCoordsCount => InvalidatedCoords.Count; [ViewVariables] public long EqualizationQueueCycleControl { get; set; } [ViewVariables] public AtmosphereProcessingState State { get; set; } = AtmosphereProcessingState.Revalidate; }