Improve set overloads

This commit is contained in:
daimond113 2025-06-08 18:02:14 +02:00
parent dab260f733
commit e3609ce15f
No known key found for this signature in database
GPG key ID: 640DC95EC1190354

24
jecs.d.ts vendored
View file

@ -151,15 +151,6 @@ export class World {
*/ */
add<C>(entity: Entity, component: undefined extends InferComponent<C> ? C : Id<undefined>): void; add<C>(entity: Entity, component: undefined extends InferComponent<C> ? C : Id<undefined>): void;
/**
* Installs a hook on the given component.
* @param component The target component.
* @param hook The hook to install.
* @param value The hook callback.
*/
set<T>(component: Entity<T>, hook: StatefulHook, value: (e: Entity<T>, id: Id<T>, data: T) => void): void;
set<T>(component: Entity<T>, hook: StatelessHook, value: (e: Entity<T>, id: Id<T>) => void): void;
/** /**
* Assigns a value to a component on the given entity. * Assigns a value to a component on the given entity.
* @param entity The target entity. * @param entity The target entity.
@ -168,6 +159,21 @@ 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;
/**
* Installs a hook on the given component.
* @param component The target component.
* @param hook The hook to install.
* @param value The hook callback.
*/
set<T>(component: Entity<T>, hook: StatefulHook, value: (e: Entity<T>, id: Id<T>, data: T) => void): void;
/**
* Installs a hook on the given component.
* @param component The target component.
* @param hook The hook to install.
* @param value The hook callback.
*/
set<T>(component: Entity<T>, hook: StatelessHook, value: (e: Entity<T>, id: Id<T>) => void): void;
/** /**
* Cleans up the world by removing empty archetypes and rebuilding the archetype collections. * Cleans up the world by removing empty archetypes and rebuilding the archetype collections.
* This helps maintain memory efficiency by removing unused archetype definitions. * This helps maintain memory efficiency by removing unused archetype definitions.