mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Typescript Types for Archetypes
Some checks failed
Some checks failed
* resolves #182 - TS types for Archetypes * description for archetype query * updated archetype number type
This commit is contained in:
parent
cc7daa6a06
commit
5c19a3b595
1 changed files with 29 additions and 0 deletions
29
jecs.d.ts
vendored
29
jecs.d.ts
vendored
|
@ -40,6 +40,23 @@ type FlattenTuple<T extends unknown[]> = T extends [infer U] ? U : LuaTuple<T>;
|
|||
type Nullable<T extends unknown[]> = { [K in keyof T]: T[K] | undefined };
|
||||
type InferComponents<A extends Id[]> = { [K in keyof A]: InferComponent<A[K]> };
|
||||
|
||||
type ArchetypeId = number
|
||||
type Column = unknown[];
|
||||
|
||||
type ArchetypeRecord = {
|
||||
count: number;
|
||||
column: number;
|
||||
}
|
||||
|
||||
export type Archetype = {
|
||||
id: number;
|
||||
types: number[];
|
||||
type: string;
|
||||
entities: number[];
|
||||
columns: Column[];
|
||||
records: ArchetypeRecord[];
|
||||
}
|
||||
|
||||
type Iter<T extends unknown[]> = IterableFunction<LuaTuple<[Entity, ...T]>>;
|
||||
|
||||
export type CachedQuery<T extends unknown[]> = {
|
||||
|
@ -47,6 +64,12 @@ export type CachedQuery<T extends unknown[]> = {
|
|||
* Returns an iterator that produces a tuple of [Entity, ...queriedComponents].
|
||||
*/
|
||||
iter(): Iter<T>;
|
||||
|
||||
/**
|
||||
* Returns the matched archetypes of the query
|
||||
* @returns An array of archetypes of the query
|
||||
*/
|
||||
archetypes(): Archetype[];
|
||||
} & Iter<T>;
|
||||
|
||||
export type Query<T extends unknown[]> = {
|
||||
|
@ -75,6 +98,12 @@ export type Query<T extends unknown[]> = {
|
|||
* @returns A new Query with the exclusion applied.
|
||||
*/
|
||||
without(...components: Id[]): Query<T>;
|
||||
|
||||
/**
|
||||
* Returns the matched archetypes of the query
|
||||
* @returns An array of archetypes of the query
|
||||
*/
|
||||
archetypes(): Archetype[];
|
||||
} & Iter<T>;
|
||||
|
||||
export class World {
|
||||
|
|
Loading…
Reference in a new issue