screeps-cartographer
Version:
An advanced (and open source) movement library for Screeps
33 lines (32 loc) • 1.48 kB
TypeScript
/// <reference types="screeps" />
import { MoveOpts, MoveTarget } from '../';
import { CachingStrategy } from '../CachingStrategies';
export declare const cachedPathKey: (key: string) => string;
/**
* Generate a path from `origin` to `destination`, based on the passed `opts`. Caches
* the path in the configured cache (or MemoryCache by default) with the provided key.
* Returns the generated path (or the cached version, if it exists).
*/
export declare function cachePath(key: string, origin: RoomPosition, targets: _HasRoomPosition | RoomPosition | MoveTarget | RoomPosition[] | MoveTarget[], opts?: MoveOpts): RoomPosition[] | undefined;
/**
* Gets a cached path for a given key
*/
export declare function getCachedPath(key: string, opts?: {
cache?: CachingStrategy;
}): RoomPosition[] | undefined;
/**
* Clears a cached path for a given key
*/
export declare function resetCachedPath(key: string, opts?: {
cache?: CachingStrategy;
}): void;
export interface MoveByCachedPathOpts extends MoveOpts {
reverse?: boolean;
}
/**
* Moves a creep along a cached path. If `opts.reverse`, moves it backwards.
* Returns ERR_NO_PATH if the cached path doesn't exist, and ERR_NOT_FOUND if
* the creep is not on the path. In most cases, you'll want to use `moveByPath`
* instead; this is used internally by `moveTo`.
*/
export declare function followPath(creep: Creep | PowerCreep, key: string, opts?: MoveByCachedPathOpts): -2 | -10 | CreepMoveReturnCode | -5;