mirror of
https://github.com/Ukendio/jecs.git
synced 2025-06-20 08:19:18 +00:00
Merge branch 'main' of https://github.com/Ukendio/jecs
This commit is contained in:
commit
3d7968652d
1 changed files with 46 additions and 23 deletions
69
jecs.d.ts
vendored
69
jecs.d.ts
vendored
|
@ -108,6 +108,13 @@ export class World {
|
||||||
*/
|
*/
|
||||||
constructor();
|
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.
|
* Creates a new entity.
|
||||||
* @returns An entity (Tag) with no data.
|
* @returns An entity (Tag) with no data.
|
||||||
|
@ -130,19 +137,6 @@ export class World {
|
||||||
*/
|
*/
|
||||||
target(entity: Entity, relation: Entity, index?: number): Entity | undefined;
|
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.
|
* Deletes an entity (and its components/relationships) from the world entirely.
|
||||||
* @param entity The entity to delete.
|
* @param entity The entity to delete.
|
||||||
|
@ -164,6 +158,19 @@ export class World {
|
||||||
*/
|
*/
|
||||||
set<E extends Id<unknown>>(entity: Entity, component: E, value: InferComponent<E>): void;
|
set<E extends Id<unknown>>(entity: Entity, component: E, value: InferComponent<E>): 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.
|
* Removes a component from the given entity.
|
||||||
* @param entity The target entity.
|
* @param entity The target entity.
|
||||||
|
@ -191,12 +198,6 @@ export class World {
|
||||||
*/
|
*/
|
||||||
has(entity: Entity, ...components: Id[]): boolean;
|
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,
|
* Gets the parent (the target of a `ChildOf` relationship) for an entity,
|
||||||
* if such a relationship exists.
|
* if such a relationship exists.
|
||||||
|
@ -205,11 +206,17 @@ export class World {
|
||||||
parent(entity: Entity): Entity | undefined;
|
parent(entity: Entity): Entity | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches the world for entities that match specified components.
|
* Checks if an entity exists in the world.
|
||||||
* @param components The list of components to query.
|
* @param entity The entity to verify.
|
||||||
* @returns A Query object to iterate over results.
|
|
||||||
*/
|
*/
|
||||||
query<T extends Id[]>(...components: T): Query<InferComponents<T>>;
|
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.
|
* 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
|
* @returns An iterator function that yields child entities
|
||||||
*/
|
*/
|
||||||
children(parent: Entity): IterableFunction<Entity>;
|
children(parent: Entity): IterableFunction<Entity>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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<T extends Id[]>(...components: T): Query<InferComponents<T>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function component<T>(): Entity<T>;
|
||||||
|
|
||||||
|
export function tag<T>(): Entity<T>;
|
||||||
|
|
||||||
|
// note: original types had id: Entity, id: Id<T>, which does not work with TS.
|
||||||
|
export function meta<T>(e: Entity, id: Id<T>, value?: T): Entity<T>
|
||||||
|
|
||||||
|
export function is_tag<T>(world: World, id: Id<T>): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a composite key (pair)
|
* Creates a composite key (pair)
|
||||||
* @param pred The first entity (predicate)
|
* @param pred The first entity (predicate)
|
||||||
|
|
Loading…
Reference in a new issue