react-simple-game-engine 0.1.14 → 0.1.17
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/lib/classes/entities/entity.d.ts +4 -4
- package/lib/classes/entities/entity.d.ts.map +1 -1
- package/lib/classes/entities/entity.js +9 -6
- package/lib/classes/scene-management.d.ts +10 -7
- package/lib/classes/scene-management.d.ts.map +1 -1
- package/lib/classes/scene-management.js +26 -6
- package/package.json +1 -1
@@ -20,11 +20,11 @@ export declare abstract class Entity<P extends Record<string, any> = Record<stri
|
|
20
20
|
get props(): P;
|
21
21
|
/**
|
22
22
|
* @param {string} name
|
23
|
-
* @param {number} interval in seconds
|
24
|
-
* @param {TimerJobListener} job function that run per
|
25
|
-
* @
|
23
|
+
* @param {number} interval in seconds
|
24
|
+
* @param {TimerJobListener} job function that run per #interval
|
25
|
+
* @void
|
26
26
|
*/
|
27
|
-
onTimer(name: string, interval: number, job: TimerJobListener): void;
|
27
|
+
onTimer(name: string, interval: number, job: TimerJobListener, defaultRun?: boolean): void;
|
28
28
|
addChild(target: EntitySult | LogicComponent<EntitySult>): void;
|
29
29
|
removeChild(entity: EntitySult): void;
|
30
30
|
createBody(transform: CreateBodyDefine["transform"], options?: CreateBodyDefine["bodyOptions"]): MasterBody;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity.ts"],"names":[],"mappings":"AAAA,OAAO,MAAwB,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,UAAU,EACV,KAAK,EACN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,aAAK,gBAAgB,GAAG,MAAM,IAAI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param {string} name
|
92
|
-
* @param {number} interval in seconds
|
93
|
-
* @param {TimerJobListener} job function that run per
|
94
|
-
* @
|
92
|
+
* @param {number} interval in seconds
|
93
|
+
* @param {TimerJobListener} job function that run per #interval
|
94
|
+
* @void
|
95
95
|
*/
|
96
|
-
Entity.prototype.onTimer = function (name, interval, job) {
|
96
|
+
Entity.prototype.onTimer = function (name, interval, job, defaultRun) {
|
97
|
+
if (defaultRun === void 0) { defaultRun = false; }
|
97
98
|
if (!this.timerJobListeners[name]) {
|
98
99
|
this.timerJobListeners[name] = {
|
99
100
|
timeCounter: 0,
|
100
101
|
interval: interval,
|
101
102
|
job: job,
|
103
|
+
defaultRun: defaultRun,
|
102
104
|
};
|
103
105
|
}
|
104
106
|
else {
|
@@ -145,10 +147,11 @@ var Entity = /** @class */ (function (_super) {
|
|
145
147
|
Entity.prototype.update = function () {
|
146
148
|
this.onUpdate();
|
147
149
|
for (var name_1 in this.timerJobListeners) {
|
148
|
-
var _a = this.timerJobListeners[name_1], timeCounter = _a.timeCounter, interval = _a.interval, job = _a.job;
|
149
|
-
if (timeCounter / 1000 >= interval) {
|
150
|
+
var _a = this.timerJobListeners[name_1], timeCounter = _a.timeCounter, interval = _a.interval, job = _a.job, defaultRun = _a.defaultRun;
|
151
|
+
if (defaultRun || timeCounter / 1000 >= interval) {
|
150
152
|
timeCounter = 0;
|
151
153
|
job();
|
154
|
+
this.timerJobListeners[name_1].defaultRun = false;
|
152
155
|
}
|
153
156
|
timeCounter += Renderer.deltaTime;
|
154
157
|
this.timerJobListeners[name_1].timeCounter = timeCounter;
|
@@ -1,19 +1,22 @@
|
|
1
1
|
import { Scene } from "./scene";
|
2
|
+
declare type SceneClass = {
|
3
|
+
new (): Scene;
|
4
|
+
tag?: string;
|
5
|
+
};
|
2
6
|
declare type ChangeSceneListener = (scene: Scene) => void;
|
3
7
|
export declare class SceneManagement {
|
4
8
|
private Scenes;
|
5
9
|
private _currentScene;
|
6
10
|
private changeSceneListener;
|
7
|
-
static getTag(Scene:
|
8
|
-
|
9
|
-
}): string | undefined;
|
10
|
-
constructor(Scenes: {
|
11
|
-
new (): Scene;
|
12
|
-
tag?: string;
|
13
|
-
}[]);
|
11
|
+
static getTag(Scene: SceneClass): string | undefined;
|
12
|
+
constructor(Scenes: SceneClass[]);
|
14
13
|
get currentScene(): Scene<any>;
|
15
14
|
onChangeScene(func: ChangeSceneListener): void;
|
15
|
+
canNext(): boolean;
|
16
|
+
next(): void;
|
17
|
+
replay(): void;
|
16
18
|
gotoScene(tag: string): void;
|
19
|
+
private startScene;
|
17
20
|
}
|
18
21
|
export {};
|
19
22
|
//# sourceMappingURL=scene-management.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scene-management.d.ts","sourceRoot":"","sources":["../../src/classes/scene-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,aAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAClD,qBAAa,eAAe;IAOd,OAAO,CAAC,MAAM;IAN1B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,mBAAmB,CAAuB;IAClD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE
|
1
|
+
{"version":3,"file":"scene-management.d.ts","sourceRoot":"","sources":["../../src/classes/scene-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,aAAK,UAAU,GAAG;IAAE,QAAQ,KAAK,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD,aAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAClD,qBAAa,eAAe;IAOd,OAAO,CAAC,MAAM;IAN1B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,mBAAmB,CAAuB;IAClD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU;gBAIX,MAAM,EAAE,UAAU,EAAE;IAKxC,IAAI,YAAY,eAEf;IAED,aAAa,CAAC,IAAI,EAAE,mBAAmB;IAIvC,OAAO;IAQP,IAAI;IAUJ,MAAM;IAIN,SAAS,CAAC,GAAG,EAAE,MAAM;IAarB,OAAO,CAAC,UAAU;CAKnB"}
|
@@ -17,22 +17,42 @@ var SceneManagement = /** @class */ (function () {
|
|
17
17
|
SceneManagement.prototype.onChangeScene = function (func) {
|
18
18
|
this.changeSceneListener = func;
|
19
19
|
};
|
20
|
+
SceneManagement.prototype.canNext = function () {
|
21
|
+
var _this = this;
|
22
|
+
var currentIndex = this.Scenes.findIndex(function (Scene) { return _this._currentScene instanceof Scene; });
|
23
|
+
var NextScene = this.Scenes[currentIndex + 1];
|
24
|
+
return !!NextScene;
|
25
|
+
};
|
26
|
+
SceneManagement.prototype.next = function () {
|
27
|
+
var _this = this;
|
28
|
+
var currentIndex = this.Scenes.findIndex(function (Scene) { return _this._currentScene instanceof Scene; });
|
29
|
+
var NextScene = this.Scenes[currentIndex + 1];
|
30
|
+
if (NextScene) {
|
31
|
+
this.startScene(NextScene);
|
32
|
+
}
|
33
|
+
};
|
34
|
+
SceneManagement.prototype.replay = function () {
|
35
|
+
this.gotoScene(this._currentScene.tag);
|
36
|
+
};
|
20
37
|
SceneManagement.prototype.gotoScene = function (tag) {
|
21
|
-
var _a;
|
22
|
-
|
23
|
-
var Scene_1 = _b[_i];
|
38
|
+
for (var _i = 0, _a = this.Scenes; _i < _a.length; _i++) {
|
39
|
+
var Scene_1 = _a[_i];
|
24
40
|
var _tag = SceneManagement.getTag(Scene_1);
|
25
41
|
if (_tag === tag) {
|
26
42
|
if (this._currentScene) {
|
27
43
|
this._currentScene.destructor();
|
28
44
|
}
|
29
|
-
this.
|
30
|
-
this._currentScene.manager = this;
|
31
|
-
(_a = this.changeSceneListener) === null || _a === void 0 ? void 0 : _a.call(this, this._currentScene);
|
45
|
+
this.startScene(Scene_1);
|
32
46
|
break;
|
33
47
|
}
|
34
48
|
}
|
35
49
|
};
|
50
|
+
SceneManagement.prototype.startScene = function (Scene) {
|
51
|
+
var _a;
|
52
|
+
this._currentScene = new Scene();
|
53
|
+
this._currentScene.manager = this;
|
54
|
+
(_a = this.changeSceneListener) === null || _a === void 0 ? void 0 : _a.call(this, this._currentScene);
|
55
|
+
};
|
36
56
|
return SceneManagement;
|
37
57
|
}());
|
38
58
|
export { SceneManagement };
|