Pathfinder parallel change (#18736)

This commit is contained in:
metalgearsloth
2023-08-06 14:41:57 +10:00
committed by GitHub
parent 1d0160d158
commit cc5d83fe21
3 changed files with 11 additions and 11 deletions

View File

@@ -85,12 +85,18 @@ namespace Content.Server.NPC.Pathfinding
public override void Update(float frameTime)
{
base.Update(frameTime);
UpdateGrid();
var options = new ParallelOptions()
{
MaxDegreeOfParallelism = _parallel.ParallelProcessCount,
};
UpdateGrid(options);
_stopwatch.Restart();
var amount = Math.Min(PathTickLimit, _pathRequests.Count);
var results = ArrayPool<PathResult>.Shared.Rent(amount);
Parallel.For(0, amount, i =>
Parallel.For(0, amount, options, i =>
{
// If we're over the limit (either time-sliced or hard cap).
if (_stopwatch.Elapsed >= PathTime)