Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: DEATHB4DEFEAT <[email protected]>
Signed-off-by: VMSolidus <[email protected]>
  • Loading branch information
VMSolidus and DEATHB4DEFEAT authored Jan 20, 2025
1 parent 914d0f0 commit 0653462
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ public void ConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonCompon
if (eventHorizon.InheritMomentum && TryComp<PhysicsComponent>(hungry, out var thisPhysics) && TryComp<PhysicsComponent>(morsel, out var otherPhysics))
{
var impulse = (otherPhysics.LinearVelocity - thisPhysics.LinearVelocity)
* otherPhysics.FixturesMass
* thisPhysics.FixturesMass / (thisPhysics.FixturesMass + otherPhysics.FixturesMass); // accounts for the expected mass change from consuming the object
* otherPhysics.FixturesMass
* thisPhysics.FixturesMass / (thisPhysics.FixturesMass + otherPhysics.FixturesMass); // Accounts for the expected mass change from consuming the object
_physics.ApplyLinearImpulse(hungry, impulse, body: thisPhysics);
}

Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Singularity/EntitySystems/GravityWellSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,19 @@ public void GravPulse(EntityUid uid, out Vector2 appliedImpulse, MapCoordinates
if (!CanGravPulseAffect(entity))
continue;

isStatic |= TryComp<MovedByPressureComponent>(entity, out var movedPressure) && !movedPressure.Enabled; //Treat magboots users as static
isStatic |= TryComp<MovedByPressureComponent>(entity, out var movedPressure) && !movedPressure.Enabled; // Treat magboots users as static

var displacement = epicenter - _transform.GetWorldPosition(entity, xformQuery);
var distance2 = displacement.LengthSquared();
if (distance2 < minRange2)
continue;

var scaling = (1f / distance2) * physics.FixturesMass; // TODO: Variable falloff gradiants.
var scaling = (1f / distance2) * physics.FixturesMass; // TODO: Variable falloff gradients
if (isStatic)
scaling *= staticImpulse ?? 1f;

var impulse = Vector2.Transform(displacement, baseMatrixDeltaV) * scaling;
if (!isStatic) // impulse shouldn't be applied to static entities
if (!isStatic) // Impulse shouldn't be applied to static entities
_physics.ApplyLinearImpulse(entity, impulse, body: physics);

appliedImpulse += impulse;
Expand Down

0 comments on commit 0653462

Please sign in to comment.