-
Notifications
You must be signed in to change notification settings - Fork 4
/
entity-component-system.d.ts
56 lines (52 loc) · 1.56 KB
/
entity-component-system.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
declare module "entity-component-system" {
export class EntityComponentSystem {
constructor();
add(system: System): void;
addEach(system: System, search: string): void;
run(entityPool: EntityPool, elapsedTime: number): void;
runs(): number;
timings(): { [key: string]: number };
resetTimings(): void;
}
export class EntityPool {
constructor();
create(): number;
destroy(id: number): void;
registerComponent<Component>(
component: string,
factory: () => Component,
reset?: (component: Component) => void,
size?: number
): void;
addComponent<Component>(id: number, component: string): Component;
getComponent<Component>(id: number, component: string): Component;
setComponent<Component>(
id: number,
component: string,
value: Component
): void;
removeComponent<Component>(id: number, component: string): Component;
onAddComponent<Component>(
component: string,
callback: Callback<Component>
): void;
onRemoveComponent<Component>(
component: string,
callback: Callback<Component>
): void;
registerSearch(search: string, components: string[]): void;
find(search: string): number[];
load(entities: EntityJson[]): void;
save(): EntityJson[];
}
export interface System {
(entityPool: EntityPool, elapsedTime: number): void;
}
export interface Callback<Component> {
(id: number, component: string, value: Component): void;
}
export interface EntityJson {
id: number;
[componentName: string]: any;
}
}