@rpgjs/client 5.0.0-beta.2 → 5.0.0-beta.20

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 (314) hide show
  1. package/CHANGELOG.md +123 -0
  2. package/dist/Game/AnimationManager.d.ts +2 -1
  3. package/dist/Game/AnimationManager.js +21 -9
  4. package/dist/Game/AnimationManager.js.map +1 -1
  5. package/dist/Game/AnimationManager.spec.d.ts +1 -0
  6. package/dist/Game/ClientVisuals.d.ts +61 -0
  7. package/dist/Game/ClientVisuals.js +96 -0
  8. package/dist/Game/ClientVisuals.js.map +1 -0
  9. package/dist/Game/ClientVisuals.spec.d.ts +1 -0
  10. package/dist/Game/Event.js.map +1 -1
  11. package/dist/Game/EventComponentResolver.d.ts +16 -0
  12. package/dist/Game/EventComponentResolver.js +52 -0
  13. package/dist/Game/EventComponentResolver.js.map +1 -0
  14. package/dist/Game/EventComponentResolver.spec.d.ts +1 -0
  15. package/dist/Game/Map.d.ts +9 -1
  16. package/dist/Game/Map.js +83 -5
  17. package/dist/Game/Map.js.map +1 -1
  18. package/dist/Game/Object.d.ts +49 -15
  19. package/dist/Game/Object.js +101 -42
  20. package/dist/Game/Object.js.map +1 -1
  21. package/dist/Game/Object.spec.d.ts +1 -0
  22. package/dist/Game/Player.js.map +1 -1
  23. package/dist/Game/ProjectileManager.d.ts +98 -0
  24. package/dist/Game/ProjectileManager.js +196 -0
  25. package/dist/Game/ProjectileManager.js.map +1 -0
  26. package/dist/Game/ProjectileManager.spec.d.ts +1 -0
  27. package/dist/Gui/Gui.d.ts +20 -6
  28. package/dist/Gui/Gui.js +96 -54
  29. package/dist/Gui/Gui.js.map +1 -1
  30. package/dist/Gui/Gui.spec.d.ts +1 -0
  31. package/dist/Gui/NotificationManager.js.map +1 -1
  32. package/dist/Resource.js +1 -1
  33. package/dist/Resource.js.map +1 -1
  34. package/dist/RpgClient.d.ts +194 -15
  35. package/dist/RpgClientEngine.d.ts +176 -11
  36. package/dist/RpgClientEngine.js +669 -68
  37. package/dist/RpgClientEngine.js.map +1 -1
  38. package/dist/Sound.js.map +1 -1
  39. package/dist/_virtual/{_@oxc-project_runtime@0.122.0/helpers → _@oxc-project_runtime@0.133.0/helpers/esm}/decorate.js +1 -1
  40. package/dist/_virtual/{_@oxc-project_runtime@0.122.0/helpers → _@oxc-project_runtime@0.133.0/helpers/esm}/decorateMetadata.js +1 -1
  41. package/dist/_virtual/_rolldown/runtime.js +13 -0
  42. package/dist/components/animations/animation.ce.js +6 -5
  43. package/dist/components/animations/animation.ce.js.map +1 -1
  44. package/dist/components/animations/fx.ce.js +60 -0
  45. package/dist/components/animations/fx.ce.js.map +1 -0
  46. package/dist/components/animations/hit.ce.js +24 -28
  47. package/dist/components/animations/hit.ce.js.map +1 -1
  48. package/dist/components/animations/index.d.ts +1 -0
  49. package/dist/components/animations/index.js +6 -4
  50. package/dist/components/animations/index.js.map +1 -1
  51. package/dist/components/character.ce.js +606 -248
  52. package/dist/components/character.ce.js.map +1 -1
  53. package/dist/components/dynamics/bar.ce.js +99 -0
  54. package/dist/components/dynamics/bar.ce.js.map +1 -0
  55. package/dist/components/dynamics/image.ce.js +26 -0
  56. package/dist/components/dynamics/image.ce.js.map +1 -0
  57. package/dist/components/dynamics/parse-value.d.ts +3 -0
  58. package/dist/components/dynamics/parse-value.js +54 -35
  59. package/dist/components/dynamics/parse-value.js.map +1 -1
  60. package/dist/components/dynamics/parse-value.spec.d.ts +1 -0
  61. package/dist/components/dynamics/shape-utils.d.ts +16 -0
  62. package/dist/components/dynamics/shape-utils.js +73 -0
  63. package/dist/components/dynamics/shape-utils.js.map +1 -0
  64. package/dist/components/dynamics/shape-utils.spec.d.ts +1 -0
  65. package/dist/components/dynamics/shape.ce.js +86 -0
  66. package/dist/components/dynamics/shape.ce.js.map +1 -0
  67. package/dist/components/dynamics/text.ce.js +36 -56
  68. package/dist/components/dynamics/text.ce.js.map +1 -1
  69. package/dist/components/gui/box.ce.js +9 -9
  70. package/dist/components/gui/box.ce.js.map +1 -1
  71. package/dist/components/gui/dialogbox/index.ce.js +75 -65
  72. package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
  73. package/dist/components/gui/gameover.ce.js +47 -68
  74. package/dist/components/gui/gameover.ce.js.map +1 -1
  75. package/dist/components/gui/hud/hud.ce.js +23 -31
  76. package/dist/components/gui/hud/hud.ce.js.map +1 -1
  77. package/dist/components/gui/menu/equip-menu.ce.js +121 -172
  78. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
  79. package/dist/components/gui/menu/exit-menu.ce.js +15 -10
  80. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
  81. package/dist/components/gui/menu/items-menu.ce.js +62 -77
  82. package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
  83. package/dist/components/gui/menu/main-menu.ce.js +89 -104
  84. package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
  85. package/dist/components/gui/menu/options-menu.ce.js +12 -8
  86. package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
  87. package/dist/components/gui/menu/skills-menu.ce.js +17 -19
  88. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
  89. package/dist/components/gui/mobile/index.js +2 -2
  90. package/dist/components/gui/mobile/index.js.map +1 -1
  91. package/dist/components/gui/mobile/mobile.ce.js +7 -5
  92. package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
  93. package/dist/components/gui/notification/notification.ce.js +28 -26
  94. package/dist/components/gui/notification/notification.ce.js.map +1 -1
  95. package/dist/components/gui/save-load.ce.js +81 -256
  96. package/dist/components/gui/save-load.ce.js.map +1 -1
  97. package/dist/components/gui/shop/shop.ce.js +107 -142
  98. package/dist/components/gui/shop/shop.ce.js.map +1 -1
  99. package/dist/components/gui/title-screen.ce.js +50 -73
  100. package/dist/components/gui/title-screen.ce.js.map +1 -1
  101. package/dist/components/index.d.ts +2 -1
  102. package/dist/components/index.js +1 -0
  103. package/dist/components/interaction-components.ce.js +22 -0
  104. package/dist/components/interaction-components.ce.js.map +1 -0
  105. package/dist/components/player-components-utils.d.ts +67 -0
  106. package/dist/components/player-components-utils.js +162 -0
  107. package/dist/components/player-components-utils.js.map +1 -0
  108. package/dist/components/player-components-utils.spec.d.ts +1 -0
  109. package/dist/components/player-components.ce.js +191 -0
  110. package/dist/components/player-components.ce.js.map +1 -0
  111. package/dist/components/prebuilt/hp-bar.ce.js +45 -45
  112. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
  113. package/dist/components/prebuilt/light-halo.ce.js +39 -60
  114. package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
  115. package/dist/components/scenes/canvas.ce.js +205 -27
  116. package/dist/components/scenes/canvas.ce.js.map +1 -1
  117. package/dist/components/scenes/draw-map.ce.js +39 -39
  118. package/dist/components/scenes/draw-map.ce.js.map +1 -1
  119. package/dist/components/scenes/event-layer.ce.js +51 -10
  120. package/dist/components/scenes/event-layer.ce.js.map +1 -1
  121. package/dist/core/inject.js +1 -1
  122. package/dist/core/inject.js.map +1 -1
  123. package/dist/core/setup.js +1 -1
  124. package/dist/core/setup.js.map +1 -1
  125. package/dist/decorators/spritesheet.d.ts +1 -0
  126. package/dist/decorators/spritesheet.js +11 -0
  127. package/dist/decorators/spritesheet.js.map +1 -0
  128. package/dist/i18n.d.ts +55 -0
  129. package/dist/i18n.js +60 -0
  130. package/dist/i18n.js.map +1 -0
  131. package/dist/i18n.spec.d.ts +1 -0
  132. package/dist/index.d.ts +7 -0
  133. package/dist/index.js +29 -21
  134. package/dist/module.js +45 -4
  135. package/dist/module.js.map +1 -1
  136. package/dist/node_modules/.pnpm/{@signe_di@2.9.0 → @signe_di@3.1.0}/node_modules/@signe/di/dist/index.js +7 -117
  137. package/dist/node_modules/.pnpm/@signe_di@3.1.0/node_modules/@signe/di/dist/index.js.map +1 -0
  138. package/dist/node_modules/.pnpm/@signe_reactive@3.1.0/node_modules/@signe/reactive/dist/index.js +239 -0
  139. package/dist/node_modules/.pnpm/@signe_reactive@3.1.0/node_modules/@signe/reactive/dist/index.js.map +1 -0
  140. package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/chunk-EUXUH3YW.js +13 -0
  141. package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +1 -0
  142. package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/index.js +698 -0
  143. package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/index.js.map +1 -0
  144. package/dist/node_modules/.pnpm/@signe_sync@3.1.0_react@19.2.7/node_modules/@signe/sync/dist/client/index.js +43 -0
  145. package/dist/node_modules/.pnpm/@signe_sync@3.1.0_react@19.2.7/node_modules/@signe/sync/dist/client/index.js.map +1 -0
  146. package/dist/node_modules/.pnpm/{@signe_sync@2.9.0 → @signe_sync@3.1.0_react@19.2.7}/node_modules/@signe/sync/dist/index.js +57 -141
  147. package/dist/node_modules/.pnpm/@signe_sync@3.1.0_react@19.2.7/node_modules/@signe/sync/dist/index.js.map +1 -0
  148. package/dist/node_modules/.pnpm/{partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js → partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/index.js} +30 -17
  149. package/dist/node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/index.js.map +1 -0
  150. package/dist/node_modules/.pnpm/{partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js → partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/ws.js} +65 -34
  151. package/dist/node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/ws.js.map +1 -0
  152. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.js +13 -0
  153. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.js.map +1 -0
  154. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js +106 -0
  155. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js.map +1 -0
  156. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js +13 -0
  157. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js.map +1 -0
  158. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js +121 -0
  159. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js.map +1 -0
  160. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js +10 -0
  161. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
  162. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js +110 -0
  163. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
  164. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js +99 -0
  165. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js.map +1 -0
  166. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js +82 -0
  167. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js.map +1 -0
  168. package/dist/node_modules/.pnpm/{zod@3.24.2/node_modules/zod/lib/index.js → zod@3.25.76/node_modules/zod/v3/types.js} +74 -611
  169. package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js.map +1 -0
  170. package/dist/presets/animation.js.map +1 -1
  171. package/dist/presets/faceset.js.map +1 -1
  172. package/dist/presets/icon.js.map +1 -1
  173. package/dist/presets/index.js.map +1 -1
  174. package/dist/presets/lpc.js.map +1 -1
  175. package/dist/presets/rmspritesheet.js.map +1 -1
  176. package/dist/services/AbstractSocket.d.ts +2 -0
  177. package/dist/services/AbstractSocket.js.map +1 -1
  178. package/dist/services/actionInput.d.ts +14 -0
  179. package/dist/services/actionInput.js +59 -0
  180. package/dist/services/actionInput.js.map +1 -0
  181. package/dist/services/actionInput.spec.d.ts +1 -0
  182. package/dist/services/interactions.d.ts +159 -0
  183. package/dist/services/interactions.js +460 -0
  184. package/dist/services/interactions.js.map +1 -0
  185. package/dist/services/interactions.spec.d.ts +1 -0
  186. package/dist/services/keyboardControls.d.ts +1 -0
  187. package/dist/services/keyboardControls.js +1 -0
  188. package/dist/services/keyboardControls.js.map +1 -1
  189. package/dist/services/loadMap.d.ts +9 -0
  190. package/dist/services/loadMap.js +1 -1
  191. package/dist/services/loadMap.js.map +1 -1
  192. package/dist/services/mmorpg-connection.d.ts +5 -0
  193. package/dist/services/mmorpg-connection.js +50 -0
  194. package/dist/services/mmorpg-connection.js.map +1 -0
  195. package/dist/services/mmorpg-connection.spec.d.ts +1 -0
  196. package/dist/services/mmorpg.d.ts +11 -4
  197. package/dist/services/mmorpg.js +57 -33
  198. package/dist/services/mmorpg.js.map +1 -1
  199. package/dist/services/pointerContext.d.ts +11 -0
  200. package/dist/services/pointerContext.js +48 -0
  201. package/dist/services/pointerContext.js.map +1 -0
  202. package/dist/services/pointerContext.spec.d.ts +1 -0
  203. package/dist/services/save.js.map +1 -1
  204. package/dist/services/save.spec.d.ts +1 -0
  205. package/dist/services/standalone-message.d.ts +1 -0
  206. package/dist/services/standalone-message.js +9 -0
  207. package/dist/services/standalone-message.js.map +1 -0
  208. package/dist/services/standalone.d.ts +4 -1
  209. package/dist/services/standalone.js +36 -16
  210. package/dist/services/standalone.js.map +1 -1
  211. package/dist/services/standalone.spec.d.ts +1 -0
  212. package/dist/utils/getEntityProp.js +4 -3
  213. package/dist/utils/getEntityProp.js.map +1 -1
  214. package/dist/utils/getEntityProp.spec.d.ts +1 -0
  215. package/dist/utils/mapId.d.ts +1 -0
  216. package/dist/utils/mapId.js +6 -0
  217. package/dist/utils/mapId.js.map +1 -0
  218. package/dist/utils/readPropValue.d.ts +2 -0
  219. package/dist/utils/readPropValue.js +13 -0
  220. package/dist/utils/readPropValue.js.map +1 -0
  221. package/package.json +13 -13
  222. package/src/Game/AnimationManager.spec.ts +30 -0
  223. package/src/Game/AnimationManager.ts +26 -10
  224. package/src/Game/ClientVisuals.spec.ts +56 -0
  225. package/src/Game/ClientVisuals.ts +184 -0
  226. package/src/Game/EventComponentResolver.spec.ts +84 -0
  227. package/src/Game/EventComponentResolver.ts +74 -0
  228. package/src/Game/Map.ts +134 -2
  229. package/src/Game/Object.spec.ts +59 -0
  230. package/src/Game/Object.ts +181 -77
  231. package/src/Game/ProjectileManager.spec.ts +449 -0
  232. package/src/Game/ProjectileManager.ts +346 -0
  233. package/src/Gui/Gui.spec.ts +340 -0
  234. package/src/Gui/Gui.ts +129 -57
  235. package/src/Resource.ts +1 -2
  236. package/src/RpgClient.ts +220 -17
  237. package/src/RpgClientEngine.ts +959 -116
  238. package/src/components/animations/fx.ce +101 -0
  239. package/src/components/animations/index.ts +4 -2
  240. package/src/components/character.ce +681 -45
  241. package/src/components/dynamics/bar.ce +88 -0
  242. package/src/components/dynamics/image.ce +21 -0
  243. package/src/components/dynamics/parse-value.spec.ts +83 -0
  244. package/src/components/dynamics/parse-value.ts +111 -37
  245. package/src/components/dynamics/shape-utils.spec.ts +46 -0
  246. package/src/components/dynamics/shape-utils.ts +61 -0
  247. package/src/components/dynamics/shape.ce +90 -0
  248. package/src/components/dynamics/text.ce +35 -149
  249. package/src/components/gui/dialogbox/index.ce +52 -21
  250. package/src/components/gui/gameover.ce +6 -4
  251. package/src/components/gui/menu/equip-menu.ce +11 -9
  252. package/src/components/gui/menu/exit-menu.ce +6 -4
  253. package/src/components/gui/menu/items-menu.ce +11 -9
  254. package/src/components/gui/menu/main-menu.ce +14 -12
  255. package/src/components/gui/menu/options-menu.ce +4 -3
  256. package/src/components/gui/menu/skills-menu.ce +2 -1
  257. package/src/components/gui/notification/notification.ce +7 -1
  258. package/src/components/gui/save-load.ce +13 -11
  259. package/src/components/gui/shop/shop.ce +20 -18
  260. package/src/components/gui/title-screen.ce +6 -4
  261. package/src/components/index.ts +2 -1
  262. package/src/components/interaction-components.ce +23 -0
  263. package/src/components/player-components-utils.spec.ts +109 -0
  264. package/src/components/player-components-utils.ts +205 -0
  265. package/src/components/player-components.ce +222 -0
  266. package/src/components/prebuilt/hp-bar.ce +4 -3
  267. package/src/components/prebuilt/light-halo.ce +2 -2
  268. package/src/components/scenes/canvas.ce +219 -15
  269. package/src/components/scenes/draw-map.ce +34 -22
  270. package/src/components/scenes/event-layer.ce +55 -4
  271. package/src/core/setup.ts +2 -2
  272. package/src/decorators/spritesheet.ts +8 -0
  273. package/src/i18n.spec.ts +39 -0
  274. package/src/i18n.ts +59 -0
  275. package/src/index.ts +7 -0
  276. package/src/module.ts +61 -11
  277. package/src/services/AbstractSocket.ts +3 -0
  278. package/src/services/actionInput.spec.ts +155 -0
  279. package/src/services/actionInput.ts +120 -0
  280. package/src/services/interactions.spec.ts +175 -0
  281. package/src/services/interactions.ts +722 -0
  282. package/src/services/keyboardControls.ts +2 -1
  283. package/src/services/loadMap.ts +5 -1
  284. package/src/services/mmorpg-connection.spec.ts +99 -0
  285. package/src/services/mmorpg-connection.ts +69 -0
  286. package/src/services/mmorpg.ts +70 -36
  287. package/src/services/pointerContext.spec.ts +36 -0
  288. package/src/services/pointerContext.ts +84 -0
  289. package/src/services/save.spec.ts +127 -0
  290. package/src/services/standalone-message.ts +7 -0
  291. package/src/services/standalone.spec.ts +54 -0
  292. package/src/services/standalone.ts +44 -12
  293. package/src/utils/getEntityProp.spec.ts +96 -0
  294. package/src/utils/getEntityProp.ts +4 -3
  295. package/src/utils/mapId.ts +2 -0
  296. package/src/utils/readPropValue.ts +16 -0
  297. package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +0 -1
  298. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +0 -457
  299. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +0 -1
  300. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +0 -463
  301. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +0 -1
  302. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +0 -2191
  303. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +0 -1
  304. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +0 -10
  305. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +0 -1
  306. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +0 -91
  307. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +0 -1
  308. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +0 -1
  309. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +0 -14
  310. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +0 -1
  311. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +0 -1
  312. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +0 -1
  313. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +0 -2
  314. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +0 -1
@@ -1,146 +1,44 @@
1
1
  import { inject } from "../core/inject.js";
2
+ import { getKeyboardControlBind, keyboardEventMatchesBind, resolveKeyboardActionInput, resolveKeyboardDirectionInput } from "../services/actionInput.js";
3
+ import { getCanMoveValue } from "../utils/readPropValue.js";
2
4
  import { RpgGui } from "../Gui/Gui.js";
5
+ import { normalizeEventComponent } from "../Game/EventComponentResolver.js";
3
6
  import { RpgClientEngine } from "../RpgClientEngine.js";
4
- import { Container, Sprite, animatedSignal, computed, cond, h, loop, mount, on, signal, tick, useDefineProps, useProps } from "canvasengine";
5
- import { Particle } from "@canvasengine/presets";
6
- import { Direction, ModulesToken } from "@rpgjs/common";
7
+ import __ce_component$1 from "./player-components.ce.js";
8
+ import __ce_component$2 from "./interaction-components.ce.js";
9
+ import { Container, Sprite, animatedSignal, computed, cond, effect, h, loop, mount, on, signal, tick, useDefineEmits, useDefineProps, useProps } from "canvasengine";
10
+ import { Animation, Direction, ModulesToken, shouldRenderLightingShadows } from "@rpgjs/common";
7
11
  import { combineLatest, filter, lastValueFrom, map, pairwise, startWith } from "rxjs";
12
+ import { Particle } from "@canvasengine/presets";
13
+ import { Assets } from "pixi.js";
8
14
  //#region src/components/character.ce
9
15
  function component($$props) {
10
16
  useProps($$props);
11
17
  const defineProps = useDefineProps($$props);
12
- var __assign = this && this.__assign || function() {
13
- __assign = Object.assign || function(t) {
14
- for (var s, i = 1, n = arguments.length; i < n; i++) {
15
- s = arguments[i];
16
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
17
- }
18
- return t;
19
- };
20
- return __assign.apply(this, arguments);
21
- };
22
- var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
23
- function adopt(value) {
24
- return value instanceof P ? value : new P(function(resolve) {
25
- resolve(value);
26
- });
27
- }
28
- return new (P || (P = Promise))(function(resolve, reject) {
29
- function fulfilled(value) {
30
- try {
31
- step(generator.next(value));
32
- } catch (e) {
33
- reject(e);
34
- }
35
- }
36
- function rejected(value) {
37
- try {
38
- step(generator["throw"](value));
39
- } catch (e) {
40
- reject(e);
41
- }
42
- }
43
- function step(result) {
44
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
45
- }
46
- step((generator = generator.apply(thisArg, _arguments || [])).next());
47
- });
48
- };
49
- var __generator = this && this.__generator || function(thisArg, body) {
50
- var _ = {
51
- label: 0,
52
- sent: function() {
53
- if (t[0] & 1) throw t[1];
54
- return t[1];
55
- },
56
- trys: [],
57
- ops: []
58
- }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
59
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
60
- return this;
61
- }), g;
62
- function verb(n) {
63
- return function(v) {
64
- return step([n, v]);
65
- };
66
- }
67
- function step(op) {
68
- if (f) throw new TypeError("Generator is already executing.");
69
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
70
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
71
- if (y = 0, t) op = [op[0] & 2, t.value];
72
- switch (op[0]) {
73
- case 0:
74
- case 1:
75
- t = op;
76
- break;
77
- case 4:
78
- _.label++;
79
- return {
80
- value: op[1],
81
- done: false
82
- };
83
- case 5:
84
- _.label++;
85
- y = op[1];
86
- op = [0];
87
- continue;
88
- case 7:
89
- op = _.ops.pop();
90
- _.trys.pop();
91
- continue;
92
- default:
93
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
94
- _ = 0;
95
- continue;
96
- }
97
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
98
- _.label = op[1];
99
- break;
100
- }
101
- if (op[0] === 6 && _.label < t[1]) {
102
- _.label = t[1];
103
- t = op;
104
- break;
105
- }
106
- if (t && _.label < t[2]) {
107
- _.label = t[2];
108
- _.ops.push(op);
109
- break;
110
- }
111
- if (t[2]) _.ops.pop();
112
- _.trys.pop();
113
- continue;
114
- }
115
- op = body.call(thisArg, _);
116
- } catch (e) {
117
- op = [6, e];
118
- y = 0;
119
- } finally {
120
- f = t = 0;
121
- }
122
- if (op[0] & 5) throw op[1];
123
- return {
124
- value: op[0] ? op[1] : void 0,
125
- done: true
126
- };
127
- }
128
- };
129
- var _a = defineProps(), object = _a.object, id = _a.id;
130
- var client = inject(RpgClientEngine);
131
- var hooks = inject(ModulesToken);
132
- var guiService = inject(RpgGui);
18
+ useDefineEmits($$props);
19
+ const { object, id } = defineProps();
20
+ const sprite = object();
21
+ const client = inject(RpgClientEngine);
22
+ const hooks = inject(ModulesToken);
23
+ const guiService = inject(RpgGui);
133
24
  client.spritesheets;
134
- var playerId = client.playerId;
135
- var componentsBehind = client.spriteComponentsBehind;
136
- var componentsInFront = client.spriteComponentsInFront;
137
- var isMe = computed(function() {
138
- return id() === playerId;
25
+ const componentsBehind = client.spriteComponentsBehind;
26
+ const componentsInFront = client.spriteComponentsInFront;
27
+ const readProp = (value) => typeof value === "function" ? value() : value;
28
+ const isCurrentPlayer = () => {
29
+ const playerId = client.playerIdSignal();
30
+ const currentPlayer = playerId ? client.sceneMap?.players?.()?.[playerId] : void 0;
31
+ return readProp(id) === playerId || readProp(sprite?.id) === playerId || sprite === currentPlayer || sprite === client.sceneMap?.getCurrentPlayer?.();
32
+ };
33
+ const isMe = computed(isCurrentPlayer);
34
+ const shadowsEnabled = computed(() => {
35
+ const lighting = client.sceneMap?.lighting?.();
36
+ return shouldRenderLightingShadows(lighting);
139
37
  });
140
- var normalizeComponent = function(comp) {
141
- var componentRef;
142
- var propsValue;
143
- var dependenciesFn;
38
+ const normalizeComponent = (comp) => {
39
+ let componentRef;
40
+ let propsValue;
41
+ let dependenciesFn;
144
42
  if (typeof comp === "function" || comp && typeof comp === "object" && !comp.component) {
145
43
  componentRef = comp;
146
44
  propsValue = void 0;
@@ -156,40 +54,50 @@ function component($$props) {
156
54
  }
157
55
  return {
158
56
  component: componentRef,
159
- props: typeof propsValue === "function" ? propsValue(object) : propsValue || {},
160
- dependencies: dependenciesFn ? dependenciesFn(object) : []
57
+ props: typeof propsValue === "function" ? propsValue(sprite) : propsValue || {},
58
+ dependencies: dependenciesFn ? dependenciesFn(sprite) : []
161
59
  };
162
60
  };
163
- var normalizeComponents = function(components) {
164
- return components.map(function(comp) {
165
- return normalizeComponent(comp);
166
- });
61
+ const normalizeComponents = (components) => {
62
+ return components.map((comp) => normalizeComponent(comp));
167
63
  };
168
- var normalizedComponentsBehind = computed(function() {
64
+ const normalizedComponentsBehind = computed(() => {
169
65
  return normalizeComponents(componentsBehind());
170
66
  });
171
- var normalizedComponentsInFront = computed(function() {
67
+ const normalizedComponentsInFront = computed(() => {
172
68
  return normalizeComponents(componentsInFront());
173
69
  });
174
- var shouldFollowCamera = computed(function() {
175
- var cameraTargetId = client.cameraFollowTargetId();
70
+ const isEventSprite = () => {
71
+ return typeof sprite?.isEvent === "function" ? sprite.isEvent() : sprite?._type === "event";
72
+ };
73
+ const resolvedEventComponents = computed(() => {
74
+ if (!isEventSprite()) return [];
75
+ const eventComponent = normalizeEventComponent(client.resolveEventComponent(sprite), sprite);
76
+ return eventComponent ? [eventComponent] : [];
77
+ });
78
+ const shouldFollowCamera = computed(() => {
79
+ const cameraTargetId = client.cameraFollowTargetId();
176
80
  if (cameraTargetId !== null) return id() === cameraTargetId;
177
81
  return isMe();
178
82
  });
179
- var attachedGuis = computed(function() {
83
+ const attachedGuis = computed(() => {
180
84
  return guiService.getAttachedGuis();
181
85
  });
182
- var shouldDisplayAttachedGui = computed(function() {
86
+ const shouldDisplayAttachedGui = computed(() => {
183
87
  return guiService.shouldDisplayAttachedGui(id());
184
- }), x = object.x, y = object.y, tint = object.tint, direction = object.direction, animationName = object.animationName, animationCurrentIndex = object.animationCurrentIndex, emitParticleTrigger = object.emitParticleTrigger, particleName = object.particleName;
185
- object.graphics;
186
- var hitbox = object.hitbox, isConnected = object.isConnected, graphicsSignals = object.graphicsSignals, flashTrigger = object.flashTrigger;
187
- var flashType = signal("alpha");
188
- var flashDuration = signal(300);
189
- var flashCycles = signal(1);
190
- var flashAlpha = signal(.3);
191
- var flashTint = signal(16777215);
192
- on(flashTrigger, function(data) {
88
+ });
89
+ const { x, y, tint, direction, animationName, animationCurrentIndex, emitParticleTrigger, particleName, graphics, hitbox, isConnected, graphicsSignals, flashTrigger } = sprite;
90
+ const renderedGraphics = computed(() => {
91
+ const eventComponent = resolvedEventComponents()[0];
92
+ if (eventComponent && !eventComponent.renderGraphic) return [];
93
+ return graphicsSignals();
94
+ });
95
+ const flashType = signal("alpha");
96
+ const flashDuration = signal(300);
97
+ const flashCycles = signal(1);
98
+ const flashAlpha = signal(.3);
99
+ const flashTint = signal(16777215);
100
+ on(flashTrigger, (data) => {
193
101
  if (data && typeof data === "object") {
194
102
  if (data.type !== void 0) flashType.set(data.type);
195
103
  if (data.duration !== void 0) flashDuration.set(data.duration);
@@ -198,149 +106,558 @@ function component($$props) {
198
106
  if (data.tint !== void 0) flashTint.set(data.tint);
199
107
  }
200
108
  });
201
- var flashConfig = computed(function() {
109
+ const flashConfig = computed(() => ({
110
+ trigger: flashTrigger,
111
+ type: flashType(),
112
+ duration: flashDuration(),
113
+ cycles: flashCycles(),
114
+ alpha: flashAlpha(),
115
+ tint: flashTint()
116
+ }));
117
+ const particleSettings = client.particleSettings;
118
+ const canControls = () => isMe() && getCanMoveValue(sprite);
119
+ const keyboardControls = client.globalConfig.keyboardControls;
120
+ const activeDirectionKeys = /* @__PURE__ */ new Map();
121
+ const resolveHeldDirection = () => {
122
+ const directions = Array.from(activeDirectionKeys.values());
123
+ return directions[directions.length - 1];
124
+ };
125
+ const resolveSpriteDirection = () => {
126
+ const heldDirection = resolveHeldDirection();
127
+ if (heldDirection) return heldDirection;
128
+ if (typeof sprite.getDirection === "function") return sprite.getDirection();
129
+ if (typeof sprite.direction === "function") return sprite.direction();
130
+ return direction();
131
+ };
132
+ const directionToDashVector = (currentDirection) => {
133
+ switch (currentDirection) {
134
+ case Direction.Left: return {
135
+ x: -1,
136
+ y: 0
137
+ };
138
+ case Direction.Right: return {
139
+ x: 1,
140
+ y: 0
141
+ };
142
+ case Direction.Up: return {
143
+ x: 0,
144
+ y: -1
145
+ };
146
+ case Direction.Down:
147
+ default: return {
148
+ x: 0,
149
+ y: 1
150
+ };
151
+ }
152
+ };
153
+ const withCurrentDirection = (payload) => {
154
+ if (payload.action !== "action") return payload;
155
+ const data = payload.data && typeof payload.data === "object" ? { ...payload.data } : {};
202
156
  return {
203
- trigger: flashTrigger,
204
- type: flashType(),
205
- duration: flashDuration(),
206
- cycles: flashCycles(),
207
- alpha: flashAlpha(),
208
- tint: flashTint()
157
+ ...payload,
158
+ data: {
159
+ ...data,
160
+ direction: data.direction ?? resolveSpriteDirection()
161
+ }
209
162
  };
210
- });
211
- var particleSettings = client.particleSettings;
212
- var canControls = function() {
213
- return isMe() && object.canMove();
214
163
  };
215
- var keyboardControls = client.globalConfig.keyboardControls;
216
- var visible = computed(function() {
217
- if (object.isEvent()) return true;
164
+ const resolveCurrentActionInput = () => withCurrentDirection(resolveKeyboardActionInput(keyboardControls.action, client, sprite));
165
+ const playPredictedWalkAnimation = () => {
166
+ if (sprite.animationFixed) return;
167
+ if (sprite.animationIsPlaying && sprite.animationIsPlaying()) return;
168
+ realAnimationName.set("walk");
169
+ };
170
+ const resumeHeldDirectionWalkAnimation = () => {
171
+ if (!isCurrentPlayer()) return false;
172
+ if (activeDirectionKeys.size === 0) return false;
173
+ if (!canControls()) return false;
174
+ if (sprite.animationFixed) return false;
175
+ if (sprite.animationIsPlaying && sprite.animationIsPlaying()) return false;
176
+ realAnimationName.set("walk");
177
+ return true;
178
+ };
179
+ const processMovementInput = (input) => {
180
+ if (!canControls()) return;
181
+ client.processInput({ input });
182
+ playPredictedWalkAnimation();
183
+ };
184
+ const processDashInput = () => {
185
+ if (!canControls()) return;
186
+ client.processDash({ direction: directionToDashVector(resolveSpriteDirection()) });
187
+ };
188
+ const actionBind = () => getKeyboardControlBind(keyboardControls.action);
189
+ const keyboardEventId = (event) => `${event.keyCode}:${event.code}:${event.key}`;
190
+ const handleNativeActionWhileMoving = (event) => {
191
+ const inputDirection = resolveKeyboardDirectionInput(event, keyboardControls);
192
+ if (inputDirection) {
193
+ const keyId = keyboardEventId(event);
194
+ if (event.type === "keydown") {
195
+ activeDirectionKeys.delete(keyId);
196
+ activeDirectionKeys.set(keyId, inputDirection);
197
+ resumeHeldDirectionWalkAnimation();
198
+ } else activeDirectionKeys.delete(keyId);
199
+ }
200
+ if (!isCurrentPlayer()) return;
201
+ if (event.type !== "keydown" || event.repeat) return;
202
+ if (activeDirectionKeys.size === 0) return;
203
+ if (!keyboardEventMatchesBind(event, actionBind())) return;
204
+ if (!canControls()) return;
205
+ client.processAction(resolveCurrentActionInput());
206
+ };
207
+ const visible = computed(() => {
208
+ if (sprite.isEvent()) return true;
218
209
  return isConnected();
219
210
  });
220
- var controls = signal({
211
+ const controls = {
221
212
  down: {
222
213
  repeat: true,
223
214
  bind: keyboardControls.down,
224
- keyDown: function() {
225
- if (canControls()) client.processInput({ input: Direction.Down });
215
+ keyDown() {
216
+ processMovementInput(Direction.Down);
226
217
  }
227
218
  },
228
219
  up: {
229
220
  repeat: true,
230
221
  bind: keyboardControls.up,
231
- keyDown: function() {
232
- if (canControls()) client.processInput({ input: Direction.Up });
222
+ keyDown() {
223
+ processMovementInput(Direction.Up);
233
224
  }
234
225
  },
235
226
  left: {
236
227
  repeat: true,
237
228
  bind: keyboardControls.left,
238
- keyDown: function() {
239
- if (canControls()) client.processInput({ input: Direction.Left });
229
+ keyDown() {
230
+ processMovementInput(Direction.Left);
240
231
  }
241
232
  },
242
233
  right: {
243
234
  repeat: true,
244
235
  bind: keyboardControls.right,
245
- keyDown: function() {
246
- if (canControls()) client.processInput({ input: Direction.Right });
236
+ keyDown() {
237
+ processMovementInput(Direction.Right);
247
238
  }
248
239
  },
249
240
  action: {
250
- bind: keyboardControls.action,
251
- keyDown: function() {
252
- if (canControls()) client.processAction({ action: "action" });
241
+ bind: getKeyboardControlBind(keyboardControls.action),
242
+ keyDown() {
243
+ if (canControls()) client.processAction(resolveCurrentActionInput());
244
+ }
245
+ },
246
+ dash: {
247
+ bind: keyboardControls.dash,
248
+ keyDown() {
249
+ processDashInput();
253
250
  }
254
251
  },
255
252
  escape: {
256
253
  bind: keyboardControls.escape,
257
- keyDown: function() {
254
+ keyDown() {
258
255
  if (canControls()) client.processAction({ action: "escape" });
259
256
  }
260
257
  },
261
258
  gamepad: { enabled: true }
259
+ };
260
+ const smoothX = animatedSignal(x(), { duration: isMe() ? 0 : 0 });
261
+ const smoothY = animatedSignal(y(), { duration: isMe() ? 0 : 0 });
262
+ const z = computed(() => {
263
+ const box = hitbox?.();
264
+ return sprite.y() + (box?.h ?? 0) + sprite.z();
262
265
  });
263
- var smoothX = animatedSignal(x(), { duration: isMe() ? 0 : 0 });
264
- var smoothY = animatedSignal(y(), { duration: isMe() ? 0 : 0 });
265
- var z = computed(function() {
266
- return object.y() + object.z();
267
- });
268
- var realAnimationName = signal(animationName());
269
- var xSubscription = x.observable.subscribe(function(value) {
266
+ const realAnimationName = signal(animationName());
267
+ const xSubscription = x.observable.subscribe((value) => {
270
268
  smoothX.set(value);
271
269
  });
272
- var ySubscription = y.observable.subscribe(function(value) {
270
+ const ySubscription = y.observable.subscribe((value) => {
273
271
  smoothY.set(value);
274
272
  });
275
- var sheet = function(graphicObject) {
273
+ const sheet = (graphicObject) => {
276
274
  return {
277
275
  definition: graphicObject,
278
276
  playing: realAnimationName(),
279
277
  params: { direction: direction() },
280
- onFinish: function() {
281
- animationCurrentIndex.update(function(index) {
282
- return index + 1;
283
- });
278
+ onFinish() {
279
+ animationCurrentIndex.update((index) => index + 1);
284
280
  }
285
281
  };
286
282
  };
287
- var movementAnimations = ["walk", "stand"];
288
- var epsilon = 0;
289
- var stateX$ = smoothX.animatedState.observable;
290
- var stateY$ = smoothY.animatedState.observable;
291
- var animationName$ = animationName.observable;
292
- var moving$ = combineLatest([stateX$, stateY$]).pipe(map(function(_a) {
293
- var sx = _a[0], sy = _a[1];
294
- var xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;
295
- var yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;
283
+ const graphicScale = (graphicObject) => {
284
+ const scale = graphicObject?.displayScale ?? graphicObject?.scale;
285
+ if (Array.isArray(scale)) return scale;
286
+ if (typeof scale === "number") return [scale, scale];
287
+ if (scale && typeof scale === "object") {
288
+ const x = typeof scale.x === "number" ? scale.x : 1;
289
+ return [x, typeof scale.y === "number" ? scale.y : x];
290
+ }
291
+ };
292
+ const shadowCaster = (graphicObject) => {
293
+ const box = hitbox();
294
+ const bounds = graphicBounds();
295
+ const scale = graphicScale(graphicObject);
296
+ const scaleY = Array.isArray(scale) && typeof scale[1] === "number" ? Math.abs(scale[1]) : 1;
297
+ const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32) * scaleY;
298
+ return {
299
+ enabled: shadowsEnabled,
300
+ height,
301
+ footAnchor: {
302
+ x: .5,
303
+ y: 1
304
+ },
305
+ footOffset: {
306
+ x: 0,
307
+ y: 2
308
+ },
309
+ alpha: .5,
310
+ blur: 3.5,
311
+ gradientPower: 2,
312
+ hardness: .42,
313
+ minLength: Math.max(6, (box?.h ?? 32) * .25),
314
+ maxLength: Math.max(90, height * 1.8),
315
+ contactAlpha: .3,
316
+ contactScale: .3
317
+ };
318
+ };
319
+ const imageDimensions = signal({});
320
+ const loadingImageDimensions = /* @__PURE__ */ new Set();
321
+ const toPositiveNumber = (value) => {
322
+ const number = typeof value === "number" ? value : parseFloat(value);
323
+ return Number.isFinite(number) && number > 0 ? number : void 0;
324
+ };
325
+ const toFiniteNumber = (value, fallback = 0) => {
326
+ const number = typeof value === "number" ? value : parseFloat(value);
327
+ return Number.isFinite(number) ? number : fallback;
328
+ };
329
+ const clampRatio = (value) => Math.min(1, Math.max(0, value));
330
+ const normalizePair = (value, fallback = [1, 1]) => {
331
+ if (Array.isArray(value)) {
332
+ const x = toFiniteNumber(value[0], fallback[0]);
333
+ return [x, toFiniteNumber(value[1] ?? value[0], x)];
334
+ }
335
+ if (typeof value === "number") return [value, value];
336
+ if (value && typeof value === "object") {
337
+ const x = toFiniteNumber(value.x, fallback[0]);
338
+ return [x, toFiniteNumber(value.y ?? value.x, x)];
339
+ }
340
+ return fallback;
341
+ };
342
+ const normalizeAnchor = (value) => {
343
+ if (!Array.isArray(value)) return void 0;
344
+ const [x, y] = normalizePair(value, [0, 0]);
345
+ return [clampRatio(x), clampRatio(y)];
346
+ };
347
+ const resolveImageSource = (image) => {
348
+ if (typeof image === "string") return image;
349
+ if (typeof image?.default === "string") return image.default;
350
+ };
351
+ const parentTextureOptions = (graphicObject) => {
352
+ return [
353
+ "width",
354
+ "height",
355
+ "framesHeight",
356
+ "framesWidth",
357
+ "rectWidth",
358
+ "rectHeight",
359
+ "offset",
360
+ "image",
361
+ "sound",
362
+ "spriteRealSize",
363
+ "scale",
364
+ "anchor",
365
+ "pivot",
366
+ "x",
367
+ "y",
368
+ "opacity"
369
+ ].reduce((options, prop) => {
370
+ if (graphicObject?.[prop] !== void 0) options[prop] = graphicObject[prop];
371
+ return options;
372
+ }, {});
373
+ };
374
+ const resolveTextureOptions = (graphicObject) => {
375
+ const textures = graphicObject?.textures ?? {};
376
+ const texture = textures[realAnimationName()] ?? textures[Animation.Stand] ?? Object.values(textures)[0] ?? {};
377
+ return {
378
+ ...parentTextureOptions(graphicObject),
379
+ ...texture
380
+ };
381
+ };
382
+ const resolveFirstAnimationFrame = (textureOptions) => {
383
+ const animations = textureOptions?.animations;
384
+ if (!animations) return {};
385
+ try {
386
+ const frames = typeof animations === "function" ? animations({ direction: direction() }) : animations;
387
+ if (!Array.isArray(frames)) return {};
388
+ const firstGroup = frames[0];
389
+ return Array.isArray(firstGroup) ? firstGroup[0] ?? {} : firstGroup ?? {};
390
+ } catch {
391
+ return {};
392
+ }
393
+ };
394
+ const optionValue = (prop, frame, textureOptions, graphicObject) => {
395
+ return frame?.[prop] ?? textureOptions?.[prop] ?? graphicObject?.[prop];
396
+ };
397
+ const resolveFrameSize = (textureOptions, dimensions) => {
398
+ const framesWidth = toPositiveNumber(textureOptions?.framesWidth) ?? 1;
399
+ const framesHeight = toPositiveNumber(textureOptions?.framesHeight) ?? 1;
400
+ const imageSource = resolveImageSource(textureOptions?.image);
401
+ const loadedSize = imageSource ? dimensions[imageSource] : void 0;
402
+ const fullWidth = toPositiveNumber(textureOptions?.width) ?? loadedSize?.width;
403
+ const fullHeight = toPositiveNumber(textureOptions?.height) ?? loadedSize?.height;
404
+ return {
405
+ width: toPositiveNumber(textureOptions?.rectWidth) ?? toPositiveNumber(textureOptions?.spriteWidth) ?? (fullWidth ? fullWidth / framesWidth : void 0),
406
+ height: toPositiveNumber(textureOptions?.rectHeight) ?? toPositiveNumber(textureOptions?.spriteHeight) ?? (fullHeight ? fullHeight / framesHeight : void 0)
407
+ };
408
+ };
409
+ const resolveHitboxAnchor = (spriteWidth, spriteHeight, realSize, box) => {
410
+ if (!spriteWidth || !spriteHeight || !box) return [0, 0];
411
+ const resolvedHeight = toPositiveNumber(typeof realSize === "number" ? realSize : realSize?.height) ?? spriteHeight;
412
+ const gap = Math.max(0, (spriteHeight - resolvedHeight) / 2);
413
+ const hitboxTopLeftX = clampRatio((spriteWidth - box.w) / 2 / spriteWidth);
414
+ const hitboxTopLeftY = clampRatio((spriteHeight - box.h - gap) / spriteHeight);
415
+ const hitboxCenterX = clampRatio(hitboxTopLeftX + box.w / 2 / spriteWidth);
416
+ const hitboxCenterY = clampRatio(hitboxTopLeftY + box.h / 2 / spriteHeight);
417
+ const footY = clampRatio((spriteHeight - gap) / spriteHeight);
418
+ switch (box.anchorMode ?? "top-left") {
419
+ case "center": return [hitboxCenterX, hitboxCenterY];
420
+ case "foot": return [hitboxCenterX, footY];
421
+ default: return [hitboxTopLeftX, hitboxTopLeftY];
422
+ }
423
+ };
424
+ const loadImageDimensions = (image) => {
425
+ const source = resolveImageSource(image);
426
+ if (!source || imageDimensions()[source] || loadingImageDimensions.has(source)) return;
427
+ loadingImageDimensions.add(source);
428
+ Assets.load(source).then((texture) => {
429
+ const width = toPositiveNumber(texture?.width);
430
+ const height = toPositiveNumber(texture?.height);
431
+ if (!width || !height) return;
432
+ imageDimensions.update((dimensions) => ({
433
+ ...dimensions,
434
+ [source]: {
435
+ width,
436
+ height
437
+ }
438
+ }));
439
+ }).catch(() => {}).finally(() => {
440
+ loadingImageDimensions.delete(source);
441
+ });
442
+ };
443
+ effect(() => {
444
+ const sources = /* @__PURE__ */ new Set();
445
+ graphicsSignals().forEach((graphicObject) => {
446
+ const baseImage = resolveImageSource(graphicObject?.image);
447
+ if (baseImage) sources.add(baseImage);
448
+ Object.values(graphicObject?.textures ?? {}).forEach((textureOptions) => {
449
+ const image = resolveImageSource(textureOptions?.image ?? graphicObject?.image);
450
+ if (image) sources.add(image);
451
+ });
452
+ });
453
+ sources.forEach((source) => loadImageDimensions(source));
454
+ });
455
+ const hitboxBounds = computed(() => {
456
+ const box = hitbox();
457
+ const width = box?.w ?? 0;
458
+ const height = box?.h ?? 0;
459
+ return {
460
+ left: 0,
461
+ top: 0,
462
+ right: width,
463
+ bottom: height,
464
+ width,
465
+ height,
466
+ centerX: width / 2,
467
+ centerY: height / 2
468
+ };
469
+ });
470
+ const graphicBounds = computed(() => {
471
+ const box = hitbox();
472
+ const fallback = hitboxBounds();
473
+ const customEventComponent = resolvedEventComponents()[0];
474
+ if (customEventComponent && !customEventComponent.renderGraphic) return fallback;
475
+ const dimensions = imageDimensions();
476
+ const graphics = graphicsSignals();
477
+ let bounds = null;
478
+ graphics.forEach((graphicObject) => {
479
+ const textureOptions = resolveTextureOptions(graphicObject);
480
+ const frame = resolveFirstAnimationFrame(textureOptions);
481
+ const size = resolveFrameSize(textureOptions, dimensions);
482
+ const spriteWidth = size.width ?? box?.w;
483
+ const spriteHeight = size.height ?? box?.h;
484
+ if (!spriteWidth || !spriteHeight) return;
485
+ const anchor = normalizeAnchor(optionValue("anchor", frame, textureOptions, graphicObject)) ?? resolveHitboxAnchor(spriteWidth, spriteHeight, optionValue("spriteRealSize", frame, textureOptions, graphicObject), box);
486
+ const scale = normalizePair(optionValue("scale", frame, textureOptions, graphicObject) ?? graphicScale(graphicObject));
487
+ const x = toFiniteNumber(optionValue("x", frame, textureOptions, graphicObject), 0);
488
+ const y = toFiniteNumber(optionValue("y", frame, textureOptions, graphicObject), 0);
489
+ const leftEdge = -anchor[0] * spriteWidth * scale[0];
490
+ const rightEdge = (1 - anchor[0]) * spriteWidth * scale[0];
491
+ const topEdge = -anchor[1] * spriteHeight * scale[1];
492
+ const bottomEdge = (1 - anchor[1]) * spriteHeight * scale[1];
493
+ const graphic = {
494
+ left: x + Math.min(leftEdge, rightEdge),
495
+ top: y + Math.min(topEdge, bottomEdge),
496
+ right: x + Math.max(leftEdge, rightEdge),
497
+ bottom: y + Math.max(topEdge, bottomEdge)
498
+ };
499
+ bounds = bounds ? {
500
+ left: Math.min(bounds.left, graphic.left),
501
+ top: Math.min(bounds.top, graphic.top),
502
+ right: Math.max(bounds.right, graphic.right),
503
+ bottom: Math.max(bounds.bottom, graphic.bottom)
504
+ } : graphic;
505
+ });
506
+ if (!bounds) return fallback;
507
+ const width = bounds.right - bounds.left;
508
+ const height = bounds.bottom - bounds.top;
509
+ return {
510
+ ...bounds,
511
+ width,
512
+ height,
513
+ centerX: bounds.left + width / 2,
514
+ centerY: bounds.top + height / 2
515
+ };
516
+ });
517
+ const interactionBounds = () => ({
518
+ bounds: graphicBounds(),
519
+ hitbox: hitboxBounds(),
520
+ graphic: graphicBounds()
521
+ });
522
+ const interactionCursor = computed(() => client.interactions.cursorFor(sprite, interactionBounds()));
523
+ const handleInteraction = (type) => (event) => {
524
+ client.updatePointerFromInteractionEvent(event);
525
+ client.interactions.handle(sprite, type, {
526
+ event,
527
+ bounds: interactionBounds()
528
+ });
529
+ };
530
+ const interactionPointerOver = handleInteraction("pointerover");
531
+ const interactionPointerOut = handleInteraction("pointerout");
532
+ const interactionPointerDown = handleInteraction("pointerdown");
533
+ const interactionPointerUp = handleInteraction("pointerup");
534
+ const interactionPointerMove = handleInteraction("pointermove");
535
+ const interactionClick = handleInteraction("click");
536
+ const movementAnimations = ["walk", "stand"];
537
+ const epsilon = 0;
538
+ const stateX$ = smoothX.animatedState.observable;
539
+ const stateY$ = smoothY.animatedState.observable;
540
+ const animationName$ = animationName.observable;
541
+ const moving$ = combineLatest([stateX$, stateY$]).pipe(map(([sx, sy]) => {
542
+ const xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;
543
+ const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;
296
544
  return !xFinished || !yFinished;
297
545
  }), startWith(false));
298
- var animationMovementSubscription = combineLatest([animationName$.pipe(startWith(animationName()), pairwise(), filter(function(_a) {
299
- return _a[0] !== _a[1];
300
- })), moving$]).subscribe(function(_a) {
301
- var _b = _a[0];
302
- _b[0];
303
- var curr = _b[1], isMoving = _a[1];
304
- if (curr == "stand" && !isMoving) realAnimationName.set(curr);
305
- else if (curr == "walk" && isMoving) realAnimationName.set(curr);
306
- else if (!movementAnimations.includes(curr)) realAnimationName.set(curr);
307
- if (!isMoving && object.animationIsPlaying && object.animationIsPlaying()) {
308
- if (movementAnimations.includes(curr)) {
309
- if (typeof object.resetAnimationState === "function") object.resetAnimationState();
546
+ const animationChange$ = animationName$.pipe(startWith(animationName()), pairwise(), filter(([prev, curr]) => prev !== curr));
547
+ let beforeRemovePromise = null;
548
+ let beforeRemoveTransitionValue = null;
549
+ const resolveRemoveContext = () => {
550
+ if (!sprite._removeTransition) return null;
551
+ const value = sprite._removeTransition();
552
+ if (!value || typeof value !== "string") return null;
553
+ try {
554
+ const context = JSON.parse(value);
555
+ if (!context || typeof context !== "object" || !context.active) return null;
556
+ context.__transitionValue = value;
557
+ return context;
558
+ } catch {
559
+ return null;
560
+ }
561
+ };
562
+ const withTimeout = (promise, timeoutMs = 0) => {
563
+ if (!timeoutMs || timeoutMs <= 0) return promise;
564
+ return Promise.race([promise, new Promise((resolve) => setTimeout(resolve, timeoutMs))]);
565
+ };
566
+ const runBeforeRemove = () => {
567
+ const context = resolveRemoveContext();
568
+ if (!context) return Promise.resolve();
569
+ if (beforeRemovePromise && beforeRemoveTransitionValue === context.__transitionValue) return beforeRemovePromise;
570
+ beforeRemoveTransitionValue = context.__transitionValue;
571
+ beforeRemovePromise = withTimeout(lastValueFrom(hooks.callHooks("client-sprite-onBeforeRemove", sprite, context)), context.timeoutMs);
572
+ return beforeRemovePromise;
573
+ };
574
+ const removeTransitionSubscription = sprite._removeTransition?.observable?.subscribe(() => {
575
+ if (resolveRemoveContext()) runBeforeRemove();
576
+ });
577
+ const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {
578
+ const isMovementAnimation = movementAnimations.includes(curr);
579
+ const isTemporaryAnimationPlaying = sprite.animationIsPlaying && sprite.animationIsPlaying();
580
+ if (sprite.animationFixed && isMovementAnimation) {
581
+ realAnimationName.set(curr);
582
+ return;
583
+ }
584
+ if (curr == "stand" && !isMoving) {
585
+ if (!resumeHeldDirectionWalkAnimation()) realAnimationName.set(curr);
586
+ } else if (curr == "walk" && isMoving) realAnimationName.set(curr);
587
+ else if (!isMovementAnimation) realAnimationName.set(curr);
588
+ if (!isMoving && isTemporaryAnimationPlaying) {
589
+ if (isMovementAnimation) {
590
+ if (typeof sprite.resetAnimationState === "function") sprite.resetAnimationState();
310
591
  }
311
592
  }
312
593
  });
313
- var onBeforeDestroy = function() {
314
- return __awaiter(void 0, void 0, void 0, function() {
315
- return __generator(this, function(_a) {
316
- switch (_a.label) {
317
- case 0:
318
- animationMovementSubscription.unsubscribe();
319
- xSubscription.unsubscribe();
320
- ySubscription.unsubscribe();
321
- return [4, lastValueFrom(hooks.callHooks("client-sprite-onDestroy", object))];
322
- case 1:
323
- _a.sent();
324
- return [4, lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, object))];
325
- case 2:
326
- _a.sent();
327
- return [2];
328
- }
594
+ const resumeWalkSubscriptions = [
595
+ sprite._canMove,
596
+ sprite._animationFixed,
597
+ sprite.animationIsPlaying
598
+ ].filter((signal) => signal?.observable).map((signal) => signal.observable.subscribe(() => {
599
+ resumeHeldDirectionWalkAnimation();
600
+ }));
601
+ const waitForTemporaryAnimationEnd = (maxDuration = 1200) => {
602
+ if (!sprite.animationIsPlaying || !sprite.animationIsPlaying()) return Promise.resolve();
603
+ return new Promise((resolve) => {
604
+ let finished = false;
605
+ let timeout;
606
+ let subscription;
607
+ const finish = () => {
608
+ if (finished) return;
609
+ finished = true;
610
+ clearTimeout(timeout);
611
+ subscription?.unsubscribe();
612
+ resolve();
613
+ };
614
+ timeout = setTimeout(finish, maxDuration);
615
+ subscription = sprite.animationIsPlaying.observable.subscribe((isPlaying) => {
616
+ if (!isPlaying) finish();
329
617
  });
618
+ if (finished) subscription.unsubscribe();
330
619
  });
331
620
  };
332
- mount(function(element) {
333
- hooks.callHooks("client-sprite-onAdd", object).subscribe();
334
- hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, object).subscribe();
335
- if (isMe()) client.setKeyboardControls(element.directives.controls);
621
+ const onBeforeDestroy = async () => {
622
+ await runBeforeRemove();
623
+ await waitForTemporaryAnimationEnd();
624
+ if (typeof document !== "undefined") {
625
+ document.removeEventListener("keydown", handleNativeActionWhileMoving);
626
+ document.removeEventListener("keyup", handleNativeActionWhileMoving);
627
+ }
628
+ removeTransitionSubscription?.unsubscribe();
629
+ animationMovementSubscription.unsubscribe();
630
+ resumeWalkSubscriptions.forEach((subscription) => subscription.unsubscribe());
631
+ xSubscription.unsubscribe();
632
+ ySubscription.unsubscribe();
633
+ await lastValueFrom(hooks.callHooks("client-sprite-onDestroy", sprite));
634
+ await lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, sprite));
635
+ };
636
+ mount((element) => {
637
+ if (typeof document !== "undefined") {
638
+ document.addEventListener("keydown", handleNativeActionWhileMoving);
639
+ document.addEventListener("keyup", handleNativeActionWhileMoving);
640
+ }
641
+ hooks.callHooks("client-sprite-onAdd", sprite).subscribe();
642
+ hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, sprite).subscribe();
643
+ effect(() => {
644
+ if (isCurrentPlayer()) client.setKeyboardControls(element.directives.controls);
645
+ });
336
646
  });
337
- var onAttachedGuiFinish = function(gui, data) {
338
- guiService.guiClose(gui.name, data);
647
+ const normalizeOpenId = (value) => {
648
+ const resolved = typeof value === "function" ? value() : value;
649
+ return typeof resolved === "string" && resolved.length > 0 ? resolved : void 0;
650
+ };
651
+ const onAttachedGuiFinish = (gui, data, guiOpenId) => {
652
+ const completedOpenId = normalizeOpenId(guiOpenId);
653
+ const currentOpenId = normalizeOpenId(gui.openId);
654
+ if (completedOpenId && currentOpenId && completedOpenId !== currentOpenId) return;
655
+ guiService.guiClose(gui.name, data, completedOpenId ?? currentOpenId);
339
656
  };
340
- var onAttachedGuiInteraction = function(gui, name, data) {
657
+ const onAttachedGuiInteraction = (gui, name, data) => {
341
658
  guiService.guiInteraction(gui.name, name, data);
342
659
  };
343
- tick(function() {
660
+ tick(() => {
344
661
  hooks.callHooks("client-sprite-onUpdate").subscribe();
345
662
  });
346
663
  return h(Container, {
@@ -350,35 +667,75 @@ function component($$props) {
350
667
  viewportFollow: shouldFollowCamera,
351
668
  controls,
352
669
  onBeforeDestroy,
353
- visible
670
+ visible,
671
+ cursor: interactionCursor,
672
+ pointerover: interactionPointerOver,
673
+ pointerout: interactionPointerOut,
674
+ pointerdown: interactionPointerDown,
675
+ pointerup: interactionPointerUp,
676
+ pointermove: interactionPointerMove,
677
+ click: interactionClick
354
678
  }, [
355
679
  loop(normalizedComponentsBehind, (compConfig) => h(Container, null, h(compConfig.component, {
356
- object,
680
+ object: sprite,
357
681
  ...compConfig.props
358
682
  }))),
683
+ h(__ce_component$1, {
684
+ object: sprite,
685
+ position: "bottom",
686
+ graphicBounds
687
+ }),
688
+ h(__ce_component$1, {
689
+ object: sprite,
690
+ position: "left",
691
+ graphicBounds
692
+ }),
359
693
  h(Particle, {
360
694
  emit: emitParticleTrigger,
361
695
  settings: particleSettings,
362
696
  zIndex: 1e3,
363
697
  name: particleName
364
698
  }),
365
- h(Container, null, loop(graphicsSignals, (graphicObj) => h(Sprite, {
699
+ h(Container, null, [loop(renderedGraphics, (graphicObj) => h(Container, { scale: computed(() => graphicScale(graphicObj)) }, h(Sprite, {
366
700
  sheet: computed(() => sheet(graphicObj)),
367
701
  direction,
368
702
  tint,
369
703
  hitbox,
704
+ shadowCaster: computed(() => shadowCaster(graphicObj)),
370
705
  flash: flashConfig
371
- }))),
706
+ }))), loop(resolvedEventComponents, (eventComponent) => h(Container, { dependencies: eventComponent.dependencies }, h(eventComponent.component, eventComponent.props)))]),
707
+ h(__ce_component$1, {
708
+ object: sprite,
709
+ position: "center",
710
+ graphicBounds
711
+ }),
712
+ h(__ce_component$1, {
713
+ object: sprite,
714
+ position: "right",
715
+ graphicBounds
716
+ }),
717
+ h(__ce_component$1, {
718
+ object: sprite,
719
+ position: "top",
720
+ graphicBounds
721
+ }),
372
722
  loop(normalizedComponentsInFront, (compConfig) => h(Container, { dependencies: compConfig.dependencies }, h(compConfig.component, {
373
- object,
723
+ object: sprite,
374
724
  ...compConfig.props
375
725
  }))),
726
+ h(__ce_component$2, {
727
+ object: sprite,
728
+ bounds: graphicBounds,
729
+ hitboxBounds,
730
+ graphicBounds
731
+ }),
376
732
  loop(attachedGuis, (attachedGui) => cond(shouldDisplayAttachedGui, () => h(Container, null, h(attachedGui.component, {
377
733
  ...attachedGui.data(),
378
734
  dependencies: attachedGui.dependencies,
379
- object,
380
- onFinish: (data) => {
381
- onAttachedGuiFinish(attachedGui, data);
735
+ object: sprite,
736
+ guiOpenId: attachedGui.openId,
737
+ onFinish: (data, guiOpenId) => {
738
+ onAttachedGuiFinish(attachedGui, data, guiOpenId);
382
739
  },
383
740
  onInteraction: (name, data) => {
384
741
  onAttachedGuiInteraction(attachedGui, name, data);
@@ -386,7 +743,8 @@ function component($$props) {
386
743
  }))))
387
744
  ]);
388
745
  }
746
+ var __ce_component = component;
389
747
  //#endregion
390
- export { component as default };
748
+ export { __ce_component as default };
391
749
 
392
750
  //# sourceMappingURL=character.ce.js.map