30 lines
840 B
TypeScript
30 lines
840 B
TypeScript
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
interface Entity {
|
|
/**
|
|
* Adds a component of the given type and returns it.
|
|
* Returns a typed subclass when the component has a dedicated module
|
|
* (`Position`, `Camera`, `Renderable`, `Trigger`, `Physics`); otherwise
|
|
* returns the base `Component`. Cast with `as Position` etc. when needed.
|
|
*/
|
|
add(type: number): Component;
|
|
toString(): string;
|
|
}
|
|
|
|
interface EntityConstructor {
|
|
/** Sentinel for an invalid entity ID. */
|
|
readonly INVALID: number;
|
|
/** Allocates a new entity from the fixed pool (max 64). */
|
|
create(): Entity;
|
|
/** Disposes the entity and all of its components. */
|
|
dispose(entity: Entity): void;
|
|
new(): never;
|
|
}
|
|
|
|
declare var Entity: EntityConstructor;
|