diff --git a/packages/ecs/package.json b/packages/ecs/package.json index 220c3f311e..5ea28c5e46 100644 --- a/packages/ecs/package.json +++ b/packages/ecs/package.json @@ -36,6 +36,7 @@ "dependencies": { "@thi.ng/api": "^6.5.0", "@thi.ng/associative": "^3.1.0", + "@thi.ng/binary": "^1.1.1", "@thi.ng/checks": "^2.4.1", "@thi.ng/dcons": "^2.1.6", "@thi.ng/idgen": "^0.0.1", diff --git a/packages/ecs/src/ecs.ts b/packages/ecs/src/ecs.ts index 9f098cac55..80f2eef80c 100644 --- a/packages/ecs/src/ecs.ts +++ b/packages/ecs/src/ecs.ts @@ -1,12 +1,13 @@ import { assert, Event, - Fn, INotify, INotifyMixin, + Listener, Type, typedArray } from "@thi.ng/api"; +import { bitSize } from "@thi.ng/binary"; import { isArray, isString } from "@thi.ng/checks"; import { IDGen } from "@thi.ng/idgen"; import { filter } from "@thi.ng/transducers"; @@ -35,7 +36,7 @@ export class ECS implements INotify { groups: Map>; constructor(capacity = 1000) { - this.idgen = new IDGen(Math.ceil(Math.log(capacity) / Math.LN2), 0); + this.idgen = new IDGen(bitSize(capacity), 0); this.components = new Map(); this.groups = new Map(); } @@ -132,17 +133,13 @@ export class ECS implements INotify { return filter((g) => g.has(id), this.groups.values()); } - // @ts-ignore: arguments - addListener(id: string, fn: Fn, scope?: any): boolean { - return false; - } + // @ts-ignore: mixin + addListener(id: string, fn: Listener, scope?: any): boolean {} - // @ts-ignore: arguments - removeListener(id: string, fn: Fn, scope?: any): boolean { - return false; - } + // @ts-ignore: mixin + removeListener(id: string, fn: Listener, scope?: any): boolean {} - // @ts-ignore: arguments + // @ts-ignore: mixin notify(event: Event) {} }