@skewedaspect/sage 0.6.0 → 0.6.2
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/dist/classes/gameEngine.d.ts +1 -0
- package/dist/sage.es.js +36 -32
- package/dist/sage.es.js.map +1 -1
- package/dist/sage.umd.js +1 -1
- package/dist/sage.umd.js.map +1 -1
- package/package.json +8 -6
package/dist/sage.es.js
CHANGED
|
@@ -3,7 +3,7 @@ var I = (r, e, t) => e in r ? A(r, e, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var n = (r, e, t) => I(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { FreeCamera as G, Vector3 as b, HemisphericLight as V, MeshBuilder as E, PhysicsAggregate as C, PhysicsShapeType as D, Scene as B, NullEngine as L, WebGPUEngine as K, Engine as T, HavokPlugin as U } from "@babylonjs/core";
|
|
5
5
|
import R from "@babylonjs/havok";
|
|
6
|
-
const m = "0.6.
|
|
6
|
+
const m = "0.6.1";
|
|
7
7
|
class z {
|
|
8
8
|
/**
|
|
9
9
|
* Creates an instance of SkewedAspectGameEngine.
|
|
@@ -23,6 +23,7 @@ class z {
|
|
|
23
23
|
n(this, "engines");
|
|
24
24
|
n(this, "eventBus");
|
|
25
25
|
n(this, "logger");
|
|
26
|
+
n(this, "started", !1);
|
|
26
27
|
n(this, "_log");
|
|
27
28
|
// Lifecycle hooks
|
|
28
29
|
n(this, "_beforeStartHook", null);
|
|
@@ -67,45 +68,48 @@ class z {
|
|
|
67
68
|
* Starts the game engine.
|
|
68
69
|
*/
|
|
69
70
|
async start() {
|
|
70
|
-
this._log.info(`Starting SkewedAspect Game Engine (Version: ${m})...`), this._beforeStartHook && (this._log.debug("Executing beforeStart hook..."), await this._beforeStartHook(this)), await this.managers.gameManager.start(this.canvas), this._log.info("Game engine started successfully"), this._onStartHook && (this._log.debug("Executing onStart hook..."), await this._onStartHook(this));
|
|
71
|
+
this.started ? this._log.warn("Game engine is already started. Skipping start.") : (this._log.info(`Starting SkewedAspect Game Engine (Version: ${m})...`), this._beforeStartHook && (this._log.debug("Executing beforeStart hook..."), await this._beforeStartHook(this)), await this.managers.gameManager.start(this.canvas), this._log.info("Game engine started successfully"), this._onStartHook && (this._log.debug("Executing onStart hook..."), await this._onStartHook(this)), this.started = !0);
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
73
74
|
* Stops the game engine.
|
|
74
75
|
*/
|
|
75
76
|
async stop() {
|
|
76
|
-
this.
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
if (this.started) {
|
|
78
|
+
this._log.info(`Stopping SkewedAspect Game Engine (Version: ${m})...`);
|
|
79
|
+
let e = null;
|
|
80
|
+
if (this._onTeardownHook)
|
|
81
|
+
try {
|
|
82
|
+
this._log.debug("Executing onTeardown hook..."), await this._onTeardownHook(this);
|
|
83
|
+
} catch (t) {
|
|
84
|
+
this._log.error(`Error in onTeardown hook: ${t}`), e = e || t;
|
|
85
|
+
}
|
|
86
|
+
for (const t of Object.keys(this.managers)) {
|
|
87
|
+
const i = this.managers[t];
|
|
88
|
+
if (typeof i.$teardown == "function")
|
|
89
|
+
try {
|
|
90
|
+
this._log.debug(`Tearing down manager: ${t}`), await i.$teardown();
|
|
91
|
+
} catch (s) {
|
|
92
|
+
this._log.error(`Error tearing down manager ${t}: ${s}`), e = e || s;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
for (const t of Object.keys(this.engines)) {
|
|
96
|
+
const i = this.engines[t];
|
|
97
|
+
if (typeof i.$teardown == "function")
|
|
98
|
+
try {
|
|
99
|
+
this._log.debug(`Tearing down engine: ${t}`), await i.$teardown();
|
|
100
|
+
} catch (s) {
|
|
101
|
+
this._log.error(`Error tearing down engine ${t}: ${s}`), e = e || s;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
79
104
|
try {
|
|
80
|
-
|
|
105
|
+
await this.managers.gameManager.stop();
|
|
81
106
|
} catch (t) {
|
|
82
|
-
this._log.error(`Error
|
|
107
|
+
this._log.error(`Error stopping game manager: ${t}`), e = e || t;
|
|
83
108
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this._log.debug(`Tearing down manager: ${t}`), await i.$teardown();
|
|
89
|
-
} catch (s) {
|
|
90
|
-
this._log.error(`Error tearing down manager ${t}: ${s}`), e = e || s;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
for (const t of Object.keys(this.engines)) {
|
|
94
|
-
const i = this.engines[t];
|
|
95
|
-
if (typeof i.$teardown == "function")
|
|
96
|
-
try {
|
|
97
|
-
this._log.debug(`Tearing down engine: ${t}`), await i.$teardown();
|
|
98
|
-
} catch (s) {
|
|
99
|
-
this._log.error(`Error tearing down engine ${t}: ${s}`), e = e || s;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
await this.managers.gameManager.stop();
|
|
104
|
-
} catch (t) {
|
|
105
|
-
this._log.error(`Error stopping game manager: ${t}`), e = e || t;
|
|
106
|
-
}
|
|
107
|
-
if (this._log.info("Game engine stopped successfully"), e)
|
|
108
|
-
throw e;
|
|
109
|
+
if (this._log.info("Game engine stopped successfully"), e)
|
|
110
|
+
throw e;
|
|
111
|
+
} else
|
|
112
|
+
this._log.warn("Game engine is not started. Skipping stop.");
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
class P {
|