-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecs.d.ts
82 lines (50 loc) · 1.62 KB
/
ecs.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
declare const Events: {
draw: string;
update: string;
enter: string;
leave: string;
resize: string;
};
declare class Entity {
private components;
constructor();
add<T extends new (...args: any[]) => any>(component: T, ...args: ConstructorParameters<T>): this;
remove(component: any): this;
get<T extends new (...args: any[]) => any>(...components: T[]): InstanceType<T>[];
getComponent<T extends new (...args: any[]) => any>(component: T): InstanceType<T>;
setComponent<T extends new (...args: any[]) => any>(cls: T, component: InstanceType<T>): void;
destroy(): this;
}
declare class System {
private requiredComponents;
private eventListeners;
constructor(...components: any[]);
hasRequiredComponents(entity: Entity): boolean;
addEventListener(event: string, listener: (...args: any[]) => void): this;
fireEvent(event: string, ...args: any[]): this;
}
declare class Engine {
private entities;
private systems;
private eventHandler;
constructor();
searchAndDestroy<T>(list: T[], target: T): void;
addEntity(entity: Entity): this;
getEntities(...components: any[]): Entity[];
removeEntity(entity: Entity): this;
addSystem(system: System): this;
getSystems(): System[];
removeSystem(system: System): this;
addEventListener(event: string, listener: (...args: any[]) => void): this;
fireEvent(event: string, ...args: any[]): this;
}
declare class StateManager {
private stack;
constructor();
switch(engine: Engine): this;
push(engine: Engine): this;
pop(): boolean;
current(): Engine;
fireEvent(event: string, ...args: any[]): this;
}
export { Entity, System, Engine, StateManager, Events };