Update content vectors to numerics (#17759)

This commit is contained in:
metalgearsloth
2023-07-08 14:08:32 +10:00
committed by GitHub
parent 15772478c9
commit 68480af109
383 changed files with 978 additions and 575 deletions

View File

@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Server.Cargo.Components;
using Content.Server.Shuttle.Components;
using Content.Server.Shuttles.Components;
@@ -309,7 +310,7 @@ namespace Content.Server.Physics.Controllers
brakeInput += pilotInput.Brakes;
}
if (pilotInput.Strafe.Length > 0f)
if (pilotInput.Strafe.Length() > 0f)
{
var offsetRotation = consoleXform.LocalRotation;
linearInput += offsetRotation.RotateVec(pilotInput.Strafe);
@@ -329,7 +330,7 @@ namespace Content.Server.Physics.Controllers
// Handle shuttle movement
if (brakeInput > 0f)
{
if (body.LinearVelocity.Length > 0f)
if (body.LinearVelocity.Length() > 0f)
{
// Minimum brake velocity for a direction to show its thrust appearance.
const float appearanceThreshold = 0.1f;
@@ -383,11 +384,11 @@ namespace Content.Server.Physics.Controllers
var impulse = force * brakeInput * ShuttleComponent.BrakeCoefficient;
impulse = shuttleNorthAngle.RotateVec(impulse);
var forceMul = frameTime * body.InvMass;
var maxVelocity = (-body.LinearVelocity).Length / forceMul;
var maxVelocity = (-body.LinearVelocity).Length() / forceMul;
// Don't overshoot
if (impulse.Length > maxVelocity)
impulse = impulse.Normalized * maxVelocity;
if (impulse.Length() > maxVelocity)
impulse = impulse.Normalized() * maxVelocity;
PhysicsSystem.ApplyForce(shuttle.Owner, impulse, body: body);
}
@@ -422,7 +423,7 @@ namespace Content.Server.Physics.Controllers
}
}
if (linearInput.Length.Equals(0f))
if (linearInput.Length().Equals(0f))
{
PhysicsSystem.SetSleepingAllowed(shuttle.Owner, body, true);
@@ -481,20 +482,20 @@ namespace Content.Server.Physics.Controllers
}
_thruster.EnableLinearThrustDirection(shuttle, dir);
var impulse = force * linearInput.Length;
var impulse = force * linearInput.Length();
totalForce += impulse;
}
totalForce = shuttleNorthAngle.RotateVec(totalForce);
var forceMul = frameTime * body.InvMass;
var maxVelocity = (ShuttleComponent.MaxLinearVelocity - body.LinearVelocity.Length) / forceMul;
var maxVelocity = (ShuttleComponent.MaxLinearVelocity - body.LinearVelocity.Length()) / forceMul;
if (maxVelocity != 0f)
{
// Don't overshoot
if (totalForce.Length > maxVelocity)
totalForce = totalForce.Normalized * maxVelocity;
if (totalForce.Length() > maxVelocity)
totalForce = totalForce.Normalized() * maxVelocity;
PhysicsSystem.ApplyForce(shuttle.Owner, totalForce, body: body);
}