@rpgjs/client 5.0.0-alpha.9 → 5.0.0-beta.10

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 (347) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +19 -0
  3. package/dist/Game/AnimationManager.d.ts +8 -0
  4. package/dist/Game/AnimationManager.js +35 -0
  5. package/dist/Game/AnimationManager.js.map +1 -0
  6. package/dist/Game/AnimationManager.spec.d.ts +1 -0
  7. package/dist/Game/Event.d.ts +1 -1
  8. package/dist/Game/Event.js +12 -0
  9. package/dist/Game/Event.js.map +1 -0
  10. package/dist/Game/Map.d.ts +31 -2
  11. package/dist/Game/Map.js +138 -0
  12. package/dist/Game/Map.js.map +1 -0
  13. package/dist/Game/Object.d.ts +189 -0
  14. package/dist/Game/Object.js +255 -0
  15. package/dist/Game/Object.js.map +1 -0
  16. package/dist/Game/Player.d.ts +1 -1
  17. package/dist/Game/Player.js +12 -0
  18. package/dist/Game/Player.js.map +1 -0
  19. package/dist/Gui/Gui.d.ts +192 -7
  20. package/dist/Gui/Gui.js +475 -0
  21. package/dist/Gui/Gui.js.map +1 -0
  22. package/dist/Gui/Gui.spec.d.ts +1 -0
  23. package/dist/Gui/NotificationManager.d.ts +23 -0
  24. package/dist/Gui/NotificationManager.js +49 -0
  25. package/dist/Gui/NotificationManager.js.map +1 -0
  26. package/dist/Resource.d.ts +97 -0
  27. package/dist/Resource.js +133 -0
  28. package/dist/Resource.js.map +1 -0
  29. package/dist/RpgClient.d.ts +295 -13
  30. package/dist/RpgClientEngine.d.ts +671 -15
  31. package/dist/RpgClientEngine.js +1442 -0
  32. package/dist/RpgClientEngine.js.map +1 -0
  33. package/dist/Sound.d.ts +199 -0
  34. package/dist/Sound.js +167 -0
  35. package/dist/Sound.js.map +1 -0
  36. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/decorate.js +9 -0
  37. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/decorateMetadata.js +6 -0
  38. package/dist/components/animations/animation.ce.js +23 -0
  39. package/dist/components/animations/animation.ce.js.map +1 -0
  40. package/dist/components/animations/hit.ce.js +64 -0
  41. package/dist/components/animations/hit.ce.js.map +1 -0
  42. package/dist/components/animations/index.d.ts +4 -0
  43. package/dist/components/animations/index.js +11 -0
  44. package/dist/components/animations/index.js.map +1 -0
  45. package/dist/components/character.ce.js +572 -0
  46. package/dist/components/character.ce.js.map +1 -0
  47. package/dist/components/dynamics/bar.ce.js +96 -0
  48. package/dist/components/dynamics/bar.ce.js.map +1 -0
  49. package/dist/components/dynamics/image.ce.js +23 -0
  50. package/dist/components/dynamics/image.ce.js.map +1 -0
  51. package/dist/components/dynamics/parse-value.d.ts +4 -0
  52. package/dist/components/dynamics/parse-value.js +63 -0
  53. package/dist/components/dynamics/parse-value.js.map +1 -0
  54. package/dist/components/dynamics/parse-value.spec.d.ts +1 -0
  55. package/dist/components/dynamics/shape-utils.d.ts +16 -0
  56. package/dist/components/dynamics/shape-utils.js +73 -0
  57. package/dist/components/dynamics/shape-utils.js.map +1 -0
  58. package/dist/components/dynamics/shape-utils.spec.d.ts +1 -0
  59. package/dist/components/dynamics/shape.ce.js +83 -0
  60. package/dist/components/dynamics/shape.ce.js.map +1 -0
  61. package/dist/components/dynamics/text.ce.js +50 -0
  62. package/dist/components/dynamics/text.ce.js.map +1 -0
  63. package/dist/components/gui/box.ce.js +26 -0
  64. package/dist/components/gui/box.ce.js.map +1 -0
  65. package/dist/components/gui/dialogbox/index.ce.js +198 -0
  66. package/dist/components/gui/dialogbox/index.ce.js.map +1 -0
  67. package/dist/components/gui/gameover.ce.js +169 -0
  68. package/dist/components/gui/gameover.ce.js.map +1 -0
  69. package/dist/components/gui/hud/hud.ce.js +83 -0
  70. package/dist/components/gui/hud/hud.ce.js.map +1 -0
  71. package/dist/components/gui/index.d.ts +15 -3
  72. package/dist/components/gui/index.js +14 -0
  73. package/dist/components/gui/menu/equip-menu.ce.js +427 -0
  74. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -0
  75. package/dist/components/gui/menu/exit-menu.ce.js +55 -0
  76. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -0
  77. package/dist/components/gui/menu/items-menu.ce.js +326 -0
  78. package/dist/components/gui/menu/items-menu.ce.js.map +1 -0
  79. package/dist/components/gui/menu/main-menu.ce.js +399 -0
  80. package/dist/components/gui/menu/main-menu.ce.js.map +1 -0
  81. package/dist/components/gui/menu/options-menu.ce.js +49 -0
  82. package/dist/components/gui/menu/options-menu.ce.js.map +1 -0
  83. package/dist/components/gui/menu/skills-menu.ce.js +102 -0
  84. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -0
  85. package/dist/components/gui/mobile/index.d.ts +8 -0
  86. package/dist/components/gui/mobile/index.js +21 -0
  87. package/dist/components/gui/mobile/index.js.map +1 -0
  88. package/dist/components/gui/mobile/mobile.ce.js +79 -0
  89. package/dist/components/gui/mobile/mobile.ce.js.map +1 -0
  90. package/dist/components/gui/notification/notification.ce.js +62 -0
  91. package/dist/components/gui/notification/notification.ce.js.map +1 -0
  92. package/dist/components/gui/save-load.ce.js +211 -0
  93. package/dist/components/gui/save-load.ce.js.map +1 -0
  94. package/dist/components/gui/shop/shop.ce.js +614 -0
  95. package/dist/components/gui/shop/shop.ce.js.map +1 -0
  96. package/dist/components/gui/title-screen.ce.js +164 -0
  97. package/dist/components/gui/title-screen.ce.js.map +1 -0
  98. package/dist/components/index.d.ts +1 -0
  99. package/dist/components/index.js +4 -0
  100. package/dist/components/player-components-utils.d.ts +67 -0
  101. package/dist/components/player-components-utils.js +162 -0
  102. package/dist/components/player-components-utils.js.map +1 -0
  103. package/dist/components/player-components-utils.spec.d.ts +1 -0
  104. package/dist/components/player-components.ce.js +188 -0
  105. package/dist/components/player-components.ce.js.map +1 -0
  106. package/dist/components/prebuilt/hp-bar.ce.js +113 -0
  107. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -0
  108. package/dist/components/prebuilt/index.d.ts +19 -0
  109. package/dist/components/prebuilt/index.js +2 -0
  110. package/dist/components/prebuilt/light-halo.ce.js +70 -0
  111. package/dist/components/prebuilt/light-halo.ce.js.map +1 -0
  112. package/dist/components/scenes/canvas.ce.js +196 -0
  113. package/dist/components/scenes/canvas.ce.js.map +1 -0
  114. package/dist/components/scenes/draw-map.ce.js +79 -0
  115. package/dist/components/scenes/draw-map.ce.js.map +1 -0
  116. package/dist/components/scenes/event-layer.ce.js +29 -0
  117. package/dist/components/scenes/event-layer.ce.js.map +1 -0
  118. package/dist/core/inject.js +18 -0
  119. package/dist/core/inject.js.map +1 -0
  120. package/dist/core/setup.js +16 -0
  121. package/dist/core/setup.js.map +1 -0
  122. package/dist/decorators/spritesheet.d.ts +1 -0
  123. package/dist/decorators/spritesheet.js +11 -0
  124. package/dist/decorators/spritesheet.js.map +1 -0
  125. package/dist/index.d.ts +16 -1
  126. package/dist/index.js +45 -14
  127. package/dist/module.d.ts +43 -4
  128. package/dist/module.js +179 -0
  129. package/dist/module.js.map +1 -0
  130. package/dist/node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js +167 -0
  131. package/dist/node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js.map +1 -0
  132. package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js +239 -0
  133. package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js.map +1 -0
  134. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js +13 -0
  135. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +1 -0
  136. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js +696 -0
  137. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js.map +1 -0
  138. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js +44 -0
  139. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js.map +1 -0
  140. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js +241 -0
  141. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js.map +1 -0
  142. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +115 -0
  143. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -0
  144. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +401 -0
  145. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -0
  146. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
  147. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3756 -0
  148. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -0
  149. package/dist/presets/animation.d.ts +31 -0
  150. package/dist/presets/animation.js +39 -0
  151. package/dist/presets/animation.js.map +1 -0
  152. package/dist/presets/faceset.d.ts +30 -0
  153. package/dist/presets/faceset.js +51 -0
  154. package/dist/presets/faceset.js.map +1 -0
  155. package/dist/presets/icon.d.ts +20 -0
  156. package/dist/presets/icon.js +15 -0
  157. package/dist/presets/icon.js.map +1 -0
  158. package/dist/presets/index.d.ts +123 -0
  159. package/dist/presets/index.js +17 -0
  160. package/dist/presets/index.js.map +1 -0
  161. package/dist/presets/lpc.d.ts +89 -0
  162. package/dist/presets/lpc.js +98 -0
  163. package/dist/presets/lpc.js.map +1 -0
  164. package/dist/presets/rmspritesheet.js +42 -0
  165. package/dist/presets/rmspritesheet.js.map +1 -0
  166. package/dist/services/AbstractSocket.d.ts +9 -5
  167. package/dist/services/AbstractSocket.js +11 -0
  168. package/dist/services/AbstractSocket.js.map +1 -0
  169. package/dist/services/keyboardControls.d.ts +15 -0
  170. package/dist/services/keyboardControls.js +23 -0
  171. package/dist/services/keyboardControls.js.map +1 -0
  172. package/dist/services/loadMap.d.ts +6 -0
  173. package/dist/services/loadMap.js +123 -0
  174. package/dist/services/loadMap.js.map +1 -0
  175. package/dist/services/mmorpg.d.ts +21 -9
  176. package/dist/services/mmorpg.js +136 -0
  177. package/dist/services/mmorpg.js.map +1 -0
  178. package/dist/services/save.d.ts +19 -0
  179. package/dist/services/save.js +77 -0
  180. package/dist/services/save.js.map +1 -0
  181. package/dist/services/save.spec.d.ts +1 -0
  182. package/dist/services/standalone.d.ts +67 -7
  183. package/dist/services/standalone.js +168 -0
  184. package/dist/services/standalone.js.map +1 -0
  185. package/dist/utils/getEntityProp.d.ts +39 -0
  186. package/dist/utils/getEntityProp.js +53 -0
  187. package/dist/utils/getEntityProp.js.map +1 -0
  188. package/dist/utils/getEntityProp.spec.d.ts +1 -0
  189. package/dist/utils/readPropValue.d.ts +2 -0
  190. package/dist/utils/readPropValue.js +13 -0
  191. package/dist/utils/readPropValue.js.map +1 -0
  192. package/package.json +14 -11
  193. package/src/Game/AnimationManager.spec.ts +30 -0
  194. package/src/Game/AnimationManager.ts +33 -0
  195. package/src/Game/Event.ts +1 -1
  196. package/src/Game/Map.ts +184 -3
  197. package/src/Game/Object.ts +409 -14
  198. package/src/Game/Player.ts +1 -1
  199. package/src/Gui/Gui.spec.ts +273 -0
  200. package/src/Gui/Gui.ts +566 -23
  201. package/src/Gui/NotificationManager.ts +69 -0
  202. package/src/Resource.ts +149 -0
  203. package/src/RpgClient.ts +309 -14
  204. package/src/RpgClientEngine.ts +1790 -63
  205. package/src/Sound.ts +253 -0
  206. package/src/components/{effects → animations}/animation.ce +3 -6
  207. package/src/components/{effects → animations}/index.ts +1 -1
  208. package/src/components/character.ce +801 -59
  209. package/src/components/dynamics/bar.ce +87 -0
  210. package/src/components/dynamics/image.ce +20 -0
  211. package/src/components/dynamics/parse-value.spec.ts +83 -0
  212. package/src/components/dynamics/parse-value.ts +154 -0
  213. package/src/components/dynamics/shape-utils.spec.ts +46 -0
  214. package/src/components/dynamics/shape-utils.ts +61 -0
  215. package/src/components/dynamics/shape.ce +89 -0
  216. package/src/components/dynamics/text.ce +68 -0
  217. package/src/components/gui/box.ce +17 -0
  218. package/src/components/gui/dialogbox/index.ce +213 -187
  219. package/src/components/gui/gameover.ce +158 -0
  220. package/src/components/gui/hud/hud.ce +61 -0
  221. package/src/components/gui/index.ts +30 -4
  222. package/src/components/gui/menu/equip-menu.ce +410 -0
  223. package/src/components/gui/menu/exit-menu.ce +41 -0
  224. package/src/components/gui/menu/items-menu.ce +317 -0
  225. package/src/components/gui/menu/main-menu.ce +294 -0
  226. package/src/components/gui/menu/options-menu.ce +35 -0
  227. package/src/components/gui/menu/skills-menu.ce +83 -0
  228. package/src/components/gui/mobile/index.ts +24 -0
  229. package/src/components/gui/mobile/mobile.ce +80 -0
  230. package/src/components/gui/notification/notification.ce +51 -0
  231. package/src/components/gui/save-load.ce +208 -0
  232. package/src/components/gui/shop/shop.ce +493 -0
  233. package/src/components/gui/title-screen.ce +163 -0
  234. package/src/components/index.ts +3 -0
  235. package/src/components/player-components-utils.spec.ts +109 -0
  236. package/src/components/player-components-utils.ts +205 -0
  237. package/src/components/player-components.ce +221 -0
  238. package/src/components/prebuilt/hp-bar.ce +255 -0
  239. package/src/components/prebuilt/index.ts +24 -0
  240. package/src/components/prebuilt/light-halo.ce +148 -0
  241. package/src/components/scenes/canvas.ce +185 -21
  242. package/src/components/scenes/draw-map.ce +55 -21
  243. package/src/components/scenes/event-layer.ce +8 -2
  244. package/src/components/scenes/transition.ce +60 -0
  245. package/src/core/setup.ts +2 -2
  246. package/src/decorators/spritesheet.ts +8 -0
  247. package/src/index.ts +17 -2
  248. package/src/module.ts +132 -10
  249. package/src/presets/animation.ts +46 -0
  250. package/src/presets/faceset.ts +60 -0
  251. package/src/presets/icon.ts +17 -0
  252. package/src/presets/index.ts +9 -1
  253. package/src/presets/lpc.ts +108 -0
  254. package/src/services/AbstractSocket.ts +10 -2
  255. package/src/services/keyboardControls.ts +20 -0
  256. package/src/services/loadMap.ts +3 -1
  257. package/src/services/mmorpg.ts +106 -12
  258. package/src/services/save.spec.ts +127 -0
  259. package/src/services/save.ts +103 -0
  260. package/src/services/standalone.ts +110 -18
  261. package/src/utils/getEntityProp.spec.ts +96 -0
  262. package/src/utils/getEntityProp.ts +88 -0
  263. package/src/utils/readPropValue.ts +16 -0
  264. package/vite.config.ts +4 -2
  265. package/dist/Game/EffectManager.d.ts +0 -5
  266. package/dist/components/effects/index.d.ts +0 -4
  267. package/dist/index.js.map +0 -1
  268. package/dist/index10.js +0 -8
  269. package/dist/index10.js.map +0 -1
  270. package/dist/index11.js +0 -10
  271. package/dist/index11.js.map +0 -1
  272. package/dist/index12.js +0 -8
  273. package/dist/index12.js.map +0 -1
  274. package/dist/index13.js +0 -17
  275. package/dist/index13.js.map +0 -1
  276. package/dist/index14.js +0 -107
  277. package/dist/index14.js.map +0 -1
  278. package/dist/index15.js +0 -50
  279. package/dist/index15.js.map +0 -1
  280. package/dist/index16.js +0 -191
  281. package/dist/index16.js.map +0 -1
  282. package/dist/index17.js +0 -9
  283. package/dist/index17.js.map +0 -1
  284. package/dist/index18.js +0 -387
  285. package/dist/index18.js.map +0 -1
  286. package/dist/index19.js +0 -31
  287. package/dist/index19.js.map +0 -1
  288. package/dist/index2.js +0 -181
  289. package/dist/index2.js.map +0 -1
  290. package/dist/index20.js +0 -24
  291. package/dist/index20.js.map +0 -1
  292. package/dist/index21.js +0 -2421
  293. package/dist/index21.js.map +0 -1
  294. package/dist/index22.js +0 -114
  295. package/dist/index22.js.map +0 -1
  296. package/dist/index23.js +0 -109
  297. package/dist/index23.js.map +0 -1
  298. package/dist/index24.js +0 -71
  299. package/dist/index24.js.map +0 -1
  300. package/dist/index25.js +0 -21
  301. package/dist/index25.js.map +0 -1
  302. package/dist/index26.js +0 -41
  303. package/dist/index26.js.map +0 -1
  304. package/dist/index27.js +0 -5
  305. package/dist/index27.js.map +0 -1
  306. package/dist/index28.js +0 -322
  307. package/dist/index28.js.map +0 -1
  308. package/dist/index29.js +0 -27
  309. package/dist/index29.js.map +0 -1
  310. package/dist/index3.js +0 -87
  311. package/dist/index3.js.map +0 -1
  312. package/dist/index30.js +0 -11
  313. package/dist/index30.js.map +0 -1
  314. package/dist/index31.js +0 -11
  315. package/dist/index31.js.map +0 -1
  316. package/dist/index32.js +0 -174
  317. package/dist/index32.js.map +0 -1
  318. package/dist/index33.js +0 -501
  319. package/dist/index33.js.map +0 -1
  320. package/dist/index34.js +0 -12
  321. package/dist/index34.js.map +0 -1
  322. package/dist/index35.js +0 -4403
  323. package/dist/index35.js.map +0 -1
  324. package/dist/index36.js +0 -316
  325. package/dist/index36.js.map +0 -1
  326. package/dist/index37.js +0 -61
  327. package/dist/index37.js.map +0 -1
  328. package/dist/index38.js +0 -20
  329. package/dist/index38.js.map +0 -1
  330. package/dist/index39.js +0 -20
  331. package/dist/index39.js.map +0 -1
  332. package/dist/index4.js +0 -67
  333. package/dist/index4.js.map +0 -1
  334. package/dist/index5.js +0 -16
  335. package/dist/index5.js.map +0 -1
  336. package/dist/index6.js +0 -17
  337. package/dist/index6.js.map +0 -1
  338. package/dist/index7.js +0 -39
  339. package/dist/index7.js.map +0 -1
  340. package/dist/index8.js +0 -108
  341. package/dist/index8.js.map +0 -1
  342. package/dist/index9.js +0 -76
  343. package/dist/index9.js.map +0 -1
  344. package/src/Game/EffectManager.ts +0 -20
  345. package/src/components/gui/dialogbox/itemMenu.ce +0 -23
  346. package/src/components/gui/dialogbox/selection.ce +0 -67
  347. /package/src/components/{effects → animations}/hit.ce +0 -0
@@ -0,0 +1,97 @@
1
+ import { RpgClientEngine } from './RpgClientEngine';
2
+ /**
3
+ * RpgResource class
4
+ *
5
+ * Provides a unified API to access resource file links (images and sounds) in the game.
6
+ * Resources are stored as Maps of resource IDs to file paths/URLs.
7
+ *
8
+ * ## Design
9
+ *
10
+ * RpgResource acts as a facade over the engine's resource storage, providing
11
+ * easy access to resource file links. It maintains Maps that are synchronized
12
+ * with the engine's internal storage, but only stores the file paths/URLs,
13
+ * not the full resource objects.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { RpgResource } from '@rpgjs/client'
18
+ *
19
+ * // Get spritesheet image link
20
+ * const imageLink = RpgResource.spritesheets.get('hero')
21
+ *
22
+ * // Get sound file link
23
+ * const soundLink = RpgResource.sounds.get('town-music')
24
+ *
25
+ * // Set a new resource link
26
+ * RpgResource.spritesheets.set('new-sprite', './assets/new-sprite.png')
27
+ * ```
28
+ */
29
+ export declare class RpgResource {
30
+ private static engine;
31
+ private static _spritesheets;
32
+ private static _sounds;
33
+ /**
34
+ * Initialize RpgResource with the engine instance
35
+ *
36
+ * This is called automatically by the engine during initialization.
37
+ * It synchronizes the resource Maps with the engine's internal storage.
38
+ *
39
+ * @param engine - The RpgClientEngine instance
40
+ */
41
+ static init(engine: RpgClientEngine): void;
42
+ /**
43
+ * Synchronize resource Maps with the engine's internal storage
44
+ *
45
+ * Extracts file links from spritesheets and sounds stored in the engine
46
+ * and updates the Maps accordingly.
47
+ *
48
+ * @private
49
+ */
50
+ private static syncResources;
51
+ /**
52
+ * Get/Set image links for spritesheets
53
+ *
54
+ * Map of spritesheet IDs to their image file paths/URLs.
55
+ * This Map is synchronized with the engine's spritesheet storage.
56
+ *
57
+ * @type {Map<string, string>}
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * // Get an image link
62
+ * const imageLink = RpgResource.spritesheets.get('hero')
63
+ *
64
+ * // Set a new image link
65
+ * RpgResource.spritesheets.set('new-sprite', './assets/new-sprite.png')
66
+ *
67
+ * // Check if a spritesheet exists
68
+ * if (RpgResource.spritesheets.has('monster')) {
69
+ * const link = RpgResource.spritesheets.get('monster')
70
+ * }
71
+ * ```
72
+ */
73
+ static get spritesheets(): Map<string, string>;
74
+ /**
75
+ * Get/Set sound file links
76
+ *
77
+ * Map of sound IDs to their audio file paths/URLs.
78
+ * This Map is synchronized with the engine's sound storage.
79
+ *
80
+ * @type {Map<string, string>}
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * // Get a sound link
85
+ * const soundLink = RpgResource.sounds.get('town-music')
86
+ *
87
+ * // Set a new sound link
88
+ * RpgResource.sounds.set('new-sound', './assets/new-sound.ogg')
89
+ *
90
+ * // Iterate over all sounds
91
+ * RpgResource.sounds.forEach((link, id) => {
92
+ * console.log(`Sound ${id}: ${link}`)
93
+ * })
94
+ * ```
95
+ */
96
+ static get sounds(): Map<string, string>;
97
+ }
@@ -0,0 +1,133 @@
1
+ //#region src/Resource.ts
2
+ /**
3
+ * RpgResource class
4
+ *
5
+ * Provides a unified API to access resource file links (images and sounds) in the game.
6
+ * Resources are stored as Maps of resource IDs to file paths/URLs.
7
+ *
8
+ * ## Design
9
+ *
10
+ * RpgResource acts as a facade over the engine's resource storage, providing
11
+ * easy access to resource file links. It maintains Maps that are synchronized
12
+ * with the engine's internal storage, but only stores the file paths/URLs,
13
+ * not the full resource objects.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { RpgResource } from '@rpgjs/client'
18
+ *
19
+ * // Get spritesheet image link
20
+ * const imageLink = RpgResource.spritesheets.get('hero')
21
+ *
22
+ * // Get sound file link
23
+ * const soundLink = RpgResource.sounds.get('town-music')
24
+ *
25
+ * // Set a new resource link
26
+ * RpgResource.spritesheets.set('new-sprite', './assets/new-sprite.png')
27
+ * ```
28
+ */
29
+ var RpgResource = class RpgResource {
30
+ static {
31
+ this.engine = null;
32
+ }
33
+ static {
34
+ this._spritesheets = /* @__PURE__ */ new Map();
35
+ }
36
+ static {
37
+ this._sounds = /* @__PURE__ */ new Map();
38
+ }
39
+ /**
40
+ * Initialize RpgResource with the engine instance
41
+ *
42
+ * This is called automatically by the engine during initialization.
43
+ * It synchronizes the resource Maps with the engine's internal storage.
44
+ *
45
+ * @param engine - The RpgClientEngine instance
46
+ */
47
+ static init(engine) {
48
+ RpgResource.engine = engine;
49
+ RpgResource.syncResources();
50
+ }
51
+ /**
52
+ * Synchronize resource Maps with the engine's internal storage
53
+ *
54
+ * Extracts file links from spritesheets and sounds stored in the engine
55
+ * and updates the Maps accordingly.
56
+ *
57
+ * @private
58
+ */
59
+ static syncResources() {
60
+ if (!RpgResource.engine) return;
61
+ RpgResource._spritesheets.clear();
62
+ RpgResource.engine.spritesheets.forEach((spritesheet, id) => {
63
+ const imageLink = spritesheet?.image || spritesheet?.imageSource || void 0;
64
+ if (imageLink) RpgResource._spritesheets.set(String(id), imageLink);
65
+ });
66
+ RpgResource._sounds.clear();
67
+ RpgResource.engine.sounds.forEach((sound, id) => {
68
+ let soundLink;
69
+ if (sound && typeof sound === "object") {
70
+ if (sound._src && Array.isArray(sound._src) && sound._src.length > 0) soundLink = sound._src[0];
71
+ else if (sound.src && typeof sound.src === "string") soundLink = sound.src;
72
+ else if (sound.src && Array.isArray(sound.src) && sound.src.length > 0) soundLink = sound.src[0];
73
+ }
74
+ if (soundLink) RpgResource._sounds.set(id, soundLink);
75
+ });
76
+ }
77
+ /**
78
+ * Get/Set image links for spritesheets
79
+ *
80
+ * Map of spritesheet IDs to their image file paths/URLs.
81
+ * This Map is synchronized with the engine's spritesheet storage.
82
+ *
83
+ * @type {Map<string, string>}
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * // Get an image link
88
+ * const imageLink = RpgResource.spritesheets.get('hero')
89
+ *
90
+ * // Set a new image link
91
+ * RpgResource.spritesheets.set('new-sprite', './assets/new-sprite.png')
92
+ *
93
+ * // Check if a spritesheet exists
94
+ * if (RpgResource.spritesheets.has('monster')) {
95
+ * const link = RpgResource.spritesheets.get('monster')
96
+ * }
97
+ * ```
98
+ */
99
+ static get spritesheets() {
100
+ RpgResource.syncResources();
101
+ return RpgResource._spritesheets;
102
+ }
103
+ /**
104
+ * Get/Set sound file links
105
+ *
106
+ * Map of sound IDs to their audio file paths/URLs.
107
+ * This Map is synchronized with the engine's sound storage.
108
+ *
109
+ * @type {Map<string, string>}
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * // Get a sound link
114
+ * const soundLink = RpgResource.sounds.get('town-music')
115
+ *
116
+ * // Set a new sound link
117
+ * RpgResource.sounds.set('new-sound', './assets/new-sound.ogg')
118
+ *
119
+ * // Iterate over all sounds
120
+ * RpgResource.sounds.forEach((link, id) => {
121
+ * console.log(`Sound ${id}: ${link}`)
122
+ * })
123
+ * ```
124
+ */
125
+ static get sounds() {
126
+ RpgResource.syncResources();
127
+ return RpgResource._sounds;
128
+ }
129
+ };
130
+ //#endregion
131
+ export { RpgResource };
132
+
133
+ //# sourceMappingURL=Resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Resource.js","names":[],"sources":["../src/Resource.ts"],"sourcesContent":["import { RpgClientEngine } from './RpgClientEngine';\n\n/**\n * RpgResource class\n * \n * Provides a unified API to access resource file links (images and sounds) in the game.\n * Resources are stored as Maps of resource IDs to file paths/URLs.\n * \n * ## Design\n * \n * RpgResource acts as a facade over the engine's resource storage, providing\n * easy access to resource file links. It maintains Maps that are synchronized\n * with the engine's internal storage, but only stores the file paths/URLs,\n * not the full resource objects.\n * \n * @example\n * ```ts\n * import { RpgResource } from '@rpgjs/client'\n * \n * // Get spritesheet image link\n * const imageLink = RpgResource.spritesheets.get('hero')\n * \n * // Get sound file link\n * const soundLink = RpgResource.sounds.get('town-music')\n * \n * // Set a new resource link\n * RpgResource.spritesheets.set('new-sprite', './assets/new-sprite.png')\n * ```\n */\nexport class RpgResource {\n private static engine: RpgClientEngine | null = null;\n private static _spritesheets: Map<string, string> = new Map();\n private static _sounds: Map<string, string> = new Map();\n\n /**\n * Initialize RpgResource with the engine instance\n * \n * This is called automatically by the engine during initialization.\n * It synchronizes the resource Maps with the engine's internal storage.\n * \n * @param engine - The RpgClientEngine instance\n */\n static init(engine: RpgClientEngine): void {\n RpgResource.engine = engine;\n RpgResource.syncResources();\n }\n\n /**\n * Synchronize resource Maps with the engine's internal storage\n * \n * Extracts file links from spritesheets and sounds stored in the engine\n * and updates the Maps accordingly.\n * \n * @private\n */\n private static syncResources(): void {\n if (!RpgResource.engine) {\n return;\n }\n\n // Sync spritesheets\n RpgResource._spritesheets.clear();\n RpgResource.engine.spritesheets.forEach((spritesheet, id) => {\n // Extract image path from spritesheet\n const imageLink = spritesheet?.image || spritesheet?.imageSource || undefined;\n if (imageLink) {\n RpgResource._spritesheets.set(String(id), imageLink);\n }\n });\n\n // Sync sounds\n RpgResource._sounds.clear();\n RpgResource.engine.sounds.forEach((sound, id) => {\n // Extract src path from sound\n let soundLink: string | undefined;\n \n // If it's a Howler instance, try to get src from _src or src property\n if (sound && typeof sound === 'object') {\n if (sound._src && Array.isArray(sound._src) && sound._src.length > 0) {\n soundLink = sound._src[0];\n } else if (sound.src && typeof sound.src === 'string') {\n soundLink = sound.src;\n } else if (sound.src && Array.isArray(sound.src) && sound.src.length > 0) {\n soundLink = sound.src[0];\n }\n }\n \n if (soundLink) {\n RpgResource._sounds.set(id, soundLink);\n }\n });\n }\n\n /**\n * Get/Set image links for spritesheets\n * \n * Map of spritesheet IDs to their image file paths/URLs.\n * This Map is synchronized with the engine's spritesheet storage.\n * \n * @type {Map<string, string>}\n * \n * @example\n * ```ts\n * // Get an image link\n * const imageLink = RpgResource.spritesheets.get('hero')\n * \n * // Set a new image link\n * RpgResource.spritesheets.set('new-sprite', './assets/new-sprite.png')\n * \n * // Check if a spritesheet exists\n * if (RpgResource.spritesheets.has('monster')) {\n * const link = RpgResource.spritesheets.get('monster')\n * }\n * ```\n */\n static get spritesheets(): Map<string, string> {\n // Sync before returning to ensure we have the latest data\n RpgResource.syncResources();\n return RpgResource._spritesheets;\n }\n\n /**\n * Get/Set sound file links\n * \n * Map of sound IDs to their audio file paths/URLs.\n * This Map is synchronized with the engine's sound storage.\n * \n * @type {Map<string, string>}\n * \n * @example\n * ```ts\n * // Get a sound link\n * const soundLink = RpgResource.sounds.get('town-music')\n * \n * // Set a new sound link\n * RpgResource.sounds.set('new-sound', './assets/new-sound.ogg')\n * \n * // Iterate over all sounds\n * RpgResource.sounds.forEach((link, id) => {\n * console.log(`Sound ${id}: ${link}`)\n * })\n * ```\n */\n static get sounds(): Map<string, string> {\n // Sync before returning to ensure we have the latest data\n RpgResource.syncResources();\n return RpgResource._sounds;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAa,cAAb,MAAa,YAAY;;gBACyB;;;uCACI,IAAI,IAAI;;;iCACd,IAAI,IAAI;;;;;;;;;;CAUtD,OAAO,KAAK,QAA+B;EACzC,YAAY,SAAS;EACrB,YAAY,cAAc;CAC5B;;;;;;;;;CAUA,OAAe,gBAAsB;EACnC,IAAI,CAAC,YAAY,QACf;EAIF,YAAY,cAAc,MAAM;EAChC,YAAY,OAAO,aAAa,SAAS,aAAa,OAAO;GAE3D,MAAM,YAAY,aAAa,SAAS,aAAa,eAAe,KAAA;GACpE,IAAI,WACF,YAAY,cAAc,IAAI,OAAO,EAAE,GAAG,SAAS;EAEvD,CAAC;EAGD,YAAY,QAAQ,MAAM;EAC1B,YAAY,OAAO,OAAO,SAAS,OAAO,OAAO;GAE/C,IAAI;GAGJ,IAAI,SAAS,OAAO,UAAU;QACxB,MAAM,QAAQ,MAAM,QAAQ,MAAM,IAAI,KAAK,MAAM,KAAK,SAAS,GACjE,YAAY,MAAM,KAAK;SAClB,IAAI,MAAM,OAAO,OAAO,MAAM,QAAQ,UAC3C,YAAY,MAAM;SACb,IAAI,MAAM,OAAO,MAAM,QAAQ,MAAM,GAAG,KAAK,MAAM,IAAI,SAAS,GACrE,YAAY,MAAM,IAAI;GAAA;GAI1B,IAAI,WACF,YAAY,QAAQ,IAAI,IAAI,SAAS;EAEzC,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;CAwBA,WAAW,eAAoC;EAE7C,YAAY,cAAc;EAC1B,OAAO,YAAY;CACrB;;;;;;;;;;;;;;;;;;;;;;;CAwBA,WAAW,SAA8B;EAEvC,YAAY,cAAc;EAC1B,OAAO,YAAY;CACrB;AACF"}
@@ -1,8 +1,27 @@
1
- import { ComponentFunction } from 'canvasengine';
1
+ import { ComponentFunction, Signal } from 'canvasengine';
2
2
  import { RpgClientEngine } from './RpgClientEngine';
3
3
  import { Loader, Container } from 'pixi.js';
4
- type RpgComponent = Container;
4
+ import { RpgClientObject } from './Game/Object';
5
+ import { MapPhysicsEntityContext, MapPhysicsInitContext } from '@rpgjs/common';
6
+ type RpgComponent = RpgClientObject;
5
7
  type SceneMap = Container;
8
+ export type SpriteComponentConfig = ComponentFunction | {
9
+ component: ComponentFunction;
10
+ props?: Record<string, any> | ((object: RpgClientObject) => Record<string, any>);
11
+ data?: Record<string, any> | ((object: RpgClientObject) => Record<string, any>);
12
+ dependencies?: (object: RpgClientObject) => any[];
13
+ };
14
+ export interface RpgSpriteBeforeRemoveContext {
15
+ reason?: string;
16
+ data?: any;
17
+ transition?: {
18
+ animation?: string;
19
+ graphic?: string | string[];
20
+ duration?: number;
21
+ effect?: string;
22
+ };
23
+ timeoutMs?: number;
24
+ }
6
25
  export interface RpgClientEngineHooks {
7
26
  /**
8
27
  * When the engine is started. If you send false, you prevent the client from connecting to the server
@@ -72,7 +91,7 @@ export interface RpgSpriteHooks {
72
91
  * }
73
92
  * ```
74
93
  */
75
- componentsBehind?: ComponentFunction[];
94
+ componentsBehind?: SpriteComponentConfig[];
76
95
  /**
77
96
  * Array of components to render in front of the sprite
78
97
  * These components will be displayed with a higher z-index than the sprite itself
@@ -86,7 +105,27 @@ export interface RpgSpriteHooks {
86
105
  * }
87
106
  * ```
88
107
  */
89
- componentsInFront?: ComponentFunction[];
108
+ componentsInFront?: SpriteComponentConfig[];
109
+ /**
110
+ * Reusable sprite components addressable by server-side component definitions.
111
+ *
112
+ * The server sends only the component id and serializable props. The client
113
+ * registry maps that id to the CanvasEngine component that renders it.
114
+ *
115
+ * @prop {Record<string, ComponentFunction>} [components]
116
+ * @memberof RpgSpriteHooks
117
+ * @example
118
+ * ```ts
119
+ * import GuildBadge from './components/guild-badge.ce'
120
+ *
121
+ * const sprite: RpgSpriteHooks = {
122
+ * components: {
123
+ * guildBadge: GuildBadge
124
+ * }
125
+ * }
126
+ * ```
127
+ */
128
+ components?: Record<string, ComponentFunction>;
90
129
  /**
91
130
  * As soon as the sprite is initialized
92
131
  *
@@ -101,6 +140,17 @@ export interface RpgSpriteHooks {
101
140
  * @memberof RpgSpriteHooks
102
141
  */
103
142
  onDestroy?: (sprite: RpgComponent) => any;
143
+ /**
144
+ * Called when a sprite removal is requested, before it disappears from the scene.
145
+ *
146
+ * Return a promise to keep the sprite visible while an animation, effect, or
147
+ * sound transition is running. The server still owns gameplay removal and
148
+ * uses the timeout carried by the remove request as a safety limit.
149
+ *
150
+ * @prop { (sprite: RpgSprite, context: RpgSpriteBeforeRemoveContext) => any } [onBeforeRemove]
151
+ * @memberof RpgSpriteHooks
152
+ */
153
+ onBeforeRemove?: (sprite: RpgComponent, context: RpgSpriteBeforeRemoveContext) => any;
104
154
  /**
105
155
  * As soon as a data is changed on the server side (the name for example), you are able to know the new data but also the old data.
106
156
  *
@@ -179,6 +229,37 @@ export interface RpgSceneMapHooks extends RpgSceneHooks<SceneMap> {
179
229
  * @memberof RpgSceneHooks
180
230
  */
181
231
  onMapLoading?: (scene: SceneMap, loader: Loader) => any;
232
+ /**
233
+ * Called when client physics has been initialized for the current map.
234
+ *
235
+ * Use this hook to initialize shared physics extensions based on map data
236
+ * (for example, tile-based collision rules used by client prediction).
237
+ *
238
+ * @prop { (scene: SceneMap, context: MapPhysicsInitContext) => any } [onPhysicsInit]
239
+ * @memberof RpgSceneMapHooks
240
+ */
241
+ onPhysicsInit?: (scene: SceneMap, context: MapPhysicsInitContext) => any;
242
+ /**
243
+ * Called when a character physics body is added to the map.
244
+ *
245
+ * @prop { (scene: SceneMap, context: MapPhysicsEntityContext) => any } [onPhysicsEntityAdd]
246
+ * @memberof RpgSceneMapHooks
247
+ */
248
+ onPhysicsEntityAdd?: (scene: SceneMap, context: MapPhysicsEntityContext) => any;
249
+ /**
250
+ * Called when a character physics body is removed from the map.
251
+ *
252
+ * @prop { (scene: SceneMap, context: MapPhysicsEntityContext) => any } [onPhysicsEntityRemove]
253
+ * @memberof RpgSceneMapHooks
254
+ */
255
+ onPhysicsEntityRemove?: (scene: SceneMap, context: MapPhysicsEntityContext) => any;
256
+ /**
257
+ * Called when the physics world is reset (e.g. before a map physics reload).
258
+ *
259
+ * @prop { (scene: SceneMap) => any } [onPhysicsReset]
260
+ * @memberof RpgSceneMapHooks
261
+ */
262
+ onPhysicsReset?: (scene: SceneMap) => any;
182
263
  }
183
264
  export interface RpgClient {
184
265
  /**
@@ -283,33 +364,207 @@ export interface RpgClient {
283
364
  * */
284
365
  spritesheets?: any[];
285
366
  /**
286
- * Array containing the list of VueJS components
367
+ * Resolver function for dynamically creating spritesheets
368
+ *
369
+ * This function is called when a spritesheet is requested but not found in the cache.
370
+ * It can be synchronous (returns directly) or asynchronous (returns a Promise).
371
+ * The resolved spritesheet is automatically cached for future use.
372
+ *
373
+ * ```ts
374
+ * import { defineModule, RpgClient } from '@rpgjs/client'
375
+ *
376
+ * defineModule<RpgClient>({
377
+ * spritesheetResolver: (id: string) => {
378
+ * // Synchronous resolver
379
+ * if (id === 'dynamic-sprite') {
380
+ * return {
381
+ * id: 'dynamic-sprite',
382
+ * image: 'path/to/image.png',
383
+ * framesWidth: 32,
384
+ * framesHeight: 32
385
+ * };
386
+ * }
387
+ * return undefined;
388
+ * }
389
+ * })
390
+ *
391
+ * // Or asynchronous resolver
392
+ * defineModule<RpgClient>({
393
+ * spritesheetResolver: async (id: string) => {
394
+ * const response = await fetch(`/api/spritesheets/${id}`);
395
+ * const data = await response.json();
396
+ * return data;
397
+ * }
398
+ * })
399
+ * ```
400
+ *
401
+ * @prop {(id: string) => any | Promise<any>} [spritesheetResolver]
402
+ * @memberof RpgClient
403
+ * */
404
+ spritesheetResolver?: (id: string) => any | Promise<any>;
405
+ /**
406
+ * Resolver function for dynamically loading sounds
287
407
  *
408
+ * The resolver is called when a sound is requested but not found in the cache.
409
+ * It can be synchronous (returns directly) or asynchronous (returns a Promise).
410
+ * The resolved sound is automatically cached for future use.
411
+ *
412
+ * ```ts
413
+ * import { defineModule, RpgClient } from '@rpgjs/client'
414
+ *
415
+ * defineModule<RpgClient>({
416
+ * soundResolver: (id: string) => {
417
+ * if (id === 'dynamic-sound') {
418
+ * return { id: 'dynamic-sound', src: 'path/to/sound.mp3' };
419
+ * }
420
+ * return undefined;
421
+ * }
422
+ * })
423
+ * ```
424
+ *
425
+ * @prop {(id: string) => any | Promise<any>} [soundResolver]
426
+ * @memberof RpgClient
427
+ * */
428
+ soundResolver?: (id: string) => any | Promise<any>;
429
+ /**
430
+ * Array containing the list of GUI components
431
+ *
432
+ * ```ts
433
+ * import { defineModule, RpgClient } from '@rpgjs/client'
434
+ * import InventoryComponent from './inventory.ce'
435
+ *
436
+ * defineModule<RpgClient>({
437
+ * gui: [
438
+ * {
439
+ * id: 'inventory',
440
+ * component: InventoryComponent,
441
+ * autoDisplay: true,
442
+ * dependencies: () => [playerSignal, inventorySignal]
443
+ * }
444
+ * ]
445
+ * })
446
+ * ```
288
447
  *
289
448
  * [Guide: Create GUI](/guide/create-gui.html)
290
449
  *
291
- * @prop {Array<Component of CanvasEngine>} [gui]
450
+ * @prop {Array<GuiOptions>} [gui]
292
451
  * @memberof RpgClient
293
452
  * */
294
- gui?: ComponentFunction[];
453
+ gui?: ({
454
+ id: string;
455
+ component: ComponentFunction;
456
+ /**
457
+ * Auto display the GUI when added to the system
458
+ * @default false
459
+ */
460
+ autoDisplay?: boolean;
461
+ /**
462
+ * Function that returns an array of Signal dependencies
463
+ * The GUI will only display when all dependencies are resolved (!= undefined)
464
+ */
465
+ dependencies?: () => Signal[];
466
+ /**
467
+ * Attach the GUI to sprites instead of displaying globally
468
+ *
469
+ * When set to `true`, the GUI component will be rendered directly on each sprite
470
+ * in the game world, rather than being displayed as a fixed overlay on the screen.
471
+ * This is useful for tooltips, health bars, name tags, or any UI element that
472
+ * should follow a specific sprite.
473
+ *
474
+ * The GUI will be rendered in the `character.ce` component for each sprite.
475
+ * You can control the display state of attached GUIs from the server side using
476
+ * `player.showAttachedGui()` and `player.hideAttachedGui()` methods.
477
+ *
478
+ * @default false
479
+ * @example
480
+ * ```ts
481
+ * import { defineModule, RpgClient } from '@rpgjs/client'
482
+ * import TooltipComponent from './tooltip.ce'
483
+ *
484
+ * defineModule<RpgClient>({
485
+ * gui: [
486
+ * {
487
+ * id: "my-tooltip",
488
+ * component: TooltipComponent,
489
+ * attachToSprite: true
490
+ * }
491
+ * ]
492
+ * })
493
+ * ```
494
+ *
495
+ * On the server side, control the display:
496
+ * ```ts
497
+ * // Show the tooltip for this player
498
+ * player.showAttachedGui()
499
+ *
500
+ * // Hide the tooltip for this player
501
+ * player.hideAttachedGui()
502
+ *
503
+ * // Show tooltip for other players
504
+ * player.showAttachedGui([otherPlayer1, otherPlayer2])
505
+ * ```
506
+ */
507
+ attachToSprite?: boolean;
508
+ /**
509
+ * Vue v4 compatibility alias for `attachToSprite`.
510
+ *
511
+ * Prefer `attachToSprite` in v5 projects. This is read by `@rpgjs/vue`
512
+ * for Vue GUI components migrated from the v4 GUI API.
513
+ */
514
+ rpgAttachToSprite?: boolean;
515
+ } | any)[];
295
516
  /**
296
517
  * Array containing the list of sounds
297
- * Each element is a simple object containing sound definitions
518
+ * Each element can be:
519
+ * - A simple object containing sound definitions
520
+ * - A class decorated with @Sound
298
521
  *
299
522
  * ```ts
300
- * import { defineModule, RpgClient } from '@rpgjs/client'
523
+ * import { defineModule, RpgClient, Sound } from '@rpgjs/client'
301
524
  *
525
+ * // Using simple objects
302
526
  * defineModule<RpgClient>({
303
527
  * sounds: [
304
528
  * {
305
- * town: require('./assets/Town_Theme.ogg'),
306
- * battle: require('./assets/Battle_Theme.ogg')
529
+ * id: 'typewriter',
530
+ * src: 'typewriter.wav'
531
+ * },
532
+ * {
533
+ * id: 'cursor',
534
+ * src: 'cursor.wav'
307
535
  * }
308
536
  * ]
309
537
  * })
538
+ *
539
+ * // Using @Sound decorator
540
+ * @Sound({
541
+ * id: 'town-music',
542
+ * sound: require('./sound/town.ogg'),
543
+ * loop: true,
544
+ * volume: 0.5
545
+ * })
546
+ * export class TownMusic {}
547
+ *
548
+ * defineModule<RpgClient>({
549
+ * sounds: [TownMusic]
550
+ * })
551
+ *
552
+ * // Multiple sounds in one class
553
+ * @Sound({
554
+ * sounds: {
555
+ * hero: require('./assets/hero.ogg'),
556
+ * monster: require('./assets/monster.ogg')
557
+ * },
558
+ * loop: true
559
+ * })
560
+ * export class CharacterSounds {}
561
+ *
562
+ * defineModule<RpgClient>({
563
+ * sounds: [CharacterSounds]
564
+ * })
310
565
  * ```
311
566
  *
312
- * @prop {Array<Object>} [sounds]
567
+ * @prop {Array<Object | Class>} [sounds]
313
568
  * @memberof RpgClient
314
569
  * */
315
570
  sounds?: any[];
@@ -356,7 +611,34 @@ export interface RpgClient {
356
611
  scenes?: {
357
612
  map: RpgSceneMapHooks;
358
613
  };
359
- effects?: {
614
+ sceneMap?: RpgSceneMapHooks;
615
+ /**
616
+ * Array containing the list of component animations
617
+ * Each element defines a temporary component to display for animations like hits, effects, etc.
618
+ *
619
+ * ```ts
620
+ * import { defineModule, RpgClient } from '@rpgjs/client'
621
+ * import HitComponent from './hit.ce'
622
+ * import ExplosionComponent from './explosion.ce'
623
+ *
624
+ * defineModule<RpgClient>({
625
+ * componentAnimations: [
626
+ * {
627
+ * id: 'hit',
628
+ * component: HitComponent
629
+ * },
630
+ * {
631
+ * id: 'explosion',
632
+ * component: ExplosionComponent
633
+ * }
634
+ * ]
635
+ * })
636
+ * ```
637
+ *
638
+ * @prop {Array<{id: string, component: ComponentFunction}>} [componentAnimations]
639
+ * @memberof RpgClient
640
+ * */
641
+ componentAnimations?: {
360
642
  id: string;
361
643
  component: ComponentFunction;
362
644
  }[];