import Vector from '../../math/Vector'; import Proximity, { ProximityCallback } from '../Proximity'; import Steerable from '../Steerable'; /** * {@code ProximityBase} is the base class for any concrete proximity based on an iterable collection of agents. * * @param Type of vector, either 2D or 3D, implementing the {@link Vector} interface * * @author davebaol */ abstract class ProximityBase> implements Proximity { /** The owner of this proximity. */ protected owner: Steerable; /** * The collection of the agents handled by this proximity. *

* Note that, being this field of type {@code Iterable}, you can either use java or libgdx collections. See * https://github.com/libgdx/gdx-ai/issues/65 */ protected agents: Steerable[]; /** * Creates a {@code ProximityBase} for the specified owner and list of agents. * @param owner the owner of this proximity * @param agents the list of agents */ public constructor(owner: Steerable, agents: Steerable[]) { this.owner = owner; this.agents = agents; } public getOwner(): Steerable { return this.owner; } public setOwner(owner: Steerable): void { this.owner = owner; } /** Returns the the agents that represent potential neighbors. */ public getAgents(): Steerable[] { return this.agents; } /** Sets the agents that represent potential neighbors. */ public setAgents(agents: Steerable[]): void { this.agents = agents; } abstract findNeighbors(callback: ProximityCallback): number; } export default ProximityBase;