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

New high pressure movement algorithm #8086

Merged
merged 1 commit into from
May 10, 2022
Merged
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 @@ -120,6 +120,25 @@ private void HighPressureMovements(GridAtmosphereComponent gridAtmosphere, TileA
// Used by ExperiencePressureDifference to correct push/throw directions from tile-relative to physics world.
var gridWorldRotation = xforms.GetComponent(gridAtmosphere.Owner).WorldRotation;

// If we're using monstermos, smooth out the yeet direction to follow the flow
if (MonstermosEqualization)
{
// We step through tiles according to the pressure direction on the current tile.
// The goal is to get a general direction of the airflow in the area.
// 3 is the magic number - enough to go around corners, but not U-turns.
var curTile = tile!;
for (var i = 0; i < 3; i++)
{
if (curTile.PressureDirection == AtmosDirection.Invalid
|| !curTile.AdjacentBits.IsFlagSet(curTile.PressureDirection))
break;
curTile = curTile.AdjacentTiles[curTile.PressureDirection.ToIndex()]!;
}

if (curTile != tile)
tile.PressureSpecificTarget = curTile;
}

foreach (var entity in _lookup.GetEntitiesIntersecting(tile.GridIndex, tile.GridIndices))
{
// Ideally containers would have their own EntityQuery internally or something given recursively it may need to slam GetComp<T> anyway.
Expand Down