diff --git a/src/index.d.ts b/src/index.d.ts index 6d7e7719..871c0c29 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -4,6 +4,11 @@ type Query = { * this: Query is necessary to use a colon instead of a period for emits. */ + + /** + * Get the next result in the query. Drain must have been called beforehand or otherwise it will error. + */ + next: (this: Query) => Query; /** * Resets the Iterator for a query. */ @@ -28,7 +33,7 @@ type Query = { } & IterableFunction>; // Utility Types -export type Entity = number & { __nominal_type_dont_use: T }; +export type Entity = number & { __DO_NOT_USE_OR_YOU_WILL_BE_FIRED: T }; export type EntityType = T extends Entity ? A : never; export type InferComponents = { [K in keyof A]: EntityType; @@ -44,7 +49,6 @@ type TupleForWorldGet = | [Entity, Entity] | [Entity, Entity, Entity] | [Entity, Entity, Entity, Entity] - | [Entity, Entity, Entity, Entity, Entity] export class World { /** @@ -67,60 +71,66 @@ export class World { /** * Gets the target of a relationship. For example, when a user calls - * `world.target(id, ChildOf(parent))`, you will obtain the parent entity. - * @param id Entity + * `world.target(entity, ChildOf(parent))`, you will obtain the parent entity. + * @param entity Entity * @param relation The Relationship * @returns The Parent Entity if it exists */ - target(id: Entity, relation: Entity): Entity | undefined; + target(entity: Entity, relation: Entity): Entity | undefined; /** * Clears an entity from the world. - * @praram id Entity to be cleared + * @praram entity Entity to be cleared */ - clear(id: Entity): void; + clear(entity: Entity): void; /** * Deletes an entity and all its related components and relationships. - * For most situations, you should be using the clear method instead of deletion. - * @param id Entity to be destroyed + * @param entity Entity to be destroyed */ - delete(id: Entity): void; + delete(entity: Entity): void; /** * Adds a component to the entity with no value - * @param id Target Entity + * @param entity Target Entity * @param component Component */ - add(id: Entity, component: Entity): void; + add(entity: Entity, component: Entity): void; /** * Assigns a value to a component on the given entity - * @param id Target Entity + * @param entity Target Entity * @param component Target Component * @param data Component Data */ - set(id: Entity, component: Entity, data: T): void; + set(entity: Entity, component: Entity, data: T): void; /** * Removes a component from the given entity - * @param id Target Entity + * @param entity Target Entity * @param component Target Component */ - remove(id: Entity, component: Entity): void; - - // Manually typed out get since there is a hard limit. + remove(entity: Entity, component: Entity): void; /** * Retrieves the values of specified components for an entity. * Some values may not exist when called. - * A maximum of 5 components are allowed at a time. + * A maximum of 4 components are allowed at a time. * @param id Target Entity * @param components Target Components * @returns Data associated with target components if it exists. */ get(id: Entity, ...components: T): FlattenTuple>> + /** + * Returns whether the entity has the specified components. + * A maximum of 4 components are allowed at a time. + * @param entity Target Entity + * @param components Target Components + * @returns If the entity contains the components + */ + has(entity: Entity, ...components: T): boolean; + /** * Searches the world for entities that match a given query * @param components Queried Components