Skip to content

Commit

Permalink
Merge branch 'master' into erm.-shadowkin-fuckery
Browse files Browse the repository at this point in the history
  • Loading branch information
SixplyDev authored Jan 15, 2025
2 parents c943670 + 6584a62 commit 7b102bf
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,18 @@ private void HighPressureMovements(Entity<GridAtmosphereComponent> gridAtmospher
// Used by ExperiencePressureDifference to correct push/throw directions from tile-relative to physics world.
var gridWorldRotation = _transformSystem.GetWorldRotation(gridAtmosphere);

// Atmos Directions only include NSEW cardinals, which means only 4 possible angles to throw at. If Monstermos is enabled, we'll instead do some
// Vector shennanigans to smooth it out so that we can throw in increments of up to pi/32.
var throwDirection = tile.PressureDirection.ToAngle().ToVec();
// If we're using monstermos, smooth out the yeet direction to follow the flow
if (MonstermosEqualization)
foreach (var nextTile in tile.AdjacentTiles)
if (nextTile is not null && nextTile.PressureDirection is not AtmosDirection.Invalid)
throwDirection += nextTile.PressureDirection.ToAngle().ToVec();

// Before you ask, yes I did actually have to convert the angles to vectors, then add them together, then convert the end result back to a normalized vector.
// We're normalizing this here and now so that we don't have to normalize it potentially hundreds of times during the next Foreach.
var throwVector = (throwDirection.ToAngle() + gridWorldRotation).ToWorldVec().Normalized();

_entSet.Clear();
_lookup.GetLocalEntitiesIntersecting(tile.GridIndex, tile.GridIndices, _entSet, 0f);

Expand All @@ -131,8 +136,7 @@ private void HighPressureMovements(Entity<GridAtmosphereComponent> gridAtmospher
(entity, EnsureComp<MovedByPressureComponent>(entity)),
gridAtmosphere.Comp.UpdateCounter,
differentiatedPressure,
throwDirection,
gridWorldRotation,
throwVector,
xforms.GetComponent(entity),
body);
}
Expand All @@ -154,8 +158,7 @@ public void ExperiencePressureDifference(
Entity<MovedByPressureComponent> ent,
int cycle,
float pressureDifference,
Vector2 direction,
Angle gridWorldRotation,
Vector2 throwVector,
TransformComponent? xform = null,
PhysicsComponent? physics = null)
{
Expand All @@ -171,11 +174,9 @@ public void ExperiencePressureDifference(
if (pressureDifference < physics.Mass)
return;

// Grid-rotation adjusted direction
var dirVec = (direction.ToAngle() + gridWorldRotation).ToWorldVec();
pressureDifference *= MathF.Max(physics.InvMass, SpaceWindMaximumCalculatedInverseMass);

_throwing.TryThrow(uid, dirVec.Normalized() * MathF.Min(pressureDifference, SpaceWindMaxVelocity), pressureDifference);
_throwing.TryThrow(uid, throwVector * MathF.Min(pressureDifference, SpaceWindMaxVelocity), pressureDifference);
component.LastHighPressureMovementAirCycle = cycle;
}
}

0 comments on commit 7b102bf

Please sign in to comment.