@rpgjs/client 5.0.0-alpha.43 → 5.0.0-alpha.44

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 (137) hide show
  1. package/dist/Game/AnimationManager.js +25 -24
  2. package/dist/Game/AnimationManager.js.map +1 -1
  3. package/dist/Game/Event.js +11 -10
  4. package/dist/Game/Event.js.map +1 -1
  5. package/dist/Game/Map.js +78 -94
  6. package/dist/Game/Map.js.map +1 -1
  7. package/dist/Game/Object.js +182 -216
  8. package/dist/Game/Object.js.map +1 -1
  9. package/dist/Game/Player.js +11 -10
  10. package/dist/Game/Player.js.map +1 -1
  11. package/dist/Gui/Gui.js +440 -473
  12. package/dist/Gui/Gui.js.map +1 -1
  13. package/dist/Gui/NotificationManager.js +48 -50
  14. package/dist/Gui/NotificationManager.js.map +1 -1
  15. package/dist/Resource.js +132 -113
  16. package/dist/Resource.js.map +1 -1
  17. package/dist/RpgClientEngine.js +1333 -1486
  18. package/dist/RpgClientEngine.js.map +1 -1
  19. package/dist/Sound.js +162 -92
  20. package/dist/Sound.js.map +1 -1
  21. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.js +9 -0
  22. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.js +6 -0
  23. package/dist/components/animations/animation.ce.js +22 -19
  24. package/dist/components/animations/animation.ce.js.map +1 -1
  25. package/dist/components/animations/hit.ce.js +67 -68
  26. package/dist/components/animations/hit.ce.js.map +1 -1
  27. package/dist/components/animations/index.js +9 -8
  28. package/dist/components/animations/index.js.map +1 -1
  29. package/dist/components/character.ce.js +390 -314
  30. package/dist/components/character.ce.js.map +1 -1
  31. package/dist/components/dynamics/parse-value.js +42 -52
  32. package/dist/components/dynamics/parse-value.js.map +1 -1
  33. package/dist/components/dynamics/text.ce.js +71 -139
  34. package/dist/components/dynamics/text.ce.js.map +1 -1
  35. package/dist/components/gui/box.ce.js +26 -25
  36. package/dist/components/gui/box.ce.js.map +1 -1
  37. package/dist/components/gui/dialogbox/index.ce.js +202 -149
  38. package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
  39. package/dist/components/gui/gameover.ce.js +190 -138
  40. package/dist/components/gui/gameover.ce.js.map +1 -1
  41. package/dist/components/gui/hud/hud.ce.js +90 -33
  42. package/dist/components/gui/hud/hud.ce.js.map +1 -1
  43. package/dist/components/gui/index.js +14 -0
  44. package/dist/components/gui/menu/equip-menu.ce.js +478 -346
  45. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
  46. package/dist/components/gui/menu/exit-menu.ce.js +52 -33
  47. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
  48. package/dist/components/gui/menu/items-menu.ce.js +341 -226
  49. package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
  50. package/dist/components/gui/menu/main-menu.ce.js +414 -205
  51. package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
  52. package/dist/components/gui/menu/options-menu.ce.js +46 -26
  53. package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
  54. package/dist/components/gui/menu/skills-menu.ce.js +104 -50
  55. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
  56. package/dist/components/gui/mobile/index.js +18 -21
  57. package/dist/components/gui/mobile/index.js.map +1 -1
  58. package/dist/components/gui/mobile/mobile.ce.js +76 -15
  59. package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
  60. package/dist/components/gui/notification/notification.ce.js +62 -36
  61. package/dist/components/gui/notification/notification.ce.js.map +1 -1
  62. package/dist/components/gui/save-load.ce.js +386 -239
  63. package/dist/components/gui/save-load.ce.js.map +1 -1
  64. package/dist/components/gui/shop/shop.ce.js +649 -319
  65. package/dist/components/gui/shop/shop.ce.js.map +1 -1
  66. package/dist/components/gui/title-screen.ce.js +187 -145
  67. package/dist/components/gui/title-screen.ce.js.map +1 -1
  68. package/dist/components/index.js +4 -0
  69. package/dist/components/prebuilt/hp-bar.ce.js +114 -104
  70. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
  71. package/dist/components/prebuilt/index.js +2 -0
  72. package/dist/components/prebuilt/light-halo.ce.js +92 -74
  73. package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
  74. package/dist/components/scenes/canvas.ce.js +58 -42
  75. package/dist/components/scenes/canvas.ce.js.map +1 -1
  76. package/dist/components/scenes/draw-map.ce.js +87 -64
  77. package/dist/components/scenes/draw-map.ce.js.map +1 -1
  78. package/dist/components/scenes/event-layer.ce.js +26 -16
  79. package/dist/components/scenes/event-layer.ce.js.map +1 -1
  80. package/dist/core/inject.js +11 -10
  81. package/dist/core/inject.js.map +1 -1
  82. package/dist/core/setup.js +13 -13
  83. package/dist/core/setup.js.map +1 -1
  84. package/dist/index.js +44 -41
  85. package/dist/module.js +169 -168
  86. package/dist/module.js.map +1 -1
  87. package/dist/node_modules/.pnpm/@signe_di@2.8.3/node_modules/@signe/di/dist/index.js +209 -298
  88. package/dist/node_modules/.pnpm/@signe_di@2.8.3/node_modules/@signe/di/dist/index.js.map +1 -1
  89. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +430 -507
  90. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +1 -1
  91. package/dist/node_modules/.pnpm/@signe_room@2.8.3/node_modules/@signe/room/dist/index.js +2062 -2571
  92. package/dist/node_modules/.pnpm/@signe_room@2.8.3/node_modules/@signe/room/dist/index.js.map +1 -1
  93. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +8 -3
  94. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -1
  95. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js +78 -101
  96. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js.map +1 -1
  97. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/index.js +264 -401
  98. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/index.js.map +1 -1
  99. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +9 -7
  100. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -1
  101. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +106 -165
  102. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -1
  103. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +361 -461
  104. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
  105. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
  106. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3633 -4280
  107. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
  108. package/dist/presets/animation.js +37 -25
  109. package/dist/presets/animation.js.map +1 -1
  110. package/dist/presets/faceset.js +49 -22
  111. package/dist/presets/faceset.js.map +1 -1
  112. package/dist/presets/icon.js +13 -13
  113. package/dist/presets/icon.js.map +1 -1
  114. package/dist/presets/index.js +15 -14
  115. package/dist/presets/index.js.map +1 -1
  116. package/dist/presets/lpc.js +96 -93
  117. package/dist/presets/lpc.js.map +1 -1
  118. package/dist/presets/rmspritesheet.js +40 -39
  119. package/dist/presets/rmspritesheet.js.map +1 -1
  120. package/dist/services/AbstractSocket.js +10 -8
  121. package/dist/services/AbstractSocket.js.map +1 -1
  122. package/dist/services/keyboardControls.js +20 -18
  123. package/dist/services/keyboardControls.js.map +1 -1
  124. package/dist/services/loadMap.js +120 -36
  125. package/dist/services/loadMap.js.map +1 -1
  126. package/dist/services/mmorpg.js +128 -136
  127. package/dist/services/mmorpg.js.map +1 -1
  128. package/dist/services/save.js +74 -66
  129. package/dist/services/save.js.map +1 -1
  130. package/dist/services/standalone.js +165 -167
  131. package/dist/services/standalone.js.map +1 -1
  132. package/dist/utils/getEntityProp.js +49 -51
  133. package/dist/utils/getEntityProp.js.map +1 -1
  134. package/package.json +8 -8
  135. package/src/components/character.ce +1 -1
  136. package/src/components/scenes/draw-map.ce +3 -1
  137. package/dist/index.js.map +0 -1
package/dist/Sound.js CHANGED
@@ -1,97 +1,167 @@
1
- import { Howler } from 'canvasengine';
2
-
3
- const SOUND_METADATA_KEY = /* @__PURE__ */ Symbol("rpgjs:sound");
1
+ import { Howler } from "canvasengine";
2
+ //#region src/Sound.ts
3
+ var SOUND_METADATA_KEY = Symbol("rpgjs:sound");
4
+ /**
5
+ * Sound decorator
6
+ *
7
+ * Decorates a class to define a sound configuration. The decorated class can be
8
+ * added to the RpgClient module configuration, and the sound will be automatically
9
+ * registered and available through RpgSound.get().
10
+ *
11
+ * ## Design
12
+ *
13
+ * The decorator stores metadata on the class that is later used by the module loader
14
+ * to register sounds with the engine. The sound is created using Howler.js for
15
+ * advanced audio features like looping, volume control, and cross-browser compatibility.
16
+ *
17
+ * @param options - Sound configuration options
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { Sound } from '@rpgjs/client'
22
+ *
23
+ * @Sound({
24
+ * id: 'town-music',
25
+ * sound: require('./sound/town.ogg'),
26
+ * loop: true,
27
+ * volume: 0.5
28
+ * })
29
+ * export class TownMusic {}
30
+ *
31
+ * // Multiple sounds in one class
32
+ * @Sound({
33
+ * sounds: {
34
+ * hero: require('./assets/hero.ogg'),
35
+ * monster: require('./assets/monster.ogg')
36
+ * },
37
+ * loop: true
38
+ * })
39
+ * export class CharacterSounds {}
40
+ * ```
41
+ */
4
42
  function Sound(options) {
5
- return function(constructor) {
6
- const metadata = {
7
- id: options.id,
8
- sound: options.sound,
9
- sounds: options.sounds,
10
- loop: options.loop,
11
- volume: options.volume
12
- };
13
- constructor[SOUND_METADATA_KEY] = metadata;
14
- return constructor;
15
- };
43
+ return function(constructor) {
44
+ constructor[SOUND_METADATA_KEY] = {
45
+ id: options.id,
46
+ sound: options.sound,
47
+ sounds: options.sounds,
48
+ loop: options.loop,
49
+ volume: options.volume
50
+ };
51
+ return constructor;
52
+ };
16
53
  }
54
+ /**
55
+ * Get sound metadata from a decorated class
56
+ *
57
+ * @param soundClass - The class decorated with @Sound
58
+ * @returns The sound metadata or undefined
59
+ */
17
60
  function getSoundMetadata(soundClass) {
18
- return soundClass[SOUND_METADATA_KEY];
19
- }
20
- class RpgSound {
21
- static {
22
- this.engine = null;
23
- }
24
- /**
25
- * Initialize RpgSound with the engine instance
26
- *
27
- * This is called automatically by the engine during initialization.
28
- *
29
- * @param engine - The RpgClientEngine instance
30
- */
31
- static init(engine) {
32
- RpgSound.engine = engine;
33
- }
34
- /**
35
- * Get a sound by its ID
36
- *
37
- * Retrieves a Howler sound instance from the engine's sound cache.
38
- * The sound must be registered beforehand (via @Sound decorator or manually).
39
- *
40
- * @param id - The sound identifier
41
- * @returns The Howler sound instance, or undefined if not found
42
- *
43
- * @example
44
- * ```ts
45
- * // Get and play a sound
46
- * const sound = RpgSound.get('town-music');
47
- * if (sound) {
48
- * sound.play();
49
- * }
50
- *
51
- * // Chain methods
52
- * RpgSound.get('battle-theme')?.volume(0.8).play();
53
- * ```
54
- */
55
- static get(id) {
56
- if (!RpgSound.engine) {
57
- console.warn("RpgSound not initialized. Make sure the engine has started.");
58
- return void 0;
59
- }
60
- const sound = RpgSound.engine.sounds.get(id);
61
- if (!sound) {
62
- console.warn(`Sound with id "${id}" not found`);
63
- return void 0;
64
- }
65
- if (sound && typeof sound.play === "function") {
66
- return sound;
67
- }
68
- if (sound && sound.src) {
69
- return sound;
70
- }
71
- return sound;
72
- }
73
- /**
74
- * Global Howler instance for managing all sounds
75
- *
76
- * Provides access to Howler.js global methods for controlling all sounds
77
- * at once (volume, mute, etc.).
78
- *
79
- * @example
80
- * ```ts
81
- * // Set global volume to 20%
82
- * RpgSound.global.volume(0.2)
83
- *
84
- * // Mute all sounds
85
- * RpgSound.global.mute(true)
86
- *
87
- * // Unmute all sounds
88
- * RpgSound.global.mute(false)
89
- * ```
90
- */
91
- static get global() {
92
- return Howler;
93
- }
61
+ return soundClass[SOUND_METADATA_KEY];
94
62
  }
95
-
63
+ /**
64
+ * RpgSound class
65
+ *
66
+ * Provides a unified API to manage sounds in the game. Uses Howler.js internally
67
+ * for advanced audio features. Sounds can be retrieved by ID and controlled
68
+ * using Howler.js methods.
69
+ *
70
+ * ## Design
71
+ *
72
+ * RpgSound acts as a facade over Howler.js, providing easy access to sounds
73
+ * registered in the engine. It supports both individual sound control and
74
+ * global sound management (volume, mute, etc.).
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * import { RpgSound } from '@rpgjs/client'
79
+ *
80
+ * // Play a sound
81
+ * RpgSound.get('town-music').play()
82
+ *
83
+ * // Control volume
84
+ * RpgSound.get('town-music').volume(0.5)
85
+ *
86
+ * // Stop a sound
87
+ * RpgSound.get('town-music').stop()
88
+ *
89
+ * // Global volume control
90
+ * RpgSound.global.volume(0.2)
91
+ * ```
92
+ */
93
+ var RpgSound = class RpgSound {
94
+ static {
95
+ this.engine = null;
96
+ }
97
+ /**
98
+ * Initialize RpgSound with the engine instance
99
+ *
100
+ * This is called automatically by the engine during initialization.
101
+ *
102
+ * @param engine - The RpgClientEngine instance
103
+ */
104
+ static init(engine) {
105
+ RpgSound.engine = engine;
106
+ }
107
+ /**
108
+ * Get a sound by its ID
109
+ *
110
+ * Retrieves a Howler sound instance from the engine's sound cache.
111
+ * The sound must be registered beforehand (via @Sound decorator or manually).
112
+ *
113
+ * @param id - The sound identifier
114
+ * @returns The Howler sound instance, or undefined if not found
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * // Get and play a sound
119
+ * const sound = RpgSound.get('town-music');
120
+ * if (sound) {
121
+ * sound.play();
122
+ * }
123
+ *
124
+ * // Chain methods
125
+ * RpgSound.get('battle-theme')?.volume(0.8).play();
126
+ * ```
127
+ */
128
+ static get(id) {
129
+ if (!RpgSound.engine) {
130
+ console.warn("RpgSound not initialized. Make sure the engine has started.");
131
+ return;
132
+ }
133
+ const sound = RpgSound.engine.sounds.get(id);
134
+ if (!sound) {
135
+ console.warn(`Sound with id "${id}" not found`);
136
+ return;
137
+ }
138
+ if (sound && typeof sound.play === "function") return sound;
139
+ if (sound && sound.src) return sound;
140
+ return sound;
141
+ }
142
+ /**
143
+ * Global Howler instance for managing all sounds
144
+ *
145
+ * Provides access to Howler.js global methods for controlling all sounds
146
+ * at once (volume, mute, etc.).
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * // Set global volume to 20%
151
+ * RpgSound.global.volume(0.2)
152
+ *
153
+ * // Mute all sounds
154
+ * RpgSound.global.mute(true)
155
+ *
156
+ * // Unmute all sounds
157
+ * RpgSound.global.mute(false)
158
+ * ```
159
+ */
160
+ static get global() {
161
+ return Howler;
162
+ }
163
+ };
164
+ //#endregion
96
165
  export { RpgSound, Sound, getSoundMetadata };
97
- //# sourceMappingURL=Sound.js.map
166
+
167
+ //# sourceMappingURL=Sound.js.map
package/dist/Sound.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Sound.js","sources":["../src/Sound.ts"],"sourcesContent":["import { Howler } from 'canvasengine';\nimport { RpgClientEngine } from './RpgClientEngine';\nimport { inject } from './core/inject';\n\n/**\n * Sound decorator options\n * \n * Defines the configuration for a sound that can be played in the game.\n * The sound can be a single file or multiple files (for different formats).\n * \n * @interface SoundOptions\n */\nexport interface SoundOptions {\n /**\n * Sound identifier. Used to retrieve the sound later with RpgSound.get()\n * \n * @type {string}\n */\n id?: string;\n\n /**\n * Single sound file path. Use require() to wrap the path.\n * \n * @type {string}\n * @example\n * sound: require('./assets/sound.ogg')\n */\n sound?: string;\n\n /**\n * Multiple sounds with different IDs. The key is the sound ID and the value is the file path.\n * Use require() to wrap each path.\n * \n * @type {{ [id: string]: string }}\n * @example\n * sounds: {\n * hero: require('./assets/hero.ogg'),\n * monster: require('./assets/monster.ogg')\n * }\n */\n sounds?: { [id: string]: string };\n\n /**\n * Whether the sound should loop when it finishes playing.\n * \n * @type {boolean}\n * @default false\n */\n loop?: boolean;\n\n /**\n * Volume level (0.0 to 1.0).\n * \n * @type {number}\n * @default 1.0\n */\n volume?: number;\n}\n\n/**\n * Metadata stored on the class decorated with @Sound\n * \n * @interface SoundMetadata\n */\ninterface SoundMetadata {\n id?: string;\n sound?: string;\n sounds?: { [id: string]: string };\n loop?: boolean;\n volume?: number;\n}\n\nconst SOUND_METADATA_KEY = Symbol('rpgjs:sound');\n\n/**\n * Sound decorator\n * \n * Decorates a class to define a sound configuration. The decorated class can be\n * added to the RpgClient module configuration, and the sound will be automatically\n * registered and available through RpgSound.get().\n * \n * ## Design\n * \n * The decorator stores metadata on the class that is later used by the module loader\n * to register sounds with the engine. The sound is created using Howler.js for\n * advanced audio features like looping, volume control, and cross-browser compatibility.\n * \n * @param options - Sound configuration options\n * \n * @example\n * ```ts\n * import { Sound } from '@rpgjs/client'\n * \n * @Sound({\n * id: 'town-music',\n * sound: require('./sound/town.ogg'),\n * loop: true,\n * volume: 0.5\n * })\n * export class TownMusic {}\n * \n * // Multiple sounds in one class\n * @Sound({\n * sounds: {\n * hero: require('./assets/hero.ogg'),\n * monster: require('./assets/monster.ogg')\n * },\n * loop: true\n * })\n * export class CharacterSounds {}\n * ```\n */\nexport function Sound(options: SoundOptions) {\n return function <T extends { new (...args: any[]): {} }>(constructor: T) {\n const metadata: SoundMetadata = {\n id: options.id,\n sound: options.sound,\n sounds: options.sounds,\n loop: options.loop,\n volume: options.volume,\n };\n\n // Store metadata on the class\n (constructor as any)[SOUND_METADATA_KEY] = metadata;\n\n return constructor;\n };\n}\n\n/**\n * Get sound metadata from a decorated class\n * \n * @param soundClass - The class decorated with @Sound\n * @returns The sound metadata or undefined\n */\nexport function getSoundMetadata(soundClass: any): SoundMetadata | undefined {\n return (soundClass as any)[SOUND_METADATA_KEY];\n}\n\n/**\n * RpgSound class\n * \n * Provides a unified API to manage sounds in the game. Uses Howler.js internally\n * for advanced audio features. Sounds can be retrieved by ID and controlled\n * using Howler.js methods.\n * \n * ## Design\n * \n * RpgSound acts as a facade over Howler.js, providing easy access to sounds\n * registered in the engine. It supports both individual sound control and\n * global sound management (volume, mute, etc.).\n * \n * @example\n * ```ts\n * import { RpgSound } from '@rpgjs/client'\n * \n * // Play a sound\n * RpgSound.get('town-music').play()\n * \n * // Control volume\n * RpgSound.get('town-music').volume(0.5)\n * \n * // Stop a sound\n * RpgSound.get('town-music').stop()\n * \n * // Global volume control\n * RpgSound.global.volume(0.2)\n * ```\n */\nexport class RpgSound {\n private static engine: RpgClientEngine | null = null;\n\n /**\n * Initialize RpgSound with the engine instance\n * \n * This is called automatically by the engine during initialization.\n * \n * @param engine - The RpgClientEngine instance\n */\n static init(engine: RpgClientEngine): void {\n RpgSound.engine = engine;\n }\n\n /**\n * Get a sound by its ID\n * \n * Retrieves a Howler sound instance from the engine's sound cache.\n * The sound must be registered beforehand (via @Sound decorator or manually).\n * \n * @param id - The sound identifier\n * @returns The Howler sound instance, or undefined if not found\n * \n * @example\n * ```ts\n * // Get and play a sound\n * const sound = RpgSound.get('town-music');\n * if (sound) {\n * sound.play();\n * }\n * \n * // Chain methods\n * RpgSound.get('battle-theme')?.volume(0.8).play();\n * ```\n */\n static get(id: string): any {\n if (!RpgSound.engine) {\n console.warn('RpgSound not initialized. Make sure the engine has started.');\n return undefined;\n }\n\n const sound = RpgSound.engine.sounds.get(id);\n if (!sound) {\n console.warn(`Sound with id \"${id}\" not found`);\n return undefined;\n }\n\n // If the sound is a Howler instance, return it directly\n if (sound && typeof sound.play === 'function') {\n return sound;\n }\n\n // If the sound has a src property, try to create a Howler instance\n if (sound && sound.src) {\n // This should have been handled during addSound, but just in case\n return sound;\n }\n\n return sound;\n }\n\n /**\n * Global Howler instance for managing all sounds\n * \n * Provides access to Howler.js global methods for controlling all sounds\n * at once (volume, mute, etc.).\n * \n * @example\n * ```ts\n * // Set global volume to 20%\n * RpgSound.global.volume(0.2)\n * \n * // Mute all sounds\n * RpgSound.global.mute(true)\n * \n * // Unmute all sounds\n * RpgSound.global.mute(false)\n * ```\n */\n static get global(): typeof Howler {\n return Howler;\n }\n}\n\n"],"names":[],"mappings":";;AAwEA,MAAM,kBAAA,0BAA4B,aAAa,CAAA;AAwCxC,SAAS,MAAM,OAAA,EAAuB;AAC3C,EAAA,OAAO,SAAkD,WAAA,EAAgB;AACvE,IAAA,MAAM,QAAA,GAA0B;AAAA,MAC9B,IAAI,OAAA,CAAQ,EAAA;AAAA,MACZ,OAAO,OAAA,CAAQ,KAAA;AAAA,MACf,QAAQ,OAAA,CAAQ,MAAA;AAAA,MAChB,MAAM,OAAA,CAAQ,IAAA;AAAA,MACd,QAAQ,OAAA,CAAQ;AAAA,KAClB;AAGA,IAAC,WAAA,CAAoB,kBAAkB,CAAA,GAAI,QAAA;AAE3C,IAAA,OAAO,WAAA;AAAA,EACT,CAAA;AACF;AAQO,SAAS,iBAAiB,UAAA,EAA4C;AAC3E,EAAA,OAAQ,WAAmB,kBAAkB,CAAA;AAC/C;AAgCO,MAAM,QAAA,CAAS;AAAA,EACpB;AAAA,IAAA,IAAA,CAAe,MAAA,GAAiC,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAShD,OAAO,KAAK,MAAA,EAA+B;AACzC,IAAA,QAAA,CAAS,MAAA,GAAS,MAAA;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBA,OAAO,IAAI,EAAA,EAAiB;AAC1B,IAAA,IAAI,CAAC,SAAS,MAAA,EAAQ;AACpB,MAAA,OAAA,CAAQ,KAAK,6DAA6D,CAAA;AAC1E,MAAA,OAAO,MAAA;AAAA,IACT;AAEA,IAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,MAAA,CAAO,MAAA,CAAO,IAAI,EAAE,CAAA;AAC3C,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,eAAA,EAAkB,EAAE,CAAA,WAAA,CAAa,CAAA;AAC9C,MAAA,OAAO,MAAA;AAAA,IACT;AAGA,IAAA,IAAI,KAAA,IAAS,OAAO,KAAA,CAAM,IAAA,KAAS,UAAA,EAAY;AAC7C,MAAA,OAAO,KAAA;AAAA,IACT;AAGA,IAAA,IAAI,KAAA,IAAS,MAAM,GAAA,EAAK;AAEtB,MAAA,OAAO,KAAA;AAAA,IACT;AAEA,IAAA,OAAO,KAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,WAAW,MAAA,GAAwB;AACjC,IAAA,OAAO,MAAA;AAAA,EACT;AACF;;;;"}
1
+ {"version":3,"file":"Sound.js","names":[],"sources":["../src/Sound.ts"],"sourcesContent":["import { Howler } from 'canvasengine';\nimport { RpgClientEngine } from './RpgClientEngine';\nimport { inject } from './core/inject';\n\n/**\n * Sound decorator options\n * \n * Defines the configuration for a sound that can be played in the game.\n * The sound can be a single file or multiple files (for different formats).\n * \n * @interface SoundOptions\n */\nexport interface SoundOptions {\n /**\n * Sound identifier. Used to retrieve the sound later with RpgSound.get()\n * \n * @type {string}\n */\n id?: string;\n\n /**\n * Single sound file path. Use require() to wrap the path.\n * \n * @type {string}\n * @example\n * sound: require('./assets/sound.ogg')\n */\n sound?: string;\n\n /**\n * Multiple sounds with different IDs. The key is the sound ID and the value is the file path.\n * Use require() to wrap each path.\n * \n * @type {{ [id: string]: string }}\n * @example\n * sounds: {\n * hero: require('./assets/hero.ogg'),\n * monster: require('./assets/monster.ogg')\n * }\n */\n sounds?: { [id: string]: string };\n\n /**\n * Whether the sound should loop when it finishes playing.\n * \n * @type {boolean}\n * @default false\n */\n loop?: boolean;\n\n /**\n * Volume level (0.0 to 1.0).\n * \n * @type {number}\n * @default 1.0\n */\n volume?: number;\n}\n\n/**\n * Metadata stored on the class decorated with @Sound\n * \n * @interface SoundMetadata\n */\ninterface SoundMetadata {\n id?: string;\n sound?: string;\n sounds?: { [id: string]: string };\n loop?: boolean;\n volume?: number;\n}\n\nconst SOUND_METADATA_KEY = Symbol('rpgjs:sound');\n\n/**\n * Sound decorator\n * \n * Decorates a class to define a sound configuration. The decorated class can be\n * added to the RpgClient module configuration, and the sound will be automatically\n * registered and available through RpgSound.get().\n * \n * ## Design\n * \n * The decorator stores metadata on the class that is later used by the module loader\n * to register sounds with the engine. The sound is created using Howler.js for\n * advanced audio features like looping, volume control, and cross-browser compatibility.\n * \n * @param options - Sound configuration options\n * \n * @example\n * ```ts\n * import { Sound } from '@rpgjs/client'\n * \n * @Sound({\n * id: 'town-music',\n * sound: require('./sound/town.ogg'),\n * loop: true,\n * volume: 0.5\n * })\n * export class TownMusic {}\n * \n * // Multiple sounds in one class\n * @Sound({\n * sounds: {\n * hero: require('./assets/hero.ogg'),\n * monster: require('./assets/monster.ogg')\n * },\n * loop: true\n * })\n * export class CharacterSounds {}\n * ```\n */\nexport function Sound(options: SoundOptions) {\n return function <T extends { new (...args: any[]): {} }>(constructor: T) {\n const metadata: SoundMetadata = {\n id: options.id,\n sound: options.sound,\n sounds: options.sounds,\n loop: options.loop,\n volume: options.volume,\n };\n\n // Store metadata on the class\n (constructor as any)[SOUND_METADATA_KEY] = metadata;\n\n return constructor;\n };\n}\n\n/**\n * Get sound metadata from a decorated class\n * \n * @param soundClass - The class decorated with @Sound\n * @returns The sound metadata or undefined\n */\nexport function getSoundMetadata(soundClass: any): SoundMetadata | undefined {\n return (soundClass as any)[SOUND_METADATA_KEY];\n}\n\n/**\n * RpgSound class\n * \n * Provides a unified API to manage sounds in the game. Uses Howler.js internally\n * for advanced audio features. Sounds can be retrieved by ID and controlled\n * using Howler.js methods.\n * \n * ## Design\n * \n * RpgSound acts as a facade over Howler.js, providing easy access to sounds\n * registered in the engine. It supports both individual sound control and\n * global sound management (volume, mute, etc.).\n * \n * @example\n * ```ts\n * import { RpgSound } from '@rpgjs/client'\n * \n * // Play a sound\n * RpgSound.get('town-music').play()\n * \n * // Control volume\n * RpgSound.get('town-music').volume(0.5)\n * \n * // Stop a sound\n * RpgSound.get('town-music').stop()\n * \n * // Global volume control\n * RpgSound.global.volume(0.2)\n * ```\n */\nexport class RpgSound {\n private static engine: RpgClientEngine | null = null;\n\n /**\n * Initialize RpgSound with the engine instance\n * \n * This is called automatically by the engine during initialization.\n * \n * @param engine - The RpgClientEngine instance\n */\n static init(engine: RpgClientEngine): void {\n RpgSound.engine = engine;\n }\n\n /**\n * Get a sound by its ID\n * \n * Retrieves a Howler sound instance from the engine's sound cache.\n * The sound must be registered beforehand (via @Sound decorator or manually).\n * \n * @param id - The sound identifier\n * @returns The Howler sound instance, or undefined if not found\n * \n * @example\n * ```ts\n * // Get and play a sound\n * const sound = RpgSound.get('town-music');\n * if (sound) {\n * sound.play();\n * }\n * \n * // Chain methods\n * RpgSound.get('battle-theme')?.volume(0.8).play();\n * ```\n */\n static get(id: string): any {\n if (!RpgSound.engine) {\n console.warn('RpgSound not initialized. Make sure the engine has started.');\n return undefined;\n }\n\n const sound = RpgSound.engine.sounds.get(id);\n if (!sound) {\n console.warn(`Sound with id \"${id}\" not found`);\n return undefined;\n }\n\n // If the sound is a Howler instance, return it directly\n if (sound && typeof sound.play === 'function') {\n return sound;\n }\n\n // If the sound has a src property, try to create a Howler instance\n if (sound && sound.src) {\n // This should have been handled during addSound, but just in case\n return sound;\n }\n\n return sound;\n }\n\n /**\n * Global Howler instance for managing all sounds\n * \n * Provides access to Howler.js global methods for controlling all sounds\n * at once (volume, mute, etc.).\n * \n * @example\n * ```ts\n * // Set global volume to 20%\n * RpgSound.global.volume(0.2)\n * \n * // Mute all sounds\n * RpgSound.global.mute(true)\n * \n * // Unmute all sounds\n * RpgSound.global.mute(false)\n * ```\n */\n static get global(): typeof Howler {\n return Howler;\n }\n}\n\n"],"mappings":";;AAwEA,IAAM,qBAAqB,OAAO,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwChD,SAAgB,MAAM,SAAuB;AAC3C,QAAO,SAAkD,aAAgB;AAUtE,cAAoB,sBATW;GAC9B,IAAI,QAAQ;GACZ,OAAO,QAAQ;GACf,QAAQ,QAAQ;GAChB,MAAM,QAAQ;GACd,QAAQ,QAAQ;GACjB;AAKD,SAAO;;;;;;;;;AAUX,SAAgB,iBAAiB,YAA4C;AAC3E,QAAQ,WAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiC7B,IAAa,WAAb,MAAa,SAAS;;gBAC4B;;;;;;;;;CAShD,OAAO,KAAK,QAA+B;AACzC,WAAS,SAAS;;;;;;;;;;;;;;;;;;;;;;;CAwBpB,OAAO,IAAI,IAAiB;AAC1B,MAAI,CAAC,SAAS,QAAQ;AACpB,WAAQ,KAAK,8DAA8D;AAC3E;;EAGF,MAAM,QAAQ,SAAS,OAAO,OAAO,IAAI,GAAG;AAC5C,MAAI,CAAC,OAAO;AACV,WAAQ,KAAK,kBAAkB,GAAG,aAAa;AAC/C;;AAIF,MAAI,SAAS,OAAO,MAAM,SAAS,WACjC,QAAO;AAIT,MAAI,SAAS,MAAM,IAEjB,QAAO;AAGT,SAAO;;;;;;;;;;;;;;;;;;;;CAqBT,WAAW,SAAwB;AACjC,SAAO"}
@@ -0,0 +1,9 @@
1
+ //#region \0@oxc-project+runtime@0.115.0/helpers/decorate.js
2
+ function __decorate(decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ }
8
+ //#endregion
9
+ export { __decorate };
@@ -0,0 +1,6 @@
1
+ //#region \0@oxc-project+runtime@0.115.0/helpers/decorateMetadata.js
2
+ function __decorateMetadata(k, v) {
3
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4
+ }
5
+ //#endregion
6
+ export { __decorateMetadata };
@@ -1,21 +1,24 @@
1
- import { useProps, useDefineProps, h, Sprite } from 'canvasengine';
2
- import { RpgClientEngine } from '../../RpgClientEngine.js';
3
- import { inject } from '../../core/inject.js';
4
-
1
+ import { inject } from "../../core/inject.js";
2
+ import { RpgClientEngine } from "../../RpgClientEngine.js";
3
+ import { Sprite, h, useDefineProps, useProps } from "canvasengine";
4
+ //#region src/components/animations/animation.ce
5
5
  function component($$props) {
6
- useProps($$props);
7
- const defineProps = useDefineProps($$props);
8
- var _a;
9
- var _b = defineProps(), x = _b.x, y = _b.y, animationName = _b.animationName, graphic = _b.graphic, onFinish = _b.onFinish;
10
- var client = inject(RpgClientEngine);
11
- var sheet = {
12
- definition: client.getSpriteSheet(graphic()),
13
- playing: (_a = animationName()) !== null && _a !== void 0 ? _a : 'default',
14
- onFinish: onFinish
15
- };
16
- let $this = h(Sprite, { sheet, x, y, anchor: 0.5 });
17
- return $this
18
- }
19
-
6
+ useProps($$props);
7
+ const defineProps = useDefineProps($$props);
8
+ var _a;
9
+ var _b = defineProps(), x = _b.x, y = _b.y, animationName = _b.animationName, graphic = _b.graphic, onFinish = _b.onFinish;
10
+ return h(Sprite, {
11
+ sheet: {
12
+ definition: inject(RpgClientEngine).getSpriteSheet(graphic()),
13
+ playing: (_a = animationName()) !== null && _a !== void 0 ? _a : "default",
14
+ onFinish
15
+ },
16
+ x,
17
+ y,
18
+ anchor: .5
19
+ });
20
+ }
21
+ //#endregion
20
22
  export { component as default };
21
- //# sourceMappingURL=animation.ce.js.map
23
+
24
+ //# sourceMappingURL=animation.ce.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"animation.ce.js","sources":["../../../src/components/animations/animation.ce"],"sourcesContent":["<Sprite sheet x y anchor={0.5} />\n\n<script>\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { inject } from \"../../core/inject\";\n\n const { x, y, animationName, graphic, onFinish } = defineProps();\n\n const client = inject(RpgClientEngine);\n\n const sheet = {\n definition: client.getSpriteSheet(graphic()),\n playing: animationName() ?? 'default',\n onFinish\n };\n</script>\n"],"names":[],"mappings":";;;;AAOqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,EAAE;AACd,IAAI,EAAE,GAAG,WAAW,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,aAAa,GAAG,EAAE,CAAC,aAAa,EAAE,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ;AAC1H,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AACpC,IAAI,KAAK,GAAG;AACZ,IAAI,UAAU,EAAE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;AAChD,IAAI,OAAO,EAAE,CAAC,EAAE,GAAG,aAAa,EAAE,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,SAAS;AAC9E,IAAI,QAAQ,EAAE;AACd,CAAC;AACD,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE;AAC1D,QAAQ,OAAO;AACf,MAAM;;;;"}
1
+ {"version":3,"file":"animation.ce.js","names":[],"sources":["../../../src/components/animations/animation.ce"],"sourcesContent":["<Sprite sheet x y anchor={0.5} />\n\n<script>\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { inject } from \"../../core/inject\";\n\n const { x, y, animationName, graphic, onFinish } = defineProps();\n\n const client = inject(RpgClientEngine);\n\n const sheet = {\n definition: client.getSpriteSheet(graphic()),\n playing: animationName() ?? 'default',\n onFinish\n };\n</script>\n"],"mappings":";;;;;AAQuB,UAAC,QAAgB;;CAEhC,IAAA;CACR,IAAI,KAAA,aAAkB,EAAC,IAAA,GAAA,GAAA,IAAe,GAAA,GAAA,gBAAU,GAAA,eAAA,UAAA,GAAA,SAAA,WAAA,GAAA;;SAE5C;GACD,YAFU,OAAA,gBAAoB,CAE9B,eAAA,SAAA,CAAA;GACD,UAAM,KAAA,eAAA,MAAA,QAAA,OAAA,KAAA,IAAA,KAAA"}
@@ -1,71 +1,70 @@
1
- import { useProps, useDefineProps, animatedSignal, signal, mount, tick, h, Text } from 'canvasengine';
2
- import { Direction } from '@rpgjs/common';
3
-
1
+ import { Text, animatedSignal, h, mount, signal, tick, useDefineProps, useProps } from "canvasengine";
2
+ import { Direction } from "@rpgjs/common";
3
+ //#region src/components/animations/hit.ce
4
4
  function component($$props) {
5
- useProps($$props);
6
- const defineProps = useDefineProps($$props);
7
- var _a = defineProps({
8
- duration: {
9
- default: 1000
10
- },
11
- color: {
12
- default: 'black'
13
- }
14
- }), text = _a.text, direction = _a.direction, onFinish = _a.onFinish, duration = _a.duration, color = _a.color, positionX = _a.x, positionY = _a.y;
15
- var scale = animatedSignal(1, {
16
- duration: duration(),
17
- });
18
- var randomPosition = function () { return Math.floor(Math.random() * 60); };
19
- var initialY = randomPosition();
20
- var x = signal(positionX());
21
- var y = signal(positionY() - initialY);
22
- var velocityX = 0;
23
- var velocityY = 0;
24
- var speed = 200;
25
- switch (direction()) {
26
- case Direction.Left:
27
- velocityX = speed;
28
- break;
29
- case Direction.Right:
30
- velocityX = -speed;
31
- break;
32
- case Direction.Up:
33
- velocityY = speed;
34
- break;
35
- case Direction.Down:
36
- velocityY = -speed;
37
- break;
5
+ useProps($$props);
6
+ var _a = useDefineProps($$props)({
7
+ duration: { default: 1e3 },
8
+ color: { default: "black" }
9
+ }), text = _a.text, direction = _a.direction, onFinish = _a.onFinish, duration = _a.duration, color = _a.color, positionX = _a.x, positionY = _a.y;
10
+ var scale = animatedSignal(1, { duration: duration() });
11
+ var randomPosition = function() {
12
+ return Math.floor(Math.random() * 60);
13
+ };
14
+ var initialY = randomPosition();
15
+ var x = signal(positionX());
16
+ var y = signal(positionY() - initialY);
17
+ var velocityX = 0;
18
+ var velocityY = 0;
19
+ var speed = 200;
20
+ switch (direction()) {
21
+ case Direction.Left:
22
+ velocityX = speed;
23
+ break;
24
+ case Direction.Right:
25
+ velocityX = -speed;
26
+ break;
27
+ case Direction.Up:
28
+ velocityY = speed;
29
+ break;
30
+ case Direction.Down:
31
+ velocityY = -speed;
32
+ break;
33
+ }
34
+ velocityX += (Math.random() - .5) * 100;
35
+ velocityY += (Math.random() - .5) * 100;
36
+ var gravity = 500;
37
+ var deceleration = .98;
38
+ mount(function() {
39
+ scale.set(.1);
40
+ });
41
+ var elapsedTime = 0;
42
+ tick(function(_a) {
43
+ var deltaTime = _a.deltaTime;
44
+ elapsedTime += deltaTime;
45
+ if (elapsedTime < duration()) {
46
+ x.update(function(x) {
47
+ return x + velocityX * deltaTime / 1e3;
48
+ });
49
+ y.update(function(y) {
50
+ return y + velocityY * deltaTime / 1e3;
51
+ });
52
+ velocityY += gravity * deltaTime / 1e3;
53
+ velocityX *= deceleration;
54
+ velocityY *= deceleration;
55
+ } else if (onFinish) onFinish();
56
+ });
57
+ return h(Text, {
58
+ x,
59
+ y,
60
+ zIndex: 1e4,
61
+ color,
62
+ scale,
63
+ size: 30,
64
+ text
65
+ });
38
66
  }
39
- velocityX += (Math.random() - 0.5) * 100;
40
- velocityY += (Math.random() - 0.5) * 100;
41
- var gravity = 500;
42
- var deceleration = 0.98;
43
- mount(function () {
44
- scale.set(0.1);
45
- });
46
- var elapsedTime = 0;
47
- tick(function (_a) {
48
- var deltaTime = _a.deltaTime;
49
- elapsedTime += deltaTime;
50
- if (elapsedTime < duration()) {
51
- // Update position
52
- x.update(function (x) { return x + (velocityX * deltaTime) / 1000; });
53
- y.update(function (y) { return y + (velocityY * deltaTime) / 1000; });
54
- // Apply gravity
55
- velocityY += (gravity * deltaTime) / 1000;
56
- // Apply deceleration
57
- velocityX *= deceleration;
58
- velocityY *= deceleration;
59
- }
60
- else {
61
- if (onFinish) {
62
- onFinish();
63
- }
64
- }
65
- });
66
- let $this = h(Text, { x, y, zIndex: 10000, color, scale, size: 30, text });
67
- return $this
68
- }
69
-
67
+ //#endregion
70
68
  export { component as default };
71
- //# sourceMappingURL=hit.ce.js.map
69
+
70
+ //# sourceMappingURL=hit.ce.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hit.ce.js","sources":["../../../src/components/animations/hit.ce"],"sourcesContent":["<Text x y zIndex={10000} color scale size={30} text />\n\n<script>\n import { animatedSignal, mount, signal, tick } from \"canvasengine\";\n import { Direction } from \"@rpgjs/common\";\n const {\n text,\n direction,\n onFinish,\n duration,\n color,\n x: positionX,\n y: positionY\n } = defineProps({\n duration: {\n default: 1000\n },\n color: {\n default: 'black'\n }\n });\n\n const scale = animatedSignal(1, {\n duration: duration(),\n });\n\n // Generate random initial position\n const randomPosition = () => Math.floor(Math.random() * 60);\n const initialY = randomPosition();\n const x = signal(positionX());\n const y = signal(positionY() - initialY);\n\n // Initial velocity\n let velocityX = 0;\n let velocityY = 0;\n\n // Set initial velocity based on direction\n const speed = 200;\n switch (direction()) {\n case Direction.Left:\n velocityX = speed;\n break;\n case Direction.Right:\n velocityX = -speed;\n break;\n case Direction.Up:\n velocityY = speed;\n break;\n case Direction.Down:\n velocityY = -speed;\n break;\n }\n\n // Add some randomness to the velocity\n velocityX += (Math.random() - 0.5) * 100;\n velocityY += (Math.random() - 0.5) * 100;\n\n const gravity = 500; // Gravity effect\n const deceleration = 0.98; // Deceleration factor\n\n mount(() => {\n scale.set(0.1);\n });\n\n let elapsedTime = 0;\n\n tick(({ deltaTime }) => {\n elapsedTime += deltaTime;\n \n if (elapsedTime < duration()) {\n // Update position\n x.update((x) => x + (velocityX * deltaTime) / 1000);\n y.update((y) => y + (velocityY * deltaTime) / 1000);\n\n // Apply gravity\n velocityY += (gravity * deltaTime) / 1000;\n\n // Apply deceleration\n velocityX *= deceleration;\n velocityY *= deceleration;\n } else {\n if (onFinish) {\n onFinish();\n }\n }\n });\n</script>\n"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"hit.ce.js","names":[],"sources":["../../../src/components/animations/hit.ce"],"sourcesContent":["<Text x y zIndex={10000} color scale size={30} text />\n\n<script>\n import { animatedSignal, mount, signal, tick } from \"canvasengine\";\n import { Direction } from \"@rpgjs/common\";\n const {\n text,\n direction,\n onFinish,\n duration,\n color,\n x: positionX,\n y: positionY\n } = defineProps({\n duration: {\n default: 1000\n },\n color: {\n default: 'black'\n }\n });\n\n const scale = animatedSignal(1, {\n duration: duration(),\n });\n\n // Generate random initial position\n const randomPosition = () => Math.floor(Math.random() * 60);\n const initialY = randomPosition();\n const x = signal(positionX());\n const y = signal(positionY() - initialY);\n\n // Initial velocity\n let velocityX = 0;\n let velocityY = 0;\n\n // Set initial velocity based on direction\n const speed = 200;\n switch (direction()) {\n case Direction.Left:\n velocityX = speed;\n break;\n case Direction.Right:\n velocityX = -speed;\n break;\n case Direction.Up:\n velocityY = speed;\n break;\n case Direction.Down:\n velocityY = -speed;\n break;\n }\n\n // Add some randomness to the velocity\n velocityX += (Math.random() - 0.5) * 100;\n velocityY += (Math.random() - 0.5) * 100;\n\n const gravity = 500; // Gravity effect\n const deceleration = 0.98; // Deceleration factor\n\n mount(() => {\n scale.set(0.1);\n });\n\n let elapsedTime = 0;\n\n tick(({ deltaTime }) => {\n elapsedTime += deltaTime;\n \n if (elapsedTime < duration()) {\n // Update position\n x.update((x) => x + (velocityX * deltaTime) / 1000);\n y.update((y) => y + (velocityY * deltaTime) / 1000);\n\n // Apply gravity\n velocityY += (gravity * deltaTime) / 1000;\n\n // Apply deceleration\n velocityX *= deceleration;\n velocityY *= deceleration;\n } else {\n if (onFinish) {\n onFinish();\n }\n }\n });\n</script>\n"],"mappings":";;;AAOI,SAAS,UAAA,SAAA;AACD,UAAA,QAAA;CAER,IAAK,KADG,eAAA,QAAA,CACH;EACL,UAAG,EACA,SAAA,KACF;EACD,OAAA,EACE,SAAS,SACV;EACJ,CAAC,EAAE,OAAO,GAAA,MAAA,YAAA,GAAA,WAAA,WAAA,GAAA,UAAA,WAAA,GAAA,UAAA,QAAA,GAAA,OAAA,YAAA,GAAA,GAAA,YAAA,GAAA;CACX,IAAI,QAAE,eAAe,GAAA,EACjB,UAAA,UAAA,EACH,CAAC;;;;CAEF,IAAE,WAAa,gBAAgB;CAC/B,IAAI,IAAA,OAAU,WAAU,CAAA;CACxB,IAAI,IAAA,OAAA,WAAA,GAAA,SAAA;;CAEJ,IAAI,YAAU;CACd,IAAE,QAAM;AACR,SAAQ,WAAW,EAAnB;EACE,KAAO,UAAU;AACX,eAAW;;EAEf,KAAC,UAAQ;AACP,eAAa,CAAA;AACb;;AAEE,eAAS;AACT;EACN,KAAO,UAAU;AACX,eAAW,CAAA;AACb;;AAEN,eAAS,KAAU,QAAK,GAAA,MAAA;AACxB,eAAM,KAAa,QAAK,GAAA,MAAA;CACxB,IAAI,UAAO;CACX,IAAI,eAAe;AACnB,OAAM,WAAY;AACd,QAAE,IAAK,GAAA;GACT;CACF,IAAI,cAAc;AAClB,MAAK,SAAM,IAAA;EACT,IAAA,YAAA,GAAA;;AAEE,MAAI,cAAM,UAAkB,EAAA;AAE9B,KAAA,OAAc,SAAW,GAAG;AAAE,WAAO,IAAG,YAAA,YAAA;KAAA;;;;AAGlC,gBAAc,UAAU,YAAa;AAErC,gBAAM;AACV,gBAAc;aAGZ,SAAA,WAAA;GAIJ;AAEM,QADY,EAAE,MAAA;EAAQ;EAAG;EAAC,QAAA;EAAA;EAAA;EAAA,MAAA;EAAA;EAAA,CAAA"}
@@ -1,10 +1,11 @@
1
- import component$1 from './hit.ce.js';
2
- import component from './animation.ce.js';
3
-
4
- const PrebuiltComponentAnimations = {
5
- Hit: component$1,
6
- Animation: component
1
+ import component from "./hit.ce.js";
2
+ import component$1 from "./animation.ce.js";
3
+ //#region src/components/animations/index.ts
4
+ var PrebuiltComponentAnimations = {
5
+ Hit: component,
6
+ Animation: component$1
7
7
  };
8
-
8
+ //#endregion
9
9
  export { PrebuiltComponentAnimations };
10
- //# sourceMappingURL=index.js.map
10
+
11
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/animations/index.ts"],"sourcesContent":["import Hit from \"./hit.ce\";\nimport Animation from \"./animation.ce\";\n\nexport const PrebuiltComponentAnimations = {\n Hit,\n Animation\n}"],"names":["Hit","Animation"],"mappings":";;;AAGO,MAAM,2BAAA,GAA8B;AAAA,OACvCA,WAAA;AAAA,aACAC;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/animations/index.ts"],"sourcesContent":["import Hit from \"./hit.ce\";\nimport Animation from \"./animation.ce\";\n\nexport const PrebuiltComponentAnimations = {\n Hit,\n Animation\n}"],"mappings":";;;AAGA,IAAa,8BAA8B;CACvC,KAAA;CACA,WAAA"}