Update content vectors to numerics (#17759)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Examine;
|
||||
using Content.Server.NPC.Components;
|
||||
using Content.Server.NPC.Pathfinding;
|
||||
@@ -113,7 +114,7 @@ public sealed partial class NPCSteeringSystem
|
||||
var direction = targetMap.Position - ourMap.Position;
|
||||
|
||||
// Are we in range
|
||||
if (direction.Length <= arrivalDistance)
|
||||
if (direction.Length() <= arrivalDistance)
|
||||
{
|
||||
// Node needs some kind of special handling like access or smashing.
|
||||
if (steering.CurrentPath.TryPeek(out var node) && !node.Data.IsFreeSpace)
|
||||
@@ -126,7 +127,7 @@ public sealed partial class NPCSteeringSystem
|
||||
lock (_obstacles)
|
||||
{
|
||||
// We're still coming to a stop so wait for the do_after.
|
||||
if (body.LinearVelocity.LengthSquared > 0.01f)
|
||||
if (body.LinearVelocity.LengthSquared() > 0.01f)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -231,21 +232,21 @@ public sealed partial class NPCSteeringSystem
|
||||
return false;
|
||||
}
|
||||
|
||||
var input = direction.Normalized;
|
||||
var input = direction.Normalized();
|
||||
var tickMovement = moveSpeed * frameTime;
|
||||
|
||||
// We have the input in world terms but need to convert it back to what movercontroller is doing.
|
||||
input = offsetRot.RotateVec(input);
|
||||
var norm = input.Normalized;
|
||||
var weight = MapValue(direction.Length, tickMovement * 0.5f, tickMovement * 0.75f);
|
||||
var norm = input.Normalized();
|
||||
var weight = MapValue(direction.Length(), tickMovement * 0.5f, tickMovement * 0.75f);
|
||||
|
||||
ApplySeek(interest, norm, weight);
|
||||
|
||||
// Prefer our current direction
|
||||
if (weight > 0f && body.LinearVelocity.LengthSquared > 0f)
|
||||
if (weight > 0f && body.LinearVelocity.LengthSquared() > 0f)
|
||||
{
|
||||
const float sameDirectionWeight = 0.1f;
|
||||
norm = body.LinearVelocity.Normalized;
|
||||
norm = body.LinearVelocity.Normalized();
|
||||
|
||||
ApplySeek(interest, norm, sameDirectionWeight);
|
||||
}
|
||||
@@ -310,7 +311,7 @@ public sealed partial class NPCSteeringSystem
|
||||
// Then don't consider pruning.
|
||||
var goal = nodes.Last().Coordinates.ToMap(EntityManager, _transform);
|
||||
var canPrune =
|
||||
_interaction.InRangeUnobstructed(mapCoordinates, goal, (goal.Position - mapCoordinates.Position).Length + 0.1f, mask);
|
||||
_interaction.InRangeUnobstructed(mapCoordinates, goal, (goal.Position - mapCoordinates.Position).Length() + 0.1f, mask);
|
||||
|
||||
while (nodes.TryPeek(out var node))
|
||||
{
|
||||
@@ -424,7 +425,7 @@ public sealed partial class NPCSteeringSystem
|
||||
continue;
|
||||
|
||||
obstacleDirection = offsetRot.RotateVec(obstacleDirection);
|
||||
var norm = obstacleDirection.Normalized;
|
||||
var norm = obstacleDirection.Normalized();
|
||||
|
||||
for (var i = 0; i < InterestDirections; i++)
|
||||
{
|
||||
@@ -506,7 +507,7 @@ public sealed partial class NPCSteeringSystem
|
||||
}
|
||||
|
||||
obstacleDirection = offsetRot.RotateVec(obstacleDirection);
|
||||
var norm = obstacleDirection.Normalized;
|
||||
var norm = obstacleDirection.Normalized();
|
||||
weight *= 0.25f;
|
||||
|
||||
for (var i = 0; i < InterestDirections; i++)
|
||||
|
||||
Reference in New Issue
Block a user