]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fixes gravity wells (#29617)
authorPlykiya <58439124+Plykiya@users.noreply.github.com>
Mon, 1 Jul 2024 15:39:05 +0000 (08:39 -0700)
committerGitHub <noreply@github.com>
Mon, 1 Jul 2024 15:39:05 +0000 (11:39 -0400)
* Fixes gravity wells

* thank you slarticodefast

* Minor nitpicks addressed

* NITPICKS UNDONE

* REDO THE NITPICK, WE LOVE MATRIX MULTIPLCATION

* Revert "REDO THE NITPICK, WE LOVE MATRIX MULTIPLCATION"

This reverts commit c782eee1a1c7bda90c7ca686928019cc5f25c8cf.

* NITPICK REDO

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
Content.Server/Singularity/EntitySystems/GravityWellSystem.cs

index f53d658ebd7f2a238b10f3070699e9b5eb3949c6..8c884d023c41abbfb53c8ee04f6eeaf8a8782687 100644 (file)
@@ -156,7 +156,7 @@ public sealed class GravityWellSystem : SharedGravityWellSystem
     /// <param name="minRange">The minimum distance at which entities can be affected by the gravity pulse.</param>
     /// <param name="baseMatrixDeltaV">The base velocity added to any entities within affected by the gravity pulse scaled by the displacement of those entities from the epicenter.</param>
     public void GravPulse(EntityCoordinates entityPos, float maxRange, float minRange, in Matrix3x2 baseMatrixDeltaV)
-        => GravPulse(entityPos.ToMap(EntityManager, _transform), maxRange, minRange, in baseMatrixDeltaV);
+        => GravPulse(_transform.ToMapCoordinates(entityPos), maxRange, minRange, in baseMatrixDeltaV);
 
     /// <summary>
     /// Greates a gravitational pulse, shoving around all entities within some distance of an epicenter.
@@ -167,7 +167,7 @@ public sealed class GravityWellSystem : SharedGravityWellSystem
     /// <param name="baseRadialDeltaV">The base radial velocity that will be added to entities within range towards the center of the gravitational pulse.</param>
     /// <param name="baseTangentialDeltaV">The base tangential velocity that will be added to entities within countrclockwise around the center of the gravitational pulse.</param>
     public void GravPulse(EntityCoordinates entityPos, float maxRange, float minRange, float baseRadialDeltaV = 0.0f, float baseTangentialDeltaV = 0.0f)
-        => GravPulse(entityPos.ToMap(EntityManager, _transform), maxRange, minRange, baseRadialDeltaV, baseTangentialDeltaV);
+        => GravPulse(_transform.ToMapCoordinates(entityPos), maxRange, minRange, baseRadialDeltaV, baseTangentialDeltaV);
 
     /// <summary>
     /// Causes a gravitational pulse, shoving around all entities within some distance of an epicenter.
@@ -206,7 +206,7 @@ public sealed class GravityWellSystem : SharedGravityWellSystem
                 continue;
 
             var scaling = (1f / distance2) * physics.Mass; // TODO: Variable falloff gradiants.
-            _physics.ApplyLinearImpulse(entity, Vector2.Transform(displacement, baseMatrixDeltaV) * scaling, body: physics);
+            _physics.ApplyLinearImpulse(entity, Vector2.TransformNormal(displacement, baseMatrixDeltaV) * scaling, body: physics);
         }
     }
 
@@ -219,10 +219,7 @@ public sealed class GravityWellSystem : SharedGravityWellSystem
     /// <param name="baseRadialDeltaV">The base amount of velocity that will be added to entities in range towards the epicenter of the pulse.</param>
     /// <param name="baseTangentialDeltaV">The base amount of velocity that will be added to entities in range counterclockwise relative to the epicenter of the pulse.</param>
     public void GravPulse(MapCoordinates mapPos, float maxRange, float minRange = 0.0f, float baseRadialDeltaV = 0.0f, float baseTangentialDeltaV = 0.0f)
-        => GravPulse(mapPos, maxRange, minRange, new Matrix3x2(
-            baseRadialDeltaV, -baseTangentialDeltaV, 0.0f,
-            +baseTangentialDeltaV, baseRadialDeltaV, 0.0f
-        ));
+        => GravPulse(mapPos, maxRange, minRange, new Matrix3x2(baseRadialDeltaV, -baseTangentialDeltaV, baseTangentialDeltaV, baseRadialDeltaV, 0.0f, 0.0f));
 
     #endregion GravPulse