Frezon (#9980)
* 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
This commit is contained in:
58
Content.Server/Atmos/Reactions/FrezonCoolantReaction.cs
Normal file
58
Content.Server/Atmos/Reactions/FrezonCoolantReaction.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Atmos.Reactions;
|
||||
|
||||
/// <summary>
|
||||
/// Takes in nitrogen and frezon and cools down the surrounding area.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public sealed class FrezonCoolantReaction : IGasReactionEffect
|
||||
{
|
||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem)
|
||||
{
|
||||
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture);
|
||||
var temperature = mixture.Temperature;
|
||||
|
||||
var energyModifier = 1f;
|
||||
var scale = (temperature - Atmospherics.FrezonCoolLowerTemperature) /
|
||||
(Atmospherics.FrezonCoolMidTemperature - Atmospherics.FrezonCoolLowerTemperature);
|
||||
|
||||
if (scale > 1f)
|
||||
{
|
||||
// Scale energy but not frezon usage if we're in a very, very hot place
|
||||
energyModifier = Math.Min(scale, Atmospherics.FrezonCoolMaximumEnergyModifier);
|
||||
scale = 1f;
|
||||
}
|
||||
|
||||
if (scale <= 0)
|
||||
return ReactionResult.NoReaction;
|
||||
|
||||
var initialNit = mixture.GetMoles(Gas.Nitrogen);
|
||||
var initialFrezon = mixture.GetMoles(Gas.Frezon);
|
||||
|
||||
var burnRate = initialFrezon * scale / Atmospherics.FrezonCoolRateModifier;
|
||||
|
||||
var energyReleased = 0f;
|
||||
if (burnRate > Atmospherics.MinimumHeatCapacity)
|
||||
{
|
||||
var nitAmt = Math.Min(burnRate * Atmospherics.FrezonNitrogenCoolRatio, initialNit);
|
||||
var frezonAmt = Math.Min(burnRate, initialFrezon);
|
||||
mixture.AdjustMoles(Gas.Nitrogen, -nitAmt);
|
||||
mixture.AdjustMoles(Gas.Frezon, -frezonAmt);
|
||||
// TODO nitrous oxide
|
||||
mixture.AdjustMoles(Gas.CarbonDioxide, nitAmt + frezonAmt);
|
||||
energyReleased = burnRate * Atmospherics.FrezonCoolEnergyReleased * energyModifier;
|
||||
}
|
||||
|
||||
if (energyReleased >= 0f)
|
||||
return ReactionResult.NoReaction;
|
||||
|
||||
var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture);
|
||||
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
|
||||
mixture.Temperature = (temperature * oldHeatCapacity + energyReleased) / newHeatCapacity;
|
||||
|
||||
return ReactionResult.Reacting;
|
||||
}
|
||||
}
|
||||
40
Content.Server/Atmos/Reactions/FrezonProductionReaction.cs
Normal file
40
Content.Server/Atmos/Reactions/FrezonProductionReaction.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
25
Content.Server/Atmos/Reactions/MiasmicSubsumationReaction.cs
Normal file
25
Content.Server/Atmos/Reactions/MiasmicSubsumationReaction.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Atmos.Reactions;
|
||||
|
||||
/// <summary>
|
||||
/// Converts frezon into miasma when the two come into contact. Does not occur at very high temperatures.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public sealed class MiasmicSubsumationReaction : IGasReactionEffect
|
||||
{
|
||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem)
|
||||
{
|
||||
var initialMiasma = mixture.GetMoles(Gas.Miasma);
|
||||
var initialFrezon = mixture.GetMoles(Gas.Frezon);
|
||||
|
||||
var convert = Math.Min(Math.Min(initialFrezon, initialMiasma), Atmospherics.MiasmicSubsumationMaxConversionRate);
|
||||
|
||||
mixture.AdjustMoles(Gas.Miasma, convert);
|
||||
mixture.AdjustMoles(Gas.Frezon, -convert);
|
||||
|
||||
return ReactionResult.Reacting;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user