diff --git a/jecs.d.ts b/jecs.d.ts index 7e53388..01239fd 100644 --- a/jecs.d.ts +++ b/jecs.d.ts @@ -108,6 +108,13 @@ export class World { */ constructor(); + /** + * Enforces a check for entities to be created within a desired range. + * @param range_begin The starting point + * @param range_end The end point (optional) + */ + range(range_begin: number, range_end?: number): void; + /** * Creates a new entity. * @returns An entity (Tag) with no data. @@ -130,19 +137,6 @@ export class World { */ target(entity: Entity, relation: Entity, index?: number): Entity | undefined; - /** - * Cleans up the world by removing empty archetypes and rebuilding the archetype collections. - * This helps maintain memory efficiency by removing unused archetype definitions. - */ - cleanup(): void; - - /** - * Clears all components and relationships from the given entity, but - * does not delete the entity from the world. - * @param entity The entity to clear. - */ - clear(entity: Entity): void; - /** * Deletes an entity (and its components/relationships) from the world entirely. * @param entity The entity to delete. @@ -164,6 +158,19 @@ export class World { */ set>(entity: Entity, component: E, value: InferComponent): void; + /** + * Cleans up the world by removing empty archetypes and rebuilding the archetype collections. + * This helps maintain memory efficiency by removing unused archetype definitions. + */ + cleanup(): void; + + /** + * Clears all components and relationships from the given entity, but + * does not delete the entity from the world. + * @param entity The entity to clear. + */ + clear(entity: Entity): void; + /** * Removes a component from the given entity. * @param entity The target entity. @@ -191,12 +198,6 @@ export class World { */ has(entity: Entity, ...components: Id[]): boolean; - /** - * Checks if an entity exists in the world. - * @param entity The entity to verify. - */ - contains(entity: Entity): boolean; - /** * Gets the parent (the target of a `ChildOf` relationship) for an entity, * if such a relationship exists. @@ -205,11 +206,17 @@ export class World { parent(entity: Entity): Entity | undefined; /** - * Searches the world for entities that match specified components. - * @param components The list of components to query. - * @returns A Query object to iterate over results. + * Checks if an entity exists in the world. + * @param entity The entity to verify. */ - query(...components: T): Query>; + contains(entity: Entity): boolean; + + /** + * Checks if an entity with the given ID is currently alive, ignoring its generation. + * @param entity The entity to verify. + * @returns boolean true if any entity with the given ID exists (ignoring generation), false otherwise + */ + exists(entity: Entity): boolean; /** * Returns an iterator that yields all entities that have the specified component or relationship. @@ -225,8 +232,24 @@ export class World { * @returns An iterator function that yields child entities */ children(parent: Entity): IterableFunction; + + /** + * Searches the world for entities that match specified components. + * @param components The list of components to query. + * @returns A Query object to iterate over results. + */ + query(...components: T): Query>; } +export function component(): Entity; + +export function tag(): Entity; + +// note: original types had id: Entity, id: Id, which does not work with TS. +export function meta(e: Entity, id: Id, value?: T): Entity + +export function is_tag(world: World, id: Id): boolean; + /** * Creates a composite key (pair) * @param pred The first entity (predicate)