declare type Pathing = number; interface BaseEntity { collisionRadius: number; blocksPathing?: Pathing; blocksTilemap?: Footprint; pathing?: Pathing; requiresPathing?: Pathing; requiresTilemap?: Footprint; structure?: boolean; } declare type SimpleEntity = BaseEntity & { x: number; y: number; }; declare type ComplexEntity = BaseEntity & { position: { x: number; y: number; }; }; declare type Entity = SimpleEntity | ComplexEntity; export interface Footprint { top: number; left: number; height: number; width: number; map: number[]; } declare class Tile { x: number; y: number; world: { x: number; y: number; }; /** The pathing of the tile without any entities on top of it. */ originalPathing: Pathing; pathing: Pathing; nodes: Tile[]; __np?: number; __npTag?: number; __startRealPlusEstimatedCost?: number; __startTag?: number; __startRealCostFromOrigin?: number; __startEstimatedCostRemaining?: number; __startVisited?: boolean; __startClosed?: boolean; __startParent?: Tile | null; __endRealPlusEstimatedCost?: number; __endTag?: number; __endRealCostFromOrigin?: number; __endEstimatedCostRemaining?: number; __endVisited?: boolean; __endClosed?: boolean; __endParent?: Tile | null; /** Maps an entity to their pathing on this tile */ private entities; constructor(xTile: number, yTile: number, xWorld: number, yWorld: number, pathing: Pathing); addEntity(entity: Entity, pathing: Pathing): void; removeEntity(entity: Entity): void; updateEntity(entity: Entity, pathing: Pathing): void; recalculatePathing(): void; pathable(pathing: Pathing): boolean; } export interface Point { x: number; y: number; } export declare class PathingMap { readonly resolution: number; private readonly layers?; readonly heightWorld: number; readonly widthWorld: number; readonly heightMap: number; readonly widthMap: number; readonly grid: Tile[][]; private _elem?; private readonly entities; constructor({ pathing, resolution, layers, }: { pathing: Pathing[][]; resolution?: number; layers?: number[][]; }); /** * Internals of PathingMap#pathable. Not private for interfacee typing * reasons. */ _pathable(map: Footprint, xTile: number, yTile: number, test?: (tile: Tile) => boolean): boolean; pathable(entity: Entity, xWorld?: number, yWorld?: number): boolean; /** * Temporarily removes an entity from the PathingMap, invokes the passed * function, re-adds the entity, and returns the result of the function. */ withoutEntity(entity: Entity, fn: () => A): A; /** * Given an initial position `(xWorld, yWorld)`, returns the nearest point * the entity can be placed, measured by euclidean distance (thus would form * a circle instead of square for repeated placements). */ nearestPathing(xWorld: number, yWorld: number, entity: Entity, test?: (tile: Tile) => boolean): Point; private _layer; /** * Returns the layer for a given world coordinate. Some pathing calculations * are constrained to specific layers, such as * PathingMap#nearestSpiralPathing. */ layer(xWorld: number, yWorld: number): number | undefined; /** * Given an initial position `(xWorld, yWorld)`, returns the nearest point * on the same layer at which the entity can be placed, as discovered by * spiraling out (thus would form a square instead of circle for repeated * placements). */ nearestSpiralPathing(xWorld: number, yWorld: number, entity: Entity, layer?: number | undefined): Point; worldToTile(world: Point): Tile; xWorldToTile(x: number): number; yWorldToTile(y: number): number; xTileToWorld(x: number): number; yTileToWorld(y: number): number; /** * Calculates a tilemap/footprint required to place something at `(xWorld, * yWorld)` with `radius`. */ pointToTilemap(xWorld: number, yWorld: number, radius?: number, { type, includeOutOfBounds }?: { type?: number | undefined; includeOutOfBounds?: boolean | undefined; }): Footprint; private yBoundTile; private xBoundTile; /** * Calculates the shortest path for an entity to reach `target`. If a path * is not possible, or is extremely long, a partial path will be returned. */ path(entity: Entity, target: Point, start?: Point): Point[]; /** * Rechecks a path to make sure it's still pathable. Can return false even * if the path is still pathable. * @param path The array of points that make up the path to be checked. * @param entity The object of the path to be checked. Includes clearance * (radius) and pathing type. * @param amount How far along the path we should check at a minimum. We'll * likely overcheck, since we just verify segments of the path. * @param offset How far along that path we start checking at maximum. */ recheck(path: Point[], entity: Entity, amount?: number, offset?: number): boolean; private _smooth; /** * Internals of ParthingMap#linearPathable. Public for testing purposes. */ _linearPathable(entity: Entity, startTile: Tile, endTile: Tile): boolean; entityToTileCoordsBounded(entity: Entity, position?: Point): { x: number; y: number; }; entityToTile(entity: Entity, position?: Point): Tile; /** * Checks whether an entity is clearance to go from `startWorld` to * `endWorld`. */ linearPathable(entity: Entity, startWorld: Point, endWorld: Point): boolean; /** * Adds an entity to the PathingMap, adding it to any tiles it intersects * with. */ addEntity(entity: Entity): void; /** * Notifies the PathingMap the entity may occupy a new tiles, removing * it from tiles it no longer intersects and adding it to tiles it now * intersects. * Note: This will not reflect changes to the entity's pathing type. An * entities pathing type is treatede as immutable. */ updateEntity(entity: Entity): void; /** * Removes the entity from the PathingMap, clearing it from all tiles. */ removeEntity(entity: Entity): void; } export {};