N2ODecompositionReaction.cs 957 B

1234567891011121314151617181920212223242526272829
  1. using Content.Server.Atmos.EntitySystems;
  2. using Content.Shared.Atmos;
  3. using Content.Shared.Atmos.Reactions;
  4. using JetBrains.Annotations;
  5. namespace Content.Server.Atmos.Reactions;
  6. /// <summary>
  7. /// Decomposes Nitrous Oxide into Nitrogen and Oxygen.
  8. /// </summary>
  9. [UsedImplicitly]
  10. public sealed partial class N2ODecompositionReaction : IGasReactionEffect
  11. {
  12. public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
  13. {
  14. var cacheN2O = mixture.GetMoles(Gas.NitrousOxide);
  15. var burnedFuel = cacheN2O / Atmospherics.N2ODecompositionRate;
  16. if (burnedFuel <= 0 || cacheN2O - burnedFuel < 0)
  17. return ReactionResult.NoReaction;
  18. mixture.AdjustMoles(Gas.NitrousOxide, -burnedFuel);
  19. mixture.AdjustMoles(Gas.Nitrogen, burnedFuel);
  20. mixture.AdjustMoles(Gas.Oxygen, burnedFuel / 2);
  21. return ReactionResult.Reacting;
  22. }
  23. }