From: Kevin Zheng Date: Thu, 14 Sep 2023 03:38:56 +0000 (-0800) Subject: Make slow spacing variables CCVars (#19862) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=a622844a5f638743a5988e18887bee5a7188ad78;p=space-station-14.git Make slow spacing variables CCVars (#19862) --- diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.CVars.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.CVars.cs index 4954f3e237..60e215204d 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.CVars.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.CVars.cs @@ -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); diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Monstermos.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Monstermos.cs index 46aa73eccd..c7191b2779 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Monstermos.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Monstermos.cs @@ -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); diff --git a/Content.Shared/Atmos/Atmospherics.cs b/Content.Shared/Atmos/Atmospherics.cs index e0cea00151..13603eb6c8 100644 --- a/Content.Shared/Atmos/Atmospherics.cs +++ b/Content.Shared/Atmos/Atmospherics.cs @@ -309,25 +309,6 @@ namespace Content.Shared.Atmos /// public const float MaxTransferRate = 200; - /// - /// 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 - /// - public const float SpacingEscapeRatio = 0.05f; - - /// - /// 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. - /// - public const float SpacingMinGas = 2.0f; - - /// - /// 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) - /// - public const float SpacingMaxWind = 500.0f; - #endregion } diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 34294ebcbd..19464a4fc3 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -959,6 +959,28 @@ namespace Content.Shared.CCVar public static readonly CVarDef AtmosGridImpulse = CVarDef.Create("atmos.grid_impulse", false, CVar.SERVERONLY); + /// + /// 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 + /// + public static readonly CVarDef AtmosSpacingEscapeRatio = + CVarDef.Create("atmos.mmos_spacing_speed", 0.05f, CVar.SERVERONLY); + + /// + /// 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. + /// + public static readonly CVarDef AtmosSpacingMinGas = + CVarDef.Create("atmos.mmos_min_gas", 2.0f, CVar.SERVERONLY); + + /// + /// 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) + /// + public static readonly CVarDef AtmosSpacingMaxWind = + CVarDef.Create("atmos.mmos_max_wind", 500f, CVar.SERVERONLY); + /// /// Whether atmos superconduction is enabled. ///