GridPathfindingChunk.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using Content.Shared.NPC;
  2. namespace Content.Server.NPC.Pathfinding;
  3. public sealed class GridPathfindingChunk
  4. {
  5. // TODO: Make this a 1d array
  6. [ViewVariables]
  7. public readonly PathfindingBreadcrumb[,] Points = new PathfindingBreadcrumb[
  8. (SharedPathfindingSystem.ChunkSize) * SharedPathfindingSystem.SubStep,
  9. (SharedPathfindingSystem.ChunkSize) * SharedPathfindingSystem.SubStep];
  10. [ViewVariables]
  11. public Vector2i Origin;
  12. [ViewVariables]
  13. public readonly List<PathPoly>[] Polygons = new List<PathPoly>[SharedPathfindingSystem.ChunkSize * SharedPathfindingSystem.ChunkSize];
  14. /// <summary>
  15. /// Store the recalculated polygons to know what needs changing.
  16. /// </summary>
  17. internal readonly List<PathPoly>[] BufferPolygons = new List<PathPoly>[SharedPathfindingSystem.ChunkSize * SharedPathfindingSystem.ChunkSize];
  18. /// <summary>
  19. /// The relevant polygon for this chunk's portals
  20. /// </summary>
  21. [ViewVariables]
  22. public readonly Dictionary<PathPortal, PathPoly> PortalPolys = new();
  23. /// <summary>
  24. /// This chunk's portals.
  25. /// </summary>
  26. [ViewVariables]
  27. public readonly List<PathPortal> Portals = new();
  28. public GridPathfindingChunk()
  29. {
  30. for (var x = 0; x < Polygons.Length; x++)
  31. {
  32. Polygons[x] = new List<PathPoly>();
  33. BufferPolygons[x] = new List<PathPoly>();
  34. }
  35. }
  36. }