World Map Strategy Kit · Scripting Support (C#)
WMSK (namespace WorldMapStrategyKit)
Methods and properties for the built-in pathfinding system.
bool enablePathFindingSystem { get; set; }Enable or disable the pathfinding engine. Must be enabled before using FindRoute methods.
HeuristicFormula pathFindingHeuristicFormula { get; set; }Heuristic formula used for path calculations (Manhattan, Euclidean, DiagonalShortCut, etc.).
float pathFindingMaxCost { get; set; }Maximum accumulated cost for pathfinding search. Higher values allow longer paths but may be slower.
bool pathFindingEnableCustomRouteMatrix { get; set; }Enable a custom cost matrix for pathfinding (allows per-cell cost control).
float[] pathFindingCustomRouteMatrix { get; set; }Custom traversal cost array. Values > 0 define movement cost; 0 means blocked. Array length must match total grid cells.
int pathFindingMaxStepsThe maximum number of steps for any path.
bool pathFindingVisualizeMatrixCostSwitches the map texture with a texture with the matrix costs colors
Texture2D pathFindingLandMapLand map for path finding purposes.
Texture2D pathFindingWaterMapWatermap for path finding purposes.
CellCosts[] pathFindingCustomCellCostsReturns a copy of the current cells cost array or set it.
List<Vector2> FindRoute(Vector2 startPosition, Vector2 endPosition, TERRAIN_CAPABILITY terrainCapability = Any, float minAlt = 0, float maxAlt = 1f, float maxSearchCost = -1, int maxSearchSteps = -1)Returns an optimal route between two map positions as a list of Vector2 waypoints, or null if no path is found.
List<Vector2> FindRoute(Vector2 startPosition, Vector2 endPosition, out float totalCost, TERRAIN_CAPABILITY terrainCapability = Any, float minAlt = 0, float maxAlt = 1f, float maxSearchCost = -1)Returns an optimal route and also outputs the total traversal cost.
List<int> FindRoute(Country startingCountry, Country destinationCountry, float maxSearchCost = -1)Finds a route between two countries. Returns a list of country indices along the path, or null if no route is found.
List<int> FindRoute(Cell startingCell, Cell destinationCell, TERRAIN_CAPABILITY terrainCapability = Any, float maxSearchCost = -1, int maxSearchSteps = -1)Finds a route between two grid cells. Returns a list of cell indices along the path, or null if no route is found.
IEnumerator FindRouteAsCoroutine(FindRouteASyncFinishMethod finished, Vector2 startPosition, Vector2 endPosition, TERRAIN_CAPABILITY terrainCapability = Any, float minAlt = 0, float maxAlt = 1f, float maxSearchCost = -1)Coroutine version of FindRoute. Use with StartCoroutine(). The callback receives the list of waypoints and the total cost when complete.
void PathFindingPrewarmCountryPositions()Precomputes country region positions for faster path-finding calculations.
void SetPathFindingLandMap(Texture2D texture)Sets the texture of the land map for path finding purposes. Calling this method will ensure the textures are reloaded.
void SetPathFindingWaterMap(Texture2D texture)Sets the texture of the water map for path finding purposes. Calling this method will ensure the textures are reloaded.
IEnumerator FindRouteAsCoroutine(FindRouteASyncFinishMethod finished, Vector2 startPosition, Vector2 endPosition, TERRAIN_CAPABILITY terrainCapability, float minAltitude, float maxAltitude, float maxSearchCost, int maxSearchSteps, bool ignoreStartingTerrainType)Returns an optimal route from startPosition to endPosition with options. This method is designed to be called as coroutine. Upon termination, the "finished" method will be called passing the list of points of the path and the total cost. The route. Delegate to be called when the path calculation finishes. This delegate receives the list of points and the total cost. Start position in map coordinates (-0.5...0.5) End position in map coordinates (-0.5...0.5) The total cost of traversing the path Type of terrain that the unit can pass through Minimum altitude (0..1) Maximum altutude (0..1) Maximum search cost for the path finding algorithm. A value of -1 will use the global default defined by pathFindingMaxCost If true, the unit will be able to move one step ignoring the terrain type it's at the start position.
IEnumerator FindRouteAsCoroutine(FindRouteCellsASyncFinishMethod finished, Cell startingCell, Cell destinationCell, TERRAIN_CAPABILITY terrainCapability, float maxSearchCost, float minAltitude, float maxAltitude, int maxSearchSteps)Returns an optimal route from starting Cell to destination Cell. This method is designed to be called as coroutine. Upon termination, the "finished" method will be called passing the list of points of the path and the total cost. The route. Delegate to be called when the path calculation finishes. This delegate receives the list of indices of cells contained in the path and the total cost. Start position in map coordinates (-0.5...0.5) End position in map coordinates (-0.5...0.5) The total cost of traversing the path Type of terrain that the unit can pass through Minimum altitude (0..1) Maximum altutude (0..1) Maximum search cost for the path finding algorithm. A value of -1 will use the global default defined by pathFindingMaxCost
void PathFindingCustomRouteMatrixReset()Resets the custom route matrix. Use this custom route matrix to set location customized costs.
void PathFindingCustomRouteMatrixSet(Vector2 position, int cost)Sets the movement cost for a given map position.
void PathFindingCustomRouteMatrixSet(List positions, int cost)Sets the movement cost for a list of map positions.
void PathFindingCustomRouteMatrixSet(Region region, int cost)Sets the movement cost for a region of the map.
void PathFindingCustomRouteMatrixSet(Country country, int cost)Sets the movement cost for a country.
void PathFindingCustomRouteMatrixSet(Province province, int cost)Sets the movement cost for a province.
void PathFindingPrewarmCountryPositions()Prewarms country region positions for later use of path-finding
List PathFindingGetProvincesInPath(List path)Returns the indices of the provinces the path is crossing.
List PathFindingGetCountriesInPath(List path)Returns the indices of the provinces the path is crossing.
List PathFindingGetCitiesInPath(List path)Returns the indices of the cities the path is crossing.
List PathFindingGetMountPointsInPath(List path)Returns the indices of the mount points the path is crossing.
void PathFindingCellSetSideCost(int cellIndex, CELL_SIDE side, int cost)Sets the cost for crossing a given cell side. Note that the cost is only assigned in one direction (from this cell to the outside).
void PathFindingCellSetSideCost(int cell1, int cell2, int cost)Sets the extra cost for crossing a given cell side. The cell side is automatically determined and both directions are used.
void PathFindingCellSetAllSidesCost(int cellIndex, int cost)Sets the cost for crossing any cell side. Note that the cost is only assigned in one direction (from this cell to the outside).
float PathFindingCellGetSideCost(int cellIndex, CELL_SIDE side)Gets the extra cost for crossing a given cell side
void PathFindingSetLand(Vector2 pos, float size)Sets land mask bits in a circle defined by a position and radius Position in local map coordinates (-0.5..0.5) Size of the filling box in the same local map space coordinates
void PathFindingSetWater(Vector2 pos, float size)Sets water mask bits in a circle defined by a position and radius Position in local map coordinates (-0.5..0.5) Size of the filling box in the same local map space coordinates
Help us improve this documentation page.