TileAtmosphere.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. using Content.Server.Atmos.Components;
  2. using Content.Server.Atmos.EntitySystems;
  3. using Content.Shared.Atmos;
  4. using Content.Shared.Maps;
  5. using Robust.Shared.Map;
  6. namespace Content.Server.Atmos
  7. {
  8. /// <summary>
  9. /// Internal Atmos class that stores data about the atmosphere in a grid.
  10. /// You shouldn't use this directly, use <see cref="AtmosphereSystem"/> instead.
  11. /// </summary>
  12. [Access(typeof(AtmosphereSystem), typeof(GasTileOverlaySystem), typeof(AtmosDebugOverlaySystem))]
  13. public sealed class TileAtmosphere : IGasMixtureHolder
  14. {
  15. [ViewVariables]
  16. public int ArchivedCycle;
  17. [ViewVariables]
  18. public int CurrentCycle;
  19. [ViewVariables]
  20. public float Temperature { get; set; } = Atmospherics.T20C;
  21. [ViewVariables]
  22. public TileAtmosphere? PressureSpecificTarget { get; set; }
  23. /// <summary>
  24. /// This is either the pressure difference, or the quantity of moles transferred if monstermos is enabled.
  25. /// </summary>
  26. [ViewVariables]
  27. public float PressureDifference { get; set; }
  28. [ViewVariables(VVAccess.ReadWrite)]
  29. public float HeatCapacity { get; set; } = Atmospherics.MinimumHeatCapacity;
  30. [ViewVariables]
  31. public float ThermalConductivity { get; set; } = 0.05f;
  32. [ViewVariables]
  33. public bool Excited { get; set; }
  34. /// <summary>
  35. /// Whether this tile should be considered space.
  36. /// </summary>
  37. [ViewVariables]
  38. public bool Space { get; set; }
  39. /// <summary>
  40. /// Adjacent tiles in the same order as <see cref="AtmosDirection"/>. (NSEW)
  41. /// </summary>
  42. [ViewVariables]
  43. public readonly TileAtmosphere?[] AdjacentTiles = new TileAtmosphere[Atmospherics.Directions];
  44. /// <summary>
  45. /// Neighbouring tiles to which air can flow. This is a combination of this tile's unblocked direction, and the
  46. /// unblocked directions on adjacent tiles.
  47. /// </summary>
  48. [ViewVariables]
  49. public AtmosDirection AdjacentBits = AtmosDirection.Invalid;
  50. [ViewVariables, Access(typeof(AtmosphereSystem), Other = AccessPermissions.ReadExecute)]
  51. public MonstermosInfo MonstermosInfo;
  52. [ViewVariables]
  53. public Hotspot Hotspot;
  54. [ViewVariables]
  55. public AtmosDirection PressureDirection;
  56. // For debug purposes.
  57. [ViewVariables]
  58. public AtmosDirection LastPressureDirection;
  59. [ViewVariables]
  60. [Access(typeof(AtmosphereSystem))]
  61. public EntityUid GridIndex { get; set; }
  62. [ViewVariables]
  63. public Vector2i GridIndices;
  64. [ViewVariables]
  65. public ExcitedGroup? ExcitedGroup { get; set; }
  66. /// <summary>
  67. /// The air in this tile. If null, this tile is completely air-blocked.
  68. /// This can be immutable if the tile is spaced.
  69. /// </summary>
  70. [ViewVariables]
  71. [Access(typeof(AtmosphereSystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends
  72. public GasMixture? Air { get; set; }
  73. /// <summary>
  74. /// Like Air, but a copy stored each atmos tick before tile processing takes place. This lets us update Air
  75. /// in-place without affecting the results based on update order.
  76. /// </summary>
  77. [ViewVariables]
  78. public GasMixture? AirArchived;
  79. [DataField("lastShare")]
  80. public float LastShare;
  81. GasMixture IGasMixtureHolder.Air
  82. {
  83. get => Air ?? new GasMixture(Atmospherics.CellVolume){ Temperature = Temperature };
  84. set => Air = value;
  85. }
  86. [ViewVariables]
  87. public float MaxFireTemperatureSustained { get; set; }
  88. /// <summary>
  89. /// If true, then this tile is directly exposed to the map's atmosphere, either because the grid has no tile at
  90. /// this position, or because the tile type is not airtight.
  91. /// </summary>
  92. [ViewVariables]
  93. public bool MapAtmosphere;
  94. /// <summary>
  95. /// If true, this tile does not actually exist on the grid, it only exists to represent the map's atmosphere for
  96. /// adjacent grid tiles.
  97. /// </summary>
  98. [ViewVariables]
  99. public bool NoGridTile;
  100. /// <summary>
  101. /// If true, this tile is queued for processing in <see cref="GridAtmosphereComponent.PossiblyDisconnectedTiles"/>
  102. /// </summary>
  103. [ViewVariables]
  104. public bool TrimQueued;
  105. /// <summary>
  106. /// Cached information about airtight entities on this tile. This gets updated anytime a tile gets invalidated
  107. /// (i.e., gets added to <see cref="GridAtmosphereComponent.InvalidatedCoords"/>).
  108. /// </summary>
  109. public AtmosphereSystem.AirtightData AirtightData;
  110. public TileAtmosphere(EntityUid gridIndex, Vector2i gridIndices, GasMixture? mixture = null, bool immutable = false, bool space = false)
  111. {
  112. GridIndex = gridIndex;
  113. GridIndices = gridIndices;
  114. Air = mixture;
  115. AirArchived = Air != null ? Air.Clone() : null;
  116. Space = space;
  117. if(immutable)
  118. Air?.MarkImmutable();
  119. }
  120. public TileAtmosphere(TileAtmosphere other)
  121. {
  122. GridIndex = other.GridIndex;
  123. GridIndices = other.GridIndices;
  124. Space = other.Space;
  125. NoGridTile = other.NoGridTile;
  126. MapAtmosphere = other.MapAtmosphere;
  127. Air = other.Air?.Clone();
  128. AirArchived = Air != null ? Air.Clone() : null;
  129. }
  130. public TileAtmosphere()
  131. {
  132. }
  133. }
  134. }