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

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 (304) hide show
  1. package/dist/Game/AnimationManager.d.ts +8 -0
  2. package/dist/Game/AnimationManager.js +26 -0
  3. package/dist/Game/AnimationManager.js.map +1 -0
  4. package/dist/Game/Event.d.ts +1 -1
  5. package/dist/Game/Event.js +12 -0
  6. package/dist/Game/Event.js.map +1 -0
  7. package/dist/Game/Map.d.ts +23 -2
  8. package/dist/Game/Map.js +80 -0
  9. package/dist/Game/Map.js.map +1 -0
  10. package/dist/Game/Object.d.ts +157 -0
  11. package/dist/Game/Object.js +211 -0
  12. package/dist/Game/Object.js.map +1 -0
  13. package/dist/Game/Player.d.ts +1 -1
  14. package/dist/Game/Player.js +12 -0
  15. package/dist/Game/Player.js.map +1 -0
  16. package/dist/Gui/Gui.d.ts +177 -5
  17. package/dist/Gui/Gui.js +445 -0
  18. package/dist/Gui/Gui.js.map +1 -0
  19. package/dist/Gui/NotificationManager.d.ts +23 -0
  20. package/dist/Gui/NotificationManager.js +49 -0
  21. package/dist/Gui/NotificationManager.js.map +1 -0
  22. package/dist/Resource.d.ts +97 -0
  23. package/dist/Resource.js +133 -0
  24. package/dist/Resource.js.map +1 -0
  25. package/dist/RpgClient.d.ts +238 -11
  26. package/dist/RpgClientEngine.d.ts +615 -14
  27. package/dist/RpgClientEngine.js +1334 -0
  28. package/dist/RpgClientEngine.js.map +1 -0
  29. package/dist/Sound.d.ts +199 -0
  30. package/dist/Sound.js +167 -0
  31. package/dist/Sound.js.map +1 -0
  32. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
  33. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js +6 -0
  34. package/dist/components/animations/animation.ce.js +24 -0
  35. package/dist/components/animations/animation.ce.js.map +1 -0
  36. package/dist/components/animations/hit.ce.js +70 -0
  37. package/dist/components/animations/hit.ce.js.map +1 -0
  38. package/dist/components/animations/index.d.ts +4 -0
  39. package/dist/components/animations/index.js +11 -0
  40. package/dist/components/animations/index.js.map +1 -0
  41. package/dist/components/character.ce.js +392 -0
  42. package/dist/components/character.ce.js.map +1 -0
  43. package/dist/components/dynamics/parse-value.d.ts +1 -0
  44. package/dist/components/dynamics/parse-value.js +44 -0
  45. package/dist/components/dynamics/parse-value.js.map +1 -0
  46. package/dist/components/dynamics/text.ce.js +73 -0
  47. package/dist/components/dynamics/text.ce.js.map +1 -0
  48. package/dist/components/gui/box.ce.js +28 -0
  49. package/dist/components/gui/box.ce.js.map +1 -0
  50. package/dist/components/gui/dialogbox/index.ce.js +205 -0
  51. package/dist/components/gui/dialogbox/index.ce.js.map +1 -0
  52. package/dist/components/gui/gameover.ce.js +193 -0
  53. package/dist/components/gui/gameover.ce.js.map +1 -0
  54. package/dist/components/gui/hud/hud.ce.js +92 -0
  55. package/dist/components/gui/hud/hud.ce.js.map +1 -0
  56. package/dist/components/gui/index.d.ts +15 -3
  57. package/dist/components/gui/index.js +14 -0
  58. package/dist/components/gui/menu/equip-menu.ce.js +481 -0
  59. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -0
  60. package/dist/components/gui/menu/exit-menu.ce.js +54 -0
  61. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -0
  62. package/dist/components/gui/menu/items-menu.ce.js +344 -0
  63. package/dist/components/gui/menu/items-menu.ce.js.map +1 -0
  64. package/dist/components/gui/menu/main-menu.ce.js +417 -0
  65. package/dist/components/gui/menu/main-menu.ce.js.map +1 -0
  66. package/dist/components/gui/menu/options-menu.ce.js +48 -0
  67. package/dist/components/gui/menu/options-menu.ce.js.map +1 -0
  68. package/dist/components/gui/menu/skills-menu.ce.js +107 -0
  69. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -0
  70. package/dist/components/gui/mobile/index.d.ts +8 -0
  71. package/dist/components/gui/mobile/index.js +21 -0
  72. package/dist/components/gui/mobile/index.js.map +1 -0
  73. package/dist/components/gui/mobile/mobile.ce.js +78 -0
  74. package/dist/components/gui/mobile/mobile.ce.js.map +1 -0
  75. package/dist/components/gui/notification/notification.ce.js +64 -0
  76. package/dist/components/gui/notification/notification.ce.js.map +1 -0
  77. package/dist/components/gui/save-load.ce.js +389 -0
  78. package/dist/components/gui/save-load.ce.js.map +1 -0
  79. package/dist/components/gui/shop/shop.ce.js +652 -0
  80. package/dist/components/gui/shop/shop.ce.js.map +1 -0
  81. package/dist/components/gui/title-screen.ce.js +190 -0
  82. package/dist/components/gui/title-screen.ce.js.map +1 -0
  83. package/dist/components/index.d.ts +1 -0
  84. package/dist/components/index.js +4 -0
  85. package/dist/components/prebuilt/hp-bar.ce.js +116 -0
  86. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -0
  87. package/dist/components/prebuilt/index.d.ts +19 -0
  88. package/dist/components/prebuilt/index.js +2 -0
  89. package/dist/components/prebuilt/light-halo.ce.js +94 -0
  90. package/dist/components/prebuilt/light-halo.ce.js.map +1 -0
  91. package/dist/components/scenes/canvas.ce.js +60 -0
  92. package/dist/components/scenes/canvas.ce.js.map +1 -0
  93. package/dist/components/scenes/draw-map.ce.js +89 -0
  94. package/dist/components/scenes/draw-map.ce.js.map +1 -0
  95. package/dist/components/scenes/event-layer.ce.js +28 -0
  96. package/dist/components/scenes/event-layer.ce.js.map +1 -0
  97. package/dist/core/inject.js +18 -0
  98. package/dist/core/inject.js.map +1 -0
  99. package/dist/core/setup.js +16 -0
  100. package/dist/core/setup.js.map +1 -0
  101. package/dist/index.d.ts +15 -1
  102. package/dist/index.js +44 -14
  103. package/dist/module.d.ts +43 -4
  104. package/dist/module.js +176 -0
  105. package/dist/module.js.map +1 -0
  106. package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js +277 -0
  107. package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +1 -0
  108. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +457 -0
  109. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +1 -0
  110. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +463 -0
  111. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +1 -0
  112. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +2191 -0
  113. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +1 -0
  114. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +10 -0
  115. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -0
  116. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +91 -0
  117. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +1 -0
  118. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js +325 -0
  119. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +1 -0
  120. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +14 -0
  121. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -0
  122. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +115 -0
  123. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -0
  124. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +401 -0
  125. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -0
  126. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
  127. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3756 -0
  128. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -0
  129. package/dist/presets/animation.d.ts +31 -0
  130. package/dist/presets/animation.js +39 -0
  131. package/dist/presets/animation.js.map +1 -0
  132. package/dist/presets/faceset.d.ts +30 -0
  133. package/dist/presets/faceset.js +51 -0
  134. package/dist/presets/faceset.js.map +1 -0
  135. package/dist/presets/icon.d.ts +20 -0
  136. package/dist/presets/icon.js +15 -0
  137. package/dist/presets/icon.js.map +1 -0
  138. package/dist/presets/index.d.ts +123 -0
  139. package/dist/presets/index.js +17 -0
  140. package/dist/presets/index.js.map +1 -0
  141. package/dist/presets/lpc.d.ts +89 -0
  142. package/dist/presets/lpc.js +98 -0
  143. package/dist/presets/lpc.js.map +1 -0
  144. package/dist/presets/rmspritesheet.js +42 -0
  145. package/dist/presets/rmspritesheet.js.map +1 -0
  146. package/dist/services/AbstractSocket.d.ts +9 -5
  147. package/dist/services/AbstractSocket.js +11 -0
  148. package/dist/services/AbstractSocket.js.map +1 -0
  149. package/dist/services/keyboardControls.d.ts +15 -0
  150. package/dist/services/keyboardControls.js +23 -0
  151. package/dist/services/keyboardControls.js.map +1 -0
  152. package/dist/services/loadMap.js +123 -0
  153. package/dist/services/loadMap.js.map +1 -0
  154. package/dist/services/mmorpg.d.ts +21 -9
  155. package/dist/services/mmorpg.js +131 -0
  156. package/dist/services/mmorpg.js.map +1 -0
  157. package/dist/services/save.d.ts +19 -0
  158. package/dist/services/save.js +77 -0
  159. package/dist/services/save.js.map +1 -0
  160. package/dist/services/standalone.d.ts +67 -7
  161. package/dist/services/standalone.js +168 -0
  162. package/dist/services/standalone.js.map +1 -0
  163. package/dist/utils/getEntityProp.d.ts +39 -0
  164. package/dist/utils/getEntityProp.js +52 -0
  165. package/dist/utils/getEntityProp.js.map +1 -0
  166. package/package.json +13 -9
  167. package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
  168. package/src/Game/Event.ts +1 -1
  169. package/src/Game/Map.ts +95 -3
  170. package/src/Game/Object.ts +330 -14
  171. package/src/Game/Player.ts +1 -1
  172. package/src/Gui/Gui.ts +506 -18
  173. package/src/Gui/NotificationManager.ts +69 -0
  174. package/src/Resource.ts +150 -0
  175. package/src/RpgClient.ts +246 -12
  176. package/src/RpgClientEngine.ts +1641 -62
  177. package/src/Sound.ts +253 -0
  178. package/src/components/{effects → animations}/animation.ce +3 -6
  179. package/src/components/{effects → animations}/index.ts +1 -1
  180. package/src/components/character.ce +387 -52
  181. package/src/components/dynamics/parse-value.ts +80 -0
  182. package/src/components/dynamics/text.ce +183 -0
  183. package/src/components/gui/box.ce +17 -0
  184. package/src/components/gui/dialogbox/index.ce +204 -187
  185. package/src/components/gui/gameover.ce +158 -0
  186. package/src/components/gui/hud/hud.ce +61 -0
  187. package/src/components/gui/index.ts +30 -4
  188. package/src/components/gui/menu/equip-menu.ce +410 -0
  189. package/src/components/gui/menu/exit-menu.ce +41 -0
  190. package/src/components/gui/menu/items-menu.ce +317 -0
  191. package/src/components/gui/menu/main-menu.ce +294 -0
  192. package/src/components/gui/menu/options-menu.ce +35 -0
  193. package/src/components/gui/menu/skills-menu.ce +83 -0
  194. package/src/components/gui/mobile/index.ts +24 -0
  195. package/src/components/gui/mobile/mobile.ce +80 -0
  196. package/src/components/gui/notification/notification.ce +51 -0
  197. package/src/components/gui/save-load.ce +208 -0
  198. package/src/components/gui/shop/shop.ce +493 -0
  199. package/src/components/gui/title-screen.ce +163 -0
  200. package/src/components/index.ts +3 -0
  201. package/src/components/prebuilt/hp-bar.ce +255 -0
  202. package/src/components/prebuilt/index.ts +24 -0
  203. package/src/components/prebuilt/light-halo.ce +148 -0
  204. package/src/components/scenes/canvas.ce +20 -15
  205. package/src/components/scenes/draw-map.ce +60 -13
  206. package/src/components/scenes/event-layer.ce +7 -0
  207. package/src/components/scenes/transition.ce +60 -0
  208. package/src/index.ts +16 -2
  209. package/src/module.ts +127 -9
  210. package/src/presets/animation.ts +46 -0
  211. package/src/presets/faceset.ts +60 -0
  212. package/src/presets/icon.ts +17 -0
  213. package/src/presets/index.ts +9 -1
  214. package/src/presets/lpc.ts +108 -0
  215. package/src/services/AbstractSocket.ts +10 -2
  216. package/src/services/keyboardControls.ts +20 -0
  217. package/src/services/loadMap.ts +1 -1
  218. package/src/services/mmorpg.ts +100 -12
  219. package/src/services/save.ts +103 -0
  220. package/src/services/standalone.ts +110 -18
  221. package/src/utils/getEntityProp.ts +87 -0
  222. package/vite.config.ts +4 -2
  223. package/dist/Game/EffectManager.d.ts +0 -5
  224. package/dist/components/effects/index.d.ts +0 -4
  225. package/dist/index.js.map +0 -1
  226. package/dist/index10.js +0 -8
  227. package/dist/index10.js.map +0 -1
  228. package/dist/index11.js +0 -10
  229. package/dist/index11.js.map +0 -1
  230. package/dist/index12.js +0 -8
  231. package/dist/index12.js.map +0 -1
  232. package/dist/index13.js +0 -17
  233. package/dist/index13.js.map +0 -1
  234. package/dist/index14.js +0 -107
  235. package/dist/index14.js.map +0 -1
  236. package/dist/index15.js +0 -50
  237. package/dist/index15.js.map +0 -1
  238. package/dist/index16.js +0 -191
  239. package/dist/index16.js.map +0 -1
  240. package/dist/index17.js +0 -9
  241. package/dist/index17.js.map +0 -1
  242. package/dist/index18.js +0 -387
  243. package/dist/index18.js.map +0 -1
  244. package/dist/index19.js +0 -31
  245. package/dist/index19.js.map +0 -1
  246. package/dist/index2.js +0 -181
  247. package/dist/index2.js.map +0 -1
  248. package/dist/index20.js +0 -24
  249. package/dist/index20.js.map +0 -1
  250. package/dist/index21.js +0 -2421
  251. package/dist/index21.js.map +0 -1
  252. package/dist/index22.js +0 -114
  253. package/dist/index22.js.map +0 -1
  254. package/dist/index23.js +0 -109
  255. package/dist/index23.js.map +0 -1
  256. package/dist/index24.js +0 -71
  257. package/dist/index24.js.map +0 -1
  258. package/dist/index25.js +0 -21
  259. package/dist/index25.js.map +0 -1
  260. package/dist/index26.js +0 -41
  261. package/dist/index26.js.map +0 -1
  262. package/dist/index27.js +0 -5
  263. package/dist/index27.js.map +0 -1
  264. package/dist/index28.js +0 -322
  265. package/dist/index28.js.map +0 -1
  266. package/dist/index29.js +0 -27
  267. package/dist/index29.js.map +0 -1
  268. package/dist/index3.js +0 -87
  269. package/dist/index3.js.map +0 -1
  270. package/dist/index30.js +0 -11
  271. package/dist/index30.js.map +0 -1
  272. package/dist/index31.js +0 -11
  273. package/dist/index31.js.map +0 -1
  274. package/dist/index32.js +0 -174
  275. package/dist/index32.js.map +0 -1
  276. package/dist/index33.js +0 -501
  277. package/dist/index33.js.map +0 -1
  278. package/dist/index34.js +0 -12
  279. package/dist/index34.js.map +0 -1
  280. package/dist/index35.js +0 -4403
  281. package/dist/index35.js.map +0 -1
  282. package/dist/index36.js +0 -316
  283. package/dist/index36.js.map +0 -1
  284. package/dist/index37.js +0 -61
  285. package/dist/index37.js.map +0 -1
  286. package/dist/index38.js +0 -20
  287. package/dist/index38.js.map +0 -1
  288. package/dist/index39.js +0 -20
  289. package/dist/index39.js.map +0 -1
  290. package/dist/index4.js +0 -67
  291. package/dist/index4.js.map +0 -1
  292. package/dist/index5.js +0 -16
  293. package/dist/index5.js.map +0 -1
  294. package/dist/index6.js +0 -17
  295. package/dist/index6.js.map +0 -1
  296. package/dist/index7.js +0 -39
  297. package/dist/index7.js.map +0 -1
  298. package/dist/index8.js +0 -108
  299. package/dist/index8.js.map +0 -1
  300. package/dist/index9.js +0 -76
  301. package/dist/index9.js.map +0 -1
  302. package/src/components/gui/dialogbox/itemMenu.ce +0 -23
  303. package/src/components/gui/dialogbox/selection.ce +0 -67
  304. /package/src/components/{effects → animations}/hit.ce +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RpgClientEngine.js","names":[],"sources":["../src/RpgClientEngine.ts"],"sourcesContent":["import Canvas from \"./components/scenes/canvas.ce\";\nimport { inject } from './core/inject'\nimport { signal, bootstrapCanvas, Howl, trigger } from \"canvasengine\";\nimport { AbstractWebsocket, WebSocketToken } from \"./services/AbstractSocket\";\nimport { LoadMapService, LoadMapToken } from \"./services/loadMap\";\nimport { RpgSound } from \"./Sound\";\nimport { RpgResource } from \"./Resource\";\nimport { Hooks, ModulesToken, Direction } from \"@rpgjs/common\";\nimport { load } from \"@signe/sync\";\nimport { RpgClientMap } from \"./Game/Map\"\nimport { RpgGui } from \"./Gui/Gui\";\nimport { AnimationManager } from \"./Game/AnimationManager\";\nimport { lastValueFrom, Observable, combineLatest, BehaviorSubject, filter, switchMap, take } from \"rxjs\";\nimport { GlobalConfigToken } from \"./module\";\nimport * as PIXI from \"pixi.js\";\nimport { PrebuiltComponentAnimations } from \"./components/animations\";\nimport {\n PredictionController,\n type PredictionHistoryEntry,\n type PredictionState,\n} from \"@rpgjs/common\";\nimport { NotificationManager } from \"./Gui/NotificationManager\";\nimport { SaveClientService } from \"./services/save\";\n\ninterface MovementTrajectoryPoint {\n frame: number;\n tick: number;\n timestamp: number;\n input: Direction;\n x: number;\n y: number;\n direction?: Direction;\n}\n\nexport class RpgClientEngine<T = any> {\n private guiService: RpgGui;\n private webSocket: AbstractWebsocket;\n private loadMapService: LoadMapService;\n private hooks: Hooks;\n private sceneMap: RpgClientMap\n private selector: HTMLElement;\n public globalConfig: T;\n public sceneComponent: any;\n stopProcessingInput = false;\n width = signal(\"100%\");\n height = signal(\"100%\");\n spritesheets: Map<string, any> = new Map();\n sounds: Map<string, any> = new Map();\n componentAnimations: any[] = [];\n private spritesheetResolver?: (id: string) => any | Promise<any>;\n private soundResolver?: (id: string) => any | Promise<any>;\n particleSettings: {\n emitters: any[]\n } = {\n emitters: []\n }\n renderer: PIXI.Renderer;\n tick: Observable<number>;\n private canvasApp?: any;\n private canvasElement?: any;\n playerIdSignal = signal<string | null>(null);\n spriteComponentsBehind = signal<any[]>([]);\n spriteComponentsInFront = signal<any[]>([]);\n /** ID of the sprite that the camera should follow. null means follow the current player */\n cameraFollowTargetId = signal<string | null>(null);\n /** Trigger for map shake animation */\n mapShakeTrigger = trigger();\n\n controlsReady = signal(undefined); \n gamePause = signal(false);\n\n private predictionEnabled = false;\n private prediction?: PredictionController<Direction>;\n private readonly SERVER_CORRECTION_THRESHOLD = 30;\n private inputFrameCounter = 0;\n private pendingPredictionFrames: number[] = [];\n private lastClientPhysicsStepAt = 0;\n private frameOffset = 0;\n // Ping/Pong for RTT measurement\n private rtt: number = 0; // Round-trip time in ms\n private pingInterval: any = null;\n private readonly PING_INTERVAL_MS = 5000; // Send ping every 5 seconds\n private lastInputTime = 0;\n private readonly MOVE_PATH_RESEND_INTERVAL_MS = 120;\n private readonly MAX_MOVE_TRAJECTORY_POINTS = 240;\n private lastMovePathSentAt = 0;\n private lastMovePathSentFrame = 0;\n // Track map loading state for onAfterLoading hook using RxJS\n private mapLoadCompleted$ = new BehaviorSubject<boolean>(false);\n private playerIdReceived$ = new BehaviorSubject<boolean>(false);\n private playersReceived$ = new BehaviorSubject<boolean>(false);\n private eventsReceived$ = new BehaviorSubject<boolean>(false);\n private onAfterLoadingSubscription?: any;\n private sceneResetQueued = false;\n \n // Store subscriptions and event listeners for cleanup\n private tickSubscriptions: any[] = [];\n private resizeHandler?: () => void;\n private notificationManager: NotificationManager = new NotificationManager();\n\n constructor(public context) {\n this.webSocket = inject(WebSocketToken);\n this.guiService = inject(RpgGui);\n this.loadMapService = inject(LoadMapToken);\n this.hooks = inject<Hooks>(ModulesToken);\n this.globalConfig = inject(GlobalConfigToken)\n\n if (!this.globalConfig) {\n this.globalConfig = {} as T\n }\n if (!(this.globalConfig as any).box) {\n (this.globalConfig as any).box = {\n styles: {\n backgroundColor: \"#1a1a2e\",\n backgroundOpacity: 0.9\n },\n sounds: {}\n }\n }\n\n this.addComponentAnimation({\n id: \"animation\",\n component: PrebuiltComponentAnimations.Animation\n })\n\n this.predictionEnabled = (this.globalConfig as any)?.prediction?.enabled !== false;\n this.initializePredictionController();\n }\n\n /**\n * Assigns a CanvasEngine KeyboardControls instance to the dependency injection context\n * \n * This method registers a KeyboardControls instance from CanvasEngine into the DI container,\n * making it available for injection throughout the application. The particularity is that\n * this method is automatically called when a sprite is displayed on the map, allowing the\n * controls to be automatically associated with the active sprite.\n * \n * ## Design\n * \n * - The instance is stored in the DI context under the `KeyboardControls` token\n * - It's automatically assigned when a sprite component mounts (in `character.ce`)\n * - The controls instance comes from the CanvasEngine component's directives\n * - Once registered, it can be retrieved using `inject(KeyboardControls)` from anywhere\n * \n * @param controlInstance - The CanvasEngine KeyboardControls instance to register\n * \n * @example\n * ```ts\n * // The method is automatically called when a sprite is displayed:\n * // client.setKeyboardControls(element.directives.controls)\n * \n * // Later, retrieve and use the controls instance:\n * import { Input, inject, KeyboardControls } from '@rpgjs/client'\n * \n * const controls = inject(KeyboardControls)\n * const control = controls.getControl(Input.Enter)\n * \n * if (control) {\n * console.log(control.actionName) // 'action'\n * }\n * ```\n */\n setKeyboardControls(controlInstance: any) {\n const currentValues = this.context.values['inject:' + 'KeyboardControls']\n this.context.values['inject:' + 'KeyboardControls'] = {\n ...currentValues,\n values: new Map([['__default__', controlInstance]])\n }\n this.controlsReady.set(undefined);\n }\n\n async start() {\n this.sceneMap = new RpgClientMap()\n this.sceneMap.configureClientPrediction(this.predictionEnabled);\n this.sceneMap.loadPhysic();\n this.selector = document.body.querySelector(\"#rpg\") as HTMLElement;\n\n const bootstrapOptions = (this.globalConfig as any)?.bootstrapCanvasOptions;\n const { app, canvasElement } = await bootstrapCanvas(\n this.selector,\n Canvas,\n bootstrapOptions\n );\n this.canvasApp = app;\n this.canvasElement = canvasElement;\n this.renderer = app.renderer as PIXI.Renderer;\n this.tick = canvasElement?.propObservables?.context['tick'].observable\n\n const inputCheckSubscription = this.tick.subscribe(() => {\n if (Date.now() - this.lastInputTime > 100) {\n const player = this.getCurrentPlayer();\n if (!player) return;\n (this.sceneMap as any).stopMovement(player);\n }\n });\n this.tickSubscriptions.push(inputCheckSubscription);\n\n\n this.hooks.callHooks(\"client-spritesheets-load\", this).subscribe();\n this.hooks.callHooks(\"client-spritesheetResolver-load\", this).subscribe();\n this.hooks.callHooks(\"client-sounds-load\", this).subscribe();\n this.hooks.callHooks(\"client-soundResolver-load\", this).subscribe();\n \n RpgSound.init(this);\n RpgResource.init(this);\n this.hooks.callHooks(\"client-gui-load\", this).subscribe();\n this.hooks.callHooks(\"client-particles-load\", this).subscribe();\n this.hooks.callHooks(\"client-componentAnimations-load\", this).subscribe();\n this.hooks.callHooks(\"client-sprite-load\", this).subscribe();\n\n await lastValueFrom(this.hooks.callHooks(\"client-engine-onStart\", this));\n\n // wondow is resize\n this.resizeHandler = () => {\n this.hooks.callHooks(\"client-engine-onWindowResize\", this).subscribe();\n };\n window.addEventListener('resize', this.resizeHandler);\n\n const tickSubscription = this.tick.subscribe((tick) => {\n this.stepClientPhysicsTick();\n this.flushPendingPredictedStates();\n this.flushPendingMovePath();\n this.hooks.callHooks(\"client-engine-onStep\", this, tick).subscribe();\n\n // Clean up old prediction states and input history every 60 ticks (approximately every second at 60fps)\n if (tick % 60 === 0) {\n const now = Date.now();\n this.prediction?.cleanup(now);\n this.prediction?.tryApplyPendingSnapshot();\n }\n });\n this.tickSubscriptions.push(tickSubscription);\n\n await this.webSocket.connection(() => {\n const saveClient = inject(SaveClientService);\n saveClient.initialize(this.webSocket);\n this.initListeners()\n this.guiService._initialize()\n this.startPingPong();\n });\n }\n\n private prepareSyncPayload(data: any): any {\n const payload = { ...(data ?? {}) };\n delete payload.ack;\n delete payload.timestamp;\n\n const myId = this.playerIdSignal();\n const players = payload.players;\n const shouldMaskLocalPosition =\n this.predictionEnabled && !!this.prediction?.hasPendingInputs();\n if (shouldMaskLocalPosition && myId && players && players[myId]) {\n const localPatch = { ...players[myId] };\n delete localPatch.x;\n delete localPatch.y;\n delete localPatch.direction;\n delete localPatch._frames;\n payload.players = {\n ...players,\n [myId]: localPatch,\n };\n }\n\n return payload;\n }\n\n private normalizeAckWithSyncState(\n ack: { frame: number; serverTick?: number; x?: number; y?: number; direction?: Direction },\n syncData: any,\n ): { frame: number; serverTick?: number; x?: number; y?: number; direction?: Direction } {\n const myId = this.playerIdSignal();\n if (!myId) {\n return ack;\n }\n\n const localPatch = syncData?.players?.[myId];\n if (typeof localPatch?.x !== \"number\" || typeof localPatch?.y !== \"number\") {\n return ack;\n }\n\n return {\n ...ack,\n x: localPatch.x,\n y: localPatch.y,\n direction: localPatch.direction ?? ack.direction,\n };\n }\n\n private initListeners() {\n this.webSocket.on(\"sync\", (data) => {\n if (data.pId) {\n this.playerIdSignal.set(data.pId);\n // Signal that player ID was received\n this.playerIdReceived$.next(true);\n }\n\n if (this.sceneResetQueued) {\n this.sceneMap.reset();\n this.sceneMap.loadPhysic();\n this.sceneResetQueued = false;\n }\n\n // Apply client-side prediction filtering and server reconciliation\n this.hooks.callHooks(\"client-sceneMap-onChanges\", this.sceneMap, { partial: data }).subscribe();\n\n const ack = data?.ack;\n const normalizedAck =\n ack && typeof ack.frame === \"number\"\n ? this.normalizeAckWithSyncState(ack, data)\n : undefined;\n const payload = this.prepareSyncPayload(data);\n load(this.sceneMap, payload, true);\n\n if (normalizedAck) {\n this.applyServerAck(normalizedAck);\n }\n\n for (const playerId in payload.players ?? {}) {\n const player = payload.players[playerId]\n if (!player._param) continue\n for (const param in player._param) {\n this.sceneMap.players()[playerId]._param()[param] = player._param[param]\n }\n }\n \n // Check if players and events are present in sync data\n const players = payload.players || this.sceneMap.players();\n if (players && Object.keys(players).length > 0) {\n this.playersReceived$.next(true);\n }\n \n const events = payload.events || this.sceneMap.events();\n if (events !== undefined) {\n this.eventsReceived$.next(true);\n }\n });\n\n // Handle pong responses for RTT measurement\n this.webSocket.on(\"pong\", (data: { serverTick: number; clientFrame: number; clientTime: number }) => {\n const now = Date.now();\n this.rtt = now - data.clientTime;\n\n // Calculate frame offset: how many ticks ahead the server is compared to our frame counter\n // This helps us estimate which server tick corresponds to each client input frame\n const estimatedTicksInFlight = Math.floor(this.rtt / 2 / (1000 / 60)); // Estimate ticks during half RTT\n const estimatedServerTickNow = data.serverTick + estimatedTicksInFlight;\n\n // Update frame offset (only if we have inputs to calibrate with)\n if (this.inputFrameCounter > 0) {\n this.frameOffset = estimatedServerTickNow - data.clientFrame;\n }\n\n console.debug(`[Ping/Pong] RTT: ${this.rtt}ms, ServerTick: ${data.serverTick}, FrameOffset: ${this.frameOffset}`);\n });\n\n this.webSocket.on(\"changeMap\", (data) => {\n this.sceneResetQueued = true;\n // Reset camera follow to default (follow current player) when changing maps\n this.cameraFollowTargetId.set(null);\n const transferToken = typeof data?.transferToken === \"string\" ? data.transferToken : undefined;\n this.loadScene(data.mapId, transferToken);\n });\n\n this.webSocket.on(\"showComponentAnimation\", (data) => {\n const { params, object, position, id } = data;\n if (!object && position === undefined) {\n throw new Error(\"Please provide an object or x and y coordinates\");\n }\n const player = object ? this.sceneMap.getObjectById(object) : undefined;\n this.getComponentAnimation(id).displayEffect(params, player || position)\n });\n\n this.webSocket.on(\"notification\", (data) => {\n this.notificationManager.add(data);\n });\n\n this.webSocket.on(\"setAnimation\", (data) => { \n const { animationName, nbTimes, object, graphic } = data;\n const player = this.sceneMap.getObjectById(object);\n if (graphic !== undefined) {\n player.setAnimation(animationName, graphic, nbTimes);\n } else {\n player.setAnimation(animationName, nbTimes);\n }\n })\n\n this.webSocket.on(\"playSound\", (data) => {\n const { soundId, volume, loop } = data;\n this.playSound(soundId, { volume, loop });\n });\n\n this.webSocket.on(\"stopSound\", (data) => {\n const { soundId } = data;\n this.stopSound(soundId);\n });\n\n this.webSocket.on(\"stopAllSounds\", () => {\n this.stopAllSounds();\n });\n\n this.webSocket.on(\"cameraFollow\", (data) => {\n const { targetId, smoothMove } = data;\n this.setCameraFollow(targetId, smoothMove);\n });\n\n this.webSocket.on(\"flash\", (data) => {\n const { object, type, duration, cycles, alpha, tint } = data;\n const sprite = object ? this.sceneMap.getObjectById(object) : undefined;\n if (sprite && typeof sprite.flash === 'function') {\n sprite.flash({ type, duration, cycles, alpha, tint });\n }\n });\n\n this.webSocket.on(\"shakeMap\", (data) => {\n const { intensity, duration, frequency, direction } = data || {};\n (this.mapShakeTrigger as any).start({\n intensity,\n duration,\n frequency,\n direction\n });\n });\n\n this.webSocket.on(\"weatherState\", (data) => {\n const raw = (data && typeof data === \"object\" && \"value\" in data)\n ? (data as any).value\n : data;\n\n if (raw === null) {\n this.sceneMap.weatherState.set(null);\n return;\n }\n\n const validEffects = [\"rain\", \"snow\", \"fog\", \"cloud\"];\n if (!raw || !validEffects.includes((raw as any).effect)) {\n return;\n }\n\n this.sceneMap.weatherState.set({\n effect: (raw as any).effect,\n preset: (raw as any).preset,\n params: (raw as any).params,\n transitionMs: (raw as any).transitionMs,\n durationMs: (raw as any).durationMs,\n startedAt: (raw as any).startedAt,\n seed: (raw as any).seed,\n });\n });\n\n this.webSocket.on('open', () => {\n this.hooks.callHooks(\"client-engine-onConnected\", this, this.socket).subscribe();\n // Start ping/pong for synchronization\n this.startPingPong();\n })\n\n this.webSocket.on('close', () => {\n this.hooks.callHooks(\"client-engine-onDisconnected\", this, this.socket).subscribe();\n // Stop ping/pong when disconnected\n this.stopPingPong();\n })\n\n this.webSocket.on('error', (error) => {\n this.hooks.callHooks(\"client-engine-onConnectError\", this, error, this.socket).subscribe();\n })\n }\n\n /**\n * Start periodic ping/pong for client-server synchronization\n * \n * Sends ping requests to the server to measure round-trip time (RTT) and\n * calculate the frame offset between client and server ticks.\n * \n * ## Design\n * \n * - Sends ping every 5 seconds\n * - Measures RTT for latency compensation\n * - Calculates frame offset to map client frames to server ticks\n * - Used for accurate server reconciliation\n * \n * @example\n * ```ts\n * // Called automatically when connection opens\n * this.startPingPong();\n * ```\n */\n private startPingPong(): void {\n // Stop existing interval if any\n this.stopPingPong();\n\n // Send initial ping immediately\n this.sendPing();\n\n // Set up periodic pings\n this.pingInterval = setInterval(() => {\n this.sendPing();\n }, this.PING_INTERVAL_MS);\n }\n\n /**\n * Stop periodic ping/pong\n * \n * Stops the ping interval when disconnecting or changing maps.\n * \n * @example\n * ```ts\n * // Called automatically when connection closes\n * this.stopPingPong();\n * ```\n */\n private stopPingPong(): void {\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n }\n\n /**\n * Send a ping request to the server\n * \n * Sends current client time and frame counter to the server,\n * which will respond with its server tick for synchronization.\n * \n * @example\n * ```ts\n * // Send a ping to measure RTT\n * this.sendPing();\n * ```\n */\n private sendPing(): void {\n const clientTime = Date.now();\n const clientFrame = this.getPhysicsTick();\n\n this.webSocket.emit('ping', {\n clientTime,\n clientFrame\n });\n }\n\n private async loadScene(mapId: string, transferToken?: string) {\n await lastValueFrom(this.hooks.callHooks(\"client-sceneMap-onBeforeLoading\", this.sceneMap));\n\n // Clear client prediction states when changing maps\n this.clearClientPredictionStates();\n\n // Reset all conditions for new map loading\n this.mapLoadCompleted$.next(false);\n this.playerIdReceived$.next(false);\n this.playersReceived$.next(false);\n this.eventsReceived$.next(false);\n\n // Unsubscribe previous subscription if exists\n if (this.onAfterLoadingSubscription) {\n this.onAfterLoadingSubscription.unsubscribe();\n }\n\n // Setup RxJS observable to wait for all conditions\n this.setupOnAfterLoadingObserver();\n\n this.webSocket.updateProperties({\n room: mapId,\n query: transferToken ? { transferToken } : undefined,\n })\n await this.webSocket.reconnect(() => {\n const saveClient = inject(SaveClientService);\n saveClient.initialize(this.webSocket);\n this.initListeners()\n this.guiService._initialize()\n })\n const res = await this.loadMapService.load(mapId)\n this.sceneMap.data.set(res)\n \n // Check if playerId is already present\n if (this.playerIdSignal()) {\n this.playerIdReceived$.next(true);\n }\n \n // Check if players and events are already present in sceneMap\n const players = this.sceneMap.players();\n if (players && Object.keys(players).length > 0) {\n this.playersReceived$.next(true);\n }\n \n const events = this.sceneMap.events();\n if (events !== undefined) {\n this.eventsReceived$.next(true);\n }\n \n // Signal that map loading is completed (this should be last to ensure other checks are done)\n this.mapLoadCompleted$.next(true);\n this.sceneMap.configureClientPrediction(this.predictionEnabled);\n this.sceneMap.loadPhysic()\n }\n\n addSpriteSheet<T = any>(spritesheetClass: any, id?: string): any {\n this.spritesheets.set(id || spritesheetClass.id, spritesheetClass);\n return spritesheetClass as any;\n }\n\n /**\n * Set a resolver function for spritesheets\n * \n * The resolver is called when a spritesheet is requested but not found in the cache.\n * It can be synchronous (returns directly) or asynchronous (returns a Promise).\n * The resolved spritesheet is automatically cached for future use.\n * \n * @param resolver - Function that takes a spritesheet ID and returns a spritesheet or Promise of spritesheet\n * \n * @example\n * ```ts\n * // Synchronous resolver\n * engine.setSpritesheetResolver((id) => {\n * if (id === 'dynamic-sprite') {\n * return { id: 'dynamic-sprite', image: 'path/to/image.png', framesWidth: 32, framesHeight: 32 };\n * }\n * return undefined;\n * });\n * \n * // Asynchronous resolver (loading from API)\n * engine.setSpritesheetResolver(async (id) => {\n * const response = await fetch(`/api/spritesheets/${id}`);\n * const data = await response.json();\n * return data;\n * });\n * ```\n */\n setSpritesheetResolver(resolver: (id: string) => any | Promise<any>): void {\n this.spritesheetResolver = resolver;\n }\n\n /**\n * Get a spritesheet by ID, using resolver if not found in cache\n * \n * This method first checks if the spritesheet exists in the cache.\n * If not found and a resolver is set, it calls the resolver to create the spritesheet.\n * The resolved spritesheet is automatically cached for future use.\n * \n * @param id - The spritesheet ID to retrieve\n * @returns The spritesheet if found or created, or undefined if not found and no resolver\n * @returns Promise<any> if the resolver is asynchronous\n * \n * @example\n * ```ts\n * // Synchronous usage\n * const spritesheet = engine.getSpriteSheet('my-sprite');\n * \n * // Asynchronous usage (when resolver returns Promise)\n * const spritesheet = await engine.getSpriteSheet('dynamic-sprite');\n * ```\n */\n getSpriteSheet(id: string): any | Promise<any> {\n // Check cache first\n if (this.spritesheets.has(id)) {\n return this.spritesheets.get(id);\n }\n\n // If not in cache and resolver exists, use it\n if (this.spritesheetResolver) {\n const result = this.spritesheetResolver(id);\n\n // Check if result is a Promise\n if (result instanceof Promise) {\n return result.then((spritesheet) => {\n if (spritesheet) {\n // Cache the resolved spritesheet\n this.spritesheets.set(id, spritesheet);\n }\n return spritesheet;\n });\n } else {\n // Synchronous result\n if (result) {\n // Cache the resolved spritesheet\n this.spritesheets.set(id, result);\n }\n return result;\n }\n }\n\n // No resolver and not in cache\n return undefined;\n }\n\n /**\n * Add a sound to the engine\n * \n * Adds a sound to the engine's sound cache. The sound can be:\n * - A simple object with `id` and `src` properties\n * - A Howler instance\n * - An object with a `play()` method\n * \n * If the sound has a `src` property, a Howler instance will be created automatically.\n * \n * @param sound - The sound object or Howler instance\n * @param id - Optional sound ID (if not provided, uses sound.id)\n * @returns The added sound\n * \n * @example\n * ```ts\n * // Simple sound object\n * engine.addSound({ id: 'click', src: 'click.mp3' });\n * \n * // With explicit ID\n * engine.addSound({ src: 'music.mp3' }, 'background-music');\n * ```\n */\n addSound(sound: any, id?: string): any {\n const soundId = id || sound.id;\n \n if (!soundId) {\n console.warn('Sound added without an ID. It will not be retrievable.');\n return sound;\n }\n\n // If sound has a src property, create a Howler instance\n if (sound.src && typeof sound.src === 'string') {\n const howlOptions: any = {\n src: [sound.src],\n loop: sound.loop || false,\n volume: sound.volume !== undefined ? sound.volume : 1.0,\n };\n\n const howl = new (Howl as any).Howl(howlOptions);\n this.sounds.set(soundId, howl);\n return howl;\n }\n\n // If sound already has a play method (Howler instance or custom), use it directly\n if (sound && typeof sound.play === 'function') {\n this.sounds.set(soundId, sound);\n return sound;\n }\n\n // Otherwise, store as-is\n this.sounds.set(soundId, sound);\n return sound;\n }\n\n /**\n * Set a resolver function for sounds\n * \n * The resolver is called when a sound is requested but not found in the cache.\n * It can be synchronous (returns directly) or asynchronous (returns a Promise).\n * The resolved sound is automatically cached for future use.\n * \n * @param resolver - Function that takes a sound ID and returns a sound or Promise of sound\n * \n * @example\n * ```ts\n * // Synchronous resolver\n * engine.setSoundResolver((id) => {\n * if (id === 'dynamic-sound') {\n * return { id: 'dynamic-sound', src: 'path/to/sound.mp3' };\n * }\n * return undefined;\n * });\n * \n * // Asynchronous resolver (loading from API)\n * engine.setSoundResolver(async (id) => {\n * const response = await fetch(`/api/sounds/${id}`);\n * const data = await response.json();\n * return data;\n * });\n * ```\n */\n setSoundResolver(resolver: (id: string) => any | Promise<any>): void {\n this.soundResolver = resolver;\n }\n\n /**\n * Get a sound by ID, using resolver if not found in cache\n * \n * This method first checks if the sound exists in the cache.\n * If not found and a resolver is set, it calls the resolver to create the sound.\n * The resolved sound is automatically cached for future use.\n * \n * @param id - The sound ID to retrieve\n * @returns The sound if found or created, or undefined if not found and no resolver\n * @returns Promise<any> if the resolver is asynchronous\n * \n * @example\n * ```ts\n * // Synchronous usage\n * const sound = engine.getSound('my-sound');\n * \n * // Asynchronous usage (when resolver returns Promise)\n * const sound = await engine.getSound('dynamic-sound');\n * ```\n */\n getSound(id: string): any | Promise<any> {\n // Check cache first\n if (this.sounds.has(id)) {\n return this.sounds.get(id);\n }\n\n // If not in cache and resolver exists, use it\n if (this.soundResolver) {\n const result = this.soundResolver(id);\n\n // Check if result is a Promise\n if (result instanceof Promise) {\n return result.then((sound) => {\n if (sound) {\n // Cache the resolved sound\n this.sounds.set(id, sound);\n }\n return sound;\n });\n } else {\n // Synchronous result\n if (result) {\n // Cache the resolved sound\n this.sounds.set(id, result);\n }\n return result;\n }\n }\n\n // No resolver and not in cache\n return undefined;\n }\n\n /**\n * Play a sound by its ID\n * \n * This method retrieves a sound from the cache or resolver and plays it.\n * If the sound is not found, it will attempt to resolve it using the soundResolver.\n * Uses Howler.js for audio playback instead of native Audio elements.\n * \n * @param soundId - The sound ID to play\n * @param options - Optional sound configuration\n * @param options.volume - Volume level (0.0 to 1.0, overrides sound default)\n * @param options.loop - Whether the sound should loop (overrides sound default)\n * \n * @example\n * ```ts\n * // Play a sound synchronously\n * engine.playSound('item-pickup');\n * \n * // Play a sound with volume and loop\n * engine.playSound('background-music', { volume: 0.5, loop: true });\n * \n * // Play a sound asynchronously (when resolver returns Promise)\n * await engine.playSound('dynamic-sound', { volume: 0.8 });\n * ```\n */\n async playSound(soundId: string, options?: { volume?: number; loop?: boolean }): Promise<void> {\n const sound = await this.getSound(soundId);\n if (sound && sound.play) {\n // Sound is already a Howler instance or has a play method\n const howlSoundId = sound._sounds?.[0]?._id;\n \n // Apply volume if provided\n if (options?.volume !== undefined) {\n if (howlSoundId !== undefined) {\n sound.volume(Math.max(0, Math.min(1, options.volume)), howlSoundId);\n } else {\n sound.volume(Math.max(0, Math.min(1, options.volume)));\n }\n }\n \n // Apply loop if provided\n if (options?.loop !== undefined) {\n if (howlSoundId !== undefined) {\n sound.loop(options.loop, howlSoundId);\n } else {\n sound.loop(options.loop);\n }\n }\n \n if (howlSoundId !== undefined) {\n sound.play(howlSoundId);\n } else {\n sound.play();\n }\n } else if (sound && sound.src) {\n // If sound is just a source URL, create a Howler instance and cache it\n const howlOptions: any = {\n src: [sound.src],\n loop: options?.loop !== undefined ? options.loop : (sound.loop || false),\n volume: options?.volume !== undefined ? Math.max(0, Math.min(1, options.volume)) : (sound.volume !== undefined ? sound.volume : 1.0),\n };\n\n const howl = new (Howl as any).Howl(howlOptions);\n \n // Cache the Howler instance for future use\n this.sounds.set(soundId, howl);\n \n // Play the sound\n howl.play();\n } else {\n console.warn(`Sound with id \"${soundId}\" not found or cannot be played`);\n }\n }\n\n /**\n * Stop a sound that is currently playing\n * \n * This method stops a sound that was previously started with `playSound()`.\n * \n * @param soundId - The sound ID to stop\n * \n * @example\n * ```ts\n * // Start a looping sound\n * engine.playSound('background-music', { loop: true });\n * \n * // Later, stop it\n * engine.stopSound('background-music');\n * ```\n */\n stopSound(soundId: string): void {\n const sound = this.sounds.get(soundId);\n if (sound && sound.stop) {\n sound.stop();\n } else {\n console.warn(`Sound with id \"${soundId}\" not found or cannot be stopped`);\n }\n }\n\n /**\n * Stop all currently playing sounds\n * \n * This method stops all sounds that are currently playing.\n * Useful when changing maps to prevent sound overlap.\n * \n * @example\n * ```ts\n * // Stop all sounds\n * engine.stopAllSounds();\n * ```\n */\n stopAllSounds(): void {\n this.sounds.forEach((sound) => {\n if (sound && sound.stop) {\n sound.stop();\n }\n });\n }\n\n /**\n * Set the camera to follow a specific sprite\n * \n * This method changes which sprite the camera viewport should follow.\n * The camera will smoothly animate to the target sprite if smoothMove options are provided.\n * \n * ## Design\n * \n * The camera follow target is stored in a signal that is read by sprite components.\n * Each sprite checks if it should be followed by comparing its ID with the target ID.\n * When smoothMove options are provided, the viewport animation is handled by CanvasEngine's\n * viewport system.\n * \n * @param targetId - The ID of the sprite to follow. Set to null to follow the current player\n * @param smoothMove - Animation options. Can be a boolean (default: true) or an object with time and ease\n * @param smoothMove.time - Duration of the animation in milliseconds (optional)\n * @param smoothMove.ease - Easing function name from https://easings.net (optional)\n * \n * @example\n * ```ts\n * // Follow another player with default smooth animation\n * engine.setCameraFollow(otherPlayerId, true);\n * \n * // Follow an event with custom smooth animation\n * engine.setCameraFollow(eventId, {\n * time: 1000,\n * ease: \"easeInOutQuad\"\n * });\n * \n * // Follow without animation (instant)\n * engine.setCameraFollow(targetId, false);\n * \n * // Return to following current player\n * engine.setCameraFollow(null);\n * ```\n */\n setCameraFollow(\n targetId: string | null,\n smoothMove?: boolean | { time?: number; ease?: string }\n ): void {\n // Store smoothMove options for potential future use with viewport animation\n // For now, we just set the target ID and let CanvasEngine handle the viewport follow\n // The smoothMove options could be used to configure viewport animation if CanvasEngine supports it\n this.cameraFollowTargetId.set(targetId);\n \n // If smoothMove is an object, we could store it for viewport configuration\n // This would require integration with CanvasEngine's viewport animation system\n if (typeof smoothMove === \"object\" && smoothMove !== null) {\n // Future: Apply smoothMove.time and smoothMove.ease to viewport animation\n // For now, CanvasEngine handles viewport following automatically\n }\n }\n\n addParticle(particle: any) {\n this.particleSettings.emitters.push(particle)\n return particle;\n }\n\n /**\n * Add a component to render behind sprites\n * Components added with this method will be displayed with a lower z-index than the sprite\n * \n * Supports multiple formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...} }`\n * 3. With dynamic props: `{ component: LightHalo, props: (object) => {...} }`\n * 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`\n * \n * Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).\n * The object (sprite) is passed to the dependencies function to allow sprite-specific dependency resolution.\n * \n * @param component - The component to add behind sprites, or a configuration object\n * @param component.component - The component function to render\n * @param component.props - Static props object or function that receives the sprite object and returns props\n * @param component.dependencies - Function that receives the sprite object and returns an array of Signals\n * @returns The added component or configuration\n * \n * @example\n * ```ts\n * // Add a shadow component behind all sprites\n * engine.addSpriteComponentBehind(ShadowComponent);\n * \n * // Add a component with static props\n * engine.addSpriteComponentBehind({ \n * component: LightHalo, \n * props: { radius: 30 } \n * });\n * \n * // Add a component with dynamic props and dependencies\n * engine.addSpriteComponentBehind({ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * });\n * ```\n */\n addSpriteComponentBehind(component: any) {\n this.spriteComponentsBehind.update((components: any[]) => [...components, component])\n return component\n }\n\n /**\n * Add a component to render in front of sprites\n * Components added with this method will be displayed with a higher z-index than the sprite\n * \n * Supports multiple formats:\n * 1. Direct component: `HealthBarComponent`\n * 2. Configuration object: `{ component: StatusIndicator, props: {...} }`\n * 3. With dynamic props: `{ component: HealthBar, props: (object) => {...} }`\n * 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`\n * \n * Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).\n * The object (sprite) is passed to the dependencies function to allow sprite-specific dependency resolution.\n * \n * @param component - The component to add in front of sprites, or a configuration object\n * @param component.component - The component function to render\n * @param component.props - Static props object or function that receives the sprite object and returns props\n * @param component.dependencies - Function that receives the sprite object and returns an array of Signals\n * @returns The added component or configuration\n * \n * @example\n * ```ts\n * // Add a health bar component in front of all sprites\n * engine.addSpriteComponentInFront(HealthBarComponent);\n * \n * // Add a component with static props\n * engine.addSpriteComponentInFront({ \n * component: StatusIndicator, \n * props: { type: 'poison' } \n * });\n * \n * // Add a component with dynamic props and dependencies\n * engine.addSpriteComponentInFront({ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * });\n * ```\n */\n addSpriteComponentInFront(component: any | { component: any, props: (object: any) => any, dependencies?: (object: any) => any[] }) {\n this.spriteComponentsInFront.update((components: any[]) => [...components, component])\n return component\n }\n\n /**\n * Add a component animation to the engine\n * \n * Component animations are temporary visual effects that can be displayed\n * on sprites or objects, such as hit indicators, spell effects, or status animations.\n * \n * @param componentAnimation - The component animation configuration\n * @param componentAnimation.id - Unique identifier for the animation\n * @param componentAnimation.component - The component function to render\n * @returns The added component animation configuration\n * \n * @example\n * ```ts\n * // Add a hit animation component\n * engine.addComponentAnimation({\n * id: 'hit',\n * component: HitComponent\n * });\n * \n * // Add an explosion effect component\n * engine.addComponentAnimation({\n * id: 'explosion',\n * component: ExplosionComponent\n * });\n * ```\n */\n addComponentAnimation(componentAnimation: {\n component: any,\n id: string\n }) {\n const instance = new AnimationManager()\n this.componentAnimations.push({\n id: componentAnimation.id,\n component: componentAnimation.component,\n instance: instance,\n current: instance.current\n })\n return componentAnimation;\n }\n\n /**\n * Get a component animation by its ID\n * \n * Retrieves the EffectManager instance for a specific component animation,\n * which can be used to display the animation on sprites or objects.\n * \n * @param id - The unique identifier of the component animation\n * @returns The EffectManager instance for the animation\n * @throws Error if the component animation is not found\n * \n * @example\n * ```ts\n * // Get the hit animation and display it\n * const hitAnimation = engine.getComponentAnimation('hit');\n * hitAnimation.displayEffect({ text: \"Critical!\" }, player);\n * ```\n */\n getComponentAnimation(id: string): AnimationManager {\n const componentAnimation = this.componentAnimations.find((componentAnimation) => componentAnimation.id === id)\n if (!componentAnimation) {\n throw new Error(`Component animation with id ${id} not found`)\n }\n return componentAnimation.instance\n }\n\n /**\n * Start a transition\n * \n * Convenience method to display a transition by its ID using the GUI system.\n * \n * @param id - The unique identifier of the transition to start\n * @param props - Props to pass to the transition component\n * \n * @example\n * ```ts\n * // Start a fade transition\n * engine.startTransition('fade', { duration: 1000, color: 'black' });\n * \n * // Start with onFinish callback\n * engine.startTransition('fade', {\n * duration: 1000,\n * onFinish: () => console.log('Fade complete')\n * });\n * ```\n */\n startTransition(id: string, props: any = {}) {\n if (!this.guiService.exists(id)) {\n throw new Error(`Transition with id ${id} not found. Make sure to add it using engine.addTransition() or in your module's transitions property.`);\n }\n this.guiService.display(id, props);\n }\n\n async processInput({ input }: { input: Direction }) {\n const timestamp = Date.now();\n let frame: number;\n let tick: number;\n if (this.predictionEnabled && this.prediction) {\n const meta = this.prediction.recordInput(input, timestamp);\n frame = meta.frame;\n tick = meta.tick;\n } else {\n frame = ++this.inputFrameCounter;\n tick = this.getPhysicsTick();\n }\n this.inputFrameCounter = frame;\n this.hooks.callHooks(\"client-engine-onInput\", this, { input, playerId: this.playerId }).subscribe();\n\n const currentPlayer = this.sceneMap.getCurrentPlayer();\n const bodyReady = this.ensureCurrentPlayerBody();\n if (currentPlayer && bodyReady) {\n currentPlayer.changeDirection(input);\n (this.sceneMap as any).moveBody(currentPlayer, input);\n if (this.predictionEnabled && this.prediction) {\n this.pendingPredictionFrames.push(frame);\n if (this.pendingPredictionFrames.length > 240) {\n this.pendingPredictionFrames = this.pendingPredictionFrames.slice(-240);\n }\n }\n }\n\n this.emitMovePacket(input, frame, tick, timestamp, true);\n this.lastInputTime = Date.now();\n }\n\n processAction({ action }: { action: number }) {\n if (this.stopProcessingInput) return;\n this.hooks.callHooks(\"client-engine-onInput\", this, { input: 'action', playerId: this.playerId }).subscribe();\n this.webSocket.emit('action', { action })\n }\n\n get PIXI() {\n return PIXI\n }\n\n get socket() {\n return this.webSocket\n }\n\n get playerId() {\n return this.playerIdSignal()\n }\n\n get scene() {\n return this.sceneMap\n }\n\n private getPhysicsTick(): number {\n return this.sceneMap?.getTick?.() ?? 0;\n }\n\n private ensureCurrentPlayerBody(): boolean {\n const player = this.sceneMap?.getCurrentPlayer();\n const myId = this.playerIdSignal();\n if (!player || !myId) {\n return false;\n }\n if (!player.id) {\n player.id = myId;\n }\n if (this.sceneMap.getBody(myId)) {\n return true;\n }\n try {\n this.sceneMap.loadPhysic();\n } catch (error) {\n console.error(\"[RPGJS] Unable to initialize client physics before input:\", error);\n return false;\n }\n return !!this.sceneMap.getBody(myId);\n }\n\n private stepClientPhysicsTick(): void {\n if (!this.predictionEnabled || !this.sceneMap) {\n return;\n }\n const now = Date.now();\n if (this.lastClientPhysicsStepAt === 0) {\n this.lastClientPhysicsStepAt = now;\n }\n const deltaMs = Math.max(1, Math.min(100, now - this.lastClientPhysicsStepAt));\n this.lastClientPhysicsStepAt = now;\n this.sceneMap.stepClientPhysics(deltaMs);\n }\n\n private flushPendingPredictedStates(): void {\n if (!this.predictionEnabled || !this.prediction || this.pendingPredictionFrames.length === 0) {\n return;\n }\n const state = this.getLocalPlayerState();\n while (this.pendingPredictionFrames.length > 0) {\n const frame = this.pendingPredictionFrames.shift();\n if (typeof frame === \"number\") {\n this.prediction.attachPredictedState(frame, state);\n }\n }\n }\n\n private buildPendingMoveTrajectory(): MovementTrajectoryPoint[] {\n if (!this.predictionEnabled || !this.prediction) {\n return [];\n }\n const pendingInputs = this.prediction.getPendingInputs();\n const trajectory: MovementTrajectoryPoint[] = [];\n for (const entry of pendingInputs) {\n const state = entry.state;\n if (!state) continue;\n if (typeof state.x !== \"number\" || typeof state.y !== \"number\") continue;\n trajectory.push({\n frame: entry.frame,\n tick: entry.tick,\n timestamp: entry.timestamp,\n input: entry.direction,\n x: state.x,\n y: state.y,\n direction: state.direction ?? entry.direction,\n });\n }\n if (trajectory.length > this.MAX_MOVE_TRAJECTORY_POINTS) {\n return trajectory.slice(-this.MAX_MOVE_TRAJECTORY_POINTS);\n }\n return trajectory;\n }\n\n private emitMovePacket(\n input: Direction,\n frame: number,\n tick: number,\n timestamp: number,\n force = false,\n ): void {\n const trajectory = this.buildPendingMoveTrajectory();\n const latestTrajectoryFrame =\n trajectory.length > 0 ? trajectory[trajectory.length - 1].frame : frame;\n const shouldThrottle =\n !force &&\n latestTrajectoryFrame <= this.lastMovePathSentFrame &&\n timestamp - this.lastMovePathSentAt < this.MOVE_PATH_RESEND_INTERVAL_MS;\n if (shouldThrottle) {\n return;\n }\n\n this.webSocket.emit(\"move\", {\n input,\n timestamp,\n frame,\n tick,\n trajectory,\n });\n this.lastMovePathSentAt = timestamp;\n this.lastMovePathSentFrame = Math.max(this.lastMovePathSentFrame, latestTrajectoryFrame, frame);\n }\n\n private flushPendingMovePath(): void {\n if (!this.predictionEnabled || !this.prediction) {\n return;\n }\n const pendingInputs = this.prediction.getPendingInputs();\n if (pendingInputs.length === 0) {\n return;\n }\n const latest = pendingInputs[pendingInputs.length - 1];\n if (!latest) {\n return;\n }\n const now = Date.now();\n if (now - this.lastMovePathSentAt < this.MOVE_PATH_RESEND_INTERVAL_MS) {\n return;\n }\n this.emitMovePacket(latest.direction, latest.frame, latest.tick, now, false);\n }\n\n private getLocalPlayerState(): PredictionState<Direction> {\n const currentPlayer = this.sceneMap?.getCurrentPlayer();\n if (!currentPlayer) {\n return { x: 0, y: 0, direction: Direction.Down };\n }\n const topLeft = this.sceneMap.getBodyPosition(currentPlayer.id, \"top-left\");\n const x = topLeft?.x ?? currentPlayer.x();\n const y = topLeft?.y ?? currentPlayer.y();\n const direction = currentPlayer.direction();\n return { x, y, direction };\n }\n\n private applyAuthoritativeState(state: PredictionState<Direction>): void {\n const player = this.sceneMap?.getCurrentPlayer();\n if (!player) return;\n const hitbox = typeof player.hitbox === \"function\" ? player.hitbox() : player.hitbox;\n const width = hitbox?.w ?? 0;\n const height = hitbox?.h ?? 0;\n const updated = this.sceneMap.updateHitbox(player.id, state.x, state.y, width, height);\n if (!updated) {\n this.sceneMap.setBodyPosition(player.id, state.x, state.y, \"top-left\");\n }\n player.x.set(Math.round(state.x));\n player.y.set(Math.round(state.y));\n if (state.direction) {\n player.changeDirection(state.direction);\n }\n }\n\n private initializePredictionController(): void {\n if (!this.predictionEnabled) {\n this.prediction = undefined;\n this.sceneMap?.configureClientPrediction?.(false);\n return;\n }\n const configuredTtl = (this.globalConfig as any)?.prediction?.historyTtlMs;\n const historyTtlMs = typeof configuredTtl === \"number\" ? configuredTtl : 10000;\n const configuredMaxEntries = (this.globalConfig as any)?.prediction?.maxHistoryEntries;\n const maxHistoryEntries =\n typeof configuredMaxEntries === \"number\"\n ? configuredMaxEntries\n : Math.max(600, Math.ceil(historyTtlMs / 16) + 120);\n this.sceneMap?.configureClientPrediction?.(true);\n this.prediction = new PredictionController<Direction>({\n correctionThreshold: (this.globalConfig as any)?.prediction?.correctionThreshold ?? this.SERVER_CORRECTION_THRESHOLD,\n historyTtlMs,\n maxHistoryEntries,\n getPhysicsTick: () => this.getPhysicsTick(),\n getCurrentState: () => this.getLocalPlayerState(),\n setAuthoritativeState: (state) => this.applyAuthoritativeState(state),\n });\n }\n\n getCurrentPlayer() {\n return this.sceneMap.getCurrentPlayer()\n }\n\n emitSceneMapHook(hookName: string, ...args: any[]): void {\n this.hooks.callHooks(`client-sceneMap-${hookName}`, ...args).subscribe();\n }\n\n /**\n * Setup RxJS observer to wait for all conditions before calling onAfterLoading hook\n * \n * This method uses RxJS `combineLatest` to wait for all conditions to be met,\n * regardless of the order in which they arrive:\n * 1. The map loading is completed (loadMapService.load is finished)\n * 2. We received a player ID (pId)\n * 3. Players array has at least one element\n * 4. Events property is present in the sync data\n * \n * Once all conditions are met, it uses `switchMap` to call the onAfterLoading hook once.\n * \n * ## Design\n * \n * Uses BehaviorSubjects to track each condition state, allowing events to arrive\n * in any order. The `combineLatest` operator waits until all observables emit `true`,\n * then `take(1)` ensures the hook is called only once, and `switchMap` handles\n * the hook execution.\n * \n * @example\n * ```ts\n * // Called automatically in loadScene to setup the observer\n * this.setupOnAfterLoadingObserver();\n * ```\n */\n private setupOnAfterLoadingObserver(): void {\n this.onAfterLoadingSubscription = combineLatest([\n this.mapLoadCompleted$.pipe(filter(completed => completed === true)),\n this.playerIdReceived$.pipe(filter(received => received === true)),\n this.playersReceived$.pipe(filter(received => received === true)),\n this.eventsReceived$.pipe(filter(received => received === true))\n ]).pipe(\n take(1), // Only execute once when all conditions are met\n switchMap(() => {\n // Call the hook and return the observable\n return this.hooks.callHooks(\"client-sceneMap-onAfterLoading\", this.sceneMap);\n })\n ).subscribe();\n }\n\n /**\n * Clear client prediction states for cleanup\n * \n * Removes old prediction states and input history to prevent memory leaks.\n * Should be called when changing maps or disconnecting.\n * \n * @example\n * ```ts\n * // Clear prediction states when changing maps\n * engine.clearClientPredictionStates();\n * ```\n */\n clearClientPredictionStates() {\n this.initializePredictionController();\n this.frameOffset = 0;\n this.inputFrameCounter = 0;\n this.pendingPredictionFrames = [];\n this.lastClientPhysicsStepAt = 0;\n this.lastMovePathSentAt = 0;\n this.lastMovePathSentFrame = 0;\n }\n\n /**\n * Trigger a flash animation on a sprite\n * \n * This method allows you to trigger a flash effect on any sprite from client-side code.\n * The flash can be configured with various options including type (alpha, tint, or both),\n * duration, cycles, and color.\n * \n * ## Design\n * \n * The flash is applied directly to the sprite object using its flash trigger.\n * This is useful for client-side visual feedback, UI interactions, or local effects\n * that don't need to be synchronized with the server.\n * \n * @param spriteId - The ID of the sprite to flash. If not provided, flashes the current player\n * @param options - Flash configuration options\n * @param options.type - Type of flash effect: 'alpha' (opacity), 'tint' (color), or 'both' (default: 'alpha')\n * @param options.duration - Duration of the flash animation in milliseconds (default: 300)\n * @param options.cycles - Number of flash cycles (flash on/off) (default: 1)\n * @param options.alpha - Alpha value when flashing, from 0 to 1 (default: 0.3)\n * @param options.tint - Tint color when flashing as hex value or color name (default: 0xffffff - white)\n * \n * @example\n * ```ts\n * // Flash the current player with default settings\n * engine.flash();\n * \n * // Flash a specific sprite with red tint\n * engine.flash('sprite-id', { type: 'tint', tint: 0xff0000 });\n * \n * // Flash with both alpha and tint for dramatic effect\n * engine.flash(undefined, { \n * type: 'both', \n * alpha: 0.5, \n * tint: 0xff0000,\n * duration: 200,\n * cycles: 2\n * });\n * \n * // Quick damage flash on current player\n * engine.flash(undefined, { \n * type: 'tint', \n * tint: 'red', \n * duration: 150,\n * cycles: 1\n * });\n * ```\n */\n flash(\n spriteId?: string,\n options?: {\n type?: 'alpha' | 'tint' | 'both';\n duration?: number;\n cycles?: number;\n alpha?: number;\n tint?: number | string;\n }\n ): void {\n const targetId = spriteId || this.playerId;\n if (!targetId) return;\n\n const sprite = this.sceneMap.getObjectById(targetId);\n if (sprite && typeof sprite.flash === 'function') {\n sprite.flash(options);\n }\n }\n\n private applyServerAck(ack: { frame: number; serverTick?: number; x?: number; y?: number; direction?: Direction }) {\n if (this.predictionEnabled && this.prediction) {\n const result = this.prediction.applyServerAck({\n frame: ack.frame,\n serverTick: ack.serverTick,\n state:\n typeof ack.x === \"number\" && typeof ack.y === \"number\"\n ? { x: ack.x, y: ack.y, direction: ack.direction }\n : undefined,\n });\n if (result.state && result.needsReconciliation) {\n this.reconcilePrediction(result.state, result.pendingInputs);\n }\n return;\n }\n\n if (typeof ack.x !== \"number\" || typeof ack.y !== \"number\") {\n return;\n }\n const player = this.getCurrentPlayer();\n const myId = this.playerIdSignal();\n if (!player || !myId) {\n return;\n }\n const hitbox = typeof player.hitbox === \"function\" ? player.hitbox() : player.hitbox;\n const width = hitbox?.w ?? 0;\n const height = hitbox?.h ?? 0;\n const updated = this.sceneMap.updateHitbox(myId, ack.x, ack.y, width, height);\n if (!updated) {\n this.sceneMap.setBodyPosition(myId, ack.x, ack.y, \"top-left\");\n }\n player.x.set(Math.round(ack.x));\n player.y.set(Math.round(ack.y));\n if (ack.direction) {\n player.changeDirection(ack.direction);\n }\n }\n\n private reconcilePrediction(\n authoritativeState: PredictionState<Direction>,\n pendingInputs: PredictionHistoryEntry<Direction>[],\n ): void {\n const player = this.getCurrentPlayer();\n if (!player) {\n return;\n }\n\n (this.sceneMap as any).stopMovement(player);\n this.applyAuthoritativeState(authoritativeState);\n\n if (!pendingInputs.length) {\n return;\n }\n\n // Keep replay bounded while still tolerating high-latency links.\n const replayInputs = pendingInputs.slice(-600);\n for (const entry of replayInputs) {\n if (!entry?.direction) continue;\n (this.sceneMap as any).moveBody(player, entry.direction);\n this.sceneMap.stepPredictionTick();\n this.prediction?.attachPredictedState(entry.frame, this.getLocalPlayerState());\n }\n }\n\n /**\n * Replay unacknowledged inputs from a given frame to resimulate client prediction\n * after applying server authority at a certain frame.\n * \n * @param startFrame - The last server-acknowledged frame\n * \n * @example\n * ```ts\n * // After applying a server correction at frame N\n * this.replayUnackedInputsFromFrame(N);\n * ```\n */\n private async replayUnackedInputsFromFrame(_startFrame: number): Promise<void> {\n // Prediction controller handles replay internally. Kept for backwards compatibility.\n }\n\n /**\n * Clear all client resources and reset state\n * \n * This method should be called to clean up all client-side resources when\n * shutting down or resetting the client engine. It:\n * - Destroys the PIXI renderer\n * - Stops all sounds\n * - Cleans up subscriptions and event listeners\n * - Resets scene map\n * - Stops ping/pong interval\n * - Clears prediction states\n * \n * ## Design\n * \n * This method is used primarily in testing environments to ensure clean\n * state between tests. In production, the client engine typically persists\n * for the lifetime of the application.\n * \n * @example\n * ```ts\n * // In test cleanup\n * afterEach(() => {\n * clientEngine.clear();\n * });\n * ```\n */\n clear(): void {\n try {\n // First, unsubscribe from all tick subscriptions to stop rendering attempts\n for (const subscription of this.tickSubscriptions) {\n if (subscription && typeof subscription.unsubscribe === 'function') {\n subscription.unsubscribe();\n }\n }\n this.tickSubscriptions = [];\n\n // Stop ping/pong interval\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n // Clean up onAfterLoading subscription\n if (this.onAfterLoadingSubscription && typeof this.onAfterLoadingSubscription.unsubscribe === 'function') {\n this.onAfterLoadingSubscription.unsubscribe();\n this.onAfterLoadingSubscription = undefined;\n }\n\n // Clean up canvasElement (CanvasEngine) BEFORE destroying PIXI app\n // This prevents CanvasEngine from trying to render after PIXI is destroyed\n // CanvasEngine manages its own render loop which could try to access PIXI after destruction\n if (this.canvasElement) {\n try {\n // Try to stop or cleanup canvasElement if it has cleanup methods\n if (typeof (this.canvasElement as any).destroy === 'function') {\n (this.canvasElement as any).destroy();\n }\n // Clear the reference\n this.canvasElement = undefined;\n } catch (error) {\n // Ignore errors during canvasElement cleanup\n }\n }\n\n // Reset scene map if it exists (this should stop any ongoing animations/renders)\n if (this.sceneMap && typeof (this.sceneMap as any).reset === 'function') {\n (this.sceneMap as any).reset(true);\n }\n\n // Stop all sounds\n this.stopAllSounds();\n\n // Remove resize event listener\n if (this.resizeHandler && typeof window !== 'undefined') {\n window.removeEventListener('resize', this.resizeHandler);\n this.resizeHandler = undefined;\n }\n\n // Destroy PIXI app and renderer if they exist\n // Destroy the app first, which will destroy the renderer\n // Store renderer reference before destroying app (since app.destroy() will destroy the renderer)\n const rendererStillExists = this.renderer && typeof this.renderer.destroy === 'function';\n \n if (this.canvasApp && typeof this.canvasApp.destroy === 'function') {\n try {\n // Stop the ticker first to prevent any render calls during destruction\n if (this.canvasApp.ticker) {\n if (typeof this.canvasApp.ticker.stop === 'function') {\n this.canvasApp.ticker.stop();\n }\n // Also remove all listeners from ticker to prevent callbacks\n if (typeof this.canvasApp.ticker.removeAll === 'function') {\n this.canvasApp.ticker.removeAll();\n }\n }\n \n // Stop the renderer's ticker if it exists separately\n if (this.renderer && (this.renderer as any).ticker) {\n if (typeof (this.renderer as any).ticker.stop === 'function') {\n (this.renderer as any).ticker.stop();\n }\n if (typeof (this.renderer as any).ticker.removeAll === 'function') {\n (this.renderer as any).ticker.removeAll();\n }\n }\n \n // Remove the canvas from DOM before destroying to prevent render attempts\n if (this.canvasApp.canvas && this.canvasApp.canvas.parentNode) {\n this.canvasApp.canvas.parentNode.removeChild(this.canvasApp.canvas);\n }\n \n // Destroy with minimal options to avoid issues\n // Don't pass options that might trigger additional cleanup that could fail\n this.canvasApp.destroy(true);\n } catch (error) {\n // Ignore errors during destruction\n }\n this.canvasApp = undefined;\n // canvasApp.destroy() already destroyed the renderer, so just null it\n this.renderer = null as any;\n } else if (rendererStillExists) {\n // Fallback: destroy renderer directly only if app doesn't exist or wasn't destroyed\n try {\n // Stop the renderer's ticker if it has one\n if ((this.renderer as any).ticker) {\n if (typeof (this.renderer as any).ticker.stop === 'function') {\n (this.renderer as any).ticker.stop();\n }\n if (typeof (this.renderer as any).ticker.removeAll === 'function') {\n (this.renderer as any).ticker.removeAll();\n }\n }\n \n this.renderer.destroy(true);\n } catch (error) {\n // Ignore errors during destruction\n }\n this.renderer = null as any;\n }\n\n // Clean up prediction controller\n if (this.prediction) {\n // Prediction controller cleanup is handled internally when destroyed\n this.prediction = undefined;\n }\n\n // Reset signals\n this.playerIdSignal.set(null);\n this.cameraFollowTargetId.set(null);\n this.spriteComponentsBehind.set([]);\n this.spriteComponentsInFront.set([]);\n \n // Clear maps and arrays\n this.spritesheets.clear();\n this.sounds.clear();\n this.componentAnimations = [];\n this.particleSettings.emitters = [];\n\n // Reset state\n this.stopProcessingInput = false;\n this.lastInputTime = 0;\n this.inputFrameCounter = 0;\n this.frameOffset = 0;\n this.rtt = 0;\n this.lastMovePathSentAt = 0;\n this.lastMovePathSentFrame = 0;\n\n // Reset behavior subjects\n this.mapLoadCompleted$.next(false);\n this.playerIdReceived$.next(false);\n this.playersReceived$.next(false);\n this.eventsReceived$.next(false);\n } catch (error) {\n console.warn('Error during client engine cleanup:', error);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,IAAa,kBAAb,MAAsC;CAkEpC,YAAY,SAAgB;AAAT,OAAA,UAAA;6BAzDG;eACd,OAAO,OAAO;gBACb,OAAO,OAAO;sCACU,IAAI,KAAK;gCACf,IAAI,KAAK;6BACP,EAAE;0BAK3B,EACA,UAAU,EAAE,EACb;wBAKc,OAAsB,KAAK;gCACnB,OAAc,EAAE,CAAC;iCAChB,OAAc,EAAE,CAAC;8BAEpB,OAAsB,KAAK;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OAAO,WAAW,YAAY,KAAK,UAAU,OAAO;AAKrE,UAAK,UAAU,QAAQ,KAAK;aACrB,OAAO;AAGhB,SAAK,YAAY,KAAA;AAEjB,SAAK,WAAW;cACP,qBAAqB;AAE9B,QAAI;AAEF,SAAK,KAAK,SAAiB,QAAQ;AACjC,UAAI,OAAQ,KAAK,SAAiB,OAAO,SAAS,WAC/C,MAAK,SAAiB,OAAO,MAAM;AAEtC,UAAI,OAAQ,KAAK,SAAiB,OAAO,cAAc,WACpD,MAAK,SAAiB,OAAO,WAAW;;AAI7C,UAAK,SAAS,QAAQ,KAAK;aACpB,OAAO;AAGhB,SAAK,WAAW;;AAIlB,OAAI,KAAK,WAEP,MAAK,aAAa,KAAA;AAIpB,QAAK,eAAe,IAAI,KAAK;AAC7B,QAAK,qBAAqB,IAAI,KAAK;AACnC,QAAK,uBAAuB,IAAI,EAAE,CAAC;AACnC,QAAK,wBAAwB,IAAI,EAAE,CAAC;AAGpC,QAAK,aAAa,OAAO;AACzB,QAAK,OAAO,OAAO;AACnB,QAAK,sBAAsB,EAAE;AAC7B,QAAK,iBAAiB,WAAW,EAAE;AAGnC,QAAK,sBAAsB;AAC3B,QAAK,gBAAgB;AACrB,QAAK,oBAAoB;AACzB,QAAK,cAAc;AACnB,QAAK,MAAM;AACX,QAAK,qBAAqB;AAC1B,QAAK,wBAAwB;AAG7B,QAAK,kBAAkB,KAAK,MAAM;AAClC,QAAK,kBAAkB,KAAK,MAAM;AAClC,QAAK,iBAAiB,KAAK,MAAM;AACjC,QAAK,gBAAgB,KAAK,MAAM;WACzB,OAAO;AACd,WAAQ,KAAK,uCAAuC,MAAM"}
@@ -0,0 +1,199 @@
1
+ import { Howler } from 'canvasengine';
2
+ import { RpgClientEngine } from './RpgClientEngine';
3
+ /**
4
+ * Sound decorator options
5
+ *
6
+ * Defines the configuration for a sound that can be played in the game.
7
+ * The sound can be a single file or multiple files (for different formats).
8
+ *
9
+ * @interface SoundOptions
10
+ */
11
+ export interface SoundOptions {
12
+ /**
13
+ * Sound identifier. Used to retrieve the sound later with RpgSound.get()
14
+ *
15
+ * @type {string}
16
+ */
17
+ id?: string;
18
+ /**
19
+ * Single sound file path. Use require() to wrap the path.
20
+ *
21
+ * @type {string}
22
+ * @example
23
+ * sound: require('./assets/sound.ogg')
24
+ */
25
+ sound?: string;
26
+ /**
27
+ * Multiple sounds with different IDs. The key is the sound ID and the value is the file path.
28
+ * Use require() to wrap each path.
29
+ *
30
+ * @type {{ [id: string]: string }}
31
+ * @example
32
+ * sounds: {
33
+ * hero: require('./assets/hero.ogg'),
34
+ * monster: require('./assets/monster.ogg')
35
+ * }
36
+ */
37
+ sounds?: {
38
+ [id: string]: string;
39
+ };
40
+ /**
41
+ * Whether the sound should loop when it finishes playing.
42
+ *
43
+ * @type {boolean}
44
+ * @default false
45
+ */
46
+ loop?: boolean;
47
+ /**
48
+ * Volume level (0.0 to 1.0).
49
+ *
50
+ * @type {number}
51
+ * @default 1.0
52
+ */
53
+ volume?: number;
54
+ }
55
+ /**
56
+ * Metadata stored on the class decorated with @Sound
57
+ *
58
+ * @interface SoundMetadata
59
+ */
60
+ interface SoundMetadata {
61
+ id?: string;
62
+ sound?: string;
63
+ sounds?: {
64
+ [id: string]: string;
65
+ };
66
+ loop?: boolean;
67
+ volume?: number;
68
+ }
69
+ /**
70
+ * Sound decorator
71
+ *
72
+ * Decorates a class to define a sound configuration. The decorated class can be
73
+ * added to the RpgClient module configuration, and the sound will be automatically
74
+ * registered and available through RpgSound.get().
75
+ *
76
+ * ## Design
77
+ *
78
+ * The decorator stores metadata on the class that is later used by the module loader
79
+ * to register sounds with the engine. The sound is created using Howler.js for
80
+ * advanced audio features like looping, volume control, and cross-browser compatibility.
81
+ *
82
+ * @param options - Sound configuration options
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * import { Sound } from '@rpgjs/client'
87
+ *
88
+ * @Sound({
89
+ * id: 'town-music',
90
+ * sound: require('./sound/town.ogg'),
91
+ * loop: true,
92
+ * volume: 0.5
93
+ * })
94
+ * export class TownMusic {}
95
+ *
96
+ * // Multiple sounds in one class
97
+ * @Sound({
98
+ * sounds: {
99
+ * hero: require('./assets/hero.ogg'),
100
+ * monster: require('./assets/monster.ogg')
101
+ * },
102
+ * loop: true
103
+ * })
104
+ * export class CharacterSounds {}
105
+ * ```
106
+ */
107
+ export declare function Sound(options: SoundOptions): <T extends {
108
+ new (...args: any[]): {};
109
+ }>(constructor: T) => T;
110
+ /**
111
+ * Get sound metadata from a decorated class
112
+ *
113
+ * @param soundClass - The class decorated with @Sound
114
+ * @returns The sound metadata or undefined
115
+ */
116
+ export declare function getSoundMetadata(soundClass: any): SoundMetadata | undefined;
117
+ /**
118
+ * RpgSound class
119
+ *
120
+ * Provides a unified API to manage sounds in the game. Uses Howler.js internally
121
+ * for advanced audio features. Sounds can be retrieved by ID and controlled
122
+ * using Howler.js methods.
123
+ *
124
+ * ## Design
125
+ *
126
+ * RpgSound acts as a facade over Howler.js, providing easy access to sounds
127
+ * registered in the engine. It supports both individual sound control and
128
+ * global sound management (volume, mute, etc.).
129
+ *
130
+ * @example
131
+ * ```ts
132
+ * import { RpgSound } from '@rpgjs/client'
133
+ *
134
+ * // Play a sound
135
+ * RpgSound.get('town-music').play()
136
+ *
137
+ * // Control volume
138
+ * RpgSound.get('town-music').volume(0.5)
139
+ *
140
+ * // Stop a sound
141
+ * RpgSound.get('town-music').stop()
142
+ *
143
+ * // Global volume control
144
+ * RpgSound.global.volume(0.2)
145
+ * ```
146
+ */
147
+ export declare class RpgSound {
148
+ private static engine;
149
+ /**
150
+ * Initialize RpgSound with the engine instance
151
+ *
152
+ * This is called automatically by the engine during initialization.
153
+ *
154
+ * @param engine - The RpgClientEngine instance
155
+ */
156
+ static init(engine: RpgClientEngine): void;
157
+ /**
158
+ * Get a sound by its ID
159
+ *
160
+ * Retrieves a Howler sound instance from the engine's sound cache.
161
+ * The sound must be registered beforehand (via @Sound decorator or manually).
162
+ *
163
+ * @param id - The sound identifier
164
+ * @returns The Howler sound instance, or undefined if not found
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * // Get and play a sound
169
+ * const sound = RpgSound.get('town-music');
170
+ * if (sound) {
171
+ * sound.play();
172
+ * }
173
+ *
174
+ * // Chain methods
175
+ * RpgSound.get('battle-theme')?.volume(0.8).play();
176
+ * ```
177
+ */
178
+ static get(id: string): any;
179
+ /**
180
+ * Global Howler instance for managing all sounds
181
+ *
182
+ * Provides access to Howler.js global methods for controlling all sounds
183
+ * at once (volume, mute, etc.).
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * // Set global volume to 20%
188
+ * RpgSound.global.volume(0.2)
189
+ *
190
+ * // Mute all sounds
191
+ * RpgSound.global.mute(true)
192
+ *
193
+ * // Unmute all sounds
194
+ * RpgSound.global.mute(false)
195
+ * ```
196
+ */
197
+ static get global(): typeof Howler;
198
+ }
199
+ export {};
package/dist/Sound.js ADDED
@@ -0,0 +1,167 @@
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
+ */
42
+ function Sound(options) {
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
+ };
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
+ */
60
+ function getSoundMetadata(soundClass) {
61
+ return soundClass[SOUND_METADATA_KEY];
62
+ }
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
165
+ export { RpgSound, Sound, getSoundMetadata };
166
+
167
+ //# sourceMappingURL=Sound.js.map
@@ -0,0 +1 @@
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.122.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.122.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 };
@@ -0,0 +1,24 @@
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
+ 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
+ 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
22
+ export { component as default };
23
+
24
+ //# sourceMappingURL=animation.ce.js.map
@@ -0,0 +1 @@
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"}