-
Notifications
You must be signed in to change notification settings - Fork 592
Expand file tree
/
Copy pathHealiumProductionReaction.cs
More file actions
44 lines (35 loc) · 1.77 KB
/
Copy pathHealiumProductionReaction.cs
File metadata and controls
44 lines (35 loc) · 1.77 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
using Content.Server.Atmos;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;
namespace Content.Server._Funkystation.Atmos.Reactions;
/// <summary>
/// Funky Atmos - /tg/ gases
/// Produces Healium by mixing BZ and Frezon at temperatures between 23K and 293K. Efficiency increases in colder temperatures.
/// </summary>
[UsedImplicitly]
public sealed partial class HealiumProductionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
if (mixture.Temperature > 20f && mixture.GetMoles(Gas.HyperNoblium) >= 5f)
return ReactionResult.NoReaction;
var initBZ = mixture.GetMoles(Gas.BZ);
var initFrezon = mixture.GetMoles(Gas.Frezon);
var efficiency = Math.Min(mixture.Temperature * 0.3f, Math.Min(initFrezon * 0.36f, initBZ * 4f));
var bZRemoved = efficiency * 0.25f;
var frezonRemoved = efficiency * 2.75f;
var healiumProduced = efficiency * 3f;
if (efficiency <= 0 || initFrezon - frezonRemoved < 0 || initBZ - bZRemoved < 0)
return ReactionResult.NoReaction;
mixture.AdjustMoles(Gas.BZ, -bZRemoved);
mixture.AdjustMoles(Gas.Frezon, -frezonRemoved);
mixture.AdjustMoles(Gas.Healium, healiumProduced);
var energyReleased = efficiency * Atmospherics.HealiumProductionEnergy;
var heatCap = atmosphereSystem.GetHeatCapacity(mixture, true);
if (heatCap > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = Math.Max((mixture.Temperature * heatCap + energyReleased) / heatCap, Atmospherics.TCMB);
return ReactionResult.Reacting;
}
}