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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user