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

Atmos high pressure movements cleanup #8075

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ private void HighPressureMovements(GridAtmosphereComponent gridAtmosphere, TileA
}
}


if (tile.PressureDifference > 100)
{
// TODO ATMOS Do space wind graphics here!
}

if (_spaceWindSoundCooldown++ > SpaceWindSoundCooldownCycles)
_spaceWindSoundCooldown = 0;

// No atmos yeets, return early.
if (!SpaceWind)
return;

// Used by ExperiencePressureDifference to correct push/throw directions from tile-relative to physics world.
var gridWorldRotation = xforms.GetComponent(gridAtmosphere.Owner).WorldRotation;

Expand Down Expand Up @@ -134,25 +147,18 @@ private void HighPressureMovements(GridAtmosphereComponent gridAtmosphere, TileA
}

}

if (tile.PressureDifference > 100)
{
// TODO ATMOS Do space wind graphics here!
}

if (_spaceWindSoundCooldown++ > SpaceWindSoundCooldownCycles)
_spaceWindSoundCooldown = 0;
}

// Called from AtmosphereSystem.LINDA.cs with SpaceWind CVar check handled there.
private void ConsiderPressureDifference(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, TileAtmosphere other, float difference)
private void ConsiderPressureDifference(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, AtmosDirection differenceDirection, float difference)
{
gridAtmosphere.HighPressureDelta.Add(tile);
if (difference > tile.PressureDifference)
{
tile.PressureDifference = difference;
tile.PressureDirection = (tile.GridIndices - other.GridIndices).GetDir().ToAtmosDirection();
}

if (difference <= tile.PressureDifference)
return;

tile.PressureDifference = difference;
tile.PressureDirection = differenceDirection;
}

public void ExperiencePressureDifference(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,16 @@ private void ProcessCell(GridAtmosphereComponent gridAtmosphere, TileAtmosphere
{
var difference = Share(tile.Air!, enemyTile.Air!, adjacentTileLength);

if (SpaceWind)
// Monstermos already handles this, so let's not handle it ourselves.
if (!MonstermosEqualization)
{
if (difference > 0)
if (difference >= 0)
{
ConsiderPressureDifference(gridAtmosphere, tile, enemyTile, difference);
ConsiderPressureDifference(gridAtmosphere, tile, direction, difference);
}
else
{
ConsiderPressureDifference(gridAtmosphere, enemyTile, tile, -difference);
ConsiderPressureDifference(gridAtmosphere, enemyTile, direction.GetOpposite(), -difference);
}
}

Expand Down
23 changes: 11 additions & 12 deletions Content.Server/Atmos/EntitySystems/AtmosphereSystem.Monstermos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -547,18 +547,17 @@ private void FinalizeEq(GridAtmosphereComponent gridAtmosphere, TileAtmosphere t
var amount = transferDirections[i];
var otherTile = tile.AdjacentTiles[i];
if (otherTile?.Air == null) continue;
if (amount > 0)
{
// Everything that calls this method already ensures that Air will not be null.
if (tile.Air!.TotalMoles < amount)
FinalizeEqNeighbors(gridAtmosphere, tile, transferDirections);

otherTile.MonstermosInfo[direction.GetOpposite()] = 0;
Merge(otherTile.Air, tile.Air.Remove(amount));
InvalidateVisuals(tile.GridIndex, tile.GridIndices);
InvalidateVisuals(otherTile.GridIndex, otherTile.GridIndices);
ConsiderPressureDifference(gridAtmosphere, tile, otherTile, amount);
}
if (amount <= 0) continue;

// Everything that calls this method already ensures that Air will not be null.
if (tile.Air!.TotalMoles < amount)
FinalizeEqNeighbors(gridAtmosphere, tile, transferDirections);

otherTile.MonstermosInfo[direction.GetOpposite()] = 0;
Merge(otherTile.Air, tile.Air.Remove(amount));
InvalidateVisuals(tile.GridIndex, tile.GridIndices);
InvalidateVisuals(otherTile.GridIndex, otherTile.GridIndices);
ConsiderPressureDifference(gridAtmosphere, tile, direction, amount);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ private bool ProcessHighPressureDelta(GridAtmosphereComponent atmosphere)
if(!atmosphere.ProcessingPaused)
atmosphere.CurrentRunTiles = new Queue<TileAtmosphere>(atmosphere.HighPressureDelta);

// Note: This is still processed even if space wind is turned off since this handles playing the sounds.

var number = 0;
var bodies = EntityManager.GetEntityQuery<PhysicsComponent>();
var xforms = EntityManager.GetEntityQuery<TransformComponent>();
Expand Down