mani-game-engine 1.0.0-pre.8 → 1.0.0-pre.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/lib/clock.d.ts +63 -0
- package/lib/clock.js +147 -0
- package/lib/clock.js.map +1 -0
- package/lib/ecsInjector.d.ts +45 -0
- package/lib/ecsInjector.js +220 -0
- package/lib/ecsInjector.js.map +1 -0
- package/lib/entity.d.ts +40 -0
- package/lib/entity.js +199 -0
- package/lib/entity.js.map +1 -0
- package/lib/gameEngine.d.ts +99 -0
- package/lib/gameEngine.js +469 -0
- package/lib/gameEngine.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +37 -0
- package/lib/index.js.map +1 -0
- package/lib/injector.d.ts +125 -0
- package/lib/injector.js +305 -0
- package/lib/injector.js.map +1 -0
- package/lib/scope/scopeContext.d.ts +76 -0
- package/lib/scope/scopeContext.js +306 -0
- package/lib/scope/scopeContext.js.map +1 -0
- package/lib/systemContext.d.ts +18 -0
- package/lib/systemContext.js +54 -0
- package/lib/systemContext.js.map +1 -0
- package/lib/types.d.ts +80 -0
- package/lib/types.js +20 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/map2k.d.ts +6 -0
- package/lib/utils/map2k.js +44 -0
- package/lib/utils/map2k.js.map +1 -0
- package/package.json +12 -15
- package/src/clock.ts +163 -82
- package/src/ecsInjector.ts +131 -36
- package/src/entity.ts +208 -83
- package/src/gameEngine.ts +521 -362
- package/src/index.ts +24 -9
- package/src/injector.ts +410 -0
- package/src/scope/scopeContext.ts +122 -35
- package/src/systemContext.ts +50 -14
- package/src/types.ts +20 -10
package/src/gameEngine.ts
CHANGED
|
@@ -1,413 +1,572 @@
|
|
|
1
1
|
import {Action, Class, EngineSignals, GameEnginePlugin, OnFixedUpdateParams, OnUpdateParams, Service, System} from './types';
|
|
2
2
|
import {Signal, SignalBinding} from 'mani-signal';
|
|
3
3
|
import {Entity} from './entity';
|
|
4
|
-
import {ID, putIfAbsent} from 'mani-injector';
|
|
5
4
|
import {EcsInjector, signalHandlers, staticSignalHandlers} from './ecsInjector';
|
|
6
5
|
import {Clock, GameClock} from './clock';
|
|
7
6
|
import {SystemContext} from './systemContext';
|
|
7
|
+
import {ID, putIfAbsent} from './injector';
|
|
8
8
|
|
|
9
9
|
type AddEntry = [Entity, () => void];
|
|
10
10
|
type RemoveEntry = [Entity, () => void];
|
|
11
11
|
|
|
12
12
|
const defaultOptions = {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
fixedDeltaTime: 1 / 60,
|
|
14
|
+
plugins: [] as GameEnginePlugin[],
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export type GameEngineOptions = Partial<typeof defaultOptions>;
|
|
18
18
|
declare global {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
interface GameEngineActions {
|
|
20
|
+
'testAction': string;
|
|
21
|
+
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
type GameEngineActionParams<K extends keyof GameEngineActions> = GameEngineActions[K];
|
|
25
25
|
type GameAction<K extends keyof GameEngineActions> = (engine: GameEngine, params: GameEngineActionParams<K>) => Promise<any> | any;
|
|
26
26
|
|
|
27
|
+
let id = 0;
|
|
27
28
|
export class GameEngine {
|
|
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
|
-
|
|
29
|
+
readonly id = id++;
|
|
30
|
+
readonly onPrepare: Signal;
|
|
31
|
+
readonly onStart: Signal;
|
|
32
|
+
readonly onEnd: Signal;
|
|
33
|
+
readonly onRender: Signal<OnUpdateParams>;
|
|
34
|
+
readonly onUpdate: Signal<OnUpdateParams>;
|
|
35
|
+
readonly onFixedUpdate: Signal<OnFixedUpdateParams>;
|
|
36
|
+
readonly onPrePhysicsUpdate: Signal<OnFixedUpdateParams>;
|
|
37
|
+
readonly onPhysicsUpdate: Signal<OnFixedUpdateParams>;
|
|
38
|
+
readonly onPostPhysicsUpdate: Signal<OnFixedUpdateParams>;
|
|
39
|
+
readonly onLateFixedUpdate: Signal<OnFixedUpdateParams>;
|
|
40
|
+
readonly onLateUpdate: Signal<OnUpdateParams>;
|
|
41
|
+
readonly onAddEntity: Signal<Entity>;
|
|
42
|
+
readonly onRemoveEntity: Signal<Entity>;
|
|
43
|
+
|
|
44
|
+
private readonly onEarlyUpdateSet = new Set<System>();
|
|
45
|
+
private readonly onUpdateSet = new Set<System>();
|
|
46
|
+
private readonly onFixedUpdateSet = new Set<System>();
|
|
47
|
+
private readonly onPreFixedUpdateSet = new Set<System>();
|
|
48
|
+
private readonly onPhysicsUpdateSet = new Set<System>();
|
|
49
|
+
private readonly onPrePhysicsUpdateSet = new Set<System>();
|
|
50
|
+
private readonly onPostPhysicsUpdateSet = new Set<System>();
|
|
51
|
+
private readonly onLateFixedUpdateSet = new Set<System>();
|
|
52
|
+
private readonly onLateUpdateSet = new Set<System>();
|
|
53
|
+
private readonly onRenderUpdateSet = new Set<System>();
|
|
54
|
+
private readonly onAddEntitySet = new Set<System>();
|
|
55
|
+
private readonly onRemoveEntitySet = new Set<System>();
|
|
56
|
+
|
|
57
|
+
// TODO: for performance, we could store the systems directly in the entity
|
|
58
|
+
private readonly entitySystemMap = new Map<Entity, Set<SystemContext>>();
|
|
59
|
+
|
|
60
|
+
private readonly registeredServices = new Set<Class<Service>>();
|
|
61
|
+
private readonly services: Service[] = [];
|
|
62
|
+
private readonly systemChildInjectors = new Map<object, EcsInjector>();
|
|
63
|
+
|
|
64
|
+
private framePromise!: Promise<any>;
|
|
65
|
+
private resolveFrame: () => void = () => undefined;
|
|
66
|
+
|
|
67
|
+
private addQueue: AddEntry[] = [];
|
|
68
|
+
private removeQueue: RemoveEntry[] = [];
|
|
69
|
+
|
|
70
|
+
private _started = false;
|
|
71
|
+
|
|
72
|
+
get started(): boolean { return this._started; }
|
|
73
|
+
|
|
74
|
+
private _frameCount = 0;
|
|
75
|
+
get frameCount(): number { return this._frameCount; }
|
|
76
|
+
|
|
77
|
+
private _fixedFrameCount = 0;
|
|
78
|
+
get fixedFrameCount(): number { return this._fixedFrameCount; }
|
|
79
|
+
|
|
80
|
+
get numEntities(): number { return this.entitySystemMap.size;}
|
|
70
81
|
|
|
71
82
|
// TODO inject clock into game engine
|
|
72
83
|
// TODO inject space into game engine
|
|
73
84
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
constructor(
|
|
86
|
+
readonly injector: EcsInjector<Class<System>>,
|
|
87
|
+
readonly clock: Clock,
|
|
88
|
+
) {
|
|
89
|
+
this.injector.map(GameEngine).toValue(this);
|
|
90
|
+
|
|
91
|
+
this.onPrepare = this.injector.getSignal(EngineSignals.OnPrepare);
|
|
92
|
+
this.onStart = this.injector.getSignal(EngineSignals.OnStart);
|
|
93
|
+
this.onEnd = this.injector.getSignal(EngineSignals.OnEnd);
|
|
94
|
+
this.onRender = this.injector.getSignal(EngineSignals.OnRender);
|
|
95
|
+
this.onFixedUpdate = this.injector.getSignal(EngineSignals.OnFixedUpdate);
|
|
96
|
+
this.onUpdate = this.injector.getSignal(EngineSignals.OnUpdate);
|
|
97
|
+
this.onLateUpdate = this.injector.getSignal(EngineSignals.OnLateUpdate);
|
|
98
|
+
this.onPrePhysicsUpdate = this.injector.getSignal(EngineSignals.OnPrePhysicsUpdate);
|
|
99
|
+
this.onPhysicsUpdate = this.injector.getSignal(EngineSignals.OnPhysicsUpdate);
|
|
100
|
+
this.onPostPhysicsUpdate = this.injector.getSignal(EngineSignals.OnPostPhysicsUpdate);
|
|
101
|
+
this.onLateFixedUpdate = this.injector.getSignal(EngineSignals.onLateFixedUpdate);
|
|
102
|
+
|
|
103
|
+
this.onAddEntity = this.injector.getSignal(EngineSignals.OnAddEntity);
|
|
104
|
+
this.onRemoveEntity = this.injector.getSignal(EngineSignals.OnRemoveEntity);
|
|
105
|
+
|
|
106
|
+
this.setupClock();
|
|
107
|
+
this.prepareFrame();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static createDefault(options?: GameEngineOptions) {
|
|
111
|
+
const opts = {...defaultOptions, ...options};
|
|
112
|
+
const clock = new GameClock({
|
|
113
|
+
fixedDeltaTime: opts.fixedDeltaTime,
|
|
114
|
+
autoStart: false,
|
|
115
|
+
});
|
|
116
|
+
const injector = new EcsInjector<Class<System>>();
|
|
117
|
+
const engine = new GameEngine(injector, clock);
|
|
118
|
+
engine.installPlugins(opts.plugins);
|
|
119
|
+
return engine;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static createDefaultWithInjector(injector: EcsInjector<Class<System>>, options?: GameEngineOptions) {
|
|
123
|
+
const opts = {...defaultOptions, ...options};
|
|
124
|
+
const clock = new GameClock({
|
|
125
|
+
fixedDeltaTime: opts.fixedDeltaTime,
|
|
126
|
+
autoStart: false,
|
|
127
|
+
});
|
|
128
|
+
const engine = new GameEngine(injector, clock);
|
|
129
|
+
engine.installPlugins(opts.plugins);
|
|
130
|
+
return engine;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// TODO: test
|
|
134
|
+
addServiceClass<T extends Class<Service>>(serviceClass: T, mapping?: (injector: EcsInjector) => void): InstanceType<T> {
|
|
135
|
+
let childInjector: EcsInjector | undefined;
|
|
136
|
+
if (mapping) {
|
|
137
|
+
childInjector = this.injector.createChild();
|
|
138
|
+
mapping(childInjector);
|
|
91
139
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
autoStart: false,
|
|
98
|
-
});
|
|
99
|
-
const injector = new EcsInjector<Class<System>>();
|
|
100
|
-
const engine = new GameEngine(injector, clock);
|
|
101
|
-
engine.installPlugins(opts.plugins);
|
|
102
|
-
return engine;
|
|
140
|
+
this.mapStaticAnnotatedSignals(serviceClass);
|
|
141
|
+
const service = childInjector?.createInstance(serviceClass) || this.injector.createInstance(serviceClass);
|
|
142
|
+
this.addService(service);
|
|
143
|
+
if (childInjector) {
|
|
144
|
+
this.systemChildInjectors.set(service, childInjector);
|
|
103
145
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
registerService(serviceClass: Class<Service>): void {
|
|
146
|
-
this.mapStaticAnnotatedSignals(serviceClass);
|
|
147
|
-
if (this._started) throw new Error('Register Services before engine is started');
|
|
148
|
-
this.injector.map(serviceClass).toSingleton();
|
|
149
|
-
this.serviceClasses.add(serviceClass);
|
|
146
|
+
return service;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private addService(service: Service): void {
|
|
150
|
+
this.mapAnnotatedSignals(service);
|
|
151
|
+
service.onStart && service.onStart();
|
|
152
|
+
service.onPreFixedUpdate && this.onPreFixedUpdateSet.add(service);
|
|
153
|
+
service.onFixedUpdate && this.onFixedUpdateSet.add(service);
|
|
154
|
+
service.onUpdate && this.onUpdateSet.add(service);
|
|
155
|
+
service.onLateUpdate && this.onLateUpdateSet.add(service);
|
|
156
|
+
service.onPrePhysicsUpdate && this.onPrePhysicsUpdateSet.add(service);
|
|
157
|
+
service.onPhysicsUpdate && this.onPhysicsUpdateSet.add(service);
|
|
158
|
+
service.onPostPhysicsUpdate && this.onPostPhysicsUpdateSet.add(service);
|
|
159
|
+
service.onLateFixedUpdate && this.onLateFixedUpdateSet.add(service);
|
|
160
|
+
service.onRender && this.onRenderUpdateSet.add(service);
|
|
161
|
+
service.onAddEntity && this.onAddEntitySet.add(service);
|
|
162
|
+
service.onRemoveEntity && this.onRemoveEntitySet.add(service);
|
|
163
|
+
this.services.push(service);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
removeService(service: Service): void {
|
|
167
|
+
const index = this.services.indexOf(service);
|
|
168
|
+
if (index === -1) return;
|
|
169
|
+
this.services.splice(index, 1);
|
|
170
|
+
this.unmapAnnotatedSignals(service);
|
|
171
|
+
service.onPreFixedUpdate && this.onPreFixedUpdateSet.delete(service);
|
|
172
|
+
service.onFixedUpdate && this.onFixedUpdateSet.delete(service);
|
|
173
|
+
service.onUpdate && this.onUpdateSet.delete(service);
|
|
174
|
+
service.onLateUpdate && this.onLateUpdateSet.delete(service);
|
|
175
|
+
service.onPrePhysicsUpdate && this.onPrePhysicsUpdateSet.delete(service);
|
|
176
|
+
service.onPhysicsUpdate && this.onPhysicsUpdateSet.delete(service);
|
|
177
|
+
service.onPostPhysicsUpdate && this.onPostPhysicsUpdateSet.delete(service);
|
|
178
|
+
service.onLateFixedUpdate && this.onLateFixedUpdateSet.delete(service);
|
|
179
|
+
service.onRender && this.onRenderUpdateSet.delete(service);
|
|
180
|
+
service.onAddEntity && this.onAddEntitySet.delete(service);
|
|
181
|
+
service.onRemoveEntity && this.onRemoveEntitySet.delete(service);
|
|
182
|
+
service.onEnd && service.onEnd();
|
|
183
|
+
const childInjector = this.systemChildInjectors.get(service);
|
|
184
|
+
if (childInjector) {
|
|
185
|
+
childInjector.dispose();
|
|
186
|
+
this.systemChildInjectors.delete(service);
|
|
150
187
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
installPlugins(plugins: GameEnginePlugin[]) {
|
|
191
|
+
plugins.forEach(plugin => {
|
|
192
|
+
plugin.onPrepare && plugin.onPrepare(this);
|
|
193
|
+
});
|
|
194
|
+
plugins.forEach(plugin => {
|
|
195
|
+
plugin.onStart && plugin.onStart(this);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
registerSystem(systemClass: Class<System>): void {
|
|
200
|
+
this.mapStaticAnnotatedSignals(systemClass);
|
|
201
|
+
if (this._started) throw new Error('Register Systems before engine is started');
|
|
202
|
+
this.injector.registerSystem(systemClass);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
registerService(serviceClass: Class<Service>): void {
|
|
206
|
+
this.mapStaticAnnotatedSignals(serviceClass);
|
|
207
|
+
if (this._started) throw new Error('Register Services before engine is started');
|
|
208
|
+
this.injector.map(serviceClass).toSingleton();
|
|
209
|
+
this.registeredServices.add(serviceClass);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
getService<T extends Class<Service>>(serviceClass: T): InstanceType<T> {
|
|
213
|
+
return this.injector.get(serviceClass);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
start() {
|
|
217
|
+
this._started = true;
|
|
218
|
+
//TODO: throw when registering services or systems when engine is running
|
|
219
|
+
for (const serviceClass of this.registeredServices) {
|
|
220
|
+
const service = this.injector.get(serviceClass);
|
|
221
|
+
this.addService(service);
|
|
154
222
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
223
|
+
this.clock.start();
|
|
224
|
+
this.onStart.dispatch();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
private setupClock() {
|
|
228
|
+
this.clock.onPrepare.add(this.prepareFrame, {context: this});
|
|
229
|
+
|
|
230
|
+
this.clock.onEarlyUpdate.add(({time, deltaTime}) => {
|
|
231
|
+
for (const system of this.onEarlyUpdateSet) {
|
|
232
|
+
system.onEarlyUpdate!(time, deltaTime);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
this.clock.onFixedUpdate.add((params) => {
|
|
237
|
+
const {time, deltaTime} = params;
|
|
238
|
+
for (const system of this.onPreFixedUpdateSet) {
|
|
239
|
+
system.onPreFixedUpdate!(time, deltaTime);
|
|
240
|
+
}
|
|
241
|
+
this.onFixedUpdate.dispatch(params);
|
|
242
|
+
for (const system of this.onFixedUpdateSet) {
|
|
243
|
+
system.onFixedUpdate!(time, deltaTime);
|
|
244
|
+
}
|
|
245
|
+
this.onPhysicsUpdate.dispatch(params);
|
|
246
|
+
for (const system of this.onPhysicsUpdateSet) {
|
|
247
|
+
system.onPhysicsUpdate!(time, deltaTime);
|
|
248
|
+
}
|
|
249
|
+
this.onPostPhysicsUpdate.dispatch(params);
|
|
250
|
+
for (const system of this.onPostPhysicsUpdateSet) {
|
|
251
|
+
system.onPostPhysicsUpdate!(time, deltaTime);
|
|
252
|
+
}
|
|
253
|
+
this.onLateFixedUpdate.dispatch(params);
|
|
254
|
+
for (const system of this.onLateFixedUpdateSet) {
|
|
255
|
+
system.onLateFixedUpdate!(time, deltaTime);
|
|
256
|
+
}
|
|
257
|
+
this._fixedFrameCount++;
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// TODO: update from outside
|
|
261
|
+
this.clock.onUpdate.add(onUpdateParams => {
|
|
262
|
+
const {time, deltaTime, alpha} = onUpdateParams;
|
|
263
|
+
this.onUpdate.dispatch(onUpdateParams);
|
|
264
|
+
for (const system of this.onUpdateSet) {
|
|
265
|
+
system.onUpdate!(time, deltaTime, alpha);
|
|
266
|
+
}
|
|
267
|
+
//TODO: merge with framerate to single signal?
|
|
268
|
+
this.onLateUpdate.dispatch(onUpdateParams);
|
|
269
|
+
for (const system of this.onLateUpdateSet) {
|
|
270
|
+
system.onLateUpdate!(time, deltaTime, alpha);
|
|
271
|
+
}
|
|
272
|
+
this.onRender.dispatch(onUpdateParams);
|
|
273
|
+
for (const system of this.onRenderUpdateSet) {
|
|
274
|
+
system.onRender!(time, deltaTime, alpha);
|
|
275
|
+
}
|
|
276
|
+
this._frameCount++;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
add(entity: Entity) {
|
|
281
|
+
return new Promise<void>(resolve => this.addQueue.push([entity, resolve]));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
addAll(entity: Entity[]) {
|
|
285
|
+
return Promise.all(entity.map(entity => new Promise<void>(resolve => this.addQueue.push([entity, resolve]))));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
waitFrame() {
|
|
289
|
+
return this.framePromise;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
async remove(entity: Entity) {
|
|
293
|
+
if ((<any>entity).markRemoval) return;
|
|
294
|
+
(<any>entity).markRemoval = true;
|
|
295
|
+
return new Promise<void>(resolve => this.removeQueue.push([entity, resolve]));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async removeAll(entities: Entity[]) {
|
|
299
|
+
return Promise.all(entities.map(entity => this.remove(entity)));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
stop() {
|
|
303
|
+
// this.injector.dispose();
|
|
304
|
+
this.clock.stop();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
runAction<T extends Action>(action: T): ReturnType<T> {
|
|
308
|
+
return action(this);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
getSignal<T>(signalId: ID): Signal<T> {
|
|
312
|
+
return this.injector.getSignal<T>(signalId);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
private signalMappings = new Map<Class, [string, Signal][]>();
|
|
316
|
+
private staticSignalMappings = new Map<Class, [string, Signal][]>();
|
|
317
|
+
private signalMapBindings = new Map<Object, SignalBinding[]>();
|
|
318
|
+
|
|
319
|
+
// TODO: staticSignalMapBindings needed if we want to unregister Services or Systems
|
|
320
|
+
|
|
321
|
+
private mapStaticAnnotatedSignals(target: Class) {
|
|
322
|
+
let staticSignalMap = this.getStaticSignalMap(target);
|
|
323
|
+
if (staticSignalMap.length === 0) return;
|
|
324
|
+
|
|
325
|
+
const bindings = [];
|
|
326
|
+
for (const [key, signal] of staticSignalMap) {
|
|
327
|
+
bindings.push(signal.add((<any>target)[key], {context: target}));
|
|
165
328
|
}
|
|
329
|
+
// TODO: ignore bindings for now (store them if we implement unregister Service or Systems
|
|
330
|
+
}
|
|
166
331
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
this.clock.onEarlyUpdate.add(({time, deltaTime}) => {
|
|
171
|
-
for (const system of this.onEarlyUpdateSet) {
|
|
172
|
-
system.onEarlyUpdate!(time, deltaTime);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
this.clock.onFixedUpdate.add((params) => {
|
|
177
|
-
const {time, deltaTime} = params;
|
|
178
|
-
for (const system of this.onPreFixedUpdateSet) {
|
|
179
|
-
system.onPreFixedUpdate!();
|
|
180
|
-
}
|
|
181
|
-
for (const system of this.onFixedUpdateSet) {
|
|
182
|
-
system.onFixedUpdate!(time, deltaTime);
|
|
183
|
-
}
|
|
184
|
-
this.onFixedUpdate.dispatch(params);
|
|
185
|
-
for (const system of this.onPhysicsUpdateSet) {
|
|
186
|
-
system.onPhysicsUpdate!(time, deltaTime);
|
|
187
|
-
}
|
|
188
|
-
this.onPostPhysics.dispatch(params);
|
|
189
|
-
for (const system of this.onPostPhysicsUpdateSet) {
|
|
190
|
-
system.onPostPhysicsUpdate!(time, deltaTime);
|
|
191
|
-
}
|
|
192
|
-
this.onLateFixedUpdate.dispatch(params);
|
|
193
|
-
for (const system of this.onLateFixedUpdateSet) {
|
|
194
|
-
system.onLateFixedUpdate!(time, deltaTime);
|
|
195
|
-
}
|
|
196
|
-
this._fixedFrameCount++;
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
// TODO: update from outside
|
|
200
|
-
this.clock.onUpdate.add(onUpdateParams => {
|
|
201
|
-
const {time, deltaTime, alpha} = onUpdateParams;
|
|
202
|
-
for (const system of this.onUpdateSet) {
|
|
203
|
-
system.onUpdate!(time, deltaTime, alpha);
|
|
204
|
-
}
|
|
205
|
-
//TODO: merge with framerate to single signal?
|
|
206
|
-
|
|
207
|
-
this.onUpdate.dispatch(onUpdateParams);
|
|
208
|
-
for (const system of this.onLateUpdateSet) {
|
|
209
|
-
system.onLateUpdate!(time, deltaTime, alpha);
|
|
210
|
-
}
|
|
211
|
-
this.onLateUpdate.dispatch(onUpdateParams);
|
|
212
|
-
|
|
213
|
-
for (const system of this.onRenderUpdateSet) {
|
|
214
|
-
system.onRender!(time, deltaTime, alpha);
|
|
215
|
-
}
|
|
216
|
-
this.onRender.dispatch(onUpdateParams);
|
|
217
|
-
this._frameCount++;
|
|
218
|
-
});
|
|
219
|
-
}
|
|
332
|
+
private mapAnnotatedSignals(target: Object) {
|
|
333
|
+
const signalMap = this.getSignalMap(target.constructor);
|
|
334
|
+
if (signalMap.length === 0) return;
|
|
220
335
|
|
|
221
|
-
|
|
222
|
-
|
|
336
|
+
const bindings = [];
|
|
337
|
+
for (const [key, signal] of signalMap) {
|
|
338
|
+
bindings.push(signal.add((<any>target)[key], {context: target}));
|
|
223
339
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
340
|
+
this.signalMapBindings.set(target, bindings);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
private unmapAnnotatedSignals(target: Object) {
|
|
344
|
+
const signalBindings = this.signalMapBindings.get(target);
|
|
345
|
+
if (!signalBindings) return;
|
|
346
|
+
for (const binding of signalBindings) {
|
|
347
|
+
binding.detach();
|
|
227
348
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
private getSignalMap(target: Function) {
|
|
352
|
+
// TODO: we could speed thinks up by introducing "invisible" flags on the systems/services to avoid a map check
|
|
353
|
+
return putIfAbsent(this.signalMappings, target, (): [string, Signal][] => {
|
|
354
|
+
const handlers = signalHandlers.get(target);
|
|
355
|
+
if (!handlers) return [];
|
|
356
|
+
const result: [string, Signal][] = [];
|
|
357
|
+
for (const [key, signalId] of handlers) {
|
|
358
|
+
result.push([key, this.getSignal(signalId)]);
|
|
359
|
+
}
|
|
360
|
+
return result;
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
private getStaticSignalMap(target: Class) {
|
|
365
|
+
// TODO: we could speed thinks up by introducing "invisible" flags on the systems/services to avoid a map check
|
|
366
|
+
return putIfAbsent(this.staticSignalMappings, target, (): [string, Signal][] => {
|
|
367
|
+
const handlers = staticSignalHandlers.get(target);
|
|
368
|
+
if (!handlers) return [];
|
|
369
|
+
const result: [string, Signal][] = [];
|
|
370
|
+
for (const [key, signalId] of handlers) {
|
|
371
|
+
result.push([key, this.getSignal(signalId)]);
|
|
372
|
+
}
|
|
373
|
+
return result;
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
dispose() {
|
|
378
|
+
this.clock.stop();
|
|
379
|
+
this.clock.dispose();
|
|
380
|
+
for (const systems of this.entitySystemMap.values()) {
|
|
381
|
+
for (const context of systems) {
|
|
382
|
+
context.system.onEnd && context.system.onEnd();
|
|
383
|
+
this.unmapAnnotatedSignals(context.system);
|
|
384
|
+
}
|
|
233
385
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
this.clock.stop();
|
|
386
|
+
for (const service of this.services) {
|
|
387
|
+
service.onEnd && service.onEnd();
|
|
388
|
+
this.unmapAnnotatedSignals(service);
|
|
238
389
|
}
|
|
390
|
+
this.onEnd.dispatch();
|
|
391
|
+
|
|
392
|
+
this.onAddEntity.detachAll();
|
|
393
|
+
this.onRemoveEntity.detachAll();
|
|
394
|
+
this.onPrepare.detachAll();
|
|
395
|
+
this.onStart.detachAll();
|
|
396
|
+
this.onEnd.detachAll();
|
|
397
|
+
this.onRender.detachAll();
|
|
398
|
+
this.onUpdate.detachAll();
|
|
399
|
+
this.onFixedUpdate.detachAll();
|
|
400
|
+
this.onPrePhysicsUpdate.detachAll();
|
|
401
|
+
this.onPhysicsUpdate.detachAll();
|
|
402
|
+
this.onPostPhysicsUpdate.detachAll();
|
|
403
|
+
this.onLateFixedUpdate.detachAll();
|
|
404
|
+
this.onPhysicsUpdateSet.clear();
|
|
405
|
+
this.onPrePhysicsUpdateSet.clear();
|
|
406
|
+
this.onPostPhysicsUpdateSet.clear();
|
|
407
|
+
this.onLateFixedUpdateSet.clear();
|
|
408
|
+
this.onLateUpdate.detachAll();
|
|
409
|
+
this.onUpdate.detachAll();
|
|
410
|
+
this.onFixedUpdate.detachAll();
|
|
411
|
+
this.onRender.detachAll();
|
|
412
|
+
this.onAddEntity.detachAll();
|
|
413
|
+
this.onRemoveEntity.detachAll();
|
|
414
|
+
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
private prepareFrame() {
|
|
418
|
+
this.deferSignal = new Signal();
|
|
419
|
+
for (const [entity, resolve] of this.removeQueue) {
|
|
420
|
+
const entities = entity.getAllEntities();
|
|
421
|
+
for (const entity of entities) {
|
|
422
|
+
(<any>entity).markRemoval = false;
|
|
423
|
+
if (!(<any>entity).gameEngine) {
|
|
424
|
+
console.log('Entity not active', entity);
|
|
425
|
+
// throw new Error('Entity not active');
|
|
426
|
+
}
|
|
427
|
+
(<any>entity).gameEngine = undefined;
|
|
428
|
+
|
|
429
|
+
const systemContexts = this.entitySystemMap.get(entity);
|
|
430
|
+
this.entitySystemMap.delete(entity);
|
|
431
|
+
if (systemContexts) {
|
|
432
|
+
for (const context of systemContexts) {
|
|
433
|
+
this.disposeContext(context);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
entity.onRemove.dispatch();
|
|
437
|
+
entity.onRemove.detachAll();
|
|
438
|
+
entity._signalMap.forEach(signal => signal.detachAll());
|
|
239
439
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
440
|
+
for (const system of this.onRemoveEntitySet) {
|
|
441
|
+
system.onRemoveEntity!(entity);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
243
444
|
|
|
244
|
-
|
|
245
|
-
return this.injector.getSignal<T>(signalId);
|
|
445
|
+
resolve();
|
|
246
446
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
447
|
+
this.removeQueue = [];
|
|
448
|
+
|
|
449
|
+
for (const [entity, resolve] of this.addQueue) {
|
|
450
|
+
const preparePromises = [];
|
|
451
|
+
const nextSystemContexts: SystemContext[] = [];
|
|
452
|
+
const entities = entity.getAllEntities();
|
|
453
|
+
for (const entity of entities) {
|
|
454
|
+
if ((<any>entity).gameEngine) throw new Error('Entity already added to a gameEngine');
|
|
455
|
+
(<any>entity).gameEngine = this;
|
|
456
|
+
const systemContexts = this.injector.createSystemsForEntity(entity);
|
|
457
|
+
for (const context of systemContexts) {
|
|
458
|
+
// TODO: implement synced mode where async onPrepares aren't allowed
|
|
459
|
+
context.system.onPrepare && preparePromises.push(context.system.onPrepare());
|
|
460
|
+
nextSystemContexts.push(context);
|
|
261
461
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
for (const [key, signal] of signalMap) {
|
|
271
|
-
bindings.push(signal.add((<any>target)[key], target));
|
|
462
|
+
this.entitySystemMap.set(entity, systemContexts);
|
|
463
|
+
// we have to check if the entity is already in the map, because a system might have added dynamic components that also added to this
|
|
464
|
+
this.addSystemContextSetToMap(entity, systemContexts);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const entityWasAdded = () => {
|
|
468
|
+
for (const system of this.onAddEntitySet) {
|
|
469
|
+
system.onAddEntity!(entity);
|
|
272
470
|
}
|
|
273
|
-
|
|
471
|
+
resolve();
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
// Promise.all doesnt resolve immediately when there are no promises bu
|
|
475
|
+
if (preparePromises.length === 0) {
|
|
476
|
+
this.startSystems(nextSystemContexts, entityWasAdded);
|
|
477
|
+
} else {
|
|
478
|
+
Promise.all(preparePromises).then(() => this.startSystems(nextSystemContexts, entityWasAdded));
|
|
479
|
+
}
|
|
274
480
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
481
|
+
this.addQueue = [];
|
|
482
|
+
// create promise for next frame
|
|
483
|
+
this.resolveFrame();
|
|
484
|
+
this.framePromise = new Promise<void>(resolve => {
|
|
485
|
+
this.resolveFrame = resolve;
|
|
486
|
+
});
|
|
487
|
+
this.onPrepare.dispatch();
|
|
488
|
+
|
|
489
|
+
this.deferSignal.dispatch();
|
|
490
|
+
this.deferSignal = undefined;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* if deferSignal is set, the callback will be called when the signal is dispatched
|
|
495
|
+
* is used for example to add a dynamic component to a system within the constructor of another system
|
|
496
|
+
*/
|
|
497
|
+
deferSignal: Signal | undefined;
|
|
498
|
+
maybeDefer<T>(callback: () => T) {
|
|
499
|
+
if (this.deferSignal) {
|
|
500
|
+
this.deferSignal.addOnce(callback);
|
|
501
|
+
} else {
|
|
502
|
+
callback();
|
|
282
503
|
}
|
|
504
|
+
}
|
|
283
505
|
|
|
284
|
-
private getSignalMap(target: Function) {
|
|
285
|
-
// TODO: we could speed thinks up by introducing "invisible" flags on the systems/services to avoid a map check
|
|
286
|
-
return putIfAbsent(this.signalMappings, target, (): [string, Signal][] => {
|
|
287
|
-
const handlers = signalHandlers.get(target);
|
|
288
|
-
if (!handlers) return [];
|
|
289
|
-
const result: [string, Signal][] = [];
|
|
290
|
-
for (const [key, signalId] of handlers) {
|
|
291
|
-
result.push([key, this.getSignal(signalId)]);
|
|
292
|
-
}
|
|
293
|
-
return result;
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
506
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
return result;
|
|
307
|
-
});
|
|
507
|
+
private addSystemContextSetToMap (entity: Entity, contexts: Set<SystemContext>) {
|
|
508
|
+
const systemContexts = this.entitySystemMap.get(entity);
|
|
509
|
+
if (!systemContexts) {
|
|
510
|
+
this.entitySystemMap.set(entity, contexts);
|
|
511
|
+
} else {
|
|
512
|
+
for (const context of contexts) {
|
|
513
|
+
systemContexts.add(context);
|
|
514
|
+
}
|
|
308
515
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
private startSystems(contexts: Iterable<SystemContext>, then?: () => void) {
|
|
519
|
+
for (const context of contexts) {
|
|
520
|
+
const system = context.system;
|
|
521
|
+
this.mapAnnotatedSignals(system);
|
|
522
|
+
system.onStart && system.onStart();
|
|
523
|
+
system.onPreFixedUpdate && this.onPreFixedUpdateSet.add(system);
|
|
524
|
+
system.onFixedUpdate && this.onFixedUpdateSet.add(system);
|
|
525
|
+
system.onUpdate && this.onUpdateSet.add(system);
|
|
526
|
+
system.onLateUpdate && this.onLateUpdateSet.add(system);
|
|
527
|
+
system.onPhysicsUpdate && this.onPhysicsUpdateSet.add(system);
|
|
528
|
+
system.onPrePhysicsUpdate && this.onPrePhysicsUpdateSet.add(system);
|
|
529
|
+
system.onPostPhysicsUpdate && this.onPostPhysicsUpdateSet.add(system);
|
|
530
|
+
system.onLateFixedUpdate && this.onLateFixedUpdateSet.add(system);
|
|
531
|
+
system.onRender && this.onRenderUpdateSet.add(system);
|
|
532
|
+
system.onAddEntity && this.onAddEntitySet.add(system);
|
|
533
|
+
system.onRemoveEntity && this.onRemoveEntitySet.add(system);
|
|
320
534
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
system.onFixedUpdate && this.onFixedUpdateSet.delete(system);
|
|
344
|
-
system.onEarlyUpdate && this.onEarlyUpdateSet.delete(system);
|
|
345
|
-
system.onUpdate && this.onUpdateSet.delete(system);
|
|
346
|
-
system.onLateUpdate && this.onLateUpdateSet.delete(system);
|
|
347
|
-
system.onPhysicsUpdate && this.onPhysicsUpdateSet.delete(system);
|
|
348
|
-
system.onPostPhysicsUpdate && this.onPostPhysicsUpdateSet.delete(system);
|
|
349
|
-
system.onLateFixedUpdate && this.onLateFixedUpdateSet.delete(system);
|
|
350
|
-
system.onRender && this.onRenderUpdateSet.delete(system);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
entity.onRemove.dispatch();
|
|
354
|
-
entity.onRemove.detachAll();
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
resolve();
|
|
358
|
-
}
|
|
359
|
-
this.removeQueue = [];
|
|
360
|
-
|
|
361
|
-
for (const [entity, resolve] of this.addQueue) {
|
|
362
|
-
const preparePromises = [];
|
|
363
|
-
const nexSystemContexts: SystemContext[] = [];
|
|
364
|
-
const entities = entity.getAllEntities();
|
|
365
|
-
for (const entity of entities) {
|
|
366
|
-
if ((<any>entity).gameEngine) throw new Error('Entity already added to a gameEngine');
|
|
367
|
-
(<any>entity).gameEngine = this;
|
|
368
|
-
const systemContexts = this.injector.createSystems(entity);
|
|
369
|
-
for (const context of systemContexts) {
|
|
370
|
-
// TODO: implement synced mode where async onPrepares aren't allowed
|
|
371
|
-
context.system.onPrepare && preparePromises.push(context.system.onPrepare());
|
|
372
|
-
nexSystemContexts.push(context);
|
|
373
|
-
}
|
|
374
|
-
this.entitySystemMap.set(entity, systemContexts);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
const startSystems = () => {
|
|
378
|
-
// TODO: check if a "global" method is faster than this inner method
|
|
379
|
-
for (const context of nexSystemContexts) {
|
|
380
|
-
const system = context.system;
|
|
381
|
-
this.mapAnnotatedSignals(system);
|
|
382
|
-
system.onStart && system.onStart();
|
|
383
|
-
system.onPreFixedUpdate && this.onPreFixedUpdateSet.add(system);
|
|
384
|
-
system.onFixedUpdate && this.onFixedUpdateSet.add(system);
|
|
385
|
-
system.onEarlyUpdate && this.onEarlyUpdateSet.add(system);
|
|
386
|
-
system.onUpdate && this.onUpdateSet.add(system);
|
|
387
|
-
system.onLateUpdate && this.onLateUpdateSet.add(system);
|
|
388
|
-
system.onPhysicsUpdate && this.onPhysicsUpdateSet.add(system);
|
|
389
|
-
system.onPostPhysicsUpdate && this.onPostPhysicsUpdateSet.add(system);
|
|
390
|
-
system.onLateFixedUpdate && this.onLateFixedUpdateSet.add(system);
|
|
391
|
-
system.onRender && this.onRenderUpdateSet.add(system);
|
|
392
|
-
}
|
|
393
|
-
resolve();
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
// Promise.all doesnt resolve immediately when there are no promises bu
|
|
397
|
-
if (preparePromises.length === 0) {
|
|
398
|
-
startSystems();
|
|
399
|
-
} else {
|
|
400
|
-
Promise.all(preparePromises).then(startSystems);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
this.addQueue = [];
|
|
404
|
-
// create promise for next frame
|
|
405
|
-
this.resolveFrame();
|
|
406
|
-
this.framePromise = new Promise<void>(resolve => {
|
|
407
|
-
this.resolveFrame = resolve;
|
|
408
|
-
});
|
|
409
|
-
this.onPrepare.dispatch();
|
|
535
|
+
then?.();
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
getAllEntities(): Entity[] {
|
|
539
|
+
return Array.from(this.entitySystemMap.keys());
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
removeAllEntities() {
|
|
543
|
+
return this.removeAll(this.getAllEntities());
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
private disposeContext(context: SystemContext<System>) {
|
|
547
|
+
const system = context.system;
|
|
548
|
+
|
|
549
|
+
// if onEnd returns a promise, we need to wait for it to finish before we can dispose the system
|
|
550
|
+
const onEndPromise = system.onEnd && system.onEnd();
|
|
551
|
+
if (onEndPromise instanceof Promise) {
|
|
552
|
+
onEndPromise.then(() => {
|
|
553
|
+
context.dispose();
|
|
554
|
+
});
|
|
555
|
+
} else {
|
|
556
|
+
context.dispose();
|
|
410
557
|
}
|
|
558
|
+
|
|
559
|
+
this.unmapAnnotatedSignals(system);
|
|
560
|
+
system.onPreFixedUpdate && this.onPreFixedUpdateSet.delete(system);
|
|
561
|
+
system.onFixedUpdate && this.onFixedUpdateSet.delete(system);
|
|
562
|
+
system.onUpdate && this.onUpdateSet.delete(system);
|
|
563
|
+
system.onLateUpdate && this.onLateUpdateSet.delete(system);
|
|
564
|
+
system.onPhysicsUpdate && this.onPhysicsUpdateSet.delete(system);
|
|
565
|
+
system.onPrePhysicsUpdate && this.onPrePhysicsUpdateSet.delete(system);
|
|
566
|
+
system.onPostPhysicsUpdate && this.onPostPhysicsUpdateSet.delete(system);
|
|
567
|
+
system.onLateFixedUpdate && this.onLateFixedUpdateSet.delete(system);
|
|
568
|
+
system.onRender && this.onRenderUpdateSet.delete(system);
|
|
569
|
+
}
|
|
411
570
|
}
|
|
412
571
|
//
|
|
413
572
|
// type RunSpread<T> = T extends undefined
|