UNPKG

@rpgjs/physic

Version:

A deterministic 2D top-down physics library for RPG, sandbox and MMO games

42 lines 1.59 kB
import { PhysicsEngine } from '../../api/PhysicsEngine'; import { Entity } from '../../physics/Entity'; import { MovementBody, MovementStrategy } from '../MovementStrategy'; /** * Seeks a target while repelling from nearby obstacles using a linear falloff. * * @example * ```typescript * const strategy = new LinearRepulsion( * engine, * () => player.position.clone(), * 3, * 2, * 5, * ); * movementManager.add(enemy, strategy); * ``` */ export declare class LinearRepulsion implements MovementStrategy { private readonly engine; private readonly targetProvider; private maxSpeed; private repulseRadius; private repulseWeight; private readonly ignoredEntity?; private repulseRadiusSq; /** * @param engine - Physics engine used for spatial queries * @param targetProvider - Function returning the target position * @param maxSpeed - Maximum speed in units per second * @param repulseRadius - Radius used to sample nearby obstacles * @param repulseWeight - Weight of the repulsion force * @param ignoredEntity - Optional entity to exclude from avoidance (e.g. the target) */ constructor(engine: PhysicsEngine, targetProvider: () => { x: number; y: number; }, maxSpeed?: number, repulseRadius?: number, repulseWeight?: number, ignoredEntity?: (() => Entity | undefined) | undefined); update(body: MovementBody, _dt: number): void; setParameters(maxSpeed?: number, repulseRadius?: number, repulseWeight?: number): void; } //# sourceMappingURL=LinearRepulsion.d.ts.map