From 88053e86eaeb99e74ed5e2a724a9f97ea3e770fd Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 5 Jul 2022 23:40:30 +1000 Subject: [PATCH] Fix remote piloting rotation (#9439) --- .../Physics/Controllers/MoverController.cs | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/Content.Server/Physics/Controllers/MoverController.cs b/Content.Server/Physics/Controllers/MoverController.cs index d534f547ea..c0b2ad388f 100644 --- a/Content.Server/Physics/Controllers/MoverController.cs +++ b/Content.Server/Physics/Controllers/MoverController.cs @@ -24,7 +24,7 @@ namespace Content.Server.Physics.Controllers /// client namespace. /// private HashSet _excludedMobs = new(); - private Dictionary> _shuttlePilots = new(); + private Dictionary> _shuttlePilots = new(); protected override Filter GetSoundPlayers(EntityUid mover) { @@ -60,7 +60,7 @@ namespace Content.Server.Physics.Controllers private void HandleShuttleMovement(float frameTime) { - var newPilots = new Dictionary>(); + var newPilots = new Dictionary>(); // We just mark off their movement and the shuttle itself does its own movement foreach (var (pilot, mover) in EntityManager.EntityQuery()) @@ -85,11 +85,11 @@ namespace Content.Server.Physics.Controllers if (!newPilots.TryGetValue(shuttleComponent, out var pilots)) { - pilots = new List<(PilotComponent, IMoverComponent)>(); + pilots = new List<(PilotComponent, IMoverComponent, TransformComponent)>(); newPilots[shuttleComponent] = pilots; } - pilots.Add((pilot, mover)); + pilots.Add((pilot, mover, xform)); } // Reset inputs for non-piloted shuttles. @@ -115,21 +115,13 @@ namespace Content.Server.Physics.Controllers switch (shuttle.Mode) { case ShuttleMode.Cruise: - foreach (var (pilot, mover) in pilots) + foreach (var (pilot, mover, consoleXform) in pilots) { - var console = pilot.Console; - - if (console == null) - { - DebugTools.Assert(false); - continue; - } - var sprint = mover.VelocityDir.sprinting; if (sprint.Equals(Vector2.Zero)) continue; - var offsetRotation = EntityManager.GetComponent(console.Owner).LocalRotation; + var offsetRotation = consoleXform.LocalRotation; linearInput += offsetRotation.RotateVec(new Vector2(0f, sprint.Y)); angularInput += sprint.X; @@ -137,21 +129,13 @@ namespace Content.Server.Physics.Controllers break; case ShuttleMode.Strafing: // No angular input possible - foreach (var (pilot, mover) in pilots) + foreach (var (pilot, mover, consoleXform) in pilots) { - var console = pilot.Console; - - if (console == null) - { - DebugTools.Assert(false); - continue; - } - var sprint = mover.VelocityDir.sprinting; if (sprint.Equals(Vector2.Zero)) continue; - var offsetRotation = EntityManager.GetComponent((console).Owner).LocalRotation; + var offsetRotation = consoleXform.LocalRotation; sprint = offsetRotation.RotateVec(sprint); linearInput += sprint;