import { Stage } from "./stage"; import { Transform } from "../transform"; import { Identifiable } from "../identifiable"; import { Component } from "./component"; /** * Construction options for the Entity */ export interface EntityOptions { readonly visibility: boolean; readonly autoCreate: boolean; } /** * Everything extends the Entity as a base class. Contains a number of * callbacks from the main renderer */ export declare abstract class Entity extends Identifiable { private static readonly _OPT_DEFAULT; private readonly _transform; private readonly _components; protected _stage: Stage | null; constructor(opt?: EntityOptions | null); addComponent(component: Component): void; removeComponent(component: Component): void; /** * Checks if this Entity is a type of provided Object * * @param type The object type to check */ isType(type: new (...params: any[]) => T): boolean; /** * Performs a safe-cast from Entity to the provided type. Returns undefined if the entity * is not the provided type of object * * @param type The object type to cast this entity into */ cast(type: new (...params: any[]) => T): T | null; /** * Performs a safe-cast from Entity to the provided type. Returns a Promise that is resolved * or rejected. Use Entity.cast() for the non-promise based version * * @param type The object type to cast this entity into */ safeCast(type: new (...params: any[]) => T): Promise; /** * Returns the current parent of this object */ get parent(): Entity | null; /** * Sets the new parent for this Object into a new Entity */ set parent(entity: Entity | null); /** * Returns the Stage that this object is attached to */ get stage(): Stage; /** * Checks if this object has already been created or is about to be created */ get isCreated(): boolean; /** * Check if this object is the root scene object */ get isRoot(): boolean; /** * Returns the Transform that allows moving, rotating or scaling this object */ get transform(): Transform; /** * Executed by the Stage when this object should be created * @param stage * @returns */ _onCreate(stage: Stage): Promise; /** * Called by the Rendering Engine to construct this object asynchronously. Object * will not be executed/rendered until the promise is resolved */ protected create(): Promise | void; /** * Called by the Rendering Engine first time object is executed. This happens at the * start of a new frame for all new objects */ start(): void; /** * Called by the Rendering Engine just before a rendering is about to be done * * @param deltaTime The time difference between the last and current frame in seconds */ update(_deltaTime: number): void; /** * Called by the Rendering Engine just after a rendering was done * * @param deltaTime The time difference between the last and current frame in seconds */ lateUpdate(_deltaTime: number): void; /** * Called by the Rendering Engine when it was paused by a user or a script */ onPause(): void; /** * Called by the Rendering Engine when it was resumed from a previously paused state */ onResume(): void; /** * Called by the Rendering Engine when this object was removed from the Stage */ onDestroy(): void; /** * Called by the Rendering Engine when the Canvas/Renderer was resized to a new size * * @param newWidth The new width of the Renderer/Canvas * @param newHeight The new height of the Renderer/Canvas */ onResize(_newWidth: number, _newHeight: number): void; }