* stuff i'll have to fix anyway when n2o gets merged * everything except the finished reactions * freon coolant reaction but with bad curve * miasmic subsumation * freon production * nitrogen and diff temp scaling * uhh meant to change that * # * hitting that frezon boof
41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
using Content.Server.Atmos.EntitySystems;
|
|
using Content.Shared.Atmos;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Content.Server.Atmos.Reactions;
|
|
|
|
/// <summary>
|
|
/// Produces frezon from oxygen and tritium, with nitrogen as a catalyst that also acts as a stopper if too much is present.
|
|
/// Has a max temperature, but paradoxically gets more efficient the hotter it is.
|
|
/// </summary>
|
|
[UsedImplicitly]
|
|
public sealed class FrezonProductionReaction : IGasReactionEffect
|
|
{
|
|
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem)
|
|
{
|
|
var initialN2 = mixture.GetMoles(Gas.Nitrogen);
|
|
var initialOxy = mixture.GetMoles(Gas.Oxygen);
|
|
var initialTrit = mixture.GetMoles(Gas.Tritium);
|
|
|
|
var efficiency = mixture.Temperature / Atmospherics.FrezonProductionMaxEfficiencyTemperature;
|
|
var loss = 1 - efficiency;
|
|
|
|
// Less N2 is required the more efficient it is.
|
|
var minimumN2 = (initialOxy + initialTrit) / (Atmospherics.FrezonProductionNitrogenRatio * efficiency);
|
|
|
|
if (initialN2 < minimumN2)
|
|
return ReactionResult.NoReaction;
|
|
|
|
var oxyConversion = initialOxy / Atmospherics.FrezonProductionConversionRate;
|
|
var tritConversion = initialTrit / Atmospherics.FrezonProductionConversionRate;
|
|
var total = oxyConversion + tritConversion;
|
|
|
|
mixture.AdjustMoles(Gas.Oxygen, -oxyConversion);
|
|
mixture.AdjustMoles(Gas.Tritium, -tritConversion);
|
|
mixture.AdjustMoles(Gas.Frezon, total * efficiency);
|
|
mixture.AdjustMoles(Gas.Nitrogen, total * loss);
|
|
|
|
return ReactionResult.Reacting;
|
|
}
|
|
}
|