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

diff --git a/Content.Server/Atmos/Reactions/MiasmaOxygenReaction.cs b/Content.Server/Atmos/Reactions/MiasmaOxygenReaction.cs
new file mode 100644 (file)
index 0000000..0d4e1ef
--- /dev/null
@@ -0,0 +1,33 @@
+using Content.Server.Atmos.EntitySystems;
+using Content.Shared.Atmos;
+using JetBrains.Annotations;
+
+namespace Content.Server.Atmos.Reactions;
+
+[UsedImplicitly]
+public sealed partial class MiasmaOxygenReaction : IGasReactionEffect
+{
+    public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
+    {
+        var nMiasma = mixture.GetMoles(Gas.Miasma);
+        var nOxygen = mixture.GetMoles(Gas.Oxygen);
+        var nTotal = mixture.TotalMoles;
+
+        // Concentration-dependent reaction rate
+        var fMiasma = nMiasma/nTotal;
+        var fOxygen = nOxygen/nTotal;
+        var rate = MathF.Pow(fMiasma, 2) * MathF.Pow(fOxygen, 2);
+
+        var deltaMoles = nMiasma / Atmospherics.MiasmaOxygenReactionRate * 2 * rate;
+
+        if (deltaMoles <= 0 || nMiasma - deltaMoles < 0)
+            return ReactionResult.NoReaction;
+
+        mixture.AdjustMoles(Gas.Miasma, -deltaMoles);
+        mixture.AdjustMoles(Gas.Oxygen, -deltaMoles);
+        mixture.AdjustMoles(Gas.NitrousOxide, deltaMoles / 2);
+        mixture.AdjustMoles(Gas.WaterVapor, deltaMoles * 1.5f);
+
+        return ReactionResult.Reacting;
+    }
+}
index 24fa5ada20481472a0dba4bc59f9bfe8a7ede3ad..71908326cc1be2075a996d707f4fdcb6c447c204 100644 (file)
@@ -241,6 +241,11 @@ namespace Content.Shared.Atmos
         /// </summary>
         public const float MiasmicSubsumationMaxConversionRate = 5f;
 
+        /// <summary>
+        ///     Divisor for Miasma Oxygen reaction so that it doesn't happen instantaneously.
+        /// </summary>
+        public const float MiasmaOxygenReactionRate = 10f;
+
         /// <summary>
         ///     Determines at what pressure the ultra-high pressure red icon is displayed.
         /// </summary>
index a01bf80f31ba94b650785f41478b1f2645db7bbb..6553ae551b64bb346e8d1a326a12ca09a4786df6 100644 (file)
   effects:
   - !type:MiasmicSubsumationReaction {}
 
+- type: gasReaction
+  id: MiasmaOxygenReaction
+  priority: 2
+  minimumTemperature: 323.149
+  minimumRequirements:
+  - 0.01  # oxygen
+  - 0     # nitrogen
+  - 0     # carbon dioxide
+  - 0     # plasma
+  - 0     # tritium
+  - 0     # vapor
+  - 0.01  # miasma
+  - 0     # n2o
+  - 0     # frezon
+  effects:
+  - !type:MiasmaOxygenReaction {}
+
 #- type: gasReaction
 #  id: WaterVaporPuddle
 #  priority: 1