]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add nitrous oxide decomposition reaction (#22738)
authorusername <113782077+whateverusername0@users.noreply.github.com>
Thu, 21 Dec 2023 01:33:08 +0000 (11:33 +1000)
committerGitHub <noreply@github.com>
Thu, 21 Dec 2023 01:33:08 +0000 (17:33 -0800)
Co-authored-by: whateverusername0 <whateveremail>
Co-authored-by: Kevin Zheng <kevinz5000@gmail.com>
Content.Server/Atmos/Reactions/N2ODecompositionReaction.cs [new file with mode: 0644]
Content.Shared/Atmos/Atmospherics.cs
Resources/Prototypes/Atmospherics/reactions.yml

diff --git a/Content.Server/Atmos/Reactions/N2ODecompositionReaction.cs b/Content.Server/Atmos/Reactions/N2ODecompositionReaction.cs
new file mode 100644 (file)
index 0000000..7fce663
--- /dev/null
@@ -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;
+    }
+}
index 71908326cc1be2075a996d707f4fdcb6c447c204..148f03e2d9576ec5cbd8afb3d77c70396871a262 100644 (file)
@@ -236,6 +236,11 @@ namespace Content.Shared.Atmos
         /// </summary>
         public const float FrezonProductionConversionRate = 50f;
 
+        /// <summary>
+        ///     The maximum portion of the N2O that can decompose each reaction tick. (50%)
+        /// </summary>
+        public const float N2ODecompositionRate = 2f;
+
         /// <summary>
         ///     How many mol of frezon can be converted into miasma in one cycle.
         /// </summary>
index 6553ae551b64bb346e8d1a326a12ca09a4786df6..22ca8b66f9907df31f363154c4bc040d1dd9a0fa 100644 (file)
@@ -1,4 +1,4 @@
-- type: gasReaction
+- type: gasReaction
   id: PlasmaFire
   priority: -2
   minimumTemperature: 373.149 # Same as Atmospherics.FireMinimumTemperatureToExist
   effects:
   - !type:MiasmaOxygenReaction {}
 
+- type: gasReaction
+  id: N2ODecomposition
+  priority: 0
+  minimumTemperature: 850
+  minimumRequirements:
+  - 0     # oxygen
+  - 0     # nitrogen
+  - 0     # carbon dioxide
+  - 0     # plasma
+  - 0     # tritium
+  - 0     # vapor
+  - 0     # miasma
+  - 0.01  # n2o
+  - 0     # frezon
+  effects:
+  - !type:N2ODecompositionReaction {}
+
 #- type: gasReaction
 #  id: WaterVaporPuddle
 #  priority: 1