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.
Files changed (103) hide show
  1. package/dist/async/index.js +162 -0
  2. package/dist/async/zeppos_timer.js +58 -0
  3. package/dist/audio/index.js +260 -0
  4. package/dist/config/index.js +57 -0
  5. package/dist/debug/index.js +8 -0
  6. package/dist/index.js +103 -0
  7. package/dist/platform/index.js +1 -0
  8. package/dist/plugins/basic_command/$.js +8 -0
  9. package/dist/plugins/basic_command/audio.js +40 -0
  10. package/dist/plugins/basic_command/basic.js +124 -0
  11. package/dist/plugins/basic_command/character.js +112 -0
  12. package/dist/plugins/basic_command/conditional.js +260 -0
  13. package/dist/plugins/basic_command/config.js +22 -0
  14. package/dist/plugins/basic_command/decorator.js +24 -0
  15. package/dist/plugins/basic_command/eval.js +67 -0
  16. package/dist/plugins/basic_command/img.js +249 -0
  17. package/dist/plugins/basic_command/index.js +22 -0
  18. package/dist/plugins/basic_command/menu.js +140 -0
  19. package/dist/plugins/global_gesture/index.js +25 -0
  20. package/dist/plugins/transform/animation.js +440 -0
  21. package/dist/plugins/transform/commands.js +38 -0
  22. package/dist/plugins/transform/example_profiles.js +32 -0
  23. package/dist/plugins/transform/hz_anime.js +211 -0
  24. package/dist/plugins/transform/index.js +93 -0
  25. package/dist/script/index.js +537 -0
  26. package/dist/script/readscript.js +15 -0
  27. package/dist/script/strtools.js +157 -0
  28. package/dist/storage/decorator.js +260 -0
  29. package/dist/storage/fs.js +96 -0
  30. package/dist/storage/index.js +442 -0
  31. package/dist/system/index.js +144 -0
  32. package/dist/ui/index.js +535 -0
  33. package/dist/utils/path.js +289 -0
  34. package/license.txt +202 -0
  35. package/package.json +26 -0
  36. package/src/async/index.ts +124 -0
  37. package/src/async/zeppos_timer.js +65 -0
  38. package/src/audio/index.ts +224 -0
  39. package/src/config/index.ts +80 -0
  40. package/src/debug/index.ts +11 -0
  41. package/src/index.ts +122 -0
  42. package/src/platform/index.ts +158 -0
  43. package/src/plugins/basic_command/$.ts +11 -0
  44. package/src/plugins/basic_command/audio.ts +53 -0
  45. package/src/plugins/basic_command/basic.ts +145 -0
  46. package/src/plugins/basic_command/character.ts +144 -0
  47. package/src/plugins/basic_command/conditional.ts +349 -0
  48. package/src/plugins/basic_command/config.ts +29 -0
  49. package/src/plugins/basic_command/decorator.ts +29 -0
  50. package/src/plugins/basic_command/eval.ts +88 -0
  51. package/src/plugins/basic_command/img.ts +317 -0
  52. package/src/plugins/basic_command/index.ts +24 -0
  53. package/src/plugins/basic_command/menu.ts +178 -0
  54. package/src/plugins/global_gesture/index.ts +29 -0
  55. package/src/plugins/transform/animation.ts +542 -0
  56. package/src/plugins/transform/commands.ts +53 -0
  57. package/src/plugins/transform/example_profiles.ts +36 -0
  58. package/src/plugins/transform/hz_anime.ts +214 -0
  59. package/src/plugins/transform/index.ts +141 -0
  60. package/src/plugins/transform/readme.md +1 -0
  61. package/src/script/index.ts +623 -0
  62. package/src/script/readscript.ts +17 -0
  63. package/src/script/strtools.ts +159 -0
  64. package/src/storage/decorator.ts +473 -0
  65. package/src/storage/fs.ts +104 -0
  66. package/src/storage/index.ts +541 -0
  67. package/src/system/index.ts +95 -0
  68. package/src/ui/index.ts +699 -0
  69. package/src/utils/path.js +338 -0
  70. package/tsconfig.json +111 -0
  71. package/types/async/index.d.ts +24 -0
  72. package/types/async/zeppos_timer.d.ts +14 -0
  73. package/types/audio/index.d.ts +64 -0
  74. package/types/config/index.d.ts +9 -0
  75. package/types/debug/index.d.ts +6 -0
  76. package/types/index.d.ts +41 -0
  77. package/types/platform/index.d.ts +134 -0
  78. package/types/plugins/basic_command/$.d.ts +2 -0
  79. package/types/plugins/basic_command/audio.d.ts +2 -0
  80. package/types/plugins/basic_command/basic.d.ts +3 -0
  81. package/types/plugins/basic_command/character.d.ts +2 -0
  82. package/types/plugins/basic_command/conditional.d.ts +2 -0
  83. package/types/plugins/basic_command/config.d.ts +2 -0
  84. package/types/plugins/basic_command/decorator.d.ts +2 -0
  85. package/types/plugins/basic_command/eval.d.ts +2 -0
  86. package/types/plugins/basic_command/img.d.ts +2 -0
  87. package/types/plugins/basic_command/index.d.ts +2 -0
  88. package/types/plugins/basic_command/menu.d.ts +2 -0
  89. package/types/plugins/global_gesture/index.d.ts +2 -0
  90. package/types/plugins/transform/animation.d.ts +131 -0
  91. package/types/plugins/transform/commands.d.ts +7 -0
  92. package/types/plugins/transform/example_profiles.d.ts +2 -0
  93. package/types/plugins/transform/hz_anime.d.ts +51 -0
  94. package/types/plugins/transform/index.d.ts +13 -0
  95. package/types/script/index.d.ts +123 -0
  96. package/types/script/readscript.d.ts +2 -0
  97. package/types/script/strtools.d.ts +31 -0
  98. package/types/storage/decorator.d.ts +41 -0
  99. package/types/storage/fs.d.ts +1 -0
  100. package/types/storage/index.d.ts +86 -0
  101. package/types/system/index.d.ts +35 -0
  102. package/types/ui/index.d.ts +167 -0
  103. 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
+ }