-
Notifications
You must be signed in to change notification settings - Fork 592
Expand file tree
/
Copy pathAtmospherics.cs
More file actions
504 lines (414 loc) · 19.7 KB
/
Copy pathAtmospherics.cs
File metadata and controls
504 lines (414 loc) · 19.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
using Robust.Shared.Serialization;
// ReSharper disable InconsistentNaming
namespace Content.Shared.Atmos
{
/// <summary>
/// Class to store atmos constants.
/// </summary>
public static class Atmospherics
{
#region ATMOS
/// <summary>
/// The universal gas constant, in kPa*L/(K*mol)
/// </summary>
public const float R = 8.314462618f;
/// <summary>
/// 1 ATM in kPA.
/// </summary>
public const float OneAtmosphere = 101.325f;
/// <summary>
/// Maximum external pressure (in kPA) a gas miner will, by default, output to.
/// This is used to initialize roundstart atmos rooms.
/// </summary>
public const float GasMinerDefaultMaxExternalPressure = 6500f;
/// <summary>
/// -270.3ºC in K. CMB stands for Cosmic Microwave Background.
/// </summary>
public const float TCMB = 2.7f;
/// <summary>
/// 0ºC in K
/// </summary>
public const float T0C = 273.15f;
/// <summary>
/// 20ºC in K
/// </summary>
public const float T20C = 293.15f;
/// <summary>
/// -38.15ºC in K.
/// This is used to initialize roundstart freezer rooms.
/// </summary>
public const float FreezerTemp = 235f;
/// <summary>
/// Do not allow any gas mixture temperatures to exceed this number. It is occasionally possible
/// to have very small heat capacity (e.g. room that was just unspaced) and for large amounts of
/// energy to be transferred to it, even for a brief moment. However, this messes up subsequent
/// calculations and so cap it here. The physical interpretation is that at this temperature, any
/// gas that you would have transforms into plasma.
/// </summary>
public const float Tmax = 262144; // 1/64 of max safe integer, any values above will result in a ~0.03K epsilon
/// <summary>
/// Liters in a cell.
/// </summary>
public const float CellVolume = 2500f;
// Liters in a normal breath
public const float BreathVolume = 0.5f;
// Amount of air to take from a tile
public const float BreathPercentage = BreathVolume / CellVolume;
/// <summary>
/// Moles in a 2.5 m^3 cell at 101.325 kPa and 20ºC
/// </summary>
public const float MolesCellStandard = (OneAtmosphere * CellVolume / (T20C * R));
/// <summary>
/// Moles in a 2.5 m^3 cell at 101.325 kPa and -38.15ºC.
/// This is used in fix atmos freezer markers to ensure the air is at the correct atmospheric pressure while still being cold.
/// </summary>
public const float MolesCellFreezer = (OneAtmosphere * CellVolume / (FreezerTemp * R));
/// <summary>
/// Moles in a 2.5 m^3 cell at GasMinerDefaultMaxExternalPressure kPa and 20ºC
/// </summary>
public const float MolesCellGasMiner = (GasMinerDefaultMaxExternalPressure * CellVolume / (T20C * R));
/// <summary>
/// Compared against for superconduction.
/// </summary>
public const float MCellWithRatio = (MolesCellStandard * 0.005f);
public const float OxygenStandard = 0.21f;
public const float NitrogenStandard = 0.79f;
public const float OxygenMolesStandard = MolesCellStandard * OxygenStandard;
public const float NitrogenMolesStandard = MolesCellStandard * NitrogenStandard;
public const float OxygenMolesFreezer = MolesCellFreezer * OxygenStandard;
public const float NitrogenMolesFreezer = MolesCellFreezer * NitrogenStandard;
public const float OxygenMolesGasMiner = MolesCellGasMiner * OxygenStandard;
public const float NitrogenMolesGasMiner = MolesCellGasMiner * NitrogenStandard;
#endregion
/// <summary>
/// Visible moles multiplied by this factor to get moles at which gas is at max visibility.
/// </summary>
public const float FactorGasVisibleMax = 20f;
/// <summary>
/// Minimum number of moles a gas can have.
/// </summary>
public const float GasMinMoles = 0.00000005f;
public const float OpenHeatTransferCoefficient = 0.4f;
/// <summary>
/// Hack to make vacuums cold, sacrificing realism for gameplay.
/// </summary>
public const float HeatCapacityVacuum = 7000f;
/// <summary>
/// Ratio of air that must move to/from a tile to reset group processing
/// </summary>
public const float MinimumAirRatioToSuspend = 0.1f;
/// <summary>
/// Minimum ratio of air that must move to/from a tile
/// </summary>
public const float MinimumAirRatioToMove = 0.001f;
/// <summary>
/// Minimum amount of air that has to move before a group processing can be suspended
/// </summary>
public const float MinimumAirToSuspend = (MolesCellStandard * MinimumAirRatioToSuspend);
public const float MinimumTemperatureToMove = (T20C + 100f);
public const float MinimumMolesDeltaToMove = (MolesCellStandard * MinimumAirRatioToMove);
/// <summary>
/// Minimum temperature difference before group processing is suspended
/// </summary>
public const float MinimumTemperatureDeltaToSuspend = 4.0f;
/// <summary>
/// Minimum temperature difference before the gas temperatures are just set to be equal.
/// </summary>
public const float MinimumTemperatureDeltaToConsider = 0.01f;
/// <summary>
/// Minimum temperature for starting superconduction.
/// </summary>
public const float MinimumTemperatureStartSuperConduction = (T20C + 400f);
public const float MinimumTemperatureForSuperconduction = (T20C + 80f);
/// <summary>
/// Minimum heat capacity.
/// </summary>
public const float MinimumHeatCapacity = 0.0003f;
/// <summary>
/// For the purposes of making space "colder"
/// </summary>
public const float SpaceHeatCapacity = 7000f;
/// <summary>
/// Dictionary of chemical abbreviations for <see cref="Gas"/>
/// </summary>
public static Dictionary<Gas, string> GasAbbreviations = new Dictionary<Gas, string>()
{
[Gas.Ammonia] = Loc.GetString("gas-ammonia-abbreviation"),
[Gas.CarbonDioxide] = Loc.GetString("gas-carbon-dioxide-abbreviation"),
[Gas.Frezon] = Loc.GetString("gas-frezon-abbreviation"),
[Gas.Nitrogen] = Loc.GetString("gas-nitrogen-abbreviation"),
[Gas.NitrousOxide] = Loc.GetString("gas-nitrous-oxide-abbreviation"),
[Gas.Oxygen] = Loc.GetString("gas-oxygen-abbreviation"),
[Gas.Plasma] = Loc.GetString("gas-plasma-abbreviation"),
[Gas.Tritium] = Loc.GetString("gas-tritium-abbreviation"),
[Gas.WaterVapor] = Loc.GetString("gas-water-vapor-abbreviation"),
// Funkystation Start: Funky atmos - /tg/ gases
[Gas.BZ] = Loc.GetString("gas-bz-abbreviation"),
[Gas.Nitrium] = Loc.GetString("gas-nitrium-abbreviation"),
[Gas.Pluoxium] = Loc.GetString("gas-pluoxium-abbreviation"),
[Gas.Hydrogen] = Loc.GetString("gas-hydrogen-abbreviation"),
[Gas.HyperNoblium] = Loc.GetString("gas-hyper-noblium-abbreviation"),
[Gas.ProtoNitrate] = Loc.GetString("gas-proto-nitrate-abbreviation"),
[Gas.Zauker] = Loc.GetString("gas-zauker-abbreviation"),
[Gas.Halon] = Loc.GetString("gas-halon-abbreviation"),
[Gas.Helium] = Loc.GetString("gas-helium-abbreviation"),
[Gas.AntiNoblium] = Loc.GetString("gas-anti-noblium-abbreviation"),
// Funkystation End: Funky atmos - /tg/ gases
#region Starlight
// Starlight gases!
[Gas.Ulnitranium] = Loc.GetString("gas-ulnitranium-abbreviation"),
[Gas.ZXA] = Loc.GetString("gas-zxa-abbreviation"),
#endregion
};
#region Excited Groups
/// <summary>
/// Number of full atmos updates ticks before an excited group breaks down (averages gas contents across turfs)
/// </summary>
public const int ExcitedGroupBreakdownCycles = 4;
/// <summary>
/// Number of full atmos updates before an excited group dismantles and removes its turfs from active
/// </summary>
public const int ExcitedGroupsDismantleCycles = 16;
#endregion
/// <summary>
/// Hard limit for zone-based tile equalization.
/// </summary>
public const int MonstermosHardTileLimit = 2000;
/// <summary>
/// Limit for zone-based tile equalization.
/// </summary>
public const int MonstermosTileLimit = 200;
/// <summary>
/// Total number of gases. Increase this if you want to add more!
/// </summary>
public const int TotalNumberOfGases = 22; // Starlight Edit: 9 -> 22
/// <summary>
/// This is the actual length of the gases arrays in mixtures.
/// Set to the closest multiple of 4 relative to <see cref="TotalNumberOfGases"/> for SIMD reasons.
/// </summary>
public const int AdjustedNumberOfGases = ((TotalNumberOfGases + 3) / 4) * 4;
/// <summary>
/// Amount of heat released per mole of burnt hydrogen or tritium (hydrogen isotope)
/// </summary>
public const float FireHydrogenEnergyReleased = 284e4f;
public const float FireMinimumTemperatureToExist = T0C + 100f;
public const float FireMinimumTemperatureToSpread = T0C + 150f;
public const float FireSpreadRadiosityScale = 0.85f;
public const float FirePlasmaEnergyReleased = 160e3f; // methane is 16 kJ/mol, plus plasma's spark of magic
public const float FireGrowthRate = 40000f;
public const float SuperSaturationThreshold = 96f;
public const float SuperSaturationEnds = SuperSaturationThreshold / 3;
public const float OxygenBurnRateBase = 1.4f;
public const float PlasmaMinimumBurnTemperature = (100f+T0C);
public const float PlasmaUpperTemperature = (1370f+T0C);
public const float PlasmaOxygenFullburn = 10f;
public const float PlasmaBurnRateDelta = 9f;
public const float HydrogenBurnRateDelta = 2f; // Funky atmos - /tg/ gases
/// <summary>
/// This is calculated to help prevent singlecap bombs (Overpowered tritium/oxygen single tank bombs)
/// </summary>
public const float MinimumTritiumOxyburnEnergy = 143000f;
public const float TritiumBurnOxyFactor = 100f;
public const float TritiumBurnTritFactor = 10f;
public const float TritiumBurnFuelRatio = 2f;
public const float FrezonCoolLowerTemperature = 23.15f;
/// <summary>
/// Frezon cools better at higher temperatures.
/// </summary>
public const float FrezonCoolMidTemperature = 373.15f;
public const float FrezonCoolMaximumEnergyModifier = 10f;
/// <summary>
/// Remove X mol of nitrogen for each mol of frezon.
/// </summary>
public const float FrezonNitrogenCoolRatio = 5;
public const float FrezonCoolEnergyReleased = -600e3f;
public const float FrezonCoolRateModifier = 20f;
public const float FrezonProductionMaxEfficiencyTemperature = 73.15f;
/// <summary>
/// 1 mol of N2 is required per X mol of tritium and oxygen.
/// </summary>
public const float FrezonProductionNitrogenRatio = 10f;
/// <summary>
/// 1 mol of Tritium is required per X mol of oxygen.
/// </summary>
public const float FrezonProductionTritRatio = 50.0f;
/// <summary>
/// 1 / X of the tritium is converted into Frezon each tick
/// </summary>
public const float FrezonProductionConversionRate = 50f;
/// <summary>
/// The maximum portion of the N2O that can decompose each reaction tick. (50%)
/// </summary>
public const float N2ODecompositionRate = 2f;
/// <summary>
/// Divisor for Ammonia Oxygen reaction so that it doesn't happen instantaneously.
/// </summary>
public const float AmmoniaOxygenReactionRate = 10f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The amount of energy 1 mole of BZ forming from N2O and plasma releases.
/// </summary>
public const float BZProductionEnergy = 80e3f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The amount of energy 1 mol of Nitrium forming from Tritium, Nitrogen and BZ releases.
/// </summary>
public const float NitriumProductionEnergy = -100e3f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The amount of energy 1 mol of Nitrium decomposing into nitrogen and water vapor releases.
/// </summary>
public const float NitriumDecompositionEnergy = 30e3f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The amount of energy 1 mol of Pluoxium forming releases.
/// </summary>
public const float PluoxiumProductionEnergy = 250;
public const float MinimumHydrogenOxyburnEnergy = 143000f;
public const float HydrogenBurnOxyFactor = 100f;
public const float HydrogenBurnH2Factor = 10f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The amount of energy 1 mol of hyper-noblium forming from tritium and nitrogen releases.
/// </summary>
public const float HyperNobliumProductionEnergy = 2e7f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// Energy released per mol of BZ consumed during halon formation.
/// </summary>
public const float HalonProductionEnergy = 91232.1f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// How much energy a mole of halon combusting consumes.
/// </summary>
public const float HalonCombustionEnergy = -2500f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The amount of energy half a mole of zauker forming from hypernoblium and nitrium consumes.
/// </summary>
public const float ZaukerProductionEnergy = 5000f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The temperature scaling factor for zauker formation. At most this many moles of zauker can form per reaction tick per kelvin.
/// </summary>
public const float ZaukerTemperatureScale = 5e-6f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The amount of energy a mole of zauker decomposing in the presence of nitrogen releases.
/// </summary>
public const float ZaukerDecompositionEnergy = 460f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The maximum number of moles of zauker that can decompose per reaction tick.
/// </summary>
public const float ZaukerDecompositionMaxRate = 20f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The amount of energy 2.2 moles of proto-nitrate forming from pluoxium and hydrogen releases.
/// </summary>
public const float ProtoNitrateProductionEnergy = 650f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The temperature scaling factor for proto-nitrate formation. At most this many moles of zauker can form per reaction tick per kelvin.
/// </summary>
public const float ProtoNitrateTemperatureScale = 5e-3f;
/// <summary>
/// Funky Atmos - /tg/ gases
/// The amount of energy proto-nitrate breaking down a mole of BZ releases.
/// </summary>
public const float ProtoNitrateBZConversionEnergy = -10000f;
/// <summary>
/// Starlight, based on Funky Atmos
/// The amount of energy 1 mol of Ulnitranium forming releases.
/// </summary>
public const float UlnitraniumProductionEnergy = 350;
/// <summary>
/// Determines at what pressure the ultra-high pressure red icon is displayed.
/// </summary>
public const float HazardHighPressure = 550f;
/// <summary>
/// Determines when the orange pressure icon is displayed.
/// </summary>
public const float WarningHighPressure = 0.7f * HazardHighPressure;
/// <summary>
/// Determines when the gray low pressure icon is displayed.
/// </summary>
public const float WarningLowPressure = 2.5f * HazardLowPressure;
/// <summary>
/// Determines when the black ultra-low pressure icon is displayed.
/// </summary>
public const float HazardLowPressure = 20f;
/// <summary>
/// The amount of pressure damage someone takes is equal to ((pressure / HAZARD_HIGH_PRESSURE) - 1)*PRESSURE_DAMAGE_COEFFICIENT,
/// with the maximum of MaxHighPressureDamage.
/// </summary>
public const float PressureDamageCoefficient = 4;
/// <summary>
/// Maximum amount of damage that can be endured with high pressure.
/// </summary>
public const int MaxHighPressureDamage = 4;
/// <summary>
/// The amount of damage someone takes when in a low pressure area
/// (The pressure threshold is so low that it doesn't make sense to do any calculations,
/// so it just applies this flat value).
/// </summary>
public const int LowPressureDamage = 2; //Starlight. nerf back to old values pending changes back to 4 or lower.
public const float WindowHeatTransferCoefficient = 0.1f;
/// <summary>
/// Directions that atmos currently supports. Modify in case of multi-z.
/// See <see cref="AtmosDirection"/> on the server.
/// </summary>
public const int Directions = 4;
/// <summary>
/// The normal body temperature in degrees Celsius.
/// </summary>
public const float NormalBodyTemperature = 37f;
/// <summary>
/// I hereby decree. This is Arbitrary Suck my Dick
/// </summary>
public const float BreathMolesToReagentMultiplier = 1144;
#region Pipes
/// <summary>
/// The default pressure at which pumps and powered equipment max out at, in kPa.
/// </summary>
public const float MaxOutputPressure = 4500;
/// <summary>
/// The default maximum speed powered equipment can work at, in L/s.
/// </summary>
public const float MaxTransferRate = 200;
#endregion
}
/// <summary>
/// Gases to Ids. Keep these updated with the prototypes!
/// </summary>
[Serializable, NetSerializable]
public enum Gas : sbyte
{
Oxygen = 0,
Nitrogen = 1,
CarbonDioxide = 2,
Plasma = 3,
Tritium = 4,
WaterVapor = 5,
Ammonia = 6,
NitrousOxide = 7,
Frezon = 8,
// Funkystation Start: Funky atmos - /tg/ gases
BZ = 9,
Nitrium = 10,
Pluoxium = 11,
Hydrogen = 12,
HyperNoblium = 13,
ProtoNitrate = 14,
Zauker = 15,
Halon = 16,
Helium = 17,
AntiNoblium = 18,
// Funkystation End: Funky atmos - /tg/ gases
#region Starlight
// Starlight gases!
Ulnitranium = 19,
ZXA = 20,
#endregion
}
}