hzengine-core 0.1.2-dev
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 +162 -0
- package/dist/async/zeppos_timer.js +58 -0
- package/dist/audio/index.js +260 -0
- package/dist/config/index.js +57 -0
- package/dist/debug/index.js +8 -0
- package/dist/index.js +103 -0
- package/dist/platform/index.js +1 -0
- package/dist/plugins/basic_command/$.js +8 -0
- package/dist/plugins/basic_command/audio.js +40 -0
- package/dist/plugins/basic_command/basic.js +124 -0
- package/dist/plugins/basic_command/character.js +112 -0
- package/dist/plugins/basic_command/conditional.js +260 -0
- package/dist/plugins/basic_command/config.js +22 -0
- package/dist/plugins/basic_command/decorator.js +24 -0
- package/dist/plugins/basic_command/eval.js +67 -0
- package/dist/plugins/basic_command/img.js +249 -0
- package/dist/plugins/basic_command/index.js +22 -0
- package/dist/plugins/basic_command/menu.js +140 -0
- package/dist/plugins/global_gesture/index.js +25 -0
- package/dist/plugins/transform/animation.js +440 -0
- package/dist/plugins/transform/commands.js +38 -0
- package/dist/plugins/transform/example_profiles.js +32 -0
- package/dist/plugins/transform/hz_anime.js +211 -0
- package/dist/plugins/transform/index.js +93 -0
- package/dist/script/index.js +537 -0
- package/dist/script/readscript.js +15 -0
- package/dist/script/strtools.js +157 -0
- package/dist/storage/decorator.js +260 -0
- package/dist/storage/fs.js +96 -0
- package/dist/storage/index.js +442 -0
- package/dist/system/index.js +144 -0
- package/dist/ui/index.js +535 -0
- package/dist/utils/path.js +289 -0
- package/license.txt +202 -0
- package/package.json +26 -0
- package/src/async/index.ts +124 -0
- package/src/async/zeppos_timer.js +65 -0
- package/src/audio/index.ts +224 -0
- package/src/config/index.ts +80 -0
- package/src/debug/index.ts +11 -0
- package/src/index.ts +122 -0
- package/src/platform/index.ts +158 -0
- package/src/plugins/basic_command/$.ts +11 -0
- package/src/plugins/basic_command/audio.ts +53 -0
- package/src/plugins/basic_command/basic.ts +145 -0
- package/src/plugins/basic_command/character.ts +144 -0
- package/src/plugins/basic_command/conditional.ts +349 -0
- package/src/plugins/basic_command/config.ts +29 -0
- package/src/plugins/basic_command/decorator.ts +29 -0
- package/src/plugins/basic_command/eval.ts +88 -0
- package/src/plugins/basic_command/img.ts +317 -0
- package/src/plugins/basic_command/index.ts +24 -0
- package/src/plugins/basic_command/menu.ts +178 -0
- package/src/plugins/global_gesture/index.ts +29 -0
- package/src/plugins/transform/animation.ts +542 -0
- package/src/plugins/transform/commands.ts +53 -0
- package/src/plugins/transform/example_profiles.ts +36 -0
- package/src/plugins/transform/hz_anime.ts +214 -0
- package/src/plugins/transform/index.ts +141 -0
- package/src/plugins/transform/readme.md +1 -0
- package/src/script/index.ts +623 -0
- package/src/script/readscript.ts +17 -0
- package/src/script/strtools.ts +159 -0
- package/src/storage/decorator.ts +473 -0
- package/src/storage/fs.ts +104 -0
- package/src/storage/index.ts +541 -0
- package/src/system/index.ts +95 -0
- package/src/ui/index.ts +699 -0
- package/src/utils/path.js +338 -0
- package/tsconfig.json +111 -0
- package/types/async/index.d.ts +24 -0
- package/types/async/zeppos_timer.d.ts +14 -0
- package/types/audio/index.d.ts +64 -0
- package/types/config/index.d.ts +9 -0
- package/types/debug/index.d.ts +6 -0
- package/types/index.d.ts +41 -0
- package/types/platform/index.d.ts +134 -0
- package/types/plugins/basic_command/$.d.ts +2 -0
- package/types/plugins/basic_command/audio.d.ts +2 -0
- package/types/plugins/basic_command/basic.d.ts +3 -0
- package/types/plugins/basic_command/character.d.ts +2 -0
- package/types/plugins/basic_command/conditional.d.ts +2 -0
- package/types/plugins/basic_command/config.d.ts +2 -0
- package/types/plugins/basic_command/decorator.d.ts +2 -0
- package/types/plugins/basic_command/eval.d.ts +2 -0
- package/types/plugins/basic_command/img.d.ts +2 -0
- package/types/plugins/basic_command/index.d.ts +2 -0
- package/types/plugins/basic_command/menu.d.ts +2 -0
- package/types/plugins/global_gesture/index.d.ts +2 -0
- package/types/plugins/transform/animation.d.ts +131 -0
- package/types/plugins/transform/commands.d.ts +7 -0
- package/types/plugins/transform/example_profiles.d.ts +2 -0
- package/types/plugins/transform/hz_anime.d.ts +51 -0
- package/types/plugins/transform/index.d.ts +13 -0
- package/types/script/index.d.ts +123 -0
- package/types/script/readscript.d.ts +2 -0
- package/types/script/strtools.d.ts +31 -0
- package/types/storage/decorator.d.ts +41 -0
- package/types/storage/fs.d.ts +1 -0
- package/types/storage/index.d.ts +86 -0
- package/types/system/index.d.ts +35 -0
- package/types/ui/index.d.ts +167 -0
- package/types/utils/path.d.ts +84 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { HZEngineCore, Platform } from "../index.js";
|
|
2
|
+
import { Save } from "../storage/decorator.js";
|
|
3
|
+
|
|
4
|
+
export class System<PlatformType extends Platform> {
|
|
5
|
+
constructor(public _core: HZEngineCore<PlatformType>) {
|
|
6
|
+
_core.on("system.continue", () => {
|
|
7
|
+
this._pauseTimer = null;
|
|
8
|
+
this.continue();
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@Save("system.condition")
|
|
13
|
+
accessor condition: System.Condition = System.Condition.Free;
|
|
14
|
+
|
|
15
|
+
_pauseTimer: number | null = null;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 暂停(可指定一段时间)
|
|
19
|
+
* 后调用的会覆盖之前pause的设定时间
|
|
20
|
+
* @param delayMs
|
|
21
|
+
*/
|
|
22
|
+
pause(delayMs?: number) {
|
|
23
|
+
this._core.debug.log(`Pause`);
|
|
24
|
+
|
|
25
|
+
if (this.condition === System.Condition.Gaming) {
|
|
26
|
+
this.condition = System.Condition.Pause;
|
|
27
|
+
} else throw `pause but condition error (todo)`; // TODO
|
|
28
|
+
|
|
29
|
+
if (this._pauseTimer) {
|
|
30
|
+
this._core.async.removeTask(this._pauseTimer);
|
|
31
|
+
this._pauseTimer = null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (delayMs !== undefined) {
|
|
35
|
+
this._pauseTimer = this._core.async.addDelayTask(
|
|
36
|
+
"system.continue",
|
|
37
|
+
[],
|
|
38
|
+
delayMs
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 继续由于pause中断的游戏
|
|
45
|
+
*/
|
|
46
|
+
continue() {
|
|
47
|
+
if (this.condition !== System.Condition.Pause) return;
|
|
48
|
+
this.condition = System.Condition.Gaming;
|
|
49
|
+
this.run();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 阻塞
|
|
54
|
+
*/
|
|
55
|
+
block() {
|
|
56
|
+
if (this.condition !== System.Condition.Gaming)
|
|
57
|
+
throw `block but condition error (todo)`;
|
|
58
|
+
this.condition = System.Condition.Blocked;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 取消阻塞
|
|
62
|
+
*/
|
|
63
|
+
unBlock() {
|
|
64
|
+
if (this.condition !== System.Condition.Blocked) return;
|
|
65
|
+
this.condition = System.Condition.Gaming;
|
|
66
|
+
this.run();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
run() {
|
|
70
|
+
this.condition = System.Condition.Gaming;
|
|
71
|
+
while (this.condition === System.Condition.Gaming) {
|
|
72
|
+
// console.log("Run Single Line");
|
|
73
|
+
this._core.script.runSingleLine();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
start(initLabel: string = "start") {
|
|
78
|
+
// 初始化存档
|
|
79
|
+
this._core.storage.archiveData;
|
|
80
|
+
this._core.debug.log("Game Start");
|
|
81
|
+
|
|
82
|
+
this._core.script.clear();
|
|
83
|
+
this._core.script.jumpLabel(initLabel);
|
|
84
|
+
this.run();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export namespace System {
|
|
89
|
+
export enum Condition {
|
|
90
|
+
Free,
|
|
91
|
+
Pause,
|
|
92
|
+
Blocked,
|
|
93
|
+
Gaming,
|
|
94
|
+
}
|
|
95
|
+
}
|