mirror of
https://github.com/Ukendio/jecs.git
synced 2025-08-05 03:39:17 +00:00
Compare commits
1 commit
414ffb488a
...
5322c14fd4
Author | SHA1 | Date | |
---|---|---|---|
|
5322c14fd4 |
1 changed files with 23 additions and 46 deletions
69
jecs.d.ts
vendored
69
jecs.d.ts
vendored
|
@ -108,13 +108,6 @@ 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.
|
||||
|
@ -137,6 +130,19 @@ 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.
|
||||
|
@ -158,19 +164,6 @@ export class World {
|
|||
*/
|
||||
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.
|
||||
* @param entity The target entity.
|
||||
|
@ -198,6 +191,12 @@ 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.
|
||||
|
@ -206,17 +205,11 @@ export class World {
|
|||
parent(entity: Entity): Entity | undefined;
|
||||
|
||||
/**
|
||||
* Checks if an entity exists in the world.
|
||||
* @param entity The entity to verify.
|
||||
* 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.
|
||||
*/
|
||||
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;
|
||||
query<T extends Id[]>(...components: T): Query<InferComponents<T>>;
|
||||
|
||||
/**
|
||||
* Returns an iterator that yields all entities that have the specified component or relationship.
|
||||
|
@ -232,24 +225,8 @@ export class World {
|
|||
* @returns An iterator function that yields child entities
|
||||
*/
|
||||
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)
|
||||
* @param pred The first entity (predicate)
|
||||
|
|
Loading…
Reference in a new issue