Files
wwdpublic/Content.Server/Atmos/TileAtmosphere.cs
SimpleStation14 2138b8ac18 Mirror 26441: Fix atmos NaN error (#449)
## Mirror of PR #26441: [Fix atmos NaN
error](https://github.com/space-wizards/space-station-14/pull/26441)
from <img src="https://avatars.githubusercontent.com/u/10567778?v=4"
alt="space-wizards" width="22"/>
[space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14)

###### `fdb4a61487db9fc67714c913832427063abdea42`

PR opened by <img
src="https://avatars.githubusercontent.com/u/60421075?v=4"
width="16"/><a href="https://github.com/ElectroJr"> ElectroJr</a> at
2024-03-26 04:27:08 UTC - merged at 2024-03-26 04:44:56 UTC

---

PR changed 16 files with 43 additions and 25 deletions.

The PR had the following labels:
- Status: Needs Review


---

<details open="true"><summary><h1>Original Body</h1></summary>

> - Fixes a bug I introduced in #22521 that caused the temperature to be
set to `NaN`. I don't know for sure, but I assume this is causing the
current atmos issues
> - Fixes `FixVacuum` not working after #22521
> - Removes some redundant yaml that was setting FixVacuum to its
default value
> 
> 🆑
> - fix: Fixed an atmos bug, which was (probably) causing atmospherics
on the station to behave incorrectly.


</details>

Co-authored-by: SimpleStation14 <Unknown>
2024-06-13 15:30:31 -04:00

164 lines
5.5 KiB
C#

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
{
/// <summary>
/// Internal Atmos class that stores data about the atmosphere in a grid.
/// You shouldn't use this directly, use <see cref="AtmosphereSystem"/> instead.
/// </summary>
[Access(typeof(AtmosphereSystem), typeof(GasTileOverlaySystem), typeof(AtmosDebugOverlaySystem))]
public sealed class TileAtmosphere : IGasMixtureHolder
{
[ViewVariables]
public int ArchivedCycle;
[ViewVariables]
public int CurrentCycle;
[ViewVariables]
public float Temperature { get; set; } = Atmospherics.T20C;
[ViewVariables]
public float TemperatureArchived { get; set; } = Atmospherics.T20C;
[ViewVariables]
public TileAtmosphere? PressureSpecificTarget { get; set; }
/// <summary>
/// This is either the pressure difference, or the quantity of moles transferred if monstermos is enabled.
/// </summary>
[ViewVariables]
public float PressureDifference { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
public float HeatCapacity { get; set; } = Atmospherics.MinimumHeatCapacity;
[ViewVariables]
public float ThermalConductivity { get; set; } = 0.05f;
[ViewVariables]
public bool Excited { get; set; }
/// <summary>
/// Whether this tile should be considered space.
/// </summary>
[ViewVariables]
public bool Space { get; set; }
/// <summary>
/// Adjacent tiles in the same order as <see cref="AtmosDirection"/>. (NSEW)
/// </summary>
[ViewVariables]
public readonly TileAtmosphere?[] AdjacentTiles = new TileAtmosphere[Atmospherics.Directions];
/// <summary>
/// Neighbouring tiles to which air can flow. This is a combination of this tile's unblocked direction, and the
/// unblocked directions on adjacent tiles.
/// </summary>
[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; }
/// <summary>
/// The air in this tile. If null, this tile is completely air-blocked.
/// This can be immutable if the tile is spaced.
/// </summary>
[ViewVariables]
[Access(typeof(AtmosphereSystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends
public GasMixture? Air { get; set; }
[DataField("lastShare")]
public float LastShare;
[ViewVariables]
public readonly float[] MolesArchived = new float[Atmospherics.AdjustedNumberOfGases];
GasMixture IGasMixtureHolder.Air
{
get => Air ?? new GasMixture(Atmospherics.CellVolume){ Temperature = Temperature };
set => Air = value;
}
[ViewVariables]
public float MaxFireTemperatureSustained { get; set; }
/// <summary>
/// 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.
/// </summary>
[ViewVariables]
public bool MapAtmosphere;
/// <summary>
/// If true, this tile does not actually exist on the grid, it only exists to represent the map's atmosphere for
/// adjacent grid tiles.
/// </summary>
[ViewVariables]
public bool NoGridTile;
/// <summary>
/// If true, this tile is queued for processing in <see cref="GridAtmosphereComponent.PossiblyDisconnectedTiles"/>
/// </summary>
[ViewVariables]
public bool TrimQueued;
/// <summary>
/// Cached information about airtight entities on this tile. This gets updated anytime a tile gets invalidated
/// (i.e., gets added to <see cref="GridAtmosphereComponent.InvalidatedCoords"/>).
/// </summary>
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;
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();
Array.Copy(other.MolesArchived, MolesArchived, MolesArchived.Length);
}
public TileAtmosphere()
{
}
}
}