import { Component } from '../component'; import { Game } from '../core'; import { EntityConfig } from './entity.config'; /** * Class representing an Entity * * An Entity is any object existing within the game; be it a player, enemy, pickup, level object, camera, UI element, etc * * Entities maintain a list of Components, which give them their properties and behaviour and allow Systems to operate on them as necessary * * // TODO look at ways of reimplementing get/has Component by Type/Class * * @see Component */ export declare abstract class Entity { private readonly config; /** Unique id for the Entity */ readonly id: string; /** Entity Components, mapped by their name for simple management */ private readonly components; /** * Constructor. Take and store the Entity's config and initialise the Entity with Components if provided in the config * * @param config entity configuration */ constructor(config: EntityConfig); /** * Getter for the Entity's tag, as provide in its config * * @returns the Entity's tag */ get tag(): string; /** * Optional frame update function called by the EntityManager during frame execution, implementable by concrete Entities * * @see EntityManager * * @param frameDelta the time between the last frame and the current, for normalizing time-dependent operations */ tick(game: Game, frameDelta: number): void; /** * Optional collision callback method called by the collision system when this Entity begins colliding with another, implementable by * concrete Entities * * @param game a reference to the Game, for setting data, switching States or similar * @param other the Entity with which collision has begun */ onCollisionStart(game: Game, other: Entity): void; /** * Optional collision callback method called by the collision system when this Entity continues to collide with another on the current * frame, implementable by concrete Entities * * @param game a reference to the Game, for setting data, switching States or similar * @param other the Entity with which collision continues */ onCollisionContinue(game: Game, other: Entity): void; /** * Optional collision callback method called by the collision system when this Entity stops colliding with another, implementable by * concrete Entities * * @param game a reference to the Game, for setting data, switching states or similar * @param other the Entity with which collision has ended */ onCollisionEnd(game: Game, other: Entity): void; /** * Get a Component from the Entity by name * * Throws an error if the Component is not found on the Entity to allow type safety + simplistic no-questions consumer calls * * @typeparam T the type of the Component that will be returned * * @param name the name of the Component to retrieve * * @returns the Component */ getComponent(name: string): T; /** * Add a Component to the Entity * * @param component the Component to add */ addComponent(component: Component): void; /** * Add a list of Components to the Entity * * @param components the Components to add */ addComponents(...components: Array): void; /** * Remove a Component from the Entity by Component name * * @param name the name of the Component to remove */ removeComponent(name: string): void; /** * Remove a list of Components from the Entity by Component name * * @param names the names of the Components to remove */ removeComponents(...names: Array): void; /** * Check if the Entity has a Component by Component name * * // TODO this doesn't appear to work in dist. Why? * * @param name the name of the Component to check * * @returns a boolean indicating whether or not the Entity has the named Component */ hasComponent(name: string): boolean; /** * Check if the Entity has a list of Components by Component name * * @param names the names of the Components to check * * @returns a boolean indicating whether or not the Entity has all of the named Components */ hasComponents(...names: Array): boolean; }