import { EntityId } from './entity.cjs'; import { Component } from './component.cjs'; /** * Class for all Systems to derive from */ declare abstract class System { /** * * @param world World * @param dt Delta time */ abstract update(world: World, dt: number): void; } type ComponentConstructor = new (...args: any[]) => T; declare function entityIdGenerator(): IterableIterator; /** * Container for Systems and Entities */ declare class World { #private; private readonly idGenerator; /** * Create a new World instance * @param idGenerator Unique entity id generator */ constructor(idGenerator?: IterableIterator); get entities(): ReadonlyMap; /** * Update all world systems * @param dt Delta time */ update(dt: number): void; createEntity(): EntityId; /** * Delete an entity from the world. Entities can be recycled so do not rely * on the deleted entity reference after deleting it. * @param entity Entity to delete */ deleteEntity(entity: EntityId): boolean; findEntity(...componentCtors: ComponentConstructor[]): EntityId | undefined; addEntityComponents(entity: EntityId, ...components: Component[]): World; getEntityComponents(entity: EntityId): ComponentMap | undefined; removeEntityComponents(entity: EntityId, ...components: ComponentConstructor[]): World; /** * Register a system for addition. Systems are executed linearly in the order added. * @param system System */ addSystem(system: System): void; /** * Register a system for removal. * @param system System */ removeSystem(system: System): void; updateSystems(dt: number): void; view(...componentCtors: CC): Array<[EntityId, SafeComponentMap]>; } /** * A ComponentMap with a guaranteed set of Components. */ type SafeComponentMap = { get(ctor: C): InstanceType; } & ComponentMap; declare class ComponentMap extends Map { add(...components: Component[]): void; delete(...componentConstructors: ComponentConstructor[]): boolean; has(...componentConstructors: ComponentConstructor[]): boolean; get(componentConstructor: ComponentConstructor): C | undefined; } export { type ComponentConstructor as C, System as S, World as W, type SafeComponentMap as a, ComponentMap as b, entityIdGenerator as e };