Avoid unnecessary WorldRotation in mover code

This commit is contained in:
metalgearsloth
2021-11-13 14:14:19 +11:00
parent f7a40c8a2f
commit 6cb05f48d6

View File

@@ -118,6 +118,7 @@ namespace Content.Shared.Movement
{
if (transform.GridID != GridId.Invalid)
mover.LastGridAngle = transform.Parent!.WorldRotation;
transform.WorldRotation = physicsComponent.LinearVelocity.GetDir().ToAngle();
return;
}
@@ -128,7 +129,9 @@ namespace Content.Shared.Movement
// This is relative to the map / grid we're on.
var total = walkDir * mover.CurrentWalkSpeed + sprintDir * mover.CurrentSprintSpeed;
var worldTotal = _relativeMovement ? transform.Parent!.WorldRotation.RotateVec(total) : total;
var parentRotation = transform.Parent!.WorldRotation;
var worldTotal = _relativeMovement ? parentRotation.RotateVec(total) : total;
DebugTools.Assert(MathHelper.CloseToPercent(total.Length, worldTotal.Length));
@@ -138,7 +141,7 @@ namespace Content.Shared.Movement
if (transform.GridID == GridId.Invalid)
worldTotal = mover.LastGridAngle.RotateVec(worldTotal);
else
mover.LastGridAngle = transform.Parent!.WorldRotation;
mover.LastGridAngle = parentRotation;
if (worldTotal != Vector2.Zero)
{