diff --git a/Content.Server/NPC/Components/NPCSteeringComponent.cs b/Content.Server/NPC/Components/NPCSteeringComponent.cs
index a86d9ecd12..34b4e7b79b 100644
--- a/Content.Server/NPC/Components/NPCSteeringComponent.cs
+++ b/Content.Server/NPC/Components/NPCSteeringComponent.cs
@@ -44,8 +44,10 @@ public sealed class NPCSteeringComponent : Component
///
/// Last time the NPC steered.
///
+ [ViewVariables]
public TimeSpan LastTimeSteer;
+ [ViewVariables]
public Vector2 LastSteer;
///
diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs
index 7b3692cfae..dcedd6b19b 100644
--- a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs
+++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs
@@ -50,6 +50,7 @@ namespace Content.Server.NPC.Pathfinding
private readonly Dictionary _subscribedSessions = new();
+ [ViewVariables]
private readonly List _pathRequests = new(PathTickLimit);
private static readonly TimeSpan PathTime = TimeSpan.FromMilliseconds(3);
diff --git a/Content.Server/NPC/Systems/NPCSteeringSystem.cs b/Content.Server/NPC/Systems/NPCSteeringSystem.cs
index 6423d026f3..3080ae28e6 100644
--- a/Content.Server/NPC/Systems/NPCSteeringSystem.cs
+++ b/Content.Server/NPC/Systems/NPCSteeringSystem.cs
@@ -134,6 +134,7 @@ namespace Content.Server.NPC.Systems
{
// Cancel any active pathfinding jobs as they're irrelevant.
component.PathfindToken?.Cancel();
+ component.PathfindToken = null;
}
///
@@ -203,18 +204,12 @@ namespace Content.Server.NPC.Systems
var npcs = EntityQuery()
.ToArray();
- var options = new ParallelOptions
- {
- MaxDegreeOfParallelism = _parallel.ParallelProcessCount,
- };
- Parallel.For(0, npcs.Length, options, i =>
+ foreach (var (steering, _, mover, xform) in npcs)
{
- var (steering, _, mover, xform) = npcs[i];
-
Steer(steering, mover, xform, modifierQuery, bodyQuery, xformQuery, frameTime);
steering.LastSteer = mover.CurTickSprintMovement;
- });
+ }
if (_subscribedSessions.Count > 0)
{
@@ -261,8 +256,6 @@ namespace Content.Server.NPC.Systems
EntityQuery xformQuery,
float frameTime)
{
- IoCManager.InitThread(_dependencies, replaceExisting: true);
-
if (Deleted(steering.Coordinates.EntityId))
{
SetDirection(mover, steering, Vector2.Zero);
@@ -400,10 +393,11 @@ namespace Content.Server.NPC.Systems
steering.PathfindToken.Token,
flags);
+ steering.PathfindToken = null;
+
if (result.Result == PathResult.NoPath)
{
steering.CurrentPath.Clear();
- steering.PathfindToken = null;
steering.FailedPathCount++;
if (steering.FailedPathCount >= NPCSteeringComponent.FailedPathLimit)
@@ -419,7 +413,6 @@ namespace Content.Server.NPC.Systems
PrunePath(ourPos, targetPos.Position - ourPos.Position, result.Path);
steering.CurrentPath = result.Path;
- steering.PathfindToken = null;
}
// TODO: Move these to movercontroller