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