diff --git a/Content.Server/Atmos/TileAtmosphere.cs b/Content.Server/Atmos/TileAtmosphere.cs index 46a85990fa..eba0df192a 100644 --- a/Content.Server/Atmos/TileAtmosphere.cs +++ b/Content.Server/Atmos/TileAtmosphere.cs @@ -1,165 +1,248 @@ using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; using Content.Shared.Atmos; -using Content.Shared.Maps; -using Robust.Shared.Map; -namespace Content.Server.Atmos +namespace Content.Server.Atmos; + +/// +/// Internal Atmospherics class that stores data on an atmosphere in a single tile. +/// You should not be using these directly outside of . +/// Use the public APIs in instead. +/// +[Access(typeof(AtmosphereSystem), typeof(GasTileOverlaySystem), typeof(AtmosDebugOverlaySystem))] +public sealed class TileAtmosphere : IGasMixtureHolder { /// - /// Internal Atmos class that stores data about the atmosphere in a grid. - /// You shouldn't use this directly, use instead. + /// The last cycle this tile's air was archived into . + /// See for more info on archival. /// - [Access(typeof(AtmosphereSystem), typeof(GasTileOverlaySystem), typeof(AtmosDebugOverlaySystem))] - public sealed class TileAtmosphere : IGasMixtureHolder + [ViewVariables] + public int ArchivedCycle; + + /// + /// Current cycle this tile was processed. + /// Used to prevent double-processing in a single cycle in many processing stages. + /// + [ViewVariables] + public int CurrentCycle; + + /// + /// Current temperature of this tile, in Kelvin. + /// Used for Superconduction. + /// This is not the temperature of the attached ! + /// + [ViewVariables] + public float Temperature = Atmospherics.T20C; + + /// + /// The current target tile for pressure movement for the current cycle. + /// Gas will be moved towards this tile during pressure equalization. + /// Also see . + /// + [ViewVariables] + public TileAtmosphere? PressureSpecificTarget; + + /// + /// The current pressure difference (delta) between this tile and its pressure target. + /// If Monstermos is enabled, this value represents the quantity of moles transferred. + /// + [ViewVariables] + public float PressureDifference; + + /// + /// The current heat capacity of this tile. + /// Used for Superconduction. + /// This is not the heat capacity of the attached ! + /// + [ViewVariables(VVAccess.ReadWrite)] + public float HeatCapacity = Atmospherics.MinimumHeatCapacity; + + /// + /// The current thermal conductivity of this tile. + /// Describes how well heat moves between this tile and adjacent tiles during superconduction. + /// + [ViewVariables] + public float ThermalConductivity = 0.05f; + + /// + /// Designates whether this tile is currently excited for processing in an excited group or LINDA. + /// + [ViewVariables] + public bool Excited; + + /// + /// Whether this tile should be considered space. + /// + [ViewVariables] + public bool Space; + + /// + /// Cached adjacent tiles for this tile. + /// Ordered in the same order as + /// (should be North, South, East, West). + /// Adjacent tiles can be null if air cannot flow to them. + /// + [ViewVariables] + public readonly TileAtmosphere?[] AdjacentTiles = new TileAtmosphere[Atmospherics.Directions]; + + /// + /// Neighbouring tiles to which air can flow. This is a combination of this tile's unblocked direction, and the + /// unblocked directions on adjacent tiles. + /// + [ViewVariables] + public AtmosDirection AdjacentBits = AtmosDirection.Invalid; + + /// + /// Current information for this tile. + /// + [ViewVariables] + [Access(typeof(AtmosphereSystem), Other = AccessPermissions.ReadExecute)] + public MonstermosInfo MonstermosInfo; + + /// + /// Current information for this tile. + /// + [ViewVariables] + public Hotspot Hotspot; + + /// + /// Points to the direction of the recipient tile for pressure equalization logic + /// (Monstermos or HighPressureDelta otherwise). + /// + [ViewVariables] + public AtmosDirection PressureDirection; + + /// + /// Last cycle's for debugging purposes. + /// + [ViewVariables] + public AtmosDirection LastPressureDirection; + + /// + /// Grid entity this tile belongs to. + /// + [ViewVariables] + [Access(typeof(AtmosphereSystem))] + public EntityUid GridIndex; + + /// + /// The grid indices of this tile. + /// + [ViewVariables] + public Vector2i GridIndices; + + /// + /// The excited group this tile belongs to, if any. + /// + [ViewVariables] + public ExcitedGroup? ExcitedGroup; + + /// + /// The air in this tile. If null, this tile is completely air-blocked. + /// This can be immutable if the tile is spaced. + /// + [ViewVariables] + [Access(typeof(AtmosphereSystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends + public GasMixture? Air; + + /// + /// A copy of the air in this tile from the last time it was archived at . + /// LINDA archives the air before doing any necessary processing and uses this to perform its calculations, + /// making the results of LINDA independent of the order in which tiles are processed. + /// + [ViewVariables] + public GasMixture? AirArchived; + + /// + /// The amount of gas last shared to adjacent tiles during LINDA processing. + /// Used to determine when LINDA should dismantle an excited group + /// or extend its time alive. + /// + [DataField("lastShare")] + public float LastShare; + + /// + /// Implementation of . + /// + GasMixture IGasMixtureHolder.Air { - [ViewVariables] - public int ArchivedCycle; + get => Air ?? new GasMixture(Atmospherics.CellVolume){ Temperature = Temperature }; + set => Air = value; + } - [ViewVariables] - public int CurrentCycle; + /// + /// The maximum temperature this tile has sustained during hotspot fire processing. + /// Used for debugging. + /// + [ViewVariables] + public float MaxFireTemperatureSustained; - [ViewVariables] - public float Temperature { get; set; } = Atmospherics.T20C; + /// + /// If true, then this tile is directly exposed to the map's atmosphere, either because the grid has no tile at + /// this position, or because the tile type is not airtight. + /// + [ViewVariables] + public bool MapAtmosphere; - [ViewVariables] - public TileAtmosphere? PressureSpecificTarget { get; set; } + /// + /// If true, this tile does not actually exist on the grid, it only exists to represent the map's atmosphere for + /// adjacent grid tiles. + /// This tile often has immutable air and is sitting off the edge of the grid, where there is no grid. + /// + [ViewVariables] + public bool NoGridTile; - /// - /// This is either the pressure difference, or the quantity of moles transferred if monstermos is enabled. - /// - [ViewVariables] - public float PressureDifference { get; set; } + /// + /// If true, this tile is queued for processing in + /// + [ViewVariables] + public bool TrimQueued; - [ViewVariables(VVAccess.ReadWrite)] - public float HeatCapacity { get; set; } = Atmospherics.MinimumHeatCapacity; + /// + /// Cached information about airtight entities on this tile. This gets updated anytime a tile gets invalidated + /// (i.e., gets added to ). + /// + public AtmosphereSystem.AirtightData AirtightData; - [ViewVariables] - public float ThermalConductivity { get; set; } = 0.05f; + /// + /// Creates a new TileAtmosphere. + /// + /// The grid entity this tile belongs to. + /// >The grid indices of this tile. + /// The gas mixture of this tile. + /// If true, the gas mixture will be marked immutable. + /// If true, this tile is considered space. + public TileAtmosphere(EntityUid gridIndex, Vector2i gridIndices, GasMixture? mixture = null, bool immutable = false, bool space = false) + { + GridIndex = gridIndex; + GridIndices = gridIndices; + Air = mixture; + AirArchived = Air?.Clone(); + Space = space; - [ViewVariables] - public bool Excited { get; set; } + if(immutable) + Air?.MarkImmutable(); + } - /// - /// Whether this tile should be considered space. - /// - [ViewVariables] - public bool Space { get; set; } + /// + /// Creates a copy of another TileAtmosphere. + /// + /// The TileAtmosphere to copy. + public TileAtmosphere(TileAtmosphere other) + { + GridIndex = other.GridIndex; + GridIndices = other.GridIndices; + Space = other.Space; + NoGridTile = other.NoGridTile; + MapAtmosphere = other.MapAtmosphere; + Air = other.Air?.Clone(); + AirArchived = Air != null ? Air.Clone() : null; + } - /// - /// Adjacent tiles in the same order as . (NSEW) - /// - [ViewVariables] - public readonly TileAtmosphere?[] AdjacentTiles = new TileAtmosphere[Atmospherics.Directions]; - - /// - /// Neighbouring tiles to which air can flow. This is a combination of this tile's unblocked direction, and the - /// unblocked directions on adjacent tiles. - /// - [ViewVariables] - public AtmosDirection AdjacentBits = AtmosDirection.Invalid; - - [ViewVariables, Access(typeof(AtmosphereSystem), Other = AccessPermissions.ReadExecute)] - public MonstermosInfo MonstermosInfo; - - [ViewVariables] - public Hotspot Hotspot; - - [ViewVariables] - public AtmosDirection PressureDirection; - - // For debug purposes. - [ViewVariables] - public AtmosDirection LastPressureDirection; - - [ViewVariables] - [Access(typeof(AtmosphereSystem))] - public EntityUid GridIndex { get; set; } - - [ViewVariables] - public Vector2i GridIndices; - - [ViewVariables] - public ExcitedGroup? ExcitedGroup { get; set; } - - /// - /// The air in this tile. If null, this tile is completely air-blocked. - /// This can be immutable if the tile is spaced. - /// - [ViewVariables] - [Access(typeof(AtmosphereSystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends - public GasMixture? Air { get; set; } - - /// - /// Like Air, but a copy stored each atmos tick before tile processing takes place. This lets us update Air - /// in-place without affecting the results based on update order. - /// - [ViewVariables] - public GasMixture? AirArchived; - - [DataField("lastShare")] - public float LastShare; - - GasMixture IGasMixtureHolder.Air - { - get => Air ?? new GasMixture(Atmospherics.CellVolume){ Temperature = Temperature }; - set => Air = value; - } - - [ViewVariables] - public float MaxFireTemperatureSustained { get; set; } - - /// - /// If true, then this tile is directly exposed to the map's atmosphere, either because the grid has no tile at - /// this position, or because the tile type is not airtight. - /// - [ViewVariables] - public bool MapAtmosphere; - - /// - /// If true, this tile does not actually exist on the grid, it only exists to represent the map's atmosphere for - /// adjacent grid tiles. - /// - [ViewVariables] - public bool NoGridTile; - - /// - /// If true, this tile is queued for processing in - /// - [ViewVariables] - public bool TrimQueued; - - /// - /// Cached information about airtight entities on this tile. This gets updated anytime a tile gets invalidated - /// (i.e., gets added to ). - /// - public AtmosphereSystem.AirtightData AirtightData; - - public TileAtmosphere(EntityUid gridIndex, Vector2i gridIndices, GasMixture? mixture = null, bool immutable = false, bool space = false) - { - GridIndex = gridIndex; - GridIndices = gridIndices; - Air = mixture; - AirArchived = Air != null ? Air.Clone() : null; - Space = space; - - if(immutable) - Air?.MarkImmutable(); - } - - public TileAtmosphere(TileAtmosphere other) - { - GridIndex = other.GridIndex; - GridIndices = other.GridIndices; - Space = other.Space; - NoGridTile = other.NoGridTile; - MapAtmosphere = other.MapAtmosphere; - Air = other.Air?.Clone(); - AirArchived = Air != null ? Air.Clone() : null; - } - - public TileAtmosphere() - { - } + /// + /// Creates a new empty TileAtmosphere. + /// + public TileAtmosphere() + { } }