CVar for explosive depressurization tile ripping.

This commit is contained in:
Vera Aguilera Puerto
2021-07-23 13:07:48 +02:00
parent 07c478afb6
commit da25266dd5
8 changed files with 29 additions and 25 deletions

View File

@@ -12,6 +12,7 @@ namespace Content.Server.Atmos.EntitySystems
public string? SpaceWindSound { get; private set; } public string? SpaceWindSound { get; private set; }
public bool MonstermosEqualization { get; private set; } public bool MonstermosEqualization { get; private set; }
public bool MonstermosDepressurization { get; private set; } public bool MonstermosDepressurization { get; private set; }
public bool MonstermosRipTiles { get; private set; }
public bool Superconduction { get; private set; } public bool Superconduction { get; private set; }
public bool ExcitedGroupsSpaceIsAllConsuming { get; private set; } public bool ExcitedGroupsSpaceIsAllConsuming { get; private set; }
public float AtmosMaxProcessTime { get; private set; } public float AtmosMaxProcessTime { get; private set; }
@@ -24,6 +25,7 @@ namespace Content.Server.Atmos.EntitySystems
_cfg.OnValueChanged(CCVars.SpaceWindSound, value => SpaceWindSound = value, true); _cfg.OnValueChanged(CCVars.SpaceWindSound, value => SpaceWindSound = value, true);
_cfg.OnValueChanged(CCVars.MonstermosEqualization, value => MonstermosEqualization = value, true); _cfg.OnValueChanged(CCVars.MonstermosEqualization, value => MonstermosEqualization = value, true);
_cfg.OnValueChanged(CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true); _cfg.OnValueChanged(CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true);
_cfg.OnValueChanged(CCVars.MonstermosRipTiles, value => MonstermosRipTiles = value, true);
_cfg.OnValueChanged(CCVars.Superconduction, value => Superconduction = value, true); _cfg.OnValueChanged(CCVars.Superconduction, value => Superconduction = value, true);
_cfg.OnValueChanged(CCVars.AtmosMaxProcessTime, value => AtmosMaxProcessTime = value, true); _cfg.OnValueChanged(CCVars.AtmosMaxProcessTime, value => AtmosMaxProcessTime = value, true);
_cfg.OnValueChanged(CCVars.AtmosTickRate, value => AtmosTickRate = value, true); _cfg.OnValueChanged(CCVars.AtmosTickRate, value => AtmosTickRate = value, true);

View File

@@ -64,7 +64,7 @@ namespace Content.Server.Atmos.EntitySystems
excitedGroup.DismantleCooldown = 0; excitedGroup.DismantleCooldown = 0;
} }
private void ExcitedGroupSelfBreakdown(GridAtmosphereComponent gridAtmosphere, ExcitedGroup excitedGroup, bool spaceIsAllConsuming = false) private void ExcitedGroupSelfBreakdown(GridAtmosphereComponent gridAtmosphere, ExcitedGroup excitedGroup)
{ {
DebugTools.Assert(!excitedGroup.Disposed, "Excited group is disposed!"); DebugTools.Assert(!excitedGroup.Disposed, "Excited group is disposed!");
DebugTools.Assert(gridAtmosphere.ExcitedGroups.Contains(excitedGroup), "Grid Atmosphere does not contain Excited Group!"); DebugTools.Assert(gridAtmosphere.ExcitedGroups.Contains(excitedGroup), "Grid Atmosphere does not contain Excited Group!");
@@ -87,7 +87,7 @@ namespace Content.Server.Atmos.EntitySystems
Merge(combined, tile.Air); Merge(combined, tile.Air);
if (!spaceIsAllConsuming || !tile.Air.Immutable) if (!ExcitedGroupsSpaceIsAllConsuming || !tile.Air.Immutable)
continue; continue;
combined.Clear(); combined.Clear();

View File

@@ -353,25 +353,12 @@ namespace Content.Server.Atmos.EntitySystems
#region Tile Pry #region Tile Pry
/// <summary>
/// Pries a tile in a grid.
/// </summary>
/// <param name="grid">The grid in question.</param>
/// <param name="tile">The indices of the tile.</param>
public void PryTile(GridId grid, Vector2i tile)
{
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return;
PryTile(mapGrid, tile);
}
/// <summary> /// <summary>
/// Pries a tile in a grid. /// Pries a tile in a grid.
/// </summary> /// </summary>
/// <param name="mapGrid">The grid in question.</param> /// <param name="mapGrid">The grid in question.</param>
/// <param name="tile">The indices of the tile.</param> /// <param name="tile">The indices of the tile.</param>
public void PryTile(IMapGrid mapGrid, Vector2i tile) private void PryTile(IMapGrid mapGrid, Vector2i tile)
{ {
if (!mapGrid.TryGetTileRef(tile, out var tileRef)) if (!mapGrid.TryGetTileRef(tile, out var tileRef))
return; return;

View File

@@ -41,7 +41,7 @@ namespace Content.Server.Atmos.EntitySystems
return; return;
} }
PerformHotspotExposure(gridAtmosphere, tile); PerformHotspotExposure(tile);
if (tile.Hotspot.Bypassing) if (tile.Hotspot.Bypassing)
{ {
@@ -118,7 +118,7 @@ namespace Content.Server.Atmos.EntitySystems
} }
} }
private void PerformHotspotExposure(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile) private void PerformHotspotExposure(TileAtmosphere tile)
{ {
if (tile.Air == null || !tile.Hotspot.Valid) return; if (tile.Air == null || !tile.Hotspot.Valid) return;

View File

@@ -7,7 +7,7 @@ namespace Content.Server.Atmos.EntitySystems
{ {
public partial class AtmosphereSystem public partial class AtmosphereSystem
{ {
private void ProcessCell(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, int fireCount, bool spaceWind = true) private void ProcessCell(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, int fireCount)
{ {
// Can't process a tile without air // Can't process a tile without air
if (tile.Air == null) if (tile.Air == null)
@@ -79,7 +79,7 @@ namespace Content.Server.Atmos.EntitySystems
{ {
var difference = Share(tile.Air!, enemyTile.Air!, adjacentTileLength); var difference = Share(tile.Air!, enemyTile.Air!, adjacentTileLength);
if (spaceWind) if (SpaceWind)
{ {
if (difference > 0) if (difference > 0)
{ {

View File

@@ -554,6 +554,9 @@ namespace Content.Server.Atmos.EntitySystems
private void HandleDecompressionFloorRip(IMapGrid mapGrid, TileAtmosphere tile, float sum) private void HandleDecompressionFloorRip(IMapGrid mapGrid, TileAtmosphere tile, float sum)
{ {
if (!MonstermosRipTiles)
return;
var chance = MathHelper.Clamp(sum / 500, 0.005f, 0.5f); var chance = MathHelper.Clamp(sum / 500, 0.005f, 0.5f);
if (sum > 20 && _robustRandom.Prob(chance)) if (sum > 20 && _robustRandom.Prob(chance))

View File

@@ -64,7 +64,7 @@ namespace Content.Server.Atmos.EntitySystems
var number = 0; var number = 0;
while (atmosphere.CurrentRunTiles.TryDequeue(out var tile)) while (atmosphere.CurrentRunTiles.TryDequeue(out var tile))
{ {
ProcessCell(atmosphere, tile, atmosphere.UpdateCounter, SpaceWind); ProcessCell(atmosphere, tile, atmosphere.UpdateCounter);
if (number++ < LagCheckIterations) continue; if (number++ < LagCheckIterations) continue;
number = 0; number = 0;
@@ -90,7 +90,7 @@ namespace Content.Server.Atmos.EntitySystems
excitedGroup.DismantleCooldown++; excitedGroup.DismantleCooldown++;
if(excitedGroup.BreakdownCooldown > Atmospherics.ExcitedGroupBreakdownCycles) if(excitedGroup.BreakdownCooldown > Atmospherics.ExcitedGroupBreakdownCycles)
ExcitedGroupSelfBreakdown(gridAtmosphere, excitedGroup, ExcitedGroupsSpaceIsAllConsuming); ExcitedGroupSelfBreakdown(gridAtmosphere, excitedGroup);
else if(excitedGroup.DismantleCooldown > Atmospherics.ExcitedGroupsDismantleCycles) else if(excitedGroup.DismantleCooldown > Atmospherics.ExcitedGroupsDismantleCycles)
ExcitedGroupDismantle(gridAtmosphere, excitedGroup); ExcitedGroupDismantle(gridAtmosphere, excitedGroup);

View File

@@ -262,6 +262,13 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<bool> MonstermosDepressurization = public static readonly CVarDef<bool> MonstermosDepressurization =
CVarDef.Create<bool>("atmos.monstermos_depressurization", true, CVar.SERVERONLY); CVarDef.Create<bool>("atmos.monstermos_depressurization", true, CVar.SERVERONLY);
/// <summary>
/// Whether monstermos explosive depressurization will rip tiles..
/// Needs <see cref="MonstermosEqualization"/> and <see cref="MonstermosDepressurization"/> to be enabled to work.
/// </summary>
public static readonly CVarDef<bool> MonstermosRipTiles =
CVarDef.Create<bool>("atmos.monstermos_rip_tiles", true, CVar.SERVERONLY);
/// <summary> /// <summary>
/// Whether atmos superconduction is enabled. /// Whether atmos superconduction is enabled.
/// </summary> /// </summary>
@@ -269,6 +276,14 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<bool> Superconduction = public static readonly CVarDef<bool> Superconduction =
CVarDef.Create("atmos.superconduction", false, CVar.SERVERONLY); CVarDef.Create("atmos.superconduction", false, CVar.SERVERONLY);
/// <summary>
/// Whether all tiles in an excited group will clear themselves once being exposed to space.
/// Similar to <see cref="MonstermosDepressurization"/>, without none of the tile ripping or
/// things being thrown around very violently.
/// </summary>
public static readonly CVarDef<bool> ExcitedGroupsSpaceIsAllConsuming =
CVarDef.Create("atmos.excited_groups_space_is_all_consuming", false, CVar.SERVERONLY);
/// <summary> /// <summary>
/// Maximum time in milliseconds that atmos can take processing. /// Maximum time in milliseconds that atmos can take processing.
/// </summary> /// </summary>
@@ -281,9 +296,6 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<float> AtmosTickRate = public static readonly CVarDef<float> AtmosTickRate =
CVarDef.Create("atmos.tickrate", 26f, CVar.SERVERONLY); CVarDef.Create("atmos.tickrate", 26f, CVar.SERVERONLY);
public static readonly CVarDef<bool> ExcitedGroupsSpaceIsAllConsuming =
CVarDef.Create("atmos.excited_groups_space_is_all_consuming", false, CVar.SERVERONLY);
/* /*
* MIDI instruments * MIDI instruments
*/ */