Add nitrous oxide decomposition reaction (#22738)

Co-authored-by: whateverusername0 <whateveremail>
Co-authored-by: Kevin Zheng <kevinz5000@gmail.com>
This commit is contained in:
username
2023-12-21 11:33:08 +10:00
committed by GitHub
parent a157f7ae9b
commit c514af0366
3 changed files with 51 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using JetBrains.Annotations;
namespace Content.Server.Atmos.Reactions;
/// <summary>
/// Decomposes Nitrous Oxide into Nitrogen and Oxygen.
/// </summary>
[UsedImplicitly]
public sealed partial class N2ODecompositionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var cacheN2O = mixture.GetMoles(Gas.NitrousOxide);
var burnedFuel = cacheN2O / Atmospherics.N2ODecompositionRate;
if (burnedFuel <= 0 || cacheN2O - burnedFuel < 0)
return ReactionResult.NoReaction;
mixture.AdjustMoles(Gas.NitrousOxide, -burnedFuel);
mixture.AdjustMoles(Gas.Nitrogen, burnedFuel);
mixture.AdjustMoles(Gas.Oxygen, burnedFuel / 2);
return ReactionResult.Reacting;
}
}