import { Component } from '../component/component'; import { GameBase } from '../core/game.base'; import { EntityConfig } from './entity.config'; /** * Abstract Entity - any object existing in a Game's World, Text or UI, comprised of Components and handled by respective EntityManagers * * Concrete Entities implemented in Games should extend from this class, overring its methods as required */ 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 an EntityConfig and initialise the Entity's Components, if provided * * @param config the EntityConfig */ constructor(config: EntityConfig); /** * Retrieve the Entity's tag as provided 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 * * @param game the Game the System is operating within * @param frameDelta the frame delta as calculated by the Game */ tick(game: GameBase, frameDelta: number): void; /** * Optional collision callback method for the start of a collision with another specific Entity, implementable by concrete Entities * * @param game the 2D or 3D Game the System is operating within * @param other the Entity with which collision has begun */ onCollisionStart(game: GameBase, other: Entity): void; /** * Optional collision callback method for the continuation of a collision with another specific Entity, implentable by concrete Entities * * @param game the 2D or 3D Game the System is operating within * @param other the Entity with which collision continues */ onCollisionContinue(game: GameBase, other: Entity): void; /** * Optional collision callback method for the end of a collision with another specific Entity, implementable by concrete Entities * * @param game the 2D or 3D Game the System is operating within * @param other the Entity with which collision has ended */ onCollisionEnd(game: GameBase, other: Entity): void; /** * Retrieve a Component 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 to retrieve * * @param name the name of the Component to retrieve * * @returns the retrieved 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 the named Component from the Entity * * @param name the name of the Component to remove */ removeComponent(name: string): void; /** * Remove a list of named Components from the Entity * * @param names the names of the Components to remove */ removeComponents(...names: Array): void; /** * Check if the Entity has a named Component * * @param name the name of the Component to check * * @returns whether or not the Entity has the named Component */ hasComponent(name: string): boolean; /** * Check if the Entity has a list of named Components * * @param names the names of the Components to check * * @returns whether or not the Entity has all of the named Components */ hasComponents(...names: Array): boolean; }