mani-game-engine 1.0.0-pre.5 → 1.0.0-pre.50
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 +21 -21
- package/README.md +69 -69
- package/lib/clock.d.ts +55 -31
- package/lib/clock.js +117 -78
- package/lib/clock.js.map +1 -1
- package/lib/ecsInjector.d.ts +46 -24
- package/lib/ecsInjector.js +222 -138
- package/lib/ecsInjector.js.map +1 -1
- package/lib/entity.d.ts +35 -21
- package/lib/entity.js +167 -85
- package/lib/entity.js.map +1 -1
- package/lib/gameEngine.d.ts +89 -76
- package/lib/gameEngine.js +368 -316
- package/lib/gameEngine.js.map +1 -1
- package/lib/index.d.ts +12 -10
- package/lib/index.js +35 -10
- package/lib/index.js.map +1 -1
- package/lib/injector.d.ts +130 -0
- package/lib/injector.js +324 -0
- package/lib/injector.js.map +1 -0
- package/lib/scope/scopeContext.d.ts +71 -53
- package/lib/scope/scopeContext.js +286 -206
- package/lib/scope/scopeContext.js.map +1 -1
- package/lib/systemContext.d.ts +15 -11
- package/lib/systemContext.js +38 -16
- package/lib/systemContext.js.map +1 -1
- package/lib/types.d.ts +83 -67
- package/lib/types.js +19 -9
- package/lib/types.js.map +1 -1
- package/lib/utils/map2k.d.ts +6 -6
- package/lib/utils/map2k.js +43 -39
- package/lib/utils/map2k.js.map +1 -1
- package/package.json +39 -40
- package/src/clock.ts +163 -103
- package/src/ecsInjector.ts +279 -183
- package/src/entity.ts +202 -116
- package/src/gameEngine.ts +472 -411
- package/src/index.ts +33 -14
- package/src/injector.ts +410 -0
- package/src/scope/scopeContext.ts +369 -267
- package/src/systemContext.ts +40 -22
- package/src/types.ts +99 -82
- package/src/utils/map2k.ts +52 -52
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Jan Mankopf
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
#### Use entity component system
|
|
3
|
-
```typescript
|
|
4
|
-
import {EntityComponent, GetComponent, GetEntity, Inject, Injector} from 'mani-injector';
|
|
5
|
-
|
|
6
|
-
class Service {}
|
|
7
|
-
|
|
8
|
-
class FooComponent {}
|
|
9
|
-
class BarComponent {}
|
|
10
|
-
|
|
11
|
-
class FirstEntity {
|
|
12
|
-
@EntityComponent
|
|
13
|
-
foo: FooComponent = new FooComponent();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
class SecondEntity {
|
|
17
|
-
@EntityComponent
|
|
18
|
-
foo: FooComponent = new FooComponent();
|
|
19
|
-
@EntityComponent
|
|
20
|
-
bar: BarComponent = new BarComponent();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// this system is created for every entity that has a FooComponent
|
|
24
|
-
class FooSystem {
|
|
25
|
-
constructor(
|
|
26
|
-
// get a reference to the component when the system is created for a specific entity
|
|
27
|
-
@GetComponent readonly foo: FooComponent,
|
|
28
|
-
// you can get the entity object
|
|
29
|
-
@GetEntity readonly entity:Object
|
|
30
|
-
) {}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// this system is created for every entity that has a BarComponent
|
|
34
|
-
class BarSystem {
|
|
35
|
-
constructor(
|
|
36
|
-
@GetComponent readonly bar: BarComponent,
|
|
37
|
-
) {}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// this system is created for every entity that has a FooComponent and a BarComponent
|
|
41
|
-
class FooBarSystem {
|
|
42
|
-
constructor(
|
|
43
|
-
@GetComponent readonly foo: FooComponent,
|
|
44
|
-
@GetComponent readonly bar: BarComponent,
|
|
45
|
-
// you can inject everything that is mapped in the injector
|
|
46
|
-
@Inject readonly service: Service
|
|
47
|
-
) {}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const injector = new Injector();
|
|
52
|
-
|
|
53
|
-
injector.registerSystem(FooSystem);
|
|
54
|
-
injector.registerSystem(BarSystem);
|
|
55
|
-
injector.registerSystem(FooBarSystem);
|
|
56
|
-
injector.map(Service).toSingleton();
|
|
57
|
-
|
|
58
|
-
const entity1 = new FirstEntity();
|
|
59
|
-
const entity2 = new SecondEntity();
|
|
60
|
-
|
|
61
|
-
// array with one instance of FooSystem with a reference to the component
|
|
62
|
-
console.log(injector.createSystems(entity1));
|
|
63
|
-
|
|
64
|
-
// array with 3 systems
|
|
65
|
-
// one instance of FooSystem
|
|
66
|
-
// one instance of BarSystem
|
|
67
|
-
// one instance of FooBarSystem
|
|
68
|
-
console.log(injector.createSystems(entity2));
|
|
69
|
-
```
|
|
1
|
+
|
|
2
|
+
#### Use entity component system
|
|
3
|
+
```typescript
|
|
4
|
+
import {EntityComponent, GetComponent, GetEntity, Inject, Injector} from 'mani-injector';
|
|
5
|
+
|
|
6
|
+
class Service {}
|
|
7
|
+
|
|
8
|
+
class FooComponent {}
|
|
9
|
+
class BarComponent {}
|
|
10
|
+
|
|
11
|
+
class FirstEntity {
|
|
12
|
+
@EntityComponent
|
|
13
|
+
foo: FooComponent = new FooComponent();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class SecondEntity {
|
|
17
|
+
@EntityComponent
|
|
18
|
+
foo: FooComponent = new FooComponent();
|
|
19
|
+
@EntityComponent
|
|
20
|
+
bar: BarComponent = new BarComponent();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// this system is created for every entity that has a FooComponent
|
|
24
|
+
class FooSystem {
|
|
25
|
+
constructor(
|
|
26
|
+
// get a reference to the component when the system is created for a specific entity
|
|
27
|
+
@GetComponent readonly foo: FooComponent,
|
|
28
|
+
// you can get the entity object
|
|
29
|
+
@GetEntity readonly entity:Object
|
|
30
|
+
) {}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// this system is created for every entity that has a BarComponent
|
|
34
|
+
class BarSystem {
|
|
35
|
+
constructor(
|
|
36
|
+
@GetComponent readonly bar: BarComponent,
|
|
37
|
+
) {}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// this system is created for every entity that has a FooComponent and a BarComponent
|
|
41
|
+
class FooBarSystem {
|
|
42
|
+
constructor(
|
|
43
|
+
@GetComponent readonly foo: FooComponent,
|
|
44
|
+
@GetComponent readonly bar: BarComponent,
|
|
45
|
+
// you can inject everything that is mapped in the injector
|
|
46
|
+
@Inject readonly service: Service
|
|
47
|
+
) {}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
const injector = new Injector();
|
|
52
|
+
|
|
53
|
+
injector.registerSystem(FooSystem);
|
|
54
|
+
injector.registerSystem(BarSystem);
|
|
55
|
+
injector.registerSystem(FooBarSystem);
|
|
56
|
+
injector.map(Service).toSingleton();
|
|
57
|
+
|
|
58
|
+
const entity1 = new FirstEntity();
|
|
59
|
+
const entity2 = new SecondEntity();
|
|
60
|
+
|
|
61
|
+
// array with one instance of FooSystem with a reference to the component
|
|
62
|
+
console.log(injector.createSystems(entity1));
|
|
63
|
+
|
|
64
|
+
// array with 3 systems
|
|
65
|
+
// one instance of FooSystem
|
|
66
|
+
// one instance of BarSystem
|
|
67
|
+
// one instance of FooBarSystem
|
|
68
|
+
console.log(injector.createSystems(entity2));
|
|
69
|
+
```
|
package/lib/clock.d.ts
CHANGED
|
@@ -1,31 +1,55 @@
|
|
|
1
|
-
import { Signal } from 'mani-signal';
|
|
2
|
-
import { OnEarlyUpdateParams, OnFixedUpdateParams, OnUpdateParams } from './types';
|
|
3
|
-
declare const defaultOptions: {
|
|
4
|
-
autoStart: boolean;
|
|
5
|
-
fixedDeltaTime: number;
|
|
6
|
-
maxFrameTime: number;
|
|
7
|
-
timeScale: number;
|
|
8
|
-
};
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { Signal } from 'mani-signal';
|
|
2
|
+
import { OnEarlyUpdateParams, OnFixedUpdateParams, OnUpdateParams } from './types';
|
|
3
|
+
declare const defaultOptions: {
|
|
4
|
+
autoStart: boolean;
|
|
5
|
+
fixedDeltaTime: number;
|
|
6
|
+
maxFrameTime: number;
|
|
7
|
+
timeScale: number;
|
|
8
|
+
};
|
|
9
|
+
export type Timeout = {
|
|
10
|
+
recall?: number;
|
|
11
|
+
callback: Function;
|
|
12
|
+
callTime: number;
|
|
13
|
+
};
|
|
14
|
+
export type GameClockOptions = Partial<typeof defaultOptions>;
|
|
15
|
+
export interface Clock {
|
|
16
|
+
onPrepare: Signal<unknown>;
|
|
17
|
+
onEarlyUpdate: Signal<OnEarlyUpdateParams>;
|
|
18
|
+
onUpdate: Signal<OnUpdateParams>;
|
|
19
|
+
onFixedUpdate: Signal<OnFixedUpdateParams>;
|
|
20
|
+
timeScale: number;
|
|
21
|
+
start(): this;
|
|
22
|
+
stop(): this;
|
|
23
|
+
dispose(): void;
|
|
24
|
+
setTimeout(callback: Function, delay: number): number;
|
|
25
|
+
setInterval(callback: Function, delay: number): number;
|
|
26
|
+
clearTimeout(timeoutId: number): boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare class GameClock implements Clock {
|
|
29
|
+
private nextTimeoutId;
|
|
30
|
+
private timeouts;
|
|
31
|
+
private isRunning;
|
|
32
|
+
private requestId;
|
|
33
|
+
private currentTime;
|
|
34
|
+
private accumulator;
|
|
35
|
+
private gameTime;
|
|
36
|
+
private readonly _fixedDeltaTime;
|
|
37
|
+
private update;
|
|
38
|
+
private readonly maxFrameTime;
|
|
39
|
+
readonly onPrepare: Signal<unknown>;
|
|
40
|
+
readonly onEarlyUpdate: Signal<OnEarlyUpdateParams>;
|
|
41
|
+
readonly onUpdate: Signal<OnUpdateParams>;
|
|
42
|
+
readonly onFixedUpdate: Signal<OnFixedUpdateParams>;
|
|
43
|
+
constructor(options?: GameClockOptions);
|
|
44
|
+
dispose(): void;
|
|
45
|
+
get fixedDeltaTime(): number;
|
|
46
|
+
private _timeScale;
|
|
47
|
+
get timeScale(): number;
|
|
48
|
+
set timeScale(value: number);
|
|
49
|
+
start(): this;
|
|
50
|
+
stop(): this;
|
|
51
|
+
setTimeout(callback: Function, delay: number): number;
|
|
52
|
+
setInterval(callback: Function, delay: number): number;
|
|
53
|
+
clearTimeout(timeoutId: number): boolean;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
package/lib/clock.js
CHANGED
|
@@ -1,79 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.
|
|
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
|
-
this.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GameClock = void 0;
|
|
4
|
+
const mani_signal_1 = require("mani-signal");
|
|
5
|
+
const MIN_TIME_SCALE = 0.00001;
|
|
6
|
+
const defaultOptions = {
|
|
7
|
+
autoStart: true,
|
|
8
|
+
fixedDeltaTime: 1 / 60,
|
|
9
|
+
maxFrameTime: 0.25,
|
|
10
|
+
timeScale: 1,
|
|
11
|
+
};
|
|
12
|
+
class GameClock {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.nextTimeoutId = 0;
|
|
15
|
+
this.timeouts = new Map();
|
|
16
|
+
this.isRunning = false;
|
|
17
|
+
this.requestId = 0;
|
|
18
|
+
this.currentTime = 0;
|
|
19
|
+
this.accumulator = 0;
|
|
20
|
+
this.gameTime = 0;
|
|
21
|
+
this.update = (time) => {
|
|
22
|
+
const newTime = time * 0.001;
|
|
23
|
+
if (!this.isRunning) {
|
|
24
|
+
this.currentTime = newTime;
|
|
25
|
+
this.isRunning = true;
|
|
26
|
+
}
|
|
27
|
+
let frameTime = (newTime - this.currentTime) * this.timeScale;
|
|
28
|
+
if (frameTime > this.maxFrameTime) {
|
|
29
|
+
frameTime = this.maxFrameTime;
|
|
30
|
+
}
|
|
31
|
+
this.currentTime = newTime;
|
|
32
|
+
this.accumulator += frameTime;
|
|
33
|
+
let isMultipleFixedUpdate = false;
|
|
34
|
+
this.onPrepare.dispatch();
|
|
35
|
+
this.onEarlyUpdate.dispatch({ time: this.gameTime, deltaTime: frameTime });
|
|
36
|
+
for (const [id, timeOut] of this.timeouts) {
|
|
37
|
+
if (this.gameTime >= timeOut.callTime) {
|
|
38
|
+
timeOut.callback();
|
|
39
|
+
if (timeOut.recall) {
|
|
40
|
+
timeOut.callTime += timeOut.recall;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.timeouts.delete(id);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
while (this.accumulator >= this._fixedDeltaTime) {
|
|
48
|
+
if (isMultipleFixedUpdate) {
|
|
49
|
+
this.onPrepare.dispatch();
|
|
50
|
+
}
|
|
51
|
+
this.onFixedUpdate.dispatch({ time: this.gameTime, deltaTime: this._fixedDeltaTime });
|
|
52
|
+
isMultipleFixedUpdate = true;
|
|
53
|
+
this.accumulator -= this._fixedDeltaTime;
|
|
54
|
+
this.gameTime += this._fixedDeltaTime;
|
|
55
|
+
}
|
|
56
|
+
const alpha = this.accumulator / this._fixedDeltaTime;
|
|
57
|
+
this.onUpdate.dispatch({ time: this.gameTime + alpha * this._fixedDeltaTime, deltaTime: frameTime, alpha: alpha });
|
|
58
|
+
if (this.isRunning) {
|
|
59
|
+
this.requestId = requestAnimationFrame(this.update);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
this.onPrepare = new mani_signal_1.Signal();
|
|
63
|
+
this.onEarlyUpdate = new mani_signal_1.Signal();
|
|
64
|
+
this.onUpdate = new mani_signal_1.Signal();
|
|
65
|
+
this.onFixedUpdate = new mani_signal_1.Signal();
|
|
66
|
+
this._timeScale = 1;
|
|
67
|
+
const opts = Object.assign(Object.assign({}, defaultOptions), options);
|
|
68
|
+
this._fixedDeltaTime = opts.fixedDeltaTime;
|
|
69
|
+
this.maxFrameTime = opts.maxFrameTime;
|
|
70
|
+
this.timeScale = opts.timeScale;
|
|
71
|
+
opts.autoStart && this.start();
|
|
72
|
+
}
|
|
73
|
+
dispose() {
|
|
74
|
+
this.onPrepare.detachAll();
|
|
75
|
+
this.onEarlyUpdate.detachAll();
|
|
76
|
+
this.onUpdate.detachAll();
|
|
77
|
+
this.onFixedUpdate.detachAll();
|
|
78
|
+
}
|
|
79
|
+
get fixedDeltaTime() { return this._fixedDeltaTime; }
|
|
80
|
+
get timeScale() {
|
|
81
|
+
return this._timeScale;
|
|
82
|
+
}
|
|
83
|
+
set timeScale(value) {
|
|
84
|
+
this._timeScale = Math.max(value, MIN_TIME_SCALE);
|
|
85
|
+
}
|
|
86
|
+
start() {
|
|
87
|
+
if (this.isRunning) {
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
this.requestId = requestAnimationFrame(this.update);
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
stop() {
|
|
94
|
+
if (!this.isRunning) {
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
this.isRunning = false;
|
|
98
|
+
cancelAnimationFrame(this.requestId);
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
setTimeout(callback, delay) {
|
|
102
|
+
const timeOut = { callback, callTime: this.gameTime + delay };
|
|
103
|
+
this.nextTimeoutId++;
|
|
104
|
+
this.timeouts.set(this.nextTimeoutId, timeOut);
|
|
105
|
+
return this.nextTimeoutId;
|
|
106
|
+
}
|
|
107
|
+
setInterval(callback, delay) {
|
|
108
|
+
const timeOut = { callback, callTime: this.gameTime + delay, recall: delay };
|
|
109
|
+
this.nextTimeoutId++;
|
|
110
|
+
this.timeouts.set(this.nextTimeoutId, timeOut);
|
|
111
|
+
return this.nextTimeoutId;
|
|
112
|
+
}
|
|
113
|
+
clearTimeout(timeoutId) {
|
|
114
|
+
return this.timeouts.delete(timeoutId);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.GameClock = GameClock;
|
|
79
118
|
//# sourceMappingURL=clock.js.map
|
package/lib/clock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":";;;AAAA,6CAAmC;AAGnC,MAAM,cAAc,GAAG,OAAO,CAAC;AAI/B,MAAM,cAAc,GAAG;IACnB,SAAS,EAAE,IAAI;IACf,cAAc,EAAE,CAAC,GAAG,EAAE;IACtB,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE,CAAC;CACf,CAAC;AAwBF,MAAa,SAAS;IAgElB,YAAY,OAA0B;QA/D9B,kBAAa,GAAG,CAAC,CAAC;QAClB,aAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;QACtC,cAAS,GAAG,KAAK,CAAC;QAClB,cAAS,GAAG,CAAC,CAAC;QACd,gBAAW,GAAG,CAAC,CAAC;QAChB,gBAAW,GAAG,CAAC,CAAC;QAChB,aAAQ,GAAG,CAAC,CAAC;QAGb,WAAM,GAAG,CAAC,IAAY,EAAE,EAAE;YAC9B,MAAM,OAAO,GAAG,IAAI,GAAG,KAAK,CAAC;YAC7B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACjB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;gBAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;aACzB;YAED,IAAI,SAAS,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;YAE9D,IAAI,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE;gB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}
|
package/lib/ecsInjector.d.ts
CHANGED
|
@@ -1,24 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { SystemContext } from './systemContext';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export
|
|
1
|
+
import { Signal } from 'mani-signal';
|
|
2
|
+
import { Class, Dependency, ID, Injector, ResolverFunction } from './injector';
|
|
3
|
+
import { SystemContext } from './systemContext';
|
|
4
|
+
import { Entity } from './entity';
|
|
5
|
+
type ComponentClass = Class;
|
|
6
|
+
type EntityClass = Class;
|
|
7
|
+
type ComponentDependency = Dependency & {
|
|
8
|
+
kind: 'component';
|
|
9
|
+
index: number;
|
|
10
|
+
type: Class;
|
|
11
|
+
};
|
|
12
|
+
type DynamicComponentDependency = Dependency & {
|
|
13
|
+
kind: 'dynamic';
|
|
14
|
+
index: number;
|
|
15
|
+
type: Class;
|
|
16
|
+
};
|
|
17
|
+
export declare const GetComponent: (dependantType: Class<any>, _propertyKey: string | symbol, index: number) => any;
|
|
18
|
+
export declare const GetDynamicComponent: (dependantType: Class<any>, _propertyKey: string | symbol, index: number) => any;
|
|
19
|
+
export declare const GetEntity: (dependantType: Class<any>, _propertyKey: string | symbol, index: number) => any;
|
|
20
|
+
export declare const GetContext: (dependantType: Class<any>, _propertyKey: string | symbol, index: number) => any;
|
|
21
|
+
export declare const GetSignal: (id: ID) => (dependantType: Class<any>, _propertyKey: string | symbol, index: number) => any;
|
|
22
|
+
export declare const GetEntitySignal: (id: ID) => (dependantType: Class<any>, _propertyKey: string | symbol, index: number) => any;
|
|
23
|
+
export declare const EntityComponent: (target: object, propertyKey: string) => any;
|
|
24
|
+
export declare const signalHandlers: Map<Object, [string, ID][]>;
|
|
25
|
+
export declare const staticSignalHandlers: Map<Object, [string, ID][]>;
|
|
26
|
+
export declare const OnSignal: (id: ID) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
27
|
+
export declare class EcsInjector<SystemClass extends Class = Class> extends Injector {
|
|
28
|
+
static warnNoMatchingEntities: boolean;
|
|
29
|
+
static entityComponents: Map<EntityClass, Map<ComponentClass, string>>;
|
|
30
|
+
protected componentDependencyMap: Map<Class<any>, ComponentDependency[]>;
|
|
31
|
+
protected dynamicComponentDependencyMap: Map<Class<any>, DynamicComponentDependency[]>;
|
|
32
|
+
protected entitySystemMap: Map<Class, SystemClass[]>;
|
|
33
|
+
protected dynamicComponentSystemMap: Map<Class, SystemClass[]>;
|
|
34
|
+
protected entitySystemResolverTuples: Map<Class, Map<SystemClass, ResolverFunction[]>>;
|
|
35
|
+
private signalMap;
|
|
36
|
+
constructor(parent?: EcsInjector<SystemClass>);
|
|
37
|
+
newSignalScope(): void;
|
|
38
|
+
registerSystem<T extends SystemClass>(systemClass: T): void;
|
|
39
|
+
createSystemsForDynamicComponents(dynamicComponentClass: Class, entity: Entity): Set<SystemContext<import("./types").System>> | undefined;
|
|
40
|
+
createSystemsForEntity(entity: Entity): Set<SystemContext>;
|
|
41
|
+
private createSystems;
|
|
42
|
+
private getSystemResolverTuples;
|
|
43
|
+
getSignal<T>(id: ID): Signal<T>;
|
|
44
|
+
dispose(): void;
|
|
45
|
+
}
|
|
46
|
+
export {};
|