From 6cb05f48d67723c631739ca2f59db0692bc6d459 Mon Sep 17 00:00:00 2001 From: metalgearsloth Date: Sat, 13 Nov 2021 14:14:19 +1100 Subject: [PATCH] Avoid unnecessary WorldRotation in mover code --- Content.Shared/Movement/SharedMoverController.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Movement/SharedMoverController.cs b/Content.Shared/Movement/SharedMoverController.cs index acfde3f0b8..735d5ff559 100644 --- a/Content.Shared/Movement/SharedMoverController.cs +++ b/Content.Shared/Movement/SharedMoverController.cs @@ -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) {