Remove pathfinding graph node directions (#1223)

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2020-06-29 01:43:06 +10:00
committed by GitHub
parent 24831bf8a0
commit 29f1730d71
7 changed files with 462 additions and 372 deletions

View File

@@ -167,32 +167,11 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
{
var newChunk = new PathfindingChunk(gridId, indices);
newChunk.Initialize();
if (_graph.TryGetValue(gridId, out var chunks))
{
for (var x = -1; x < 2; x++)
{
for (var y = -1; y < 2; y++)
{
if (x == 0 && y == 0) continue;
var neighborIndices = new MapIndices(
indices.X + x * PathfindingChunk.ChunkSize,
indices.Y + y * PathfindingChunk.ChunkSize);
if (chunks.TryGetValue(neighborIndices, out var neighborChunk))
{
neighborChunk.AddNeighbor(newChunk);
}
}
}
}
else
if (!_graph.ContainsKey(gridId))
{
_graph.Add(gridId, new Dictionary<MapIndices, PathfindingChunk>());
}
_graph[gridId].Add(indices, newChunk);
return newChunk;
}