Add atmos.speedup which is effectively a atmos-only time compression CVar. This adjusts heat capacities and transfer rates to effectively globally speed up the time constants of atmos. This allows faster response to heating/cooling changes and faster cleanups (by buffing scrubbers, pumps, and everything else) that is tunable through one global time compression CVar. It also achieves this without any thermodynamic unsoundness.
71 lines
2.9 KiB
C#
71 lines
2.9 KiB
C#
using Content.Server.Atmos.EntitySystems;
|
|
using Content.Shared.Atmos;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Content.Server.Atmos.Reactions
|
|
{
|
|
[UsedImplicitly]
|
|
[DataDefinition]
|
|
public sealed partial class TritiumFireReaction : IGasReactionEffect
|
|
{
|
|
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem)
|
|
{
|
|
var energyReleased = 0f;
|
|
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture);
|
|
var temperature = mixture.Temperature;
|
|
var location = holder as TileAtmosphere;
|
|
mixture.ReactionResults[GasReaction.Fire] = 0f;
|
|
var burnedFuel = 0f;
|
|
var initialTrit = mixture.GetMoles(Gas.Tritium);
|
|
|
|
if (mixture.GetMoles(Gas.Oxygen) < initialTrit ||
|
|
Atmospherics.MinimumTritiumOxyburnEnergy > (temperature * oldHeatCapacity))
|
|
{
|
|
burnedFuel = mixture.GetMoles(Gas.Oxygen) / Atmospherics.TritiumBurnOxyFactor;
|
|
if (burnedFuel > initialTrit)
|
|
burnedFuel = initialTrit;
|
|
|
|
mixture.AdjustMoles(Gas.Tritium, -burnedFuel);
|
|
}
|
|
else
|
|
{
|
|
burnedFuel = initialTrit;
|
|
mixture.SetMoles(Gas.Tritium, mixture.GetMoles(Gas.Tritium ) * (1 - 1 / Atmospherics.TritiumBurnTritFactor));
|
|
mixture.AdjustMoles(Gas.Oxygen, -mixture.GetMoles(Gas.Tritium));
|
|
energyReleased += (Atmospherics.FireHydrogenEnergyReleased * burnedFuel * (Atmospherics.TritiumBurnTritFactor - 1));
|
|
}
|
|
|
|
if (burnedFuel > 0)
|
|
{
|
|
energyReleased += (Atmospherics.FireHydrogenEnergyReleased * burnedFuel);
|
|
|
|
// TODO ATMOS Radiation pulse here!
|
|
|
|
// Conservation of mass is important.
|
|
mixture.AdjustMoles(Gas.WaterVapor, burnedFuel);
|
|
|
|
mixture.ReactionResults[GasReaction.Fire] += burnedFuel;
|
|
}
|
|
|
|
energyReleased /= atmosphereSystem.Speedup; // adjust energy to make sure speedup doesn't cause mega temperature rise
|
|
if (energyReleased > 0)
|
|
{
|
|
var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture);
|
|
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
|
|
mixture.Temperature = ((temperature * oldHeatCapacity + energyReleased) / newHeatCapacity);
|
|
}
|
|
|
|
if (location != null)
|
|
{
|
|
temperature = mixture.Temperature;
|
|
if (temperature > Atmospherics.FireMinimumTemperatureToExist)
|
|
{
|
|
atmosphereSystem.HotspotExpose(location.GridIndex, location.GridIndices, temperature, mixture.Volume);
|
|
}
|
|
}
|
|
|
|
return mixture.ReactionResults[GasReaction.Fire] != 0 ? ReactionResult.Reacting : ReactionResult.NoReaction;
|
|
}
|
|
}
|
|
}
|