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,4 +1,5 @@
using Content.Shared.Gravity;
using System.Numerics;
using Content.Shared.Gravity;
using Content.Shared.Pulling;
using Content.Shared.Pulling.Components;
using Content.Shared.Rotatable;
@@ -72,7 +73,7 @@ namespace Content.Server.Physics.Controllers
UpdatePulledRotation(uid, pullable);
if (args.NewPosition.EntityId == args.OldPosition.EntityId &&
(args.NewPosition.Position - args.OldPosition.Position).LengthSquared < MinimumMovementDistance * MinimumMovementDistance)
(args.NewPosition.Position - args.OldPosition.Position).LengthSquared() < MinimumMovementDistance * MinimumMovementDistance)
return;
if (TryComp<PhysicsComponent>(pullable, out var physics))
@@ -98,7 +99,7 @@ namespace Content.Server.Physics.Controllers
var pulledData = TransformSystem.GetWorldPositionRotation(pulledXform, xforms);
var dir = pullerData.WorldPosition - pulledData.WorldPosition;
if (dir.LengthSquared > ThresholdRotDistance * ThresholdRotDistance)
if (dir.LengthSquared() > ThresholdRotDistance * ThresholdRotDistance)
{
var oldAngle = pulledData.WorldRotation;
var newAngle = Angle.FromWorldVec(dir);
@@ -163,9 +164,9 @@ namespace Content.Server.Physics.Controllers
var ownerPosition = pullableXform.MapPosition.Position;
var diff = movingPosition - ownerPosition;
var diffLength = diff.Length;
var diffLength = diff.Length();
if (diffLength < MaximumSettleDistance && physics.LinearVelocity.Length < MaximumSettleVelocity)
if (diffLength < MaximumSettleDistance && physics.LinearVelocity.Length() < MaximumSettleVelocity)
{
PhysicsSystem.SetLinearVelocity(pullableEnt, Vector2.Zero, body: physics);
_pullableSystem.StopMoveTo(pullable);
@@ -176,9 +177,9 @@ namespace Content.Server.Physics.Controllers
var impulseModifier = MathHelper.Lerp(AccelModifierLow, AccelModifierHigh, impulseModifierLerp);
var multiplier = diffLength < 1 ? impulseModifier * diffLength : impulseModifier;
// Note the implication that the real rules of physics don't apply to pulling control.
var accel = diff.Normalized * multiplier;
var accel = diff.Normalized() * multiplier;
// Now for the part where velocity gets shutdown...
if (diffLength < SettleShutdownDistance && physics.LinearVelocity.Length >= SettleMinimumShutdownVelocity)
if (diffLength < SettleShutdownDistance && physics.LinearVelocity.Length() >= SettleMinimumShutdownVelocity)
{
// Shutdown velocity increases as we get closer to centre
var scaling = (SettleShutdownDistance - diffLength) / SettleShutdownDistance;