Update content vectors to numerics (#17759)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Administration.Managers;
|
||||
using Content.Shared.Ghost;
|
||||
using Content.Shared.Input;
|
||||
@@ -113,7 +114,7 @@ public abstract class SharedContentEyeSystem : EntitySystem
|
||||
{
|
||||
var diff = content.TargetZoom - eye.Zoom;
|
||||
|
||||
if (diff.LengthSquared < 0.00001f)
|
||||
if (diff.LengthSquared() < 0.00001f)
|
||||
{
|
||||
eye.Zoom = content.TargetZoom;
|
||||
Dirty(eye);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Follower.Components;
|
||||
using Content.Shared.Input;
|
||||
@@ -475,10 +476,10 @@ namespace Content.Shared.Movement.Systems
|
||||
var vec = new Vector2(x, y);
|
||||
|
||||
// can't normalize zero length vector
|
||||
if (vec.LengthSquared > 1.0e-6)
|
||||
if (vec.LengthSquared() > 1.0e-6)
|
||||
{
|
||||
// Normalize so that diagonals aren't faster or something.
|
||||
vec = vec.Normalized;
|
||||
vec = vec.Normalized();
|
||||
}
|
||||
|
||||
return vec;
|
||||
|
||||
@@ -16,6 +16,7 @@ using Robust.Shared.Physics.Controllers;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
@@ -180,7 +181,7 @@ namespace Content.Shared.Movement.Systems
|
||||
var parentRotation = GetParentGridAngle(mover, xformQuery);
|
||||
var worldTotal = _relativeMovement ? parentRotation.RotateVec(total) : total;
|
||||
|
||||
DebugTools.Assert(MathHelper.CloseToPercent(total.Length, worldTotal.Length));
|
||||
DebugTools.Assert(MathHelper.CloseToPercent(total.Length(), worldTotal.Length()));
|
||||
|
||||
var velocity = physicsComponent.LinearVelocity;
|
||||
float friction;
|
||||
@@ -289,7 +290,7 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
private void Friction(float minimumFrictionSpeed, float frameTime, float friction, ref Vector2 velocity)
|
||||
{
|
||||
var speed = velocity.Length;
|
||||
var speed = velocity.Length();
|
||||
|
||||
if (speed < minimumFrictionSpeed)
|
||||
return;
|
||||
@@ -310,8 +311,8 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
private void Accelerate(ref Vector2 currentVelocity, in Vector2 velocity, float accel, float frameTime)
|
||||
{
|
||||
var wishDir = velocity != Vector2.Zero ? velocity.Normalized : Vector2.Zero;
|
||||
var wishSpeed = velocity.Length;
|
||||
var wishDir = velocity != Vector2.Zero ? velocity.Normalized() : Vector2.Zero;
|
||||
var wishSpeed = velocity.Length();
|
||||
|
||||
var currentSpeed = Vector2.Dot(currentVelocity, wishDir);
|
||||
var addSpeed = wishSpeed - currentSpeed;
|
||||
|
||||
Reference in New Issue
Block a user