diff --git a/types/component-set.d.ts b/types/component-set.d.ts new file mode 100644 index 0000000..a26bbe3 --- /dev/null +++ b/types/component-set.d.ts @@ -0,0 +1,8 @@ +/** + * Track an entity, component tuple as a unique key in a set. + */ +export function create(): any[]; +export function includes(set: any, entity: any, componentName: any): boolean; +export function add(set: any, entity: any, componentName: any): void; +export function remove(set: any, entity: any, componentName: any): void; +//# sourceMappingURL=component-set.d.ts.map \ No newline at end of file diff --git a/types/component-set.d.ts.map b/types/component-set.d.ts.map new file mode 100644 index 0000000..4daee8a --- /dev/null +++ b/types/component-set.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"component-set.d.ts","sourceRoot":"","sources":["../component-set.js"],"names":[],"mappings":"AAGA;;GAEG;AAEH,gCAEC;AAGD,6EAQC;AAGD,qEAEC;AAGD,wEAQC"} \ No newline at end of file diff --git a/types/ecs.d.ts b/types/ecs.d.ts index dd99330..25c6077 100644 --- a/types/ecs.d.ts +++ b/types/ecs.d.ts @@ -49,9 +49,8 @@ */ /** * @typedef { Object } DeferredRemovalMap - * @prop {number[]} entities indexes into entities array, sorted from highest to lowest - * @prop {string[]} components [ entity index, component name ] pairs sorted from highest to lowest - * Stored as a string but seperated with `__@@ECS@@__` + * @prop {number[]} entities + * @prop {string[]} components [ entity, component name ] */ /** * @typedef { Object } WorldStats @@ -213,11 +212,11 @@ declare namespace _default { export { cleanup }; } export default _default; -export type ListenerType = 'added' | 'removed'; +export type ListenerType = "added" | "removed"; export type ListenerResult = Entity[]; export type Component = any; export type Entity = { - [key: string]: any; + [key: string]: Component; }; export type FilteredEntityList = Entity[]; export type SystemUpdateFunction = (dt: number) => void; @@ -229,10 +228,12 @@ export type System = { onUpdate?: SystemUpdateFunction; onPostUpdate?: SystemUpdateFunction; }; -export type SystemFunction = (world: World) => System; +export type SystemFunction = { + (world: World): System; +}; export type Listener = any; export type ListenerMap = { - [key: string]: any; + [key: string]: Listener; }; export type ListenerChangeMap = { added: ListenerMap; @@ -242,13 +243,9 @@ export type FilterMap = { [filterId: string]: FilteredEntityList; }; export type DeferredRemovalMap = { - /** - * indexes into entities array, sorted from highest to lowest - */ entities: number[]; /** - * [ entity index, component name ] pairs sorted from highest to lowest - * Stored as a string but seperated with `__@@ECS@@__` + * [ entity, component name ] */ components: string[]; }; diff --git a/types/ecs.d.ts.map b/types/ecs.d.ts.map index 7e4db17..dcbe78c 100644 --- a/types/ecs.d.ts.map +++ b/types/ecs.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"ecs.d.ts","sourceRoot":"","sources":["../ecs.js"],"names":[],"mappings":"AAOA;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;GAIG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;;;;GAKG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;GAIG;AAEH;;GAEG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,sCAHW,MAAM,GACJ,KAAK,CAmEjB;AAGD;;;;GAIG;AACH,oCAHW,KAAK,GACH,MAAM,CAclB;AAGD,0DAEC;AAGD,8DAEC;AAGD;;;;;;;GAOG;AACH,4CANW,KAAK,UACL,MAAM,iBACN,MAAM,kBACN,SAAS,GACP,IAAI,CA+BhB;AAGD;;;;;;;GAOG;AACF,iDANU,KAAK,UACL,MAAM,iBACN,MAAM,oBACN,OAAO,GACL,IAAI,CAiBhB;AAGD;;;;;;GAMG;AACF,oCALU,KAAK,UACL,MAAM,oBACN,OAAO,GACL,IAAI,CAmBhB;AAGD;;;;;;;;;;;;;GAaG;AACH,mCAZW,KAAK,kBACL,MAAM,EAAE,iBAKR,YAAY,sCAIV,MAAM,EAAE,CAwCpB;AAGD;;;;;;;;;GASG;AACH,iCARW,KAAK,kBACL,MAAM,EAAE,GAKN,MAAM,GAAC,IAAI,CAIvB;AA8BD;;;;GAIG;AACH,iCAHW,KAAK,MACL,cAAc,QA+BxB;AAED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