fix viewing nav slowing shuttle down (#32381)

fix
This commit is contained in:
Ilya246
2024-11-19 06:59:42 +04:00
committed by GitHub
parent dffece473a
commit 909235cdbe

View File

@@ -314,6 +314,9 @@ public sealed class MoverController : SharedMoverController
var linearInput = Vector2.Zero; var linearInput = Vector2.Zero;
var brakeInput = 0f; var brakeInput = 0f;
var angularInput = 0f; var angularInput = 0f;
var linearCount = 0;
var brakeCount = 0;
var angularCount = 0;
foreach (var (pilotUid, pilot, _, consoleXform) in pilots) foreach (var (pilotUid, pilot, _, consoleXform) in pilots)
{ {
@@ -322,24 +325,27 @@ public sealed class MoverController : SharedMoverController
if (brakes > 0f) if (brakes > 0f)
{ {
brakeInput += brakes; brakeInput += brakes;
brakeCount++;
} }
if (strafe.Length() > 0f) if (strafe.Length() > 0f)
{ {
var offsetRotation = consoleXform.LocalRotation; var offsetRotation = consoleXform.LocalRotation;
linearInput += offsetRotation.RotateVec(strafe); linearInput += offsetRotation.RotateVec(strafe);
linearCount++;
} }
if (rotation != 0f) if (rotation != 0f)
{ {
angularInput += rotation; angularInput += rotation;
angularCount++;
} }
} }
var count = pilots.Count; // Don't slow down the shuttle if there's someone just looking at the console
linearInput /= count; linearInput /= Math.Max(1, linearCount);
angularInput /= count; angularInput /= Math.Max(1, angularCount);
brakeInput /= count; brakeInput /= Math.Max(1, brakeCount);
// Handle shuttle movement // Handle shuttle movement
if (brakeInput > 0f) if (brakeInput > 0f)