@rpgjs/client 5.0.0-beta.1 → 5.0.0-beta.11

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 (245) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +19 -0
  3. package/dist/Game/AnimationManager.d.ts +1 -1
  4. package/dist/Game/AnimationManager.js +18 -9
  5. package/dist/Game/AnimationManager.js.map +1 -1
  6. package/dist/Game/AnimationManager.spec.d.ts +1 -0
  7. package/dist/Game/Event.js.map +1 -1
  8. package/dist/Game/Map.d.ts +9 -1
  9. package/dist/Game/Map.js +63 -5
  10. package/dist/Game/Map.js.map +1 -1
  11. package/dist/Game/Object.d.ts +47 -15
  12. package/dist/Game/Object.js +82 -38
  13. package/dist/Game/Object.js.map +1 -1
  14. package/dist/Game/Player.js.map +1 -1
  15. package/dist/Game/ProjectileManager.d.ts +89 -0
  16. package/dist/Game/ProjectileManager.js +179 -0
  17. package/dist/Game/ProjectileManager.js.map +1 -0
  18. package/dist/Game/ProjectileManager.spec.d.ts +1 -0
  19. package/dist/Gui/Gui.d.ts +17 -4
  20. package/dist/Gui/Gui.js +78 -48
  21. package/dist/Gui/Gui.js.map +1 -1
  22. package/dist/Gui/Gui.spec.d.ts +1 -0
  23. package/dist/Gui/NotificationManager.js.map +1 -1
  24. package/dist/Resource.js +1 -1
  25. package/dist/Resource.js.map +1 -1
  26. package/dist/RpgClient.d.ts +110 -15
  27. package/dist/RpgClientEngine.d.ts +86 -10
  28. package/dist/RpgClientEngine.js +306 -49
  29. package/dist/RpgClientEngine.js.map +1 -1
  30. package/dist/Sound.js.map +1 -1
  31. package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.130.0}/helpers/decorate.js +1 -1
  32. package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.130.0}/helpers/decorateMetadata.js +1 -1
  33. package/dist/components/animations/animation.ce.js +4 -5
  34. package/dist/components/animations/animation.ce.js.map +1 -1
  35. package/dist/components/animations/hit.ce.js +19 -25
  36. package/dist/components/animations/hit.ce.js.map +1 -1
  37. package/dist/components/animations/index.js +4 -4
  38. package/dist/components/animations/index.js.map +1 -1
  39. package/dist/components/character.ce.js +422 -240
  40. package/dist/components/character.ce.js.map +1 -1
  41. package/dist/components/dynamics/bar.ce.js +97 -0
  42. package/dist/components/dynamics/bar.ce.js.map +1 -0
  43. package/dist/components/dynamics/image.ce.js +24 -0
  44. package/dist/components/dynamics/image.ce.js.map +1 -0
  45. package/dist/components/dynamics/parse-value.d.ts +3 -0
  46. package/dist/components/dynamics/parse-value.js +54 -35
  47. package/dist/components/dynamics/parse-value.js.map +1 -1
  48. package/dist/components/dynamics/parse-value.spec.d.ts +1 -0
  49. package/dist/components/dynamics/shape-utils.d.ts +16 -0
  50. package/dist/components/dynamics/shape-utils.js +73 -0
  51. package/dist/components/dynamics/shape-utils.js.map +1 -0
  52. package/dist/components/dynamics/shape-utils.spec.d.ts +1 -0
  53. package/dist/components/dynamics/shape.ce.js +84 -0
  54. package/dist/components/dynamics/shape.ce.js.map +1 -0
  55. package/dist/components/dynamics/text.ce.js +34 -56
  56. package/dist/components/dynamics/text.ce.js.map +1 -1
  57. package/dist/components/gui/box.ce.js +6 -8
  58. package/dist/components/gui/box.ce.js.map +1 -1
  59. package/dist/components/gui/dialogbox/index.ce.js +56 -62
  60. package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
  61. package/dist/components/gui/gameover.ce.js +42 -65
  62. package/dist/components/gui/gameover.ce.js.map +1 -1
  63. package/dist/components/gui/hud/hud.ce.js +21 -30
  64. package/dist/components/gui/hud/hud.ce.js.map +1 -1
  65. package/dist/components/gui/menu/equip-menu.ce.js +112 -165
  66. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
  67. package/dist/components/gui/menu/exit-menu.ce.js +8 -6
  68. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
  69. package/dist/components/gui/menu/items-menu.ce.js +52 -69
  70. package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
  71. package/dist/components/gui/menu/main-menu.ce.js +75 -92
  72. package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
  73. package/dist/components/gui/menu/options-menu.ce.js +5 -4
  74. package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
  75. package/dist/components/gui/menu/skills-menu.ce.js +12 -17
  76. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
  77. package/dist/components/gui/mobile/index.js +2 -2
  78. package/dist/components/gui/mobile/index.js.map +1 -1
  79. package/dist/components/gui/mobile/mobile.ce.js +5 -4
  80. package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
  81. package/dist/components/gui/notification/notification.ce.js +22 -24
  82. package/dist/components/gui/notification/notification.ce.js.map +1 -1
  83. package/dist/components/gui/save-load.ce.js +72 -249
  84. package/dist/components/gui/save-load.ce.js.map +1 -1
  85. package/dist/components/gui/shop/shop.ce.js +90 -127
  86. package/dist/components/gui/shop/shop.ce.js.map +1 -1
  87. package/dist/components/gui/title-screen.ce.js +45 -70
  88. package/dist/components/gui/title-screen.ce.js.map +1 -1
  89. package/dist/components/index.d.ts +2 -1
  90. package/dist/components/index.js +1 -0
  91. package/dist/components/player-components-utils.d.ts +67 -0
  92. package/dist/components/player-components-utils.js +162 -0
  93. package/dist/components/player-components-utils.js.map +1 -0
  94. package/dist/components/player-components-utils.spec.d.ts +1 -0
  95. package/dist/components/player-components.ce.js +189 -0
  96. package/dist/components/player-components.ce.js.map +1 -0
  97. package/dist/components/prebuilt/hp-bar.ce.js +42 -44
  98. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
  99. package/dist/components/prebuilt/light-halo.ce.js +36 -59
  100. package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
  101. package/dist/components/scenes/canvas.ce.js +165 -21
  102. package/dist/components/scenes/canvas.ce.js.map +1 -1
  103. package/dist/components/scenes/draw-map.ce.js +25 -32
  104. package/dist/components/scenes/draw-map.ce.js.map +1 -1
  105. package/dist/components/scenes/event-layer.ce.js +9 -8
  106. package/dist/components/scenes/event-layer.ce.js.map +1 -1
  107. package/dist/core/inject.js +1 -1
  108. package/dist/core/inject.js.map +1 -1
  109. package/dist/core/setup.js +1 -1
  110. package/dist/core/setup.js.map +1 -1
  111. package/dist/decorators/spritesheet.d.ts +1 -0
  112. package/dist/decorators/spritesheet.js +11 -0
  113. package/dist/decorators/spritesheet.js.map +1 -0
  114. package/dist/index.d.ts +4 -0
  115. package/dist/index.js +26 -21
  116. package/dist/module.js +15 -1
  117. package/dist/module.js.map +1 -1
  118. package/dist/node_modules/.pnpm/{@signe_di@2.9.0 → @signe_di@3.0.1}/node_modules/@signe/di/dist/index.js +7 -117
  119. package/dist/node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js.map +1 -0
  120. package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js +239 -0
  121. package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js.map +1 -0
  122. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js +13 -0
  123. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +1 -0
  124. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js +696 -0
  125. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js.map +1 -0
  126. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js +44 -0
  127. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js.map +1 -0
  128. package/dist/node_modules/.pnpm/{@signe_sync@2.9.0 → @signe_sync@3.0.1}/node_modules/@signe/sync/dist/index.js +57 -141
  129. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js.map +1 -0
  130. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -1
  131. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
  132. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +27 -27
  133. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
  134. package/dist/presets/animation.js.map +1 -1
  135. package/dist/presets/faceset.js.map +1 -1
  136. package/dist/presets/icon.js.map +1 -1
  137. package/dist/presets/index.js.map +1 -1
  138. package/dist/presets/lpc.js.map +1 -1
  139. package/dist/presets/rmspritesheet.js.map +1 -1
  140. package/dist/services/AbstractSocket.js.map +1 -1
  141. package/dist/services/actionInput.d.ts +12 -0
  142. package/dist/services/actionInput.js +27 -0
  143. package/dist/services/actionInput.js.map +1 -0
  144. package/dist/services/actionInput.spec.d.ts +1 -0
  145. package/dist/services/keyboardControls.js.map +1 -1
  146. package/dist/services/loadMap.d.ts +6 -0
  147. package/dist/services/loadMap.js +1 -1
  148. package/dist/services/loadMap.js.map +1 -1
  149. package/dist/services/mmorpg-connection.d.ts +5 -0
  150. package/dist/services/mmorpg-connection.js +50 -0
  151. package/dist/services/mmorpg-connection.js.map +1 -0
  152. package/dist/services/mmorpg-connection.spec.d.ts +1 -0
  153. package/dist/services/mmorpg.d.ts +10 -4
  154. package/dist/services/mmorpg.js +56 -33
  155. package/dist/services/mmorpg.js.map +1 -1
  156. package/dist/services/pointerContext.d.ts +11 -0
  157. package/dist/services/pointerContext.js +48 -0
  158. package/dist/services/pointerContext.js.map +1 -0
  159. package/dist/services/pointerContext.spec.d.ts +1 -0
  160. package/dist/services/save.js.map +1 -1
  161. package/dist/services/save.spec.d.ts +1 -0
  162. package/dist/services/standalone-message.d.ts +1 -0
  163. package/dist/services/standalone-message.js +9 -0
  164. package/dist/services/standalone-message.js.map +1 -0
  165. package/dist/services/standalone.js +4 -3
  166. package/dist/services/standalone.js.map +1 -1
  167. package/dist/services/standalone.spec.d.ts +1 -0
  168. package/dist/utils/getEntityProp.js +4 -3
  169. package/dist/utils/getEntityProp.js.map +1 -1
  170. package/dist/utils/getEntityProp.spec.d.ts +1 -0
  171. package/dist/utils/readPropValue.d.ts +2 -0
  172. package/dist/utils/readPropValue.js +13 -0
  173. package/dist/utils/readPropValue.js.map +1 -0
  174. package/package.json +13 -14
  175. package/src/Game/AnimationManager.spec.ts +30 -0
  176. package/src/Game/AnimationManager.ts +22 -10
  177. package/src/Game/Map.ts +91 -2
  178. package/src/Game/Object.ts +148 -69
  179. package/src/Game/ProjectileManager.spec.ts +338 -0
  180. package/src/Game/ProjectileManager.ts +324 -0
  181. package/src/Gui/Gui.spec.ts +273 -0
  182. package/src/Gui/Gui.ts +105 -50
  183. package/src/Resource.ts +1 -2
  184. package/src/RpgClient.ts +125 -17
  185. package/src/RpgClientEngine.ts +457 -87
  186. package/src/components/character.ce +441 -32
  187. package/src/components/dynamics/bar.ce +88 -0
  188. package/src/components/dynamics/image.ce +21 -0
  189. package/src/components/dynamics/parse-value.spec.ts +83 -0
  190. package/src/components/dynamics/parse-value.ts +111 -37
  191. package/src/components/dynamics/shape-utils.spec.ts +46 -0
  192. package/src/components/dynamics/shape-utils.ts +61 -0
  193. package/src/components/dynamics/shape.ce +90 -0
  194. package/src/components/dynamics/text.ce +35 -149
  195. package/src/components/gui/dialogbox/index.ce +18 -8
  196. package/src/components/gui/gameover.ce +2 -1
  197. package/src/components/gui/menu/equip-menu.ce +2 -1
  198. package/src/components/gui/menu/exit-menu.ce +2 -1
  199. package/src/components/gui/menu/items-menu.ce +3 -2
  200. package/src/components/gui/menu/main-menu.ce +2 -1
  201. package/src/components/gui/save-load.ce +2 -1
  202. package/src/components/gui/shop/shop.ce +3 -2
  203. package/src/components/gui/title-screen.ce +2 -1
  204. package/src/components/index.ts +2 -1
  205. package/src/components/player-components-utils.spec.ts +109 -0
  206. package/src/components/player-components-utils.ts +205 -0
  207. package/src/components/player-components.ce +222 -0
  208. package/src/components/prebuilt/hp-bar.ce +4 -3
  209. package/src/components/prebuilt/light-halo.ce +2 -2
  210. package/src/components/scenes/canvas.ce +175 -8
  211. package/src/components/scenes/draw-map.ce +18 -17
  212. package/src/components/scenes/event-layer.ce +1 -2
  213. package/src/core/setup.ts +2 -2
  214. package/src/decorators/spritesheet.ts +8 -0
  215. package/src/index.ts +4 -0
  216. package/src/module.ts +18 -1
  217. package/src/services/actionInput.spec.ts +101 -0
  218. package/src/services/actionInput.ts +53 -0
  219. package/src/services/loadMap.ts +2 -0
  220. package/src/services/mmorpg-connection.spec.ts +99 -0
  221. package/src/services/mmorpg-connection.ts +69 -0
  222. package/src/services/mmorpg.ts +68 -36
  223. package/src/services/pointerContext.spec.ts +36 -0
  224. package/src/services/pointerContext.ts +84 -0
  225. package/src/services/save.spec.ts +127 -0
  226. package/src/services/standalone-message.ts +7 -0
  227. package/src/services/standalone.spec.ts +34 -0
  228. package/src/services/standalone.ts +3 -2
  229. package/src/utils/getEntityProp.spec.ts +96 -0
  230. package/src/utils/getEntityProp.ts +4 -3
  231. package/src/utils/readPropValue.ts +16 -0
  232. package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +0 -1
  233. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +0 -457
  234. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +0 -1
  235. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +0 -463
  236. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +0 -1
  237. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +0 -2191
  238. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +0 -1
  239. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +0 -10
  240. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +0 -1
  241. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +0 -91
  242. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +0 -1
  243. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +0 -1
  244. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +0 -14
  245. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +0 -1
@@ -1,146 +1,40 @@
1
1
  import { inject } from "../core/inject.js";
2
+ import { getKeyboardControlBind, resolveKeyboardActionInput } from "../services/actionInput.js";
3
+ import { getCanMoveValue } from "../utils/readPropValue.js";
2
4
  import { RpgGui } from "../Gui/Gui.js";
3
5
  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";
6
+ import __ce_component$1 from "./player-components.ce.js";
7
+ import { Container, Sprite, animatedSignal, computed, cond, effect, h, loop, mount, on, signal, tick, useDefineProps, useProps } from "canvasengine";
8
+ import { Animation, Direction, ModulesToken } from "@rpgjs/common";
7
9
  import { combineLatest, filter, lastValueFrom, map, pairwise, startWith } from "rxjs";
10
+ import { Particle } from "@canvasengine/presets";
11
+ import { Assets } from "pixi.js";
8
12
  //#region src/components/character.ce
9
13
  function component($$props) {
10
14
  useProps($$props);
11
- 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);
15
+ const { object, id } = useDefineProps($$props)();
16
+ const sprite = object();
17
+ const client = inject(RpgClientEngine);
18
+ const hooks = inject(ModulesToken);
19
+ const guiService = inject(RpgGui);
133
20
  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;
21
+ const componentsBehind = client.spriteComponentsBehind;
22
+ const componentsInFront = client.spriteComponentsInFront;
23
+ const readProp = (value) => typeof value === "function" ? value() : value;
24
+ const isCurrentPlayer = () => {
25
+ const playerId = client.playerIdSignal();
26
+ const currentPlayer = playerId ? client.sceneMap?.players?.()?.[playerId] : void 0;
27
+ return readProp(id) === playerId || readProp(sprite?.id) === playerId || sprite === currentPlayer || sprite === client.sceneMap?.getCurrentPlayer?.();
28
+ };
29
+ const isMe = computed(isCurrentPlayer);
30
+ const shadowsEnabled = computed(() => {
31
+ const lighting = client.sceneMap?.lighting?.();
32
+ return Boolean(lighting?.shadows?.enabled || (lighting?.spots?.length ?? 0) > 0);
139
33
  });
140
- var normalizeComponent = function(comp) {
141
- var componentRef;
142
- var propsValue;
143
- var dependenciesFn;
34
+ const normalizeComponent = (comp) => {
35
+ let componentRef;
36
+ let propsValue;
37
+ let dependenciesFn;
144
38
  if (typeof comp === "function" || comp && typeof comp === "object" && !comp.component) {
145
39
  componentRef = comp;
146
40
  propsValue = void 0;
@@ -156,40 +50,37 @@ function component($$props) {
156
50
  }
157
51
  return {
158
52
  component: componentRef,
159
- props: typeof propsValue === "function" ? propsValue(object) : propsValue || {},
160
- dependencies: dependenciesFn ? dependenciesFn(object) : []
53
+ props: typeof propsValue === "function" ? propsValue(sprite) : propsValue || {},
54
+ dependencies: dependenciesFn ? dependenciesFn(sprite) : []
161
55
  };
162
56
  };
163
- var normalizeComponents = function(components) {
164
- return components.map(function(comp) {
165
- return normalizeComponent(comp);
166
- });
57
+ const normalizeComponents = (components) => {
58
+ return components.map((comp) => normalizeComponent(comp));
167
59
  };
168
- var normalizedComponentsBehind = computed(function() {
60
+ const normalizedComponentsBehind = computed(() => {
169
61
  return normalizeComponents(componentsBehind());
170
62
  });
171
- var normalizedComponentsInFront = computed(function() {
63
+ const normalizedComponentsInFront = computed(() => {
172
64
  return normalizeComponents(componentsInFront());
173
65
  });
174
- var shouldFollowCamera = computed(function() {
175
- var cameraTargetId = client.cameraFollowTargetId();
66
+ const shouldFollowCamera = computed(() => {
67
+ const cameraTargetId = client.cameraFollowTargetId();
176
68
  if (cameraTargetId !== null) return id() === cameraTargetId;
177
69
  return isMe();
178
70
  });
179
- var attachedGuis = computed(function() {
71
+ const attachedGuis = computed(() => {
180
72
  return guiService.getAttachedGuis();
181
73
  });
182
- var shouldDisplayAttachedGui = computed(function() {
74
+ const shouldDisplayAttachedGui = computed(() => {
183
75
  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) {
76
+ });
77
+ const { x, y, tint, direction, animationName, animationCurrentIndex, emitParticleTrigger, particleName, graphics, hitbox, isConnected, graphicsSignals, flashTrigger } = sprite;
78
+ const flashType = signal("alpha");
79
+ const flashDuration = signal(300);
80
+ const flashCycles = signal(1);
81
+ const flashAlpha = signal(.3);
82
+ const flashTint = signal(16777215);
83
+ on(flashTrigger, (data) => {
193
84
  if (data && typeof data === "object") {
194
85
  if (data.type !== void 0) flashType.set(data.type);
195
86
  if (data.duration !== void 0) flashDuration.set(data.duration);
@@ -198,149 +89,413 @@ function component($$props) {
198
89
  if (data.tint !== void 0) flashTint.set(data.tint);
199
90
  }
200
91
  });
201
- var flashConfig = computed(function() {
202
- return {
203
- trigger: flashTrigger,
204
- type: flashType(),
205
- duration: flashDuration(),
206
- cycles: flashCycles(),
207
- alpha: flashAlpha(),
208
- tint: flashTint()
209
- };
210
- });
211
- var particleSettings = client.particleSettings;
212
- var canControls = function() {
213
- return isMe() && object.canMove();
214
- };
215
- var keyboardControls = client.globalConfig.keyboardControls;
216
- var visible = computed(function() {
217
- if (object.isEvent()) return true;
92
+ const flashConfig = computed(() => ({
93
+ trigger: flashTrigger,
94
+ type: flashType(),
95
+ duration: flashDuration(),
96
+ cycles: flashCycles(),
97
+ alpha: flashAlpha(),
98
+ tint: flashTint()
99
+ }));
100
+ const particleSettings = client.particleSettings;
101
+ const canControls = () => isMe() && getCanMoveValue(sprite);
102
+ const keyboardControls = client.globalConfig.keyboardControls;
103
+ const visible = computed(() => {
104
+ if (sprite.isEvent()) return true;
218
105
  return isConnected();
219
106
  });
220
- var controls = signal({
107
+ const controls = {
221
108
  down: {
222
109
  repeat: true,
223
110
  bind: keyboardControls.down,
224
- keyDown: function() {
111
+ keyDown() {
225
112
  if (canControls()) client.processInput({ input: Direction.Down });
226
113
  }
227
114
  },
228
115
  up: {
229
116
  repeat: true,
230
117
  bind: keyboardControls.up,
231
- keyDown: function() {
118
+ keyDown() {
232
119
  if (canControls()) client.processInput({ input: Direction.Up });
233
120
  }
234
121
  },
235
122
  left: {
236
123
  repeat: true,
237
124
  bind: keyboardControls.left,
238
- keyDown: function() {
125
+ keyDown() {
239
126
  if (canControls()) client.processInput({ input: Direction.Left });
240
127
  }
241
128
  },
242
129
  right: {
243
130
  repeat: true,
244
131
  bind: keyboardControls.right,
245
- keyDown: function() {
132
+ keyDown() {
246
133
  if (canControls()) client.processInput({ input: Direction.Right });
247
134
  }
248
135
  },
249
136
  action: {
250
- bind: keyboardControls.action,
251
- keyDown: function() {
252
- if (canControls()) client.processAction({ action: "action" });
137
+ bind: getKeyboardControlBind(keyboardControls.action),
138
+ keyDown() {
139
+ if (canControls()) client.processAction(resolveKeyboardActionInput(keyboardControls.action, client, sprite));
253
140
  }
254
141
  },
255
142
  escape: {
256
143
  bind: keyboardControls.escape,
257
- keyDown: function() {
144
+ keyDown() {
258
145
  if (canControls()) client.processAction({ action: "escape" });
259
146
  }
260
147
  },
261
148
  gamepad: { enabled: true }
149
+ };
150
+ const smoothX = animatedSignal(x(), { duration: isMe() ? 0 : 0 });
151
+ const smoothY = animatedSignal(y(), { duration: isMe() ? 0 : 0 });
152
+ const z = computed(() => {
153
+ return sprite.y() + sprite.z();
262
154
  });
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) {
155
+ const realAnimationName = signal(animationName());
156
+ const xSubscription = x.observable.subscribe((value) => {
270
157
  smoothX.set(value);
271
158
  });
272
- var ySubscription = y.observable.subscribe(function(value) {
159
+ const ySubscription = y.observable.subscribe((value) => {
273
160
  smoothY.set(value);
274
161
  });
275
- var sheet = function(graphicObject) {
162
+ const sheet = (graphicObject) => {
276
163
  return {
277
164
  definition: graphicObject,
278
165
  playing: realAnimationName(),
279
166
  params: { direction: direction() },
280
- onFinish: function() {
281
- animationCurrentIndex.update(function(index) {
282
- return index + 1;
283
- });
167
+ onFinish() {
168
+ animationCurrentIndex.update((index) => index + 1);
284
169
  }
285
170
  };
286
171
  };
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;
172
+ const graphicScale = (graphicObject) => {
173
+ const scale = graphicObject?.scale;
174
+ if (Array.isArray(scale)) return scale;
175
+ if (typeof scale === "number") return [scale, scale];
176
+ if (scale && typeof scale === "object") {
177
+ const x = typeof scale.x === "number" ? scale.x : 1;
178
+ return [x, typeof scale.y === "number" ? scale.y : x];
179
+ }
180
+ };
181
+ const shadowCaster = (graphicObject) => {
182
+ const box = hitbox();
183
+ const bounds = graphicBounds();
184
+ const scale = graphicScale(graphicObject);
185
+ const scaleY = Array.isArray(scale) && typeof scale[1] === "number" ? Math.abs(scale[1]) : 1;
186
+ const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32) * scaleY;
187
+ return {
188
+ enabled: shadowsEnabled,
189
+ height,
190
+ footAnchor: {
191
+ x: .5,
192
+ y: 1
193
+ },
194
+ footOffset: {
195
+ x: 0,
196
+ y: 2
197
+ },
198
+ alpha: .5,
199
+ blur: 3.5,
200
+ gradientPower: 2,
201
+ hardness: .42,
202
+ minLength: Math.max(6, (box?.h ?? 32) * .25),
203
+ maxLength: Math.max(90, height * 1.8),
204
+ contactAlpha: .3,
205
+ contactScale: .3
206
+ };
207
+ };
208
+ const imageDimensions = signal({});
209
+ const loadingImageDimensions = /* @__PURE__ */ new Set();
210
+ const toPositiveNumber = (value) => {
211
+ const number = typeof value === "number" ? value : parseFloat(value);
212
+ return Number.isFinite(number) && number > 0 ? number : void 0;
213
+ };
214
+ const toFiniteNumber = (value, fallback = 0) => {
215
+ const number = typeof value === "number" ? value : parseFloat(value);
216
+ return Number.isFinite(number) ? number : fallback;
217
+ };
218
+ const clampRatio = (value) => Math.min(1, Math.max(0, value));
219
+ const normalizePair = (value, fallback = [1, 1]) => {
220
+ if (Array.isArray(value)) {
221
+ const x = toFiniteNumber(value[0], fallback[0]);
222
+ return [x, toFiniteNumber(value[1] ?? value[0], x)];
223
+ }
224
+ if (typeof value === "number") return [value, value];
225
+ if (value && typeof value === "object") {
226
+ const x = toFiniteNumber(value.x, fallback[0]);
227
+ return [x, toFiniteNumber(value.y ?? value.x, x)];
228
+ }
229
+ return fallback;
230
+ };
231
+ const normalizeAnchor = (value) => {
232
+ if (!Array.isArray(value)) return void 0;
233
+ const [x, y] = normalizePair(value, [0, 0]);
234
+ return [clampRatio(x), clampRatio(y)];
235
+ };
236
+ const resolveImageSource = (image) => {
237
+ if (typeof image === "string") return image;
238
+ if (typeof image?.default === "string") return image.default;
239
+ };
240
+ const parentTextureOptions = (graphicObject) => {
241
+ return [
242
+ "width",
243
+ "height",
244
+ "framesHeight",
245
+ "framesWidth",
246
+ "rectWidth",
247
+ "rectHeight",
248
+ "offset",
249
+ "image",
250
+ "sound",
251
+ "spriteRealSize",
252
+ "scale",
253
+ "anchor",
254
+ "pivot",
255
+ "x",
256
+ "y",
257
+ "opacity"
258
+ ].reduce((options, prop) => {
259
+ if (graphicObject?.[prop] !== void 0) options[prop] = graphicObject[prop];
260
+ return options;
261
+ }, {});
262
+ };
263
+ const resolveTextureOptions = (graphicObject) => {
264
+ const textures = graphicObject?.textures ?? {};
265
+ const texture = textures[realAnimationName()] ?? textures[Animation.Stand] ?? Object.values(textures)[0] ?? {};
266
+ return {
267
+ ...parentTextureOptions(graphicObject),
268
+ ...texture
269
+ };
270
+ };
271
+ const resolveFirstAnimationFrame = (textureOptions) => {
272
+ const animations = textureOptions?.animations;
273
+ if (!animations) return {};
274
+ try {
275
+ const frames = typeof animations === "function" ? animations({ direction: direction() }) : animations;
276
+ if (!Array.isArray(frames)) return {};
277
+ const firstGroup = frames[0];
278
+ return Array.isArray(firstGroup) ? firstGroup[0] ?? {} : firstGroup ?? {};
279
+ } catch {
280
+ return {};
281
+ }
282
+ };
283
+ const optionValue = (prop, frame, textureOptions, graphicObject) => {
284
+ return frame?.[prop] ?? textureOptions?.[prop] ?? graphicObject?.[prop];
285
+ };
286
+ const resolveFrameSize = (textureOptions, dimensions) => {
287
+ const framesWidth = toPositiveNumber(textureOptions?.framesWidth) ?? 1;
288
+ const framesHeight = toPositiveNumber(textureOptions?.framesHeight) ?? 1;
289
+ const imageSource = resolveImageSource(textureOptions?.image);
290
+ const loadedSize = imageSource ? dimensions[imageSource] : void 0;
291
+ const fullWidth = toPositiveNumber(textureOptions?.width) ?? loadedSize?.width;
292
+ const fullHeight = toPositiveNumber(textureOptions?.height) ?? loadedSize?.height;
293
+ return {
294
+ width: toPositiveNumber(textureOptions?.rectWidth) ?? toPositiveNumber(textureOptions?.spriteWidth) ?? (fullWidth ? fullWidth / framesWidth : void 0),
295
+ height: toPositiveNumber(textureOptions?.rectHeight) ?? toPositiveNumber(textureOptions?.spriteHeight) ?? (fullHeight ? fullHeight / framesHeight : void 0)
296
+ };
297
+ };
298
+ const resolveHitboxAnchor = (spriteWidth, spriteHeight, realSize, box) => {
299
+ if (!spriteWidth || !spriteHeight || !box) return [0, 0];
300
+ const resolvedHeight = toPositiveNumber(typeof realSize === "number" ? realSize : realSize?.height) ?? spriteHeight;
301
+ const gap = Math.max(0, (spriteHeight - resolvedHeight) / 2);
302
+ const hitboxTopLeftX = clampRatio((spriteWidth - box.w) / 2 / spriteWidth);
303
+ const hitboxTopLeftY = clampRatio((spriteHeight - box.h - gap) / spriteHeight);
304
+ const hitboxCenterX = clampRatio(hitboxTopLeftX + box.w / 2 / spriteWidth);
305
+ const hitboxCenterY = clampRatio(hitboxTopLeftY + box.h / 2 / spriteHeight);
306
+ const footY = clampRatio((spriteHeight - gap) / spriteHeight);
307
+ switch (box.anchorMode ?? "top-left") {
308
+ case "center": return [hitboxCenterX, hitboxCenterY];
309
+ case "foot": return [hitboxCenterX, footY];
310
+ default: return [hitboxTopLeftX, hitboxTopLeftY];
311
+ }
312
+ };
313
+ const loadImageDimensions = (image) => {
314
+ const source = resolveImageSource(image);
315
+ if (!source || imageDimensions()[source] || loadingImageDimensions.has(source)) return;
316
+ loadingImageDimensions.add(source);
317
+ Assets.load(source).then((texture) => {
318
+ const width = toPositiveNumber(texture?.width);
319
+ const height = toPositiveNumber(texture?.height);
320
+ if (!width || !height) return;
321
+ imageDimensions.update((dimensions) => ({
322
+ ...dimensions,
323
+ [source]: {
324
+ width,
325
+ height
326
+ }
327
+ }));
328
+ }).catch(() => {}).finally(() => {
329
+ loadingImageDimensions.delete(source);
330
+ });
331
+ };
332
+ effect(() => {
333
+ const sources = /* @__PURE__ */ new Set();
334
+ graphicsSignals().forEach((graphicObject) => {
335
+ const baseImage = resolveImageSource(graphicObject?.image);
336
+ if (baseImage) sources.add(baseImage);
337
+ Object.values(graphicObject?.textures ?? {}).forEach((textureOptions) => {
338
+ const image = resolveImageSource(textureOptions?.image ?? graphicObject?.image);
339
+ if (image) sources.add(image);
340
+ });
341
+ });
342
+ sources.forEach((source) => loadImageDimensions(source));
343
+ });
344
+ const hitboxBounds = computed(() => {
345
+ const box = hitbox();
346
+ const width = box?.w ?? 0;
347
+ const height = box?.h ?? 0;
348
+ return {
349
+ left: 0,
350
+ top: 0,
351
+ right: width,
352
+ bottom: height,
353
+ width,
354
+ height,
355
+ centerX: width / 2,
356
+ centerY: height / 2
357
+ };
358
+ });
359
+ const graphicBounds = computed(() => {
360
+ const box = hitbox();
361
+ const fallback = hitboxBounds();
362
+ const dimensions = imageDimensions();
363
+ const graphics = graphicsSignals();
364
+ let bounds = null;
365
+ graphics.forEach((graphicObject) => {
366
+ const textureOptions = resolveTextureOptions(graphicObject);
367
+ const frame = resolveFirstAnimationFrame(textureOptions);
368
+ const size = resolveFrameSize(textureOptions, dimensions);
369
+ const spriteWidth = size.width ?? box?.w;
370
+ const spriteHeight = size.height ?? box?.h;
371
+ if (!spriteWidth || !spriteHeight) return;
372
+ const anchor = normalizeAnchor(optionValue("anchor", frame, textureOptions, graphicObject)) ?? resolveHitboxAnchor(spriteWidth, spriteHeight, optionValue("spriteRealSize", frame, textureOptions, graphicObject), box);
373
+ const scale = normalizePair(optionValue("scale", frame, textureOptions, graphicObject) ?? graphicScale(graphicObject));
374
+ const x = toFiniteNumber(optionValue("x", frame, textureOptions, graphicObject), 0);
375
+ const y = toFiniteNumber(optionValue("y", frame, textureOptions, graphicObject), 0);
376
+ const leftEdge = -anchor[0] * spriteWidth * scale[0];
377
+ const rightEdge = (1 - anchor[0]) * spriteWidth * scale[0];
378
+ const topEdge = -anchor[1] * spriteHeight * scale[1];
379
+ const bottomEdge = (1 - anchor[1]) * spriteHeight * scale[1];
380
+ const graphic = {
381
+ left: x + Math.min(leftEdge, rightEdge),
382
+ top: y + Math.min(topEdge, bottomEdge),
383
+ right: x + Math.max(leftEdge, rightEdge),
384
+ bottom: y + Math.max(topEdge, bottomEdge)
385
+ };
386
+ bounds = bounds ? {
387
+ left: Math.min(bounds.left, graphic.left),
388
+ top: Math.min(bounds.top, graphic.top),
389
+ right: Math.max(bounds.right, graphic.right),
390
+ bottom: Math.max(bounds.bottom, graphic.bottom)
391
+ } : graphic;
392
+ });
393
+ if (!bounds) return fallback;
394
+ const width = bounds.right - bounds.left;
395
+ const height = bounds.bottom - bounds.top;
396
+ return {
397
+ ...bounds,
398
+ width,
399
+ height,
400
+ centerX: bounds.left + width / 2,
401
+ centerY: bounds.top + height / 2
402
+ };
403
+ });
404
+ const movementAnimations = ["walk", "stand"];
405
+ const epsilon = 0;
406
+ const stateX$ = smoothX.animatedState.observable;
407
+ const stateY$ = smoothY.animatedState.observable;
408
+ const animationName$ = animationName.observable;
409
+ const moving$ = combineLatest([stateX$, stateY$]).pipe(map(([sx, sy]) => {
410
+ const xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;
411
+ const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;
296
412
  return !xFinished || !yFinished;
297
413
  }), 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];
414
+ const animationChange$ = animationName$.pipe(startWith(animationName()), pairwise(), filter(([prev, curr]) => prev !== curr));
415
+ let beforeRemovePromise = null;
416
+ let beforeRemoveTransitionValue = null;
417
+ const resolveRemoveContext = () => {
418
+ if (!sprite._removeTransition) return null;
419
+ const value = sprite._removeTransition();
420
+ if (!value || typeof value !== "string") return null;
421
+ try {
422
+ const context = JSON.parse(value);
423
+ if (!context || typeof context !== "object" || !context.active) return null;
424
+ context.__transitionValue = value;
425
+ return context;
426
+ } catch {
427
+ return null;
428
+ }
429
+ };
430
+ const withTimeout = (promise, timeoutMs = 0) => {
431
+ if (!timeoutMs || timeoutMs <= 0) return promise;
432
+ return Promise.race([promise, new Promise((resolve) => setTimeout(resolve, timeoutMs))]);
433
+ };
434
+ const runBeforeRemove = () => {
435
+ const context = resolveRemoveContext();
436
+ if (!context) return Promise.resolve();
437
+ if (beforeRemovePromise && beforeRemoveTransitionValue === context.__transitionValue) return beforeRemovePromise;
438
+ beforeRemoveTransitionValue = context.__transitionValue;
439
+ beforeRemovePromise = withTimeout(lastValueFrom(hooks.callHooks("client-sprite-onBeforeRemove", sprite, context)), context.timeoutMs);
440
+ return beforeRemovePromise;
441
+ };
442
+ const removeTransitionSubscription = sprite._removeTransition?.observable?.subscribe(() => {
443
+ if (resolveRemoveContext()) runBeforeRemove();
444
+ });
445
+ const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {
304
446
  if (curr == "stand" && !isMoving) realAnimationName.set(curr);
305
447
  else if (curr == "walk" && isMoving) realAnimationName.set(curr);
306
448
  else if (!movementAnimations.includes(curr)) realAnimationName.set(curr);
307
- if (!isMoving && object.animationIsPlaying && object.animationIsPlaying()) {
449
+ if (!isMoving && sprite.animationIsPlaying && sprite.animationIsPlaying()) {
308
450
  if (movementAnimations.includes(curr)) {
309
- if (typeof object.resetAnimationState === "function") object.resetAnimationState();
451
+ if (typeof sprite.resetAnimationState === "function") sprite.resetAnimationState();
310
452
  }
311
453
  }
312
454
  });
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
- }
455
+ const waitForTemporaryAnimationEnd = (maxDuration = 1200) => {
456
+ if (!sprite.animationIsPlaying || !sprite.animationIsPlaying()) return Promise.resolve();
457
+ return new Promise((resolve) => {
458
+ let finished = false;
459
+ let timeout;
460
+ let subscription;
461
+ const finish = () => {
462
+ if (finished) return;
463
+ finished = true;
464
+ clearTimeout(timeout);
465
+ subscription?.unsubscribe();
466
+ resolve();
467
+ };
468
+ timeout = setTimeout(finish, maxDuration);
469
+ subscription = sprite.animationIsPlaying.observable.subscribe((isPlaying) => {
470
+ if (!isPlaying) finish();
329
471
  });
472
+ if (finished) subscription.unsubscribe();
330
473
  });
331
474
  };
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);
475
+ const onBeforeDestroy = async () => {
476
+ await runBeforeRemove();
477
+ await waitForTemporaryAnimationEnd();
478
+ removeTransitionSubscription?.unsubscribe();
479
+ animationMovementSubscription.unsubscribe();
480
+ xSubscription.unsubscribe();
481
+ ySubscription.unsubscribe();
482
+ await lastValueFrom(hooks.callHooks("client-sprite-onDestroy", sprite));
483
+ await lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, sprite));
484
+ };
485
+ mount((element) => {
486
+ hooks.callHooks("client-sprite-onAdd", sprite).subscribe();
487
+ hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, sprite).subscribe();
488
+ effect(() => {
489
+ if (isCurrentPlayer()) client.setKeyboardControls(element.directives.controls);
490
+ });
336
491
  });
337
- var onAttachedGuiFinish = function(gui, data) {
492
+ const onAttachedGuiFinish = (gui, data) => {
338
493
  guiService.guiClose(gui.name, data);
339
494
  };
340
- var onAttachedGuiInteraction = function(gui, name, data) {
495
+ const onAttachedGuiInteraction = (gui, name, data) => {
341
496
  guiService.guiInteraction(gui.name, name, data);
342
497
  };
343
- tick(function() {
498
+ tick(() => {
344
499
  hooks.callHooks("client-sprite-onUpdate").subscribe();
345
500
  });
346
501
  return h(Container, {
@@ -353,30 +508,56 @@ function component($$props) {
353
508
  visible
354
509
  }, [
355
510
  loop(normalizedComponentsBehind, (compConfig) => h(Container, null, h(compConfig.component, {
356
- object,
511
+ object: sprite,
357
512
  ...compConfig.props
358
513
  }))),
514
+ h(__ce_component$1, {
515
+ object: sprite,
516
+ position: "bottom",
517
+ graphicBounds
518
+ }),
519
+ h(__ce_component$1, {
520
+ object: sprite,
521
+ position: "left",
522
+ graphicBounds
523
+ }),
359
524
  h(Particle, {
360
525
  emit: emitParticleTrigger,
361
526
  settings: particleSettings,
362
527
  zIndex: 1e3,
363
528
  name: particleName
364
529
  }),
365
- h(Container, null, loop(graphicsSignals, (graphicObj) => h(Sprite, {
530
+ h(Container, null, loop(graphicsSignals, (graphicObj) => h(Container, { scale: computed(() => graphicScale(graphicObj)) }, h(Sprite, {
366
531
  sheet: computed(() => sheet(graphicObj)),
367
532
  direction,
368
533
  tint,
369
534
  hitbox,
535
+ shadowCaster: computed(() => shadowCaster(graphicObj)),
370
536
  flash: flashConfig
371
- }))),
537
+ })))),
538
+ h(__ce_component$1, {
539
+ object: sprite,
540
+ position: "center",
541
+ graphicBounds
542
+ }),
543
+ h(__ce_component$1, {
544
+ object: sprite,
545
+ position: "right",
546
+ graphicBounds
547
+ }),
548
+ h(__ce_component$1, {
549
+ object: sprite,
550
+ position: "top",
551
+ graphicBounds
552
+ }),
372
553
  loop(normalizedComponentsInFront, (compConfig) => h(Container, { dependencies: compConfig.dependencies }, h(compConfig.component, {
373
- object,
554
+ object: sprite,
374
555
  ...compConfig.props
375
556
  }))),
376
557
  loop(attachedGuis, (attachedGui) => cond(shouldDisplayAttachedGui, () => h(Container, null, h(attachedGui.component, {
377
558
  ...attachedGui.data(),
378
559
  dependencies: attachedGui.dependencies,
379
- object,
560
+ object: sprite,
380
561
  onFinish: (data) => {
381
562
  onAttachedGuiFinish(attachedGui, data);
382
563
  },
@@ -386,7 +567,8 @@ function component($$props) {
386
567
  }))))
387
568
  ]);
388
569
  }
570
+ var __ce_component = component;
389
571
  //#endregion
390
- export { component as default };
572
+ export { __ce_component as default };
391
573
 
392
574
  //# sourceMappingURL=character.ce.js.map