@combos-fun/engine 0.0.11 → 0.0.13
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/agent-skill.md +144 -82
- package/dist/engine.cjs.js +17 -7
- package/dist/engine.cjs.js.map +1 -1
- package/dist/engine.cjs.prod.js +1 -1
- package/dist/engine.d.ts +324 -317
- package/dist/engine.esm.js +17 -7
- package/dist/engine.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/engine.esm.js
CHANGED
|
@@ -29,6 +29,12 @@ function getComponentName(component) {
|
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
31
31
|
class Component extends EventEmitter {
|
|
32
|
+
/**
|
|
33
|
+
* Get the game instance this component belongs to
|
|
34
|
+
*/
|
|
35
|
+
get game() {
|
|
36
|
+
return this.gameObject?.scene?.game;
|
|
37
|
+
}
|
|
32
38
|
constructor(params) {
|
|
33
39
|
super();
|
|
34
40
|
/**
|
|
@@ -74,8 +80,10 @@ function getObjectCache(component, keys) {
|
|
|
74
80
|
}
|
|
75
81
|
const keyIndex = keys.length - 1;
|
|
76
82
|
let property = component;
|
|
77
|
-
// FIXME: Bug is here, property[keys[i]] maybe undefined
|
|
78
83
|
for (let i = 0; i < keyIndex; i++) {
|
|
84
|
+
if (property[keys[i]] === undefined || property[keys[i]] === null) {
|
|
85
|
+
return { property: undefined, key: undefined };
|
|
86
|
+
}
|
|
79
87
|
property = property[keys[i]];
|
|
80
88
|
}
|
|
81
89
|
cache[key] = { property, key: keys[keyIndex] };
|
|
@@ -315,7 +323,7 @@ class Transform extends Component {
|
|
|
315
323
|
for (const key of props) {
|
|
316
324
|
Object.assign(this[key], params[key]);
|
|
317
325
|
}
|
|
318
|
-
this.rotation = params.rotation
|
|
326
|
+
this.rotation = params.rotation ?? this.rotation;
|
|
319
327
|
}
|
|
320
328
|
set parent(val) {
|
|
321
329
|
if (val) {
|
|
@@ -578,7 +586,7 @@ class GameObject {
|
|
|
578
586
|
if (this.parent)
|
|
579
587
|
return this.parent.removeChild(this);
|
|
580
588
|
}
|
|
581
|
-
/**
|
|
589
|
+
/** Destroy this gameObject */
|
|
582
590
|
destroy() {
|
|
583
591
|
if (!this.transform) {
|
|
584
592
|
console.error('Cannot destroy gameObject that have already been destroyed.');
|
|
@@ -672,7 +680,7 @@ class System {
|
|
|
672
680
|
const Ctor = this.constructor;
|
|
673
681
|
this.name = Ctor.systemName;
|
|
674
682
|
}
|
|
675
|
-
/** Default
|
|
683
|
+
/** Default destroy method */
|
|
676
684
|
destroy() {
|
|
677
685
|
this.componentObserver = null;
|
|
678
686
|
this.__systemDefaultParams = null;
|
|
@@ -867,6 +875,7 @@ class Ticker {
|
|
|
867
875
|
this._lastFrameTime = frameTime;
|
|
868
876
|
const options = {
|
|
869
877
|
deltaTime,
|
|
878
|
+
delta: deltaTime,
|
|
870
879
|
time: frameTime,
|
|
871
880
|
currentTime: frameTime,
|
|
872
881
|
frameCount: ++this._frameCount,
|
|
@@ -1063,7 +1072,7 @@ const gameObjectPause = (gameObjects) => {
|
|
|
1063
1072
|
component.onPause && component.onPause();
|
|
1064
1073
|
}
|
|
1065
1074
|
catch (e) {
|
|
1066
|
-
console.error(`gameObject: ${gameObject.name}, ${component.name},
|
|
1075
|
+
console.error(`gameObject: ${gameObject.name}, ${component.name}, onPause error`, e);
|
|
1067
1076
|
}
|
|
1068
1077
|
}
|
|
1069
1078
|
}
|
|
@@ -1103,7 +1112,7 @@ class Game extends EventEmitter {
|
|
|
1103
1112
|
await this.addSystem(system);
|
|
1104
1113
|
}
|
|
1105
1114
|
if (needScene) {
|
|
1106
|
-
this.loadScene(new Scene("scene"));
|
|
1115
|
+
this.loadScene({ scene: new Scene("scene") });
|
|
1107
1116
|
}
|
|
1108
1117
|
if (autoStart) {
|
|
1109
1118
|
this.start();
|
|
@@ -1309,6 +1318,7 @@ class Game extends EventEmitter {
|
|
|
1309
1318
|
if (!scene) {
|
|
1310
1319
|
return;
|
|
1311
1320
|
}
|
|
1321
|
+
scene.game = this;
|
|
1312
1322
|
switch (mode) {
|
|
1313
1323
|
case LOAD_SCENE_MODE.SINGLE:
|
|
1314
1324
|
this.scene = scene;
|
|
@@ -1532,7 +1542,7 @@ class Resource extends EventEmitter {
|
|
|
1532
1542
|
const res = this.resourcesMap[name];
|
|
1533
1543
|
return this.makeInstanceFunctions[res.type] && (await this.makeInstanceFunctions[res.type](res));
|
|
1534
1544
|
}
|
|
1535
|
-
/**
|
|
1545
|
+
/** Destroy resource by name */
|
|
1536
1546
|
async destroy(name) {
|
|
1537
1547
|
await this._destroy(name);
|
|
1538
1548
|
}
|