mirror of
https://github.com/Ukendio/jecs.git
synced 2025-08-04 03:09:18 +00:00
Improve set overloads
This commit is contained in:
parent
dab260f733
commit
e3609ce15f
1 changed files with 15 additions and 9 deletions
24
jecs.d.ts
vendored
24
jecs.d.ts
vendored
|
@ -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.
|
||||||
|
|
Loading…
Reference in a new issue