Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another Amall Space Wind Optimization #1549

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Content.Server/Atmos/EntitySystems/AtmosphereSystem.CVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public sealed partial class AtmosphereSystem
public bool MonstermosDepressurization { get; private set; }
public bool MonstermosRipTiles { get; private set; }
public float MonstermosRipTilesMinimumPressure { get; private set; }
public float MonstermosRipTilesPressureOffset { get; private set; }
public bool GridImpulse { get; private set; }
public float SpacingEscapeRatio { get; private set; }
public float SpacingMinGas { get; private set; }
Expand Down Expand Up @@ -54,7 +53,6 @@ private void InitializeCVars()
Subs.CVar(_cfg, CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true);
Subs.CVar(_cfg, CCVars.MonstermosRipTiles, value => MonstermosRipTiles = value, true);
Subs.CVar(_cfg, CCVars.MonstermosRipTilesMinimumPressure, value => MonstermosRipTilesMinimumPressure = value, true);
Subs.CVar(_cfg, CCVars.MonstermosRipTilesPressureOffset, value => MonstermosRipTilesPressureOffset = value, true);
Subs.CVar(_cfg, CCVars.AtmosGridImpulse, value => GridImpulse = value, true);
Subs.CVar(_cfg, CCVars.AtmosSpacingEscapeRatio, value => SpacingEscapeRatio = value, true);
Subs.CVar(_cfg, CCVars.AtmosSpacingMinGas, value => SpacingMinGas = value, true);
Expand Down
315 changes: 132 additions & 183 deletions Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,14 @@ private void AdjustEqMovement(TileAtmosphere tile, AtmosDirection direction, flo
adj.MonstermosInfo[idx.ToOppositeDir()] -= amount;
}

private void HandleDecompressionFloorRip(MapGridComponent mapGrid, TileAtmosphere tile, float delta)
private void HandleDecompressionFloorRip(MapGridComponent mapGrid, TileAtmosphere tile, float sum)
{
if (!mapGrid.TryGetTileRef(tile.GridIndices, out var tileRef))
if (!MonstermosRipTiles)
return;
var tileref = tileRef.Tile;

var tileDef = (ContentTileDefinition) _tileDefinitionManager[tileref.TypeId];
if (!tileDef.Reinforced && tileDef.TileRipResistance < delta * MonstermosRipTilesPressureOffset)
var chance = MathHelper.Clamp(0.01f + sum / SpacingMaxWind * 0.3f, 0.003f, 0.3f);

if (sum > 20 && _robustRandom.Prob(chance))
PryTile(mapGrid, tile.GridIndices);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ private bool ProcessExcitedGroups(
return true;
}

private bool ProcessHighPressureDelta(Entity<GridAtmosphereComponent> ent)
private bool ProcessHighPressureDelta(Entity<GridAtmosphereComponent> ent, float frameTime)
{
var atmosphere = ent.Comp;
if (!atmosphere.ProcessingPaused)
Expand All @@ -397,7 +397,7 @@ private bool ProcessHighPressureDelta(Entity<GridAtmosphereComponent> ent)

while (atmosphere.CurrentRunTiles.TryDequeue(out var tile))
{
HighPressureMovements(ent, tile, bodies, xforms, pressureQuery, metas);
HighPressureMovements(ent, tile, bodies, xforms, pressureQuery, metas, frameTime);
tile.PressureDifference = 0f;
tile.LastPressureDirection = tile.PressureDirection;
tile.PressureDirection = AtmosDirection.Invalid;
Expand Down Expand Up @@ -647,7 +647,7 @@ private void UpdateProcessing(float frameTime)
atmosphere.State = AtmosphereProcessingState.HighPressureDelta;
continue;
case AtmosphereProcessingState.HighPressureDelta:
if (!ProcessHighPressureDelta((ent, ent)))
if (!ProcessHighPressureDelta((ent, ent), frameTime))
{
atmosphere.ProcessingPaused = true;
return;
Expand Down
16 changes: 6 additions & 10 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,9 @@ public static readonly CVarDef<bool>
public static readonly CVarDef<bool> SpaceWind =
CVarDef.Create("atmos.space_wind", true, CVar.SERVERONLY);

public static readonly CVarDef<float> SpaceWindStrengthMultiplier =
CVarDef.Create("atmos.space_wind_strength_multiplier", 1f, CVar.SERVERONLY);

/// <summary>
/// Divisor from maxForce (pressureDifference * 2.25f) to force applied on objects.
/// </summary>
Expand Down Expand Up @@ -1396,7 +1399,7 @@ public static readonly CVarDef<bool>
/// And maybe do your part to fix that? :)
/// </remarks>
public static readonly CVarDef<float> SpaceWindMinimumCalculatedMass =
CVarDef.Create("atmos.space_wind_minimum_calculated_mass", 10f, CVar.SERVERONLY);
CVarDef.Create("atmos.space_wind_minimum_calculated_mass", 5f, CVar.SERVERONLY);

/// <summary>
/// Calculated as 1/Mass, where Mass is the physics.Mass of the desired threshold.
Expand Down Expand Up @@ -1433,14 +1436,7 @@ public static readonly CVarDef<bool>
/// This should be set by default to the cube of the game's lowest mass tile as defined in their prototypes, but can be increased for server performance reasons
/// </summary>
public static readonly CVarDef<float> MonstermosRipTilesMinimumPressure =
CVarDef.Create("atmos.monstermos_rip_tiles_min_pressure", 7500f, CVar.SERVERONLY);

/// <summary>
/// Taken after the minimum pressure is checked, the effective pressure is multiplied by this amount.
/// This allows server hosts to finely tune how likely floor tiles are to be ripped apart by air pressure
/// </summary>
public static readonly CVarDef<float> MonstermosRipTilesPressureOffset =
CVarDef.Create("atmos.monstermos_rip_tiles_pressure_offset", 0.44f, CVar.SERVERONLY);
CVarDef.Create("atmos.monstermos_rip_tiles_min_pressure", 20f, CVar.SERVERONLY);

/// <summary>
/// Whether explosive depressurization will cause the grid to gain an impulse.
Expand Down Expand Up @@ -1476,7 +1472,7 @@ public static readonly CVarDef<bool>
/// This solves the problem of objects being trapped in an infinite loop of slamming into a wall repeatedly.
/// </summary>
public static readonly CVarDef<bool> MonstermosUseExpensiveAirflow =
CVarDef.Create("atmos.mmos_expensive_airflow", true, CVar.SERVERONLY);
CVarDef.Create("atmos.mmos_expensive_airflow", false, CVar.SERVERONLY);

/// <summary>
/// Whether atmos superconduction is enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ private void OnItemToggleMapInit(EntityUid uid, ItemToggleDamageOtherOnHitCompon

private void OnDoHit(EntityUid uid, DamageOtherOnHitComponent component, ThrowDoHitEvent args)
{
if (component.HitQuantity >= component.MaxHitQuantity)
if (TerminatingOrDeleted(args.Target)
|| component.HitQuantity >= component.MaxHitQuantity)
return;

var modifiedDamage = _damageable.TryChangeDamage(args.Target, GetDamage(uid, component, args.Component.Thrower),
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Objects/Misc/tiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- type: Item
sprite: Objects/Tiles/tile.rsi
size: Normal
- type: EmbeddableProjectile
- type: DamageOtherOnHit
damage:
types:
Expand Down
Loading
Loading