hzengine-core 0.1.2-dev → 0.1.3
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/async/index.js +150 -162
- package/dist/audio/index.js +249 -260
- package/dist/config/index.js +57 -57
- package/dist/debug/index.js +9 -8
- package/dist/index.js +108 -103
- package/dist/plugins/basic_command/img.js +247 -249
- package/dist/plugins/basic_command/menu.js +140 -140
- package/dist/plugins/transform/animation.js +430 -440
- package/dist/plugins/transform/hz_anime.js +196 -211
- package/dist/plugins/transform/index.js +94 -93
- package/dist/script/index.js +537 -537
- package/dist/storage/index.js +447 -440
- package/dist/system/index.js +131 -144
- package/dist/ui/index.js +525 -535
- package/package.json +1 -1
- package/src/platform/index.ts +14 -12
- package/src/plugins/transform/animation.ts +1 -1
- package/src/script/index.ts +13 -0
- package/src/storage/index.ts +47 -47
- package/tsconfig.json +1 -1
- package/types/platform/index.d.ts +137 -134
- package/types/script/index.d.ts +129 -123
- package/types/script/strtools.d.ts +31 -31
package/dist/debug/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export class Debug {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
export class Debug {
|
|
2
|
+
_core;
|
|
3
|
+
constructor(_core) {
|
|
4
|
+
this._core = _core;
|
|
5
|
+
}
|
|
6
|
+
log(...args) {
|
|
7
|
+
console.log("[HZEngine]", ...args);
|
|
8
|
+
}
|
|
9
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,103 +1,108 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HZEngineCore
|
|
3
|
-
* @copyright Copyright (c) 2024 CuberQAQ. All rights reserved.
|
|
4
|
-
*/
|
|
5
|
-
import { Async } from "./async/index.js";
|
|
6
|
-
import { Audio } from "./audio/index.js";
|
|
7
|
-
import { Config } from "./config/index.js";
|
|
8
|
-
import { Debug } from "./debug/index.js";
|
|
9
|
-
import { basic_command } from "./plugins/basic_command/index.js";
|
|
10
|
-
import { global_gesture } from "./plugins/global_gesture/index.js";
|
|
11
|
-
import { registerPlugin } from "./plugins/transform/index.js";
|
|
12
|
-
import { Script } from "./script/index.js";
|
|
13
|
-
import { Storage } from "./storage/index.js";
|
|
14
|
-
import { System } from "./system/index.js";
|
|
15
|
-
import { UI } from "./ui/index.js";
|
|
16
|
-
class HZEngineCore {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.
|
|
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
|
-
this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
1
|
+
/**
|
|
2
|
+
* HZEngineCore
|
|
3
|
+
* @copyright Copyright (c) 2024 CuberQAQ. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
import { Async } from "./async/index.js";
|
|
6
|
+
import { Audio } from "./audio/index.js";
|
|
7
|
+
import { Config } from "./config/index.js";
|
|
8
|
+
import { Debug } from "./debug/index.js";
|
|
9
|
+
import { basic_command } from "./plugins/basic_command/index.js";
|
|
10
|
+
import { global_gesture } from "./plugins/global_gesture/index.js";
|
|
11
|
+
import { registerPlugin } from "./plugins/transform/index.js";
|
|
12
|
+
import { Script } from "./script/index.js";
|
|
13
|
+
import { Storage } from "./storage/index.js";
|
|
14
|
+
import { System } from "./system/index.js";
|
|
15
|
+
import { UI } from "./ui/index.js";
|
|
16
|
+
class HZEngineCore {
|
|
17
|
+
platform;
|
|
18
|
+
_eventCallbacks = new Map();
|
|
19
|
+
storage;
|
|
20
|
+
async;
|
|
21
|
+
ui;
|
|
22
|
+
script;
|
|
23
|
+
system;
|
|
24
|
+
config;
|
|
25
|
+
audio;
|
|
26
|
+
debug;
|
|
27
|
+
constructor(platform) {
|
|
28
|
+
this.platform = platform;
|
|
29
|
+
// 請不要調整這裡的初始化順序,不然會有問題(裝飾器裡有時候要用到前面初始化的東西)
|
|
30
|
+
this.storage = new Storage(this);
|
|
31
|
+
this.async = new Async(this);
|
|
32
|
+
this.ui = new UI(this);
|
|
33
|
+
this.script = new Script(this);
|
|
34
|
+
this.system = new System(this);
|
|
35
|
+
this.config = new Config(this);
|
|
36
|
+
this.audio = new Audio(this);
|
|
37
|
+
this.debug = new Debug(this);
|
|
38
|
+
// internal plugin
|
|
39
|
+
this.loadPlugin("global_gesture", global_gesture);
|
|
40
|
+
this.loadPlugin("transform", registerPlugin);
|
|
41
|
+
this.loadPlugin("basic_command", basic_command);
|
|
42
|
+
}
|
|
43
|
+
loadProject(options) {
|
|
44
|
+
this.storage.loadProject(options);
|
|
45
|
+
}
|
|
46
|
+
start(callback) {
|
|
47
|
+
// this.system.start()
|
|
48
|
+
Async.nextTick(() => {
|
|
49
|
+
this.debug.log("[HZEngine] Game Start");
|
|
50
|
+
let title = this.storage.packageData?.name;
|
|
51
|
+
if (title == null) {
|
|
52
|
+
throw `[HZEngine] project name is null, please loadProject first or check your project.json format`;
|
|
53
|
+
}
|
|
54
|
+
this.ui.getRouter("page").push("title", {
|
|
55
|
+
title,
|
|
56
|
+
});
|
|
57
|
+
// this.on("gameEnd", () => {
|
|
58
|
+
// let router = this.ui.getRouter("page")!;
|
|
59
|
+
// if (router.length > 0) return;
|
|
60
|
+
// router.push("title", {
|
|
61
|
+
// title,
|
|
62
|
+
// });
|
|
63
|
+
// });
|
|
64
|
+
callback?.();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
end() {
|
|
68
|
+
this.debug.log("[HZEngine] Game End, return to title");
|
|
69
|
+
let title = this.storage.packageData?.name;
|
|
70
|
+
if (title == null) {
|
|
71
|
+
throw `[HZEngine] project name is null, please loadProject first or check your project.json format`;
|
|
72
|
+
}
|
|
73
|
+
this.system.condition = System.Condition.Free;
|
|
74
|
+
this.ui.resetUI();
|
|
75
|
+
if (this.ui.getRouter("page").length > 0)
|
|
76
|
+
return;
|
|
77
|
+
this.ui.getRouter("page").push("title", {
|
|
78
|
+
title,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
plugins = new Map();
|
|
82
|
+
// Load Plugin
|
|
83
|
+
loadPlugin(name, plugin) {
|
|
84
|
+
this.debug.log(`[HZEngine] load plugin [${name}]`);
|
|
85
|
+
let slot = plugin(this);
|
|
86
|
+
if (slot != undefined)
|
|
87
|
+
this.plugins.set(name, slot);
|
|
88
|
+
}
|
|
89
|
+
// Event Bus
|
|
90
|
+
on(event, cb) {
|
|
91
|
+
if (this._eventCallbacks.has(event)) {
|
|
92
|
+
this._eventCallbacks.get(event).add(cb);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this._eventCallbacks.set(event, new Set().add(cb));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
off(event, cb) {
|
|
99
|
+
return !!this._eventCallbacks.get(event)?.delete(cb);
|
|
100
|
+
}
|
|
101
|
+
emit(event, ...args) {
|
|
102
|
+
this._eventCallbacks.get(event)?.forEach((cb) => {
|
|
103
|
+
cb(...args);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export { HZEngineCore, UI, Storage, Script, System, Async };
|
|
108
|
+
export * as TransformPlugin from "./plugins/transform/index.js";
|