type i53 = number; type i24 = number; type Ty = Array; type Column = Array; type Archetype = { id: number, edges: { [key: i53]: { add: Archetype, remove: Archetype, }, }, types: Ty, type: string | number, entities: Array, columns: Array, records: { [key: number]: number }, } type ArchetypeMap = { cache: Array, first: ArchetypeMap, second: ArchetypeMap, parent: ArchetypeMap, size: number, } type ArchetypeRecord = number; export type Entity = number & { __nominal_type_dont_use: T } type EntityIndex = { dense: { [key: i24]: i53 }; sparse: { [key: i53]: Record } } type Record = { archetype: Archetype, row: number, dense: i24, componentRecord: ArchetypeMap, } type ExtractFromLuaTuple = T extends LuaTuple ? U : never; type QueryShim = { without: (...args: ExtractFromLuaTuple) => QueryShim; } & IterableFunction; interface World { entity(): Entity; component(): Entity; target(id: Entity, relation: Entity): Entity | undefined; delete(id: Entity): void; add(id: Entity, component: Entity): void; set(id: Entity, component: Entity, data: T): void; remove(id: Entity, component: Entity): void; get(id: number, component: Entity): A; // Manually typed out since there is a hard limit. get(id: number, component: Entity, component2: Entity): LuaTuple<[A, B]>; get(id: number, component: Entity, component2: Entity, component3: Entity): LuaTuple<[A, B, C]>; get(id: number, component: Entity, component2: Entity, component3: Entity, component4: Entity): LuaTuple<[A, B, C, D]>; query(...entities: T): QueryShim> } interface WorldConstructor { new(): World } export const World: WorldConstructor; export const pair: (pred: Entity, obj: Entity) => Entity; export const OnAdd: Entity; export const OnRemove: Entity; export const OnSet: Entity; export const Wildcard: Entity; export const w: Entity; export const REST: Entity; export const IS_PAIR: (e: number) => boolean; export const ECS_ID: (e: i53) => i24; export const ECS_PAIR: (pred: i53, obj: i53) => i53; export const ECS_GENERATION_INC: (e: i53) => i53; export const ECS_GENERATION: (e: i53) => i53; export const ECS_PAIR_RELATION: (entityIndex: EntityIndex, e: Entity) => i53; export const ECS_PAIR_OBJECT: (entityIndex: EntityIndex, e: Entity) => i53; export const getAlive: (entityIndex: EntityIndex, id: i24) => i53;