Skip to content

Commit

Permalink
refactor(ecs): update ECS ctor, update deps, minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Nov 12, 2019
1 parent 1135853 commit a6fa7ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/ecs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 8 additions & 11 deletions packages/ecs/src/ecs.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -35,7 +36,7 @@ export class ECS<SPEC> implements INotify {
groups: Map<string, Group<SPEC, any>>;

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();
}
Expand Down Expand Up @@ -132,17 +133,13 @@ export class ECS<SPEC> implements INotify {
return filter((g) => g.has(id), this.groups.values());
}

// @ts-ignore: arguments
addListener(id: string, fn: Fn<Event, void>, scope?: any): boolean {
return false;
}
// @ts-ignore: mixin
addListener(id: string, fn: Listener, scope?: any): boolean {}

// @ts-ignore: arguments
removeListener(id: string, fn: Fn<Event, void>, 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) {}
}

Expand Down

0 comments on commit a6fa7ff

Please sign in to comment.