Atmospherics.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. using Robust.Shared.Serialization;
  2. // ReSharper disable InconsistentNaming
  3. namespace Content.Shared.Atmos
  4. {
  5. /// <summary>
  6. /// Class to store atmos constants.
  7. /// </summary>
  8. public static class Atmospherics
  9. {
  10. #region ATMOS
  11. /// <summary>
  12. /// The universal gas constant, in kPa*L/(K*mol)
  13. /// </summary>
  14. public const float R = 8.314462618f;
  15. /// <summary>
  16. /// 1 ATM in kPA.
  17. /// </summary>
  18. public const float OneAtmosphere = 101.325f;
  19. /// <summary>
  20. /// Maximum external pressure (in kPA) a gas miner will, by default, output to.
  21. /// This is used to initialize roundstart atmos rooms.
  22. /// </summary>
  23. public const float GasMinerDefaultMaxExternalPressure = 6500f;
  24. /// <summary>
  25. /// -270.3ºC in K. CMB stands for Cosmic Microwave Background.
  26. /// </summary>
  27. public const float TCMB = 2.7f;
  28. /// <summary>
  29. /// 0ºC in K
  30. /// </summary>
  31. public const float T0C = 273.15f;
  32. /// <summary>
  33. /// 20ºC in K
  34. /// </summary>
  35. public const float T20C = 293.15f;
  36. /// <summary>
  37. /// -38.15ºC in K.
  38. /// This is used to initialize roundstart freezer rooms.
  39. /// </summary>
  40. public const float FreezerTemp = 235f;
  41. /// <summary>
  42. /// Do not allow any gas mixture temperatures to exceed this number. It is occasionally possible
  43. /// to have very small heat capacity (e.g. room that was just unspaced) and for large amounts of
  44. /// energy to be transferred to it, even for a brief moment. However, this messes up subsequent
  45. /// calculations and so cap it here. The physical interpretation is that at this temperature, any
  46. /// gas that you would have transforms into plasma.
  47. /// </summary>
  48. public const float Tmax = 262144; // 1/64 of max safe integer, any values above will result in a ~0.03K epsilon
  49. /// <summary>
  50. /// Liters in a cell.
  51. /// </summary>
  52. public const float CellVolume = 2500f;
  53. // Liters in a normal breath
  54. public const float BreathVolume = 0.5f;
  55. // Amount of air to take from a tile
  56. public const float BreathPercentage = BreathVolume / CellVolume;
  57. /// <summary>
  58. /// Moles in a 2.5 m^3 cell at 101.325 kPa and 20ºC
  59. /// </summary>
  60. public const float MolesCellStandard = (OneAtmosphere * CellVolume / (T20C * R));
  61. /// <summary>
  62. /// Moles in a 2.5 m^3 cell at 101.325 kPa and -38.15ºC.
  63. /// This is used in fix atmos freezer markers to ensure the air is at the correct atmospheric pressure while still being cold.
  64. /// </summary>
  65. public const float MolesCellFreezer = (OneAtmosphere * CellVolume / (FreezerTemp * R));
  66. /// <summary>
  67. /// Moles in a 2.5 m^3 cell at GasMinerDefaultMaxExternalPressure kPa and 20ºC
  68. /// </summary>
  69. public const float MolesCellGasMiner = (GasMinerDefaultMaxExternalPressure * CellVolume / (T20C * R));
  70. /// <summary>
  71. /// Compared against for superconduction.
  72. /// </summary>
  73. public const float MCellWithRatio = (MolesCellStandard * 0.005f);
  74. public const float OxygenStandard = 0.21f;
  75. public const float NitrogenStandard = 0.79f;
  76. public const float OxygenMolesStandard = MolesCellStandard * OxygenStandard;
  77. public const float NitrogenMolesStandard = MolesCellStandard * NitrogenStandard;
  78. public const float OxygenMolesFreezer = MolesCellFreezer * OxygenStandard;
  79. public const float NitrogenMolesFreezer = MolesCellFreezer * NitrogenStandard;
  80. #endregion
  81. /// <summary>
  82. /// Visible moles multiplied by this factor to get moles at which gas is at max visibility.
  83. /// </summary>
  84. public const float FactorGasVisibleMax = 20f;
  85. /// <summary>
  86. /// Minimum number of moles a gas can have.
  87. /// </summary>
  88. public const float GasMinMoles = 0.00000005f;
  89. public const float OpenHeatTransferCoefficient = 0.4f;
  90. /// <summary>
  91. /// Hack to make vacuums cold, sacrificing realism for gameplay.
  92. /// </summary>
  93. public const float HeatCapacityVacuum = 7000f;
  94. /// <summary>
  95. /// Ratio of air that must move to/from a tile to reset group processing
  96. /// </summary>
  97. public const float MinimumAirRatioToSuspend = 0.1f;
  98. /// <summary>
  99. /// Minimum ratio of air that must move to/from a tile
  100. /// </summary>
  101. public const float MinimumAirRatioToMove = 0.001f;
  102. /// <summary>
  103. /// Minimum amount of air that has to move before a group processing can be suspended
  104. /// </summary>
  105. public const float MinimumAirToSuspend = (MolesCellStandard * MinimumAirRatioToSuspend);
  106. public const float MinimumTemperatureToMove = (T20C + 100f);
  107. public const float MinimumMolesDeltaToMove = (MolesCellStandard * MinimumAirRatioToMove);
  108. /// <summary>
  109. /// Minimum temperature difference before group processing is suspended
  110. /// </summary>
  111. public const float MinimumTemperatureDeltaToSuspend = 4.0f;
  112. /// <summary>
  113. /// Minimum temperature difference before the gas temperatures are just set to be equal.
  114. /// </summary>
  115. public const float MinimumTemperatureDeltaToConsider = 0.01f;
  116. /// <summary>
  117. /// Minimum temperature for starting superconduction.
  118. /// </summary>
  119. public const float MinimumTemperatureStartSuperConduction = (T20C + 400f);
  120. public const float MinimumTemperatureForSuperconduction = (T20C + 80f);
  121. /// <summary>
  122. /// Minimum heat capacity.
  123. /// </summary>
  124. public const float MinimumHeatCapacity = 0.0003f;
  125. /// <summary>
  126. /// For the purposes of making space "colder"
  127. /// </summary>
  128. public const float SpaceHeatCapacity = 7000f;
  129. /// <summary>
  130. /// Dictionary of chemical abbreviations for <see cref="Gas"/>
  131. /// </summary>
  132. public static Dictionary<Gas, string> GasAbbreviations = new Dictionary<Gas, string>()
  133. {
  134. [Gas.Ammonia] = Loc.GetString("gas-ammonia-abbreviation"),
  135. [Gas.CarbonDioxide] = Loc.GetString("gas-carbon-dioxide-abbreviation"),
  136. [Gas.Frezon] = Loc.GetString("gas-frezon-abbreviation"),
  137. [Gas.Nitrogen] = Loc.GetString("gas-nitrogen-abbreviation"),
  138. [Gas.NitrousOxide] = Loc.GetString("gas-nitrous-oxide-abbreviation"),
  139. [Gas.Oxygen] = Loc.GetString("gas-oxygen-abbreviation"),
  140. [Gas.Plasma] = Loc.GetString("gas-plasma-abbreviation"),
  141. [Gas.Tritium] = Loc.GetString("gas-tritium-abbreviation"),
  142. [Gas.WaterVapor] = Loc.GetString("gas-water-vapor-abbreviation"),
  143. };
  144. #region Excited Groups
  145. /// <summary>
  146. /// Number of full atmos updates ticks before an excited group breaks down (averages gas contents across turfs)
  147. /// </summary>
  148. public const int ExcitedGroupBreakdownCycles = 4;
  149. /// <summary>
  150. /// Number of full atmos updates before an excited group dismantles and removes its turfs from active
  151. /// </summary>
  152. public const int ExcitedGroupsDismantleCycles = 16;
  153. #endregion
  154. /// <summary>
  155. /// Hard limit for zone-based tile equalization.
  156. /// </summary>
  157. public const int MonstermosHardTileLimit = 2000;
  158. /// <summary>
  159. /// Limit for zone-based tile equalization.
  160. /// </summary>
  161. public const int MonstermosTileLimit = 200;
  162. /// <summary>
  163. /// Total number of gases. Increase this if you want to add more!
  164. /// </summary>
  165. public const int TotalNumberOfGases = 9;
  166. /// <summary>
  167. /// This is the actual length of the gases arrays in mixtures.
  168. /// Set to the closest multiple of 4 relative to <see cref="TotalNumberOfGases"/> for SIMD reasons.
  169. /// </summary>
  170. public const int AdjustedNumberOfGases = ((TotalNumberOfGases + 3) / 4) * 4;
  171. /// <summary>
  172. /// Amount of heat released per mole of burnt hydrogen or tritium (hydrogen isotope)
  173. /// </summary>
  174. public const float FireHydrogenEnergyReleased = 284e3f; // hydrogen is 284 kJ/mol
  175. public const float FireMinimumTemperatureToExist = T0C + 100f;
  176. public const float FireMinimumTemperatureToSpread = T0C + 150f;
  177. public const float FireSpreadRadiosityScale = 0.85f;
  178. public const float FirePlasmaEnergyReleased = 160e3f; // methane is 16 kJ/mol, plus plasma's spark of magic
  179. public const float FireGrowthRate = 40000f;
  180. public const float SuperSaturationThreshold = 96f;
  181. public const float SuperSaturationEnds = SuperSaturationThreshold / 3;
  182. public const float OxygenBurnRateBase = 1.4f;
  183. public const float PlasmaMinimumBurnTemperature = (100f+T0C);
  184. public const float PlasmaUpperTemperature = (1370f+T0C);
  185. public const float PlasmaOxygenFullburn = 10f;
  186. public const float PlasmaBurnRateDelta = 9f;
  187. /// <summary>
  188. /// This is calculated to help prevent singlecap bombs (Overpowered tritium/oxygen single tank bombs)
  189. /// </summary>
  190. public const float MinimumTritiumOxyburnEnergy = 143000f;
  191. public const float TritiumBurnOxyFactor = 100f;
  192. public const float TritiumBurnTritFactor = 10f;
  193. public const float FrezonCoolLowerTemperature = 23.15f;
  194. /// <summary>
  195. /// Frezon cools better at higher temperatures.
  196. /// </summary>
  197. public const float FrezonCoolMidTemperature = 373.15f;
  198. public const float FrezonCoolMaximumEnergyModifier = 10f;
  199. /// <summary>
  200. /// Remove X mol of nitrogen for each mol of frezon.
  201. /// </summary>
  202. public const float FrezonNitrogenCoolRatio = 5;
  203. public const float FrezonCoolEnergyReleased = -600e3f;
  204. public const float FrezonCoolRateModifier = 20f;
  205. public const float FrezonProductionMaxEfficiencyTemperature = 73.15f;
  206. /// <summary>
  207. /// 1 mol of N2 is required per X mol of tritium and oxygen.
  208. /// </summary>
  209. public const float FrezonProductionNitrogenRatio = 10f;
  210. /// <summary>
  211. /// 1 mol of Tritium is required per X mol of oxygen.
  212. /// </summary>
  213. public const float FrezonProductionTritRatio = 8.0f;
  214. /// <summary>
  215. /// 1 / X of the tritium is converted into Frezon each tick
  216. /// </summary>
  217. public const float FrezonProductionConversionRate = 50f;
  218. /// <summary>
  219. /// The maximum portion of the N2O that can decompose each reaction tick. (50%)
  220. /// </summary>
  221. public const float N2ODecompositionRate = 2f;
  222. /// <summary>
  223. /// Divisor for Ammonia Oxygen reaction so that it doesn't happen instantaneously.
  224. /// </summary>
  225. public const float AmmoniaOxygenReactionRate = 10f;
  226. /// <summary>
  227. /// Determines at what pressure the ultra-high pressure red icon is displayed.
  228. /// </summary>
  229. public const float HazardHighPressure = 550f;
  230. /// <summary>
  231. /// Determines when the orange pressure icon is displayed.
  232. /// </summary>
  233. public const float WarningHighPressure = 0.7f * HazardHighPressure;
  234. /// <summary>
  235. /// Determines when the gray low pressure icon is displayed.
  236. /// </summary>
  237. public const float WarningLowPressure = 2.5f * HazardLowPressure;
  238. /// <summary>
  239. /// Determines when the black ultra-low pressure icon is displayed.
  240. /// </summary>
  241. public const float HazardLowPressure = 20f;
  242. /// <summary>
  243. /// The amount of pressure damage someone takes is equal to ((pressure / HAZARD_HIGH_PRESSURE) - 1)*PRESSURE_DAMAGE_COEFFICIENT,
  244. /// with the maximum of MaxHighPressureDamage.
  245. /// </summary>
  246. public const float PressureDamageCoefficient = 4;
  247. /// <summary>
  248. /// Maximum amount of damage that can be endured with high pressure.
  249. /// </summary>
  250. public const int MaxHighPressureDamage = 4;
  251. /// <summary>
  252. /// The amount of damage someone takes when in a low pressure area
  253. /// (The pressure threshold is so low that it doesn't make sense to do any calculations,
  254. /// so it just applies this flat value).
  255. /// </summary>
  256. // Original value is 4, buff back when we have proper ways for players to deal with breaches.
  257. public const int LowPressureDamage = 1;
  258. public const float WindowHeatTransferCoefficient = 0.1f;
  259. /// <summary>
  260. /// Directions that atmos currently supports. Modify in case of multi-z.
  261. /// See <see cref="AtmosDirection"/> on the server.
  262. /// </summary>
  263. public const int Directions = 4;
  264. /// <summary>
  265. /// The normal body temperature in degrees Celsius.
  266. /// </summary>
  267. public const float NormalBodyTemperature = 37f;
  268. /// <summary>
  269. /// I hereby decree. This is Arbitrary Suck my Dick
  270. /// </summary>
  271. public const float BreathMolesToReagentMultiplier = 1144;
  272. #region Pipes
  273. /// <summary>
  274. /// The default pressure at which pumps and powered equipment max out at, in kPa.
  275. /// </summary>
  276. public const float MaxOutputPressure = 4500;
  277. /// <summary>
  278. /// The default maximum speed powered equipment can work at, in L/s.
  279. /// </summary>
  280. public const float MaxTransferRate = 200;
  281. #endregion
  282. }
  283. /// <summary>
  284. /// Gases to Ids. Keep these updated with the prototypes!
  285. /// </summary>
  286. [Serializable, NetSerializable]
  287. public enum Gas : sbyte
  288. {
  289. Oxygen = 0,
  290. Nitrogen = 1,
  291. CarbonDioxide = 2,
  292. Plasma = 3,
  293. Tritium = 4,
  294. WaterVapor = 5,
  295. Ammonia = 6,
  296. NitrousOxide = 7,
  297. Frezon = 8
  298. }
  299. }