@rpgjs/physic
Version:
A deterministic 2D top-down physics library for RPG, sandbox and MMO games
47 lines • 1.47 kB
TypeScript
import { MovementBody, MovementStrategy } from '../MovementStrategy';
/**
* Makes an entity follow a list of waypoints at a constant speed.
*
* @example
* ```typescript
* movementManager.add(npc, new PathFollow(
* [{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 4 }],
* 1.5,
* true,
* 0.5,
* ));
* ```
*/
export declare class PathFollow implements MovementStrategy {
private waypoints;
private readonly speed;
private readonly loop;
private readonly pauseAtWaypoints;
private readonly tolerance;
private currentWaypoint;
private elapsedPause;
private paused;
private finished;
private direction;
/**
* Creates a path-following strategy.
*
* @param waypoints - List of waypoints to traverse
* @param speed - Travel speed in units per second
* @param loop - When true, restart from the first waypoint
* @param pauseAtWaypoints - Optional pause duration (seconds) at each waypoint
* @param tolerance - Distance tolerance to consider a waypoint reached
*/
constructor(waypoints: Array<{
x: number;
y: number;
}>, speed: number, loop?: boolean, pauseAtWaypoints?: number, tolerance?: number);
update(body: MovementBody, dt: number): void;
isFinished(): boolean;
getCurrentWaypoint(): number;
setWaypoints(waypoints: Array<{
x: number;
y: number;
}>, reset?: boolean): void;
}
//# sourceMappingURL=PathFollow.d.ts.map