Merge pull request #223 from Ukendio/encodedvenom-update-types
Some checks failed
analysis / Run Luau Analyze (push) Has been cancelled
deploy-docs / build (push) Has been cancelled
publish-npm / publish (push) Has been cancelled
unit-testing / Run Luau Tests (push) Has been cancelled
deploy-docs / Deploy (push) Has been cancelled

Update TS types
This commit is contained in:
EncodedVenom 2025-05-08 23:13:52 -04:00 committed by GitHub
commit 6881a27563
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

69
jecs.d.ts vendored
View file

@ -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<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.
@ -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<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.
@ -225,8 +232,24 @@ 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)