Make slow spacing variables CCVars (#19862)

This commit is contained in:
Kevin Zheng
2023-09-13 19:38:56 -08:00
committed by GitHub
parent 383935a1d2
commit a622844a5f
4 changed files with 43 additions and 33 deletions

View 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);

View 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)
var sum = otherTile.Air.TotalMoles;
if (SpacingEscapeRatio < 1f)
{
// 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)
{
// 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);

View 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
}

View 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>