]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make slow spacing variables CCVars (#19862)
authorKevin Zheng <kevinz5000@gmail.com>
Thu, 14 Sep 2023 03:38:56 +0000 (19:38 -0800)
committerGitHub <noreply@github.com>
Thu, 14 Sep 2023 03:38:56 +0000 (19:38 -0800)
Content.Server/Atmos/EntitySystems/AtmosphereSystem.CVars.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.Monstermos.cs
Content.Shared/Atmos/Atmospherics.cs
Content.Shared/CCVar/CCVars.cs

index 4954f3e237c8632a44570233fff35fe5a060945c..60e215204d455261f7712e47d41ac6e140648a3d 100644 (file)
@@ -16,6 +16,9 @@ namespace Content.Server.Atmos.EntitySystems
         public bool MonstermosDepressurization { get; private set; }
         public bool MonstermosRipTiles { get; private set; }
         public bool GridImpulse { get; private set; }
+        public float SpacingEscapeRatio { get; private set; }
+        public float SpacingMinGas { get; private set; }
+        public float SpacingMaxWind { get; private set; }
         public bool Superconduction { get; private set; }
         public bool ExcitedGroups { get; private set; }
         public bool ExcitedGroupsSpaceIsAllConsuming { get; private set; }
@@ -40,6 +43,9 @@ namespace Content.Server.Atmos.EntitySystems
             _cfg.OnValueChanged(CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true);
             _cfg.OnValueChanged(CCVars.MonstermosRipTiles, value => MonstermosRipTiles = value, true);
             _cfg.OnValueChanged(CCVars.AtmosGridImpulse, value => GridImpulse = value, true);
+            _cfg.OnValueChanged(CCVars.AtmosSpacingEscapeRatio, value => SpacingEscapeRatio = value, true);
+            _cfg.OnValueChanged(CCVars.AtmosSpacingMinGas, value => SpacingMinGas = value, true);
+            _cfg.OnValueChanged(CCVars.AtmosSpacingMaxWind, value => SpacingMaxWind = value, true);
             _cfg.OnValueChanged(CCVars.Superconduction, value => Superconduction = value, true);
             _cfg.OnValueChanged(CCVars.AtmosMaxProcessTime, value => AtmosMaxProcessTime = value, true);
             _cfg.OnValueChanged(CCVars.AtmosTickRate, value => AtmosTickRate = value, true);
index 46aa73eccdc20865e7df2f109d405124f3927e16..c7191b27792921ce77a2f5c1fec519de4427f1ec 100644 (file)
@@ -467,19 +467,20 @@ namespace Content.Server.Atmos.EntitySystems
                     otherTile.Air.Temperature = Atmospherics.TCMB;
                     continue;
                 }
-
-                // Pressure as a multiple of normal air pressure (takes temperature into account)
-                float pressureMultiple = (otherTile.Air.Pressure / 110.0f);
-                var sum = otherTile.Air.TotalMoles * Atmospherics.SpacingEscapeRatio * pressureMultiple;
-                if (sum < Atmospherics.SpacingMinGas)
-                {
-                    // Boost the last bit of air draining from the tile.
-                    sum = Math.Min(Atmospherics.SpacingMinGas, otherTile.Air.TotalMoles);
-                }
-                if (sum + otherTile.MonstermosInfo.CurrentTransferAmount > Atmospherics.SpacingMaxWind * pressureMultiple)
+                var sum = otherTile.Air.TotalMoles;
+                if (SpacingEscapeRatio < 1f)
                 {
-                    // Limit the flow of air out of tiles which have air flowing into them from elsewhere.
-                    sum = Math.Max(Atmospherics.SpacingMinGas, Atmospherics.SpacingMaxWind * pressureMultiple - otherTile.MonstermosInfo.CurrentTransferAmount);
+                    sum *= SpacingEscapeRatio;
+                    if (sum < SpacingMinGas)
+                    {
+                        // Boost the last bit of air draining from the tile.
+                        sum = Math.Min(SpacingMinGas, otherTile.Air.TotalMoles);
+                    }
+                    if (sum + otherTile.MonstermosInfo.CurrentTransferAmount > SpacingMaxWind)
+                    {
+                        // Limit the flow of air out of tiles which have air flowing into them from elsewhere.
+                        sum = Math.Max(SpacingMinGas, SpacingMaxWind - otherTile.MonstermosInfo.CurrentTransferAmount);
+                    }
                 }
                 totalMolesRemoved += sum;
                 otherTile.MonstermosInfo.CurrentTransferAmount += sum;
@@ -493,7 +494,7 @@ namespace Content.Server.Atmos.EntitySystems
                     otherTile2.PressureDirection = otherTile.MonstermosInfo.CurrentTransferDirection;
                 }
 
-                if (otherTile.Air != null && otherTile.Air.Pressure - sum > Atmospherics.SpacingMinGas * 0.1f)
+                if (otherTile.Air != null && otherTile.Air.Pressure - sum > SpacingMinGas * 0.1f)
                 {
                     // Transfer the air into the other tile (space wind :)
                     ReleaseGasTo(otherTile.Air!, otherTile2.Air!, sum);
@@ -652,7 +653,7 @@ namespace Content.Server.Atmos.EntitySystems
             if (!MonstermosRipTiles)
                 return;
 
-            var chance = MathHelper.Clamp(0.01f + (sum / Atmospherics.SpacingMaxWind) * 0.3f, 0.003f, 0.3f);
+            var chance = MathHelper.Clamp(0.01f + (sum / SpacingMaxWind) * 0.3f, 0.003f, 0.3f);
 
             if (sum > 20 && _robustRandom.Prob(chance))
                 PryTile(mapGrid, tile.GridIndices);
index e0cea001519ffa202be77cd382d6d0c517b75919..13603eb6c801b6d0dedd8e93b582e824dd64767d 100644 (file)
@@ -309,25 +309,6 @@ namespace Content.Shared.Atmos
         /// </summary>
         public const float MaxTransferRate = 200;
 
-        /// <summary>
-        ///     What fraction of air from a spaced tile escapes every tick.
-        ///     1.0 for instant spacing, 0.2 means 20% of remaining air lost each time
-        /// </summary>
-        public const float SpacingEscapeRatio = 0.05f;
-
-        /// <summary>
-        ///     Minimum amount of air allowed on a spaced tile before it is reset to 0 immediately in kPa
-        ///     Since the decay due to SpacingEscapeRatio follows a curve, it would never reach 0.0 exactly
-        ///     unless we truncate it somewhere.
-        /// </summary>
-        public const float SpacingMinGas = 2.0f;
-
-        /// <summary>
-        ///     How much wind can go through a single tile before that tile doesn't depressurize itself
-        ///     (I.e spacing is limited in large rooms heading into smaller spaces)
-        /// </summary>
-        public const float SpacingMaxWind = 500.0f;
-
         #endregion
     }
 
index 34294ebcbd780219ace7d6a98dfd5628bf0920b0..19464a4fc3dd9a9e64095be9afe8471e02f6a235 100644 (file)
@@ -959,6 +959,28 @@ namespace Content.Shared.CCVar
         public static readonly CVarDef<bool> AtmosGridImpulse =
             CVarDef.Create("atmos.grid_impulse", false, CVar.SERVERONLY);
 
+        /// <summary>
+        ///     What fraction of air from a spaced tile escapes every tick.
+        ///     1.0 for instant spacing, 0.2 means 20% of remaining air lost each time
+        /// </summary>
+        public static readonly CVarDef<float> AtmosSpacingEscapeRatio =
+            CVarDef.Create("atmos.mmos_spacing_speed", 0.05f, CVar.SERVERONLY);
+
+        /// <summary>
+        ///     Minimum amount of air allowed on a spaced tile before it is reset to 0 immediately in kPa
+        ///     Since the decay due to SpacingEscapeRatio follows a curve, it would never reach 0.0 exactly
+        ///     unless we truncate it somewhere.
+        /// </summary>
+        public static readonly CVarDef<float> AtmosSpacingMinGas =
+            CVarDef.Create("atmos.mmos_min_gas", 2.0f, CVar.SERVERONLY);
+
+        /// <summary>
+        ///     How much wind can go through a single tile before that tile doesn't depressurize itself
+        ///     (I.e spacing is limited in large rooms heading into smaller spaces)
+        /// </summary>
+        public static readonly CVarDef<float> AtmosSpacingMaxWind =
+            CVarDef.Create("atmos.mmos_max_wind", 500f, CVar.SERVERONLY);
+
         /// <summary>
         ///     Whether atmos superconduction is enabled.
         /// </summary>