super-ecs
Version:
Entity Component System library
70 lines (69 loc) • 2.29 kB
TypeScript
import type { Observable } from 'rxjs';
import type { System } from '../system.js';
import type { Entity } from '../entity.js';
import type { TickerDataLike } from '../types/index.js';
export declare class World {
private readonly _systems;
private readonly _entities;
private readonly _families;
private readonly _disposeEntityMap;
constructor();
/**
* Add a system to this world.
* @param system
*/
addSystem(system: System): World;
/**
* Remove a system from this world.
* @param system
*/
removeSystem(system: System): World;
/**
* Remove all systems from this world
*/
removeAllSystems(): World;
/**
* Add an entity to this world.
* @param entity
*/
addEntity(entity: Entity): World;
/**
* Remove and entity from this world.
* @param entity
*/
removeEntity(entity: Entity): World;
/**
* Removes all entities
*/
removeAllEntities(): World;
/**
* Get the entities having all the specified components.
* @param componentNames
*/
getEntities(componentNames: ReadonlyArray<symbol>): ReadonlyArray<Entity>;
/**
* For each system in the world, call its `update` method.
* @param tickerData
*/
update(tickerData: TickerDataLike): void;
/**
* Returns the Observable for entities added with the specified components. The
* Observable is also emitted when a component is added to an entity causing it
* match the specified component names.
* Note: make sure to unsubscribe. If needed, use `DisposeBag` util
* @param componentNames
*/
entityAdded$(componentNames: ReadonlyArray<symbol>): Observable<Entity>;
/**
* Returns the Observable for entities removed with the specified components.
* The Observable is also emitted when a component is removed from an entity
* causing it to no longer match the specified component names.
* Note: make sure to unsubscribe. If needed, use `DisposeBag` util
* @param componentNames
*/
entityRemoved$(componentNames: ReadonlyArray<symbol>): Observable<Entity>;
private generateFamilyId;
private ensureFamilyExists;
private onComponentAdded;
private onComponentRemoved;
}