mirror of
https://github.com/Ukendio/jecs.git
synced 2025-06-19 15:59:18 +00:00
Improve set overloads (#237)
Some checks are pending
Some checks are pending
* Improve set overloads * Change type generic
This commit is contained in:
parent
8e35900f65
commit
28ef8d7234
1 changed files with 13 additions and 7 deletions
20
jecs.d.ts
vendored
20
jecs.d.ts
vendored
|
@ -150,6 +150,14 @@ export class World {
|
|||
* @param component The component (or tag) to add.
|
||||
*/
|
||||
add<C>(entity: Entity, component: undefined extends InferComponent<C> ? C : Id<undefined>): void;
|
||||
|
||||
/**
|
||||
* Assigns a value to a component on the given entity.
|
||||
* @param entity The target entity.
|
||||
* @param component The component definition (could be a Pair or Entity).
|
||||
* @param value The value to store with that component.
|
||||
*/
|
||||
set<T>(entity: Entity, component: Id<T>, value: T): void;
|
||||
|
||||
/**
|
||||
* Installs a hook on the given component.
|
||||
|
@ -158,15 +166,13 @@ export class World {
|
|||
* @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.
|
||||
* @param entity The target entity.
|
||||
* @param component The component definition (could be a Pair or Entity).
|
||||
* @param value The value to store with that component.
|
||||
* Installs a hook on the given component.
|
||||
* @param component The target component.
|
||||
* @param hook The hook to install.
|
||||
* @param value The hook callback.
|
||||
*/
|
||||
set<E extends Id<unknown>>(entity: Entity, component: E, value: InferComponent<E>): void;
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue