malwoden
Version:
   
35 lines (34 loc) • 1.33 kB
TypeScript
import { Vector2 } from "../struct";
import { TerrainCallback, RangeVector2 } from "./pathfinding-common";
/**
* Used to find a range from a central point, like movement or ranged attacks in
* turn-based games. This uses a search similar to Dijkstra or AStar, but returns
* a list of tiles in range of a starting point, rather than a path to a goal.
*/
export declare class RangeFinder {
private getTerrain;
readonly topology: "four" | "eight";
/**
* @param config - Configuration for the RangeFinder
* @param config.topology - four | eight
* @param config.getTerrainCallback - Override the distance function for terrain costs or blocked spaces.
*/
constructor(config: {
getTerrainCallback?: TerrainCallback;
topology: "four" | "eight";
});
private getNeighbors;
/**
* Find the range from a given point.
* @param config - Configuration for the findRange
* @param config.start - Vector2 - The starting point
* @param config.maxRange - The maximum range allowed
* @param config.minRange - The minimum range allowed (optional)
* @returns - RangeVector2[] ({x,y,r}[])
*/
compute(config: {
start: Vector2;
maxRange: number;
minRange?: number;
}): RangeVector2[];
}