diff --git a/Tools/Scripts/MapGenerator.cs b/Tools/Scripts/MapGenerator.cs index 9cd2f17..adc69a5 100644 --- a/Tools/Scripts/MapGenerator.cs +++ b/Tools/Scripts/MapGenerator.cs @@ -653,8 +653,8 @@ public partial class MapGenerator : TextureRect Vector2 startPos = highwayNodes[i].Position; Vector2 endPos = highwayNodes[(i + 1) % highwayNodes.Count].Position; - Vector2[] rawPath = astar.GetPointPath( - new Vector2I((int)startPos.X, (int)startPos.Y), + Vector2[] rawPath = FindPath(astar, + new Vector2I((int)startPos.X, (int)startPos.Y), new Vector2I((int)endPos.X, (int)endPos.Y) ); @@ -688,7 +688,7 @@ public partial class MapGenerator : TextureRect } } - Vector2[] bossPath = astar.GetPointPath( + Vector2[] bossPath = FindPath(astar, new Vector2I((int)snowBoss.Position.X, (int)snowBoss.Position.Y), bestPixel ); @@ -744,8 +744,8 @@ public partial class MapGenerator : TextureRect else { // Attempt the connection. (If it freezes here, we know exactly which town caused it!) - countyPath = astar.GetPointPath( - new Vector2I((int)bestUnconnected.Position.X, (int)bestUnconnected.Position.Y), + countyPath = FindPath(astar, + new Vector2I((int)bestUnconnected.Position.X, (int)bestUnconnected.Position.Y), new Vector2I((int)bestConnected.Position.X, (int)bestConnected.Position.Y) ); } @@ -769,6 +769,19 @@ public partial class MapGenerator : TextureRect GD.Print("[A*] Logistics Network Complete!"); } + /// + /// The one place a road path is actually searched for. + /// + /// Every road — highway, branch, county — comes through here, so this is the single + /// seam where pathfinding can be changed without touching any routing decision + /// (which towns connect, in what order, at which tier). Those all live above and + /// only ever deal in town positions. + /// + private Vector2[] FindPath(AStarGrid2D astar, Vector2I from, Vector2I to) + { + return astar.GetPointPath(from, to); + } + private float GetSeaLevel(float t) => Mathf.Lerp(0.26f, 0.15f, Mathf.Clamp(t, 0f, 1f)); private Vector2I FindClosestPixel(Vector2 pos, HashSet set) {