@rpgjs/client 5.0.0-beta.10 → 5.0.0-beta.12

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 (154) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/Game/AnimationManager.d.ts +1 -0
  3. package/dist/Game/AnimationManager.js +3 -0
  4. package/dist/Game/AnimationManager.js.map +1 -1
  5. package/dist/Game/ClientVisuals.d.ts +61 -0
  6. package/dist/Game/ClientVisuals.js +96 -0
  7. package/dist/Game/ClientVisuals.js.map +1 -0
  8. package/dist/Game/ClientVisuals.spec.d.ts +1 -0
  9. package/dist/Game/EventComponentResolver.d.ts +16 -0
  10. package/dist/Game/EventComponentResolver.js +52 -0
  11. package/dist/Game/EventComponentResolver.js.map +1 -0
  12. package/dist/Game/EventComponentResolver.spec.d.ts +1 -0
  13. package/dist/Game/Map.js +9 -0
  14. package/dist/Game/Map.js.map +1 -1
  15. package/dist/Game/Object.js +2 -2
  16. package/dist/Game/Object.js.map +1 -1
  17. package/dist/Game/Object.spec.d.ts +1 -0
  18. package/dist/Game/ProjectileManager.d.ts +98 -0
  19. package/dist/Game/ProjectileManager.js +196 -0
  20. package/dist/Game/ProjectileManager.js.map +1 -0
  21. package/dist/Game/ProjectileManager.spec.d.ts +1 -0
  22. package/dist/RpgClient.d.ts +117 -13
  23. package/dist/RpgClientEngine.d.ts +82 -4
  24. package/dist/RpgClientEngine.js +296 -51
  25. package/dist/RpgClientEngine.js.map +1 -1
  26. package/dist/components/animations/fx.ce.js +58 -0
  27. package/dist/components/animations/fx.ce.js.map +1 -0
  28. package/dist/components/animations/hit.ce.js.map +1 -1
  29. package/dist/components/animations/index.d.ts +1 -0
  30. package/dist/components/animations/index.js +3 -1
  31. package/dist/components/animations/index.js.map +1 -1
  32. package/dist/components/character.ce.js +140 -40
  33. package/dist/components/character.ce.js.map +1 -1
  34. package/dist/components/dynamics/bar.ce.js +4 -3
  35. package/dist/components/dynamics/bar.ce.js.map +1 -1
  36. package/dist/components/dynamics/image.ce.js +2 -1
  37. package/dist/components/dynamics/image.ce.js.map +1 -1
  38. package/dist/components/dynamics/shape.ce.js +3 -2
  39. package/dist/components/dynamics/shape.ce.js.map +1 -1
  40. package/dist/components/dynamics/text.ce.js +9 -8
  41. package/dist/components/dynamics/text.ce.js.map +1 -1
  42. package/dist/components/gui/dialogbox/index.ce.js +3 -2
  43. package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
  44. package/dist/components/gui/gameover.ce.js +3 -2
  45. package/dist/components/gui/gameover.ce.js.map +1 -1
  46. package/dist/components/gui/hud/hud.ce.js.map +1 -1
  47. package/dist/components/gui/menu/equip-menu.ce.js +2 -1
  48. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
  49. package/dist/components/gui/menu/exit-menu.ce.js +2 -1
  50. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
  51. package/dist/components/gui/menu/items-menu.ce.js +3 -2
  52. package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
  53. package/dist/components/gui/menu/main-menu.ce.js +3 -2
  54. package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
  55. package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
  56. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
  57. package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
  58. package/dist/components/gui/notification/notification.ce.js.map +1 -1
  59. package/dist/components/gui/save-load.ce.js +2 -1
  60. package/dist/components/gui/save-load.ce.js.map +1 -1
  61. package/dist/components/gui/shop/shop.ce.js +3 -2
  62. package/dist/components/gui/shop/shop.ce.js.map +1 -1
  63. package/dist/components/gui/title-screen.ce.js +3 -2
  64. package/dist/components/gui/title-screen.ce.js.map +1 -1
  65. package/dist/components/index.d.ts +2 -1
  66. package/dist/components/index.js +1 -0
  67. package/dist/components/player-components.ce.js +11 -10
  68. package/dist/components/player-components.ce.js.map +1 -1
  69. package/dist/components/prebuilt/hp-bar.ce.js +4 -3
  70. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
  71. package/dist/components/prebuilt/light-halo.ce.js +2 -1
  72. package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
  73. package/dist/components/scenes/canvas.ce.js +12 -4
  74. package/dist/components/scenes/canvas.ce.js.map +1 -1
  75. package/dist/components/scenes/draw-map.ce.js +6 -3
  76. package/dist/components/scenes/draw-map.ce.js.map +1 -1
  77. package/dist/components/scenes/event-layer.ce.js.map +1 -1
  78. package/dist/index.d.ts +4 -0
  79. package/dist/index.js +10 -5
  80. package/dist/module.js +18 -0
  81. package/dist/module.js.map +1 -1
  82. package/dist/services/actionInput.d.ts +14 -0
  83. package/dist/services/actionInput.js +59 -0
  84. package/dist/services/actionInput.js.map +1 -0
  85. package/dist/services/actionInput.spec.d.ts +1 -0
  86. package/dist/services/mmorpg-connection.d.ts +5 -0
  87. package/dist/services/mmorpg-connection.js +50 -0
  88. package/dist/services/mmorpg-connection.js.map +1 -0
  89. package/dist/services/mmorpg-connection.spec.d.ts +1 -0
  90. package/dist/services/mmorpg.d.ts +10 -4
  91. package/dist/services/mmorpg.js +48 -30
  92. package/dist/services/mmorpg.js.map +1 -1
  93. package/dist/services/pointerContext.d.ts +11 -0
  94. package/dist/services/pointerContext.js +48 -0
  95. package/dist/services/pointerContext.js.map +1 -0
  96. package/dist/services/pointerContext.spec.d.ts +1 -0
  97. package/dist/services/standalone-message.d.ts +1 -0
  98. package/dist/services/standalone-message.js +9 -0
  99. package/dist/services/standalone-message.js.map +1 -0
  100. package/dist/services/standalone.d.ts +3 -1
  101. package/dist/services/standalone.js +34 -15
  102. package/dist/services/standalone.js.map +1 -1
  103. package/dist/services/standalone.spec.d.ts +1 -0
  104. package/dist/utils/mapId.d.ts +1 -0
  105. package/dist/utils/mapId.js +6 -0
  106. package/dist/utils/mapId.js.map +1 -0
  107. package/package.json +7 -7
  108. package/src/Game/AnimationManager.ts +4 -0
  109. package/src/Game/ClientVisuals.spec.ts +56 -0
  110. package/src/Game/ClientVisuals.ts +184 -0
  111. package/src/Game/EventComponentResolver.spec.ts +84 -0
  112. package/src/Game/EventComponentResolver.ts +74 -0
  113. package/src/Game/Map.ts +10 -0
  114. package/src/Game/Object.spec.ts +46 -0
  115. package/src/Game/Object.ts +2 -2
  116. package/src/Game/ProjectileManager.spec.ts +449 -0
  117. package/src/Game/ProjectileManager.ts +346 -0
  118. package/src/RpgClient.ts +130 -15
  119. package/src/RpgClientEngine.ts +405 -69
  120. package/src/components/animations/fx.ce +101 -0
  121. package/src/components/animations/index.ts +4 -2
  122. package/src/components/character.ce +185 -40
  123. package/src/components/dynamics/bar.ce +4 -3
  124. package/src/components/dynamics/image.ce +2 -1
  125. package/src/components/dynamics/shape.ce +3 -2
  126. package/src/components/dynamics/text.ce +9 -8
  127. package/src/components/gui/dialogbox/index.ce +3 -2
  128. package/src/components/gui/gameover.ce +2 -1
  129. package/src/components/gui/menu/equip-menu.ce +2 -1
  130. package/src/components/gui/menu/exit-menu.ce +2 -1
  131. package/src/components/gui/menu/items-menu.ce +3 -2
  132. package/src/components/gui/menu/main-menu.ce +2 -1
  133. package/src/components/gui/save-load.ce +2 -1
  134. package/src/components/gui/shop/shop.ce +3 -2
  135. package/src/components/gui/title-screen.ce +2 -1
  136. package/src/components/index.ts +2 -1
  137. package/src/components/player-components.ce +11 -10
  138. package/src/components/prebuilt/hp-bar.ce +4 -3
  139. package/src/components/prebuilt/light-halo.ce +2 -2
  140. package/src/components/scenes/canvas.ce +10 -2
  141. package/src/components/scenes/draw-map.ce +17 -3
  142. package/src/index.ts +4 -0
  143. package/src/module.ts +24 -0
  144. package/src/services/actionInput.spec.ts +155 -0
  145. package/src/services/actionInput.ts +120 -0
  146. package/src/services/mmorpg-connection.spec.ts +99 -0
  147. package/src/services/mmorpg-connection.ts +69 -0
  148. package/src/services/mmorpg.ts +60 -34
  149. package/src/services/pointerContext.spec.ts +36 -0
  150. package/src/services/pointerContext.ts +84 -0
  151. package/src/services/standalone-message.ts +7 -0
  152. package/src/services/standalone.spec.ts +34 -0
  153. package/src/services/standalone.ts +42 -12
  154. package/src/utils/mapId.ts +2 -0
@@ -1,17 +1,20 @@
1
1
  import { inject } from "../core/inject.js";
2
+ import { getKeyboardControlBind, keyboardEventMatchesBind, resolveKeyboardActionInput, resolveKeyboardDirectionInput } from "../services/actionInput.js";
2
3
  import { getCanMoveValue } from "../utils/readPropValue.js";
3
4
  import { RpgGui } from "../Gui/Gui.js";
5
+ import { normalizeEventComponent } from "../Game/EventComponentResolver.js";
4
6
  import { RpgClientEngine } from "../RpgClientEngine.js";
5
7
  import __ce_component$1 from "./player-components.ce.js";
6
8
  import { Container, Sprite, animatedSignal, computed, cond, effect, h, loop, mount, on, signal, tick, useDefineProps, useProps } from "canvasengine";
7
- import { Particle } from "@canvasengine/presets";
8
9
  import { Animation, Direction, ModulesToken } from "@rpgjs/common";
9
10
  import { combineLatest, filter, lastValueFrom, map, pairwise, startWith } from "rxjs";
11
+ import { Particle } from "@canvasengine/presets";
10
12
  import { Assets } from "pixi.js";
11
13
  //#region src/components/character.ce
12
14
  function component($$props) {
13
15
  useProps($$props);
14
16
  const { object, id } = useDefineProps($$props)();
17
+ const sprite = object();
15
18
  const client = inject(RpgClientEngine);
16
19
  const hooks = inject(ModulesToken);
17
20
  const guiService = inject(RpgGui);
@@ -22,7 +25,7 @@ function component($$props) {
22
25
  const isCurrentPlayer = () => {
23
26
  const playerId = client.playerIdSignal();
24
27
  const currentPlayer = playerId ? client.sceneMap?.players?.()?.[playerId] : void 0;
25
- return readProp(id) === playerId || readProp(object?.id) === playerId || object === currentPlayer || object === client.sceneMap?.getCurrentPlayer?.();
28
+ return readProp(id) === playerId || readProp(sprite?.id) === playerId || sprite === currentPlayer || sprite === client.sceneMap?.getCurrentPlayer?.();
26
29
  };
27
30
  const isMe = computed(isCurrentPlayer);
28
31
  const shadowsEnabled = computed(() => {
@@ -48,8 +51,8 @@ function component($$props) {
48
51
  }
49
52
  return {
50
53
  component: componentRef,
51
- props: typeof propsValue === "function" ? propsValue(object) : propsValue || {},
52
- dependencies: dependenciesFn ? dependenciesFn(object) : []
54
+ props: typeof propsValue === "function" ? propsValue(sprite) : propsValue || {},
55
+ dependencies: dependenciesFn ? dependenciesFn(sprite) : []
53
56
  };
54
57
  };
55
58
  const normalizeComponents = (components) => {
@@ -61,6 +64,14 @@ function component($$props) {
61
64
  const normalizedComponentsInFront = computed(() => {
62
65
  return normalizeComponents(componentsInFront());
63
66
  });
67
+ const isEventSprite = () => {
68
+ return typeof sprite?.isEvent === "function" ? sprite.isEvent() : sprite?._type === "event";
69
+ };
70
+ const resolvedEventComponents = computed(() => {
71
+ if (!isEventSprite()) return [];
72
+ const eventComponent = normalizeEventComponent(client.resolveEventComponent(sprite), sprite);
73
+ return eventComponent ? [eventComponent] : [];
74
+ });
64
75
  const shouldFollowCamera = computed(() => {
65
76
  const cameraTargetId = client.cameraFollowTargetId();
66
77
  if (cameraTargetId !== null) return id() === cameraTargetId;
@@ -72,7 +83,12 @@ function component($$props) {
72
83
  const shouldDisplayAttachedGui = computed(() => {
73
84
  return guiService.shouldDisplayAttachedGui(id());
74
85
  });
75
- const { x, y, tint, direction, animationName, animationCurrentIndex, emitParticleTrigger, particleName, graphics, hitbox, isConnected, graphicsSignals, flashTrigger } = object;
86
+ const { x, y, tint, direction, animationName, animationCurrentIndex, emitParticleTrigger, particleName, graphics, hitbox, isConnected, graphicsSignals, flashTrigger } = sprite;
87
+ const renderedGraphics = computed(() => {
88
+ const eventComponent = resolvedEventComponents()[0];
89
+ if (eventComponent && !eventComponent.renderGraphic) return [];
90
+ return graphicsSignals();
91
+ });
76
92
  const flashType = signal("alpha");
77
93
  const flashDuration = signal(300);
78
94
  const flashCycles = signal(1);
@@ -96,10 +112,72 @@ function component($$props) {
96
112
  tint: flashTint()
97
113
  }));
98
114
  const particleSettings = client.particleSettings;
99
- const canControls = () => isMe() && getCanMoveValue(object);
115
+ const canControls = () => isMe() && getCanMoveValue(sprite);
100
116
  const keyboardControls = client.globalConfig.keyboardControls;
117
+ const activeDirectionKeys = /* @__PURE__ */ new Map();
118
+ const resolveHeldDirection = () => {
119
+ const directions = Array.from(activeDirectionKeys.values());
120
+ return directions[directions.length - 1];
121
+ };
122
+ const resolveSpriteDirection = () => {
123
+ const heldDirection = resolveHeldDirection();
124
+ if (heldDirection) return heldDirection;
125
+ if (typeof sprite.getDirection === "function") return sprite.getDirection();
126
+ if (typeof sprite.direction === "function") return sprite.direction();
127
+ return direction();
128
+ };
129
+ const withCurrentDirection = (payload) => {
130
+ if (payload.action !== "action") return payload;
131
+ const data = payload.data && typeof payload.data === "object" ? { ...payload.data } : {};
132
+ return {
133
+ ...payload,
134
+ data: {
135
+ ...data,
136
+ direction: data.direction ?? resolveSpriteDirection()
137
+ }
138
+ };
139
+ };
140
+ const resolveCurrentActionInput = () => withCurrentDirection(resolveKeyboardActionInput(keyboardControls.action, client, sprite));
141
+ const playPredictedWalkAnimation = () => {
142
+ if (sprite.animationFixed) return;
143
+ if (sprite.animationIsPlaying && sprite.animationIsPlaying()) return;
144
+ realAnimationName.set("walk");
145
+ };
146
+ const resumeHeldDirectionWalkAnimation = () => {
147
+ if (!isCurrentPlayer()) return false;
148
+ if (activeDirectionKeys.size === 0) return false;
149
+ if (!canControls()) return false;
150
+ if (sprite.animationFixed) return false;
151
+ if (sprite.animationIsPlaying && sprite.animationIsPlaying()) return false;
152
+ realAnimationName.set("walk");
153
+ return true;
154
+ };
155
+ const processMovementInput = (input) => {
156
+ if (!canControls()) return;
157
+ client.processInput({ input });
158
+ playPredictedWalkAnimation();
159
+ };
160
+ const actionBind = () => getKeyboardControlBind(keyboardControls.action);
161
+ const keyboardEventId = (event) => `${event.keyCode}:${event.code}:${event.key}`;
162
+ const handleNativeActionWhileMoving = (event) => {
163
+ const inputDirection = resolveKeyboardDirectionInput(event, keyboardControls);
164
+ if (inputDirection) {
165
+ const keyId = keyboardEventId(event);
166
+ if (event.type === "keydown") {
167
+ activeDirectionKeys.delete(keyId);
168
+ activeDirectionKeys.set(keyId, inputDirection);
169
+ resumeHeldDirectionWalkAnimation();
170
+ } else activeDirectionKeys.delete(keyId);
171
+ }
172
+ if (!isCurrentPlayer()) return;
173
+ if (event.type !== "keydown" || event.repeat) return;
174
+ if (activeDirectionKeys.size === 0) return;
175
+ if (!keyboardEventMatchesBind(event, actionBind())) return;
176
+ if (!canControls()) return;
177
+ client.processAction(resolveCurrentActionInput());
178
+ };
101
179
  const visible = computed(() => {
102
- if (object.isEvent()) return true;
180
+ if (sprite.isEvent()) return true;
103
181
  return isConnected();
104
182
  });
105
183
  const controls = {
@@ -107,34 +185,34 @@ function component($$props) {
107
185
  repeat: true,
108
186
  bind: keyboardControls.down,
109
187
  keyDown() {
110
- if (canControls()) client.processInput({ input: Direction.Down });
188
+ processMovementInput(Direction.Down);
111
189
  }
112
190
  },
113
191
  up: {
114
192
  repeat: true,
115
193
  bind: keyboardControls.up,
116
194
  keyDown() {
117
- if (canControls()) client.processInput({ input: Direction.Up });
195
+ processMovementInput(Direction.Up);
118
196
  }
119
197
  },
120
198
  left: {
121
199
  repeat: true,
122
200
  bind: keyboardControls.left,
123
201
  keyDown() {
124
- if (canControls()) client.processInput({ input: Direction.Left });
202
+ processMovementInput(Direction.Left);
125
203
  }
126
204
  },
127
205
  right: {
128
206
  repeat: true,
129
207
  bind: keyboardControls.right,
130
208
  keyDown() {
131
- if (canControls()) client.processInput({ input: Direction.Right });
209
+ processMovementInput(Direction.Right);
132
210
  }
133
211
  },
134
212
  action: {
135
- bind: keyboardControls.action,
213
+ bind: getKeyboardControlBind(keyboardControls.action),
136
214
  keyDown() {
137
- if (canControls()) client.processAction({ action: "action" });
215
+ if (canControls()) client.processAction(resolveCurrentActionInput());
138
216
  }
139
217
  },
140
218
  escape: {
@@ -148,7 +226,7 @@ function component($$props) {
148
226
  const smoothX = animatedSignal(x(), { duration: isMe() ? 0 : 0 });
149
227
  const smoothY = animatedSignal(y(), { duration: isMe() ? 0 : 0 });
150
228
  const z = computed(() => {
151
- return object.y() + object.z();
229
+ return sprite.y() + sprite.z();
152
230
  });
153
231
  const realAnimationName = signal(animationName());
154
232
  const xSubscription = x.observable.subscribe((value) => {
@@ -357,6 +435,8 @@ function component($$props) {
357
435
  const graphicBounds = computed(() => {
358
436
  const box = hitbox();
359
437
  const fallback = hitboxBounds();
438
+ const customEventComponent = resolvedEventComponents()[0];
439
+ if (customEventComponent && !customEventComponent.renderGraphic) return fallback;
360
440
  const dimensions = imageDimensions();
361
441
  const graphics = graphicsSignals();
362
442
  let bounds = null;
@@ -413,8 +493,8 @@ function component($$props) {
413
493
  let beforeRemovePromise = null;
414
494
  let beforeRemoveTransitionValue = null;
415
495
  const resolveRemoveContext = () => {
416
- if (!object._removeTransition) return null;
417
- const value = object._removeTransition();
496
+ if (!sprite._removeTransition) return null;
497
+ const value = sprite._removeTransition();
418
498
  if (!value || typeof value !== "string") return null;
419
499
  try {
420
500
  const context = JSON.parse(value);
@@ -434,24 +514,35 @@ function component($$props) {
434
514
  if (!context) return Promise.resolve();
435
515
  if (beforeRemovePromise && beforeRemoveTransitionValue === context.__transitionValue) return beforeRemovePromise;
436
516
  beforeRemoveTransitionValue = context.__transitionValue;
437
- beforeRemovePromise = withTimeout(lastValueFrom(hooks.callHooks("client-sprite-onBeforeRemove", object, context)), context.timeoutMs);
517
+ beforeRemovePromise = withTimeout(lastValueFrom(hooks.callHooks("client-sprite-onBeforeRemove", sprite, context)), context.timeoutMs);
438
518
  return beforeRemovePromise;
439
519
  };
440
- const removeTransitionSubscription = object._removeTransition?.observable?.subscribe(() => {
520
+ const removeTransitionSubscription = sprite._removeTransition?.observable?.subscribe(() => {
441
521
  if (resolveRemoveContext()) runBeforeRemove();
442
522
  });
443
523
  const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {
444
- if (curr == "stand" && !isMoving) realAnimationName.set(curr);
445
- else if (curr == "walk" && isMoving) realAnimationName.set(curr);
446
- else if (!movementAnimations.includes(curr)) realAnimationName.set(curr);
447
- if (!isMoving && object.animationIsPlaying && object.animationIsPlaying()) {
448
- if (movementAnimations.includes(curr)) {
449
- if (typeof object.resetAnimationState === "function") object.resetAnimationState();
524
+ const isMovementAnimation = movementAnimations.includes(curr);
525
+ const isTemporaryAnimationPlaying = sprite.animationIsPlaying && sprite.animationIsPlaying();
526
+ if (sprite.animationFixed && isMovementAnimation && isTemporaryAnimationPlaying) return;
527
+ if (curr == "stand" && !isMoving) {
528
+ if (!resumeHeldDirectionWalkAnimation()) realAnimationName.set(curr);
529
+ } else if (curr == "walk" && isMoving) realAnimationName.set(curr);
530
+ else if (!isMovementAnimation) realAnimationName.set(curr);
531
+ if (!isMoving && isTemporaryAnimationPlaying) {
532
+ if (isMovementAnimation) {
533
+ if (typeof sprite.resetAnimationState === "function") sprite.resetAnimationState();
450
534
  }
451
535
  }
452
536
  });
537
+ const resumeWalkSubscriptions = [
538
+ sprite._canMove,
539
+ sprite._animationFixed,
540
+ sprite.animationIsPlaying
541
+ ].filter((signal) => signal?.observable).map((signal) => signal.observable.subscribe(() => {
542
+ resumeHeldDirectionWalkAnimation();
543
+ }));
453
544
  const waitForTemporaryAnimationEnd = (maxDuration = 1200) => {
454
- if (!object.animationIsPlaying || !object.animationIsPlaying()) return Promise.resolve();
545
+ if (!sprite.animationIsPlaying || !sprite.animationIsPlaying()) return Promise.resolve();
455
546
  return new Promise((resolve) => {
456
547
  let finished = false;
457
548
  let timeout;
@@ -464,7 +555,7 @@ function component($$props) {
464
555
  resolve();
465
556
  };
466
557
  timeout = setTimeout(finish, maxDuration);
467
- subscription = object.animationIsPlaying.observable.subscribe((isPlaying) => {
558
+ subscription = sprite.animationIsPlaying.observable.subscribe((isPlaying) => {
468
559
  if (!isPlaying) finish();
469
560
  });
470
561
  if (finished) subscription.unsubscribe();
@@ -473,16 +564,25 @@ function component($$props) {
473
564
  const onBeforeDestroy = async () => {
474
565
  await runBeforeRemove();
475
566
  await waitForTemporaryAnimationEnd();
567
+ if (typeof document !== "undefined") {
568
+ document.removeEventListener("keydown", handleNativeActionWhileMoving);
569
+ document.removeEventListener("keyup", handleNativeActionWhileMoving);
570
+ }
476
571
  removeTransitionSubscription?.unsubscribe();
477
572
  animationMovementSubscription.unsubscribe();
573
+ resumeWalkSubscriptions.forEach((subscription) => subscription.unsubscribe());
478
574
  xSubscription.unsubscribe();
479
575
  ySubscription.unsubscribe();
480
- await lastValueFrom(hooks.callHooks("client-sprite-onDestroy", object));
481
- await lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, object));
576
+ await lastValueFrom(hooks.callHooks("client-sprite-onDestroy", sprite));
577
+ await lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, sprite));
482
578
  };
483
579
  mount((element) => {
484
- hooks.callHooks("client-sprite-onAdd", object).subscribe();
485
- hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, object).subscribe();
580
+ if (typeof document !== "undefined") {
581
+ document.addEventListener("keydown", handleNativeActionWhileMoving);
582
+ document.addEventListener("keyup", handleNativeActionWhileMoving);
583
+ }
584
+ hooks.callHooks("client-sprite-onAdd", sprite).subscribe();
585
+ hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, sprite).subscribe();
486
586
  effect(() => {
487
587
  if (isCurrentPlayer()) client.setKeyboardControls(element.directives.controls);
488
588
  });
@@ -506,16 +606,16 @@ function component($$props) {
506
606
  visible
507
607
  }, [
508
608
  loop(normalizedComponentsBehind, (compConfig) => h(Container, null, h(compConfig.component, {
509
- object,
609
+ object: sprite,
510
610
  ...compConfig.props
511
611
  }))),
512
612
  h(__ce_component$1, {
513
- object,
613
+ object: sprite,
514
614
  position: "bottom",
515
615
  graphicBounds
516
616
  }),
517
617
  h(__ce_component$1, {
518
- object,
618
+ object: sprite,
519
619
  position: "left",
520
620
  graphicBounds
521
621
  }),
@@ -525,37 +625,37 @@ function component($$props) {
525
625
  zIndex: 1e3,
526
626
  name: particleName
527
627
  }),
528
- h(Container, null, loop(graphicsSignals, (graphicObj) => h(Container, { scale: computed(() => graphicScale(graphicObj)) }, h(Sprite, {
628
+ h(Container, null, [loop(renderedGraphics, (graphicObj) => h(Container, { scale: computed(() => graphicScale(graphicObj)) }, h(Sprite, {
529
629
  sheet: computed(() => sheet(graphicObj)),
530
630
  direction,
531
631
  tint,
532
632
  hitbox,
533
633
  shadowCaster: computed(() => shadowCaster(graphicObj)),
534
634
  flash: flashConfig
535
- })))),
635
+ }))), loop(resolvedEventComponents, (eventComponent) => h(Container, { dependencies: eventComponent.dependencies }, h(eventComponent.component, eventComponent.props)))]),
536
636
  h(__ce_component$1, {
537
- object,
637
+ object: sprite,
538
638
  position: "center",
539
639
  graphicBounds
540
640
  }),
541
641
  h(__ce_component$1, {
542
- object,
642
+ object: sprite,
543
643
  position: "right",
544
644
  graphicBounds
545
645
  }),
546
646
  h(__ce_component$1, {
547
- object,
647
+ object: sprite,
548
648
  position: "top",
549
649
  graphicBounds
550
650
  }),
551
651
  loop(normalizedComponentsInFront, (compConfig) => h(Container, { dependencies: compConfig.dependencies }, h(compConfig.component, {
552
- object,
652
+ object: sprite,
553
653
  ...compConfig.props
554
654
  }))),
555
655
  loop(attachedGuis, (attachedGui) => cond(shouldDisplayAttachedGui, () => h(Container, null, h(attachedGui.component, {
556
656
  ...attachedGui.data(),
557
657
  dependencies: attachedGui.dependencies,
558
- object,
658
+ object: sprite,
559
659
  onFinish: (data) => {
560
660
  onAttachedGuiFinish(attachedGui, data);
561
661
  },
@@ -1 +1 @@
1
- {"version":3,"file":"character.ce.js","names":[],"sources":["../../src/components/character.ce"],"sourcesContent":["<Container x={smoothX} y={smoothY} zIndex={z} viewportFollow={shouldFollowCamera} controls onBeforeDestroy visible>\n @for (compConfig of normalizedComponentsBehind) {\n <Container>\n <compConfig.component object ...compConfig.props />\n </Container>\n } \n <PlayerComponents object position=\"bottom\" graphicBounds />\n <PlayerComponents object position=\"left\" graphicBounds />\n <Particle emit={emitParticleTrigger} settings={particleSettings} zIndex={1000} name={particleName} />\n <Container>\n @for (graphicObj of graphicsSignals) {\n <Container scale={graphicScale(graphicObj)}>\n <Sprite \n sheet={sheet(graphicObj)} \n direction \n tint \n hitbox\n shadowCaster={shadowCaster(graphicObj)}\n flash={flashConfig}\n />\n </Container>\n }\n </Container>\n <PlayerComponents object position=\"center\" graphicBounds />\n <PlayerComponents object position=\"right\" graphicBounds />\n <PlayerComponents object position=\"top\" graphicBounds />\n @for (compConfig of normalizedComponentsInFront) {\n <Container dependencies={compConfig.dependencies}>\n <compConfig.component object ...compConfig.props />\n </Container>\n }\n @for (attachedGui of attachedGuis) {\n @if (shouldDisplayAttachedGui) {\n <Container>\n <attachedGui.component ...attachedGui.data() dependencies={attachedGui.dependencies} object={object} onFinish={(data) => {\n onAttachedGuiFinish(attachedGui, data)\n }} onInteraction={(name, data) => {\n onAttachedGuiInteraction(attachedGui, name, data)\n }} />\n </Container>\n }\n }\n</Container>\n\n<script>\n import { signal, effect, mount, computed, tick, animatedSignal, on } from \"canvasengine\";\n import { Assets } from \"pixi.js\";\n\n import { lastValueFrom, combineLatest, pairwise, filter, map, startWith } from \"rxjs\";\n import { Particle } from \"@canvasengine/presets\";\n import { GameEngineToken, ModulesToken } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { inject } from \"../core/inject\"; \n import { Direction, Animation } from \"@rpgjs/common\";\n import Hit from \"./effects/hit.ce\";\n import PlayerComponents from \"./player-components.ce\";\n import { RpgGui } from \"../Gui/Gui\";\n import { getCanMoveValue } from \"../utils/readPropValue\";\n\n const { object, id } = defineProps();\n\n const client = inject(RpgClientEngine);\n const hooks = inject(ModulesToken);\n const guiService = inject(RpgGui);\n\n const spritesheets = client.spritesheets;\n const componentsBehind = client.spriteComponentsBehind;\n const componentsInFront = client.spriteComponentsInFront;\n const readProp = (value) => typeof value === 'function' ? value() : value;\n const isCurrentPlayer = () => {\n const playerId = client.playerIdSignal();\n const currentPlayer = playerId ? client.sceneMap?.players?.()?.[playerId] : undefined;\n return readProp(id) === playerId\n || readProp(object?.id) === playerId\n || object === currentPlayer\n || object === client.sceneMap?.getCurrentPlayer?.();\n };\n const isMe = computed(isCurrentPlayer);\n const shadowsEnabled = computed(() => {\n const lighting = client.sceneMap?.lighting?.();\n return Boolean(lighting?.shadows?.enabled || (lighting?.spots?.length ?? 0) > 0);\n });\n\n /**\n * Normalize a single sprite component configuration\n * \n * Handles both direct component references and configuration objects with optional props and dependencies.\n * Extracts the component reference and creates a computed function that returns the props.\n * \n * ## Design\n * \n * Supports two formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...}, dependencies: (object) => [...] }`\n * \n * The normalization process:\n * - Extracts the actual component from either format\n * - Extracts dependencies function if provided\n * - Creates a computed function that returns props (static object or dynamic function result)\n * - Returns a normalized object with `component`, `props`, and `dependencies`\n * \n * @param comp - Component reference or configuration object\n * @returns Normalized component configuration with component, props, and dependencies\n * \n * @example\n * ```ts\n * // Direct component\n * normalizeComponent(ShadowComponent)\n * // => { component: ShadowComponent, props: {}, dependencies: undefined }\n * \n * // With static props\n * normalizeComponent({ component: LightHalo, props: { radius: 30 } })\n * // => { component: LightHalo, props: { radius: 30 }, dependencies: undefined }\n * \n * // With dynamic props and dependencies\n * normalizeComponent({ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * })\n * // => { component: HealthBar, props: {...}, dependencies: (object) => [...] }\n * ```\n */\n const normalizeComponent = (comp) => {\n let componentRef;\n let propsValue;\n let dependenciesFn;\n \n // If it's a direct component reference\n if (typeof comp === 'function' || (comp && typeof comp === 'object' && !comp.component)) {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n // If it's a configuration object with component and props\n else if (comp && typeof comp === 'object' && comp.component) {\n componentRef = comp.component;\n // Support both \"data\" (legacy) and \"props\" (new) for backward compatibility\n propsValue = comp.props !== undefined ? comp.props : comp.data;\n dependenciesFn = comp.dependencies;\n }\n // Fallback: treat as direct component\n else {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n \n // Return props directly (object or function), not as computed\n // The computed will be created in the template when needed\n return {\n component: componentRef,\n props: typeof propsValue === 'function' ? propsValue(object) : propsValue || {},\n dependencies: dependenciesFn ? dependenciesFn(object) : []\n };\n };\n\n /**\n * Normalize an array of sprite components\n * \n * Applies normalization to each component in the array using `normalizeComponent`.\n * \n * @param components - Array of component references or configuration objects\n * @returns Array of normalized component configurations\n */\n const normalizeComponents = (components) => {\n return components.map((comp) => normalizeComponent(comp));\n };\n\n\n /**\n * Normalized components to render behind sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * Supports multiple formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...} }`\n * 3. With dynamic props: `{ component: LightHalo, props: (object) => {...} }`\n * 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`\n * \n * Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).\n * The object is passed to the dependencies function to allow sprite-specific dependency resolution.\n * \n * @example\n * ```ts\n * // Direct component\n * componentsBehind: [ShadowComponent]\n * \n * // With static props\n * componentsBehind: [{ component: LightHalo, props: { radius: 30 } }]\n * \n * // With dynamic props and dependencies\n * componentsBehind: [{ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * }]\n * ```\n */\n const normalizedComponentsBehind = computed(() => {\n return normalizeComponents(componentsBehind());\n });\n\n /**\n * Normalized components to render in front of sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * See `normalizedComponentsBehind` for format details.\n * Components with dependencies will only be displayed when all dependencies are resolved.\n */\n const normalizedComponentsInFront = computed(() => {\n return normalizeComponents(componentsInFront());\n });\n \n /**\n * Determine if the camera should follow this sprite\n * \n * The camera follows this sprite if:\n * - It's explicitly set as the camera follow target, OR\n * - It's the current player and no explicit target is set (default behavior)\n */\n const shouldFollowCamera = computed(() => {\n const cameraTargetId = client.cameraFollowTargetId();\n // If a target is explicitly set, only follow if this sprite is the target\n if (cameraTargetId !== null) {\n return id() === cameraTargetId;\n }\n // Otherwise, follow the current player (default behavior)\n return isMe();\n });\n\n /**\n * Get all attached GUI components that should be rendered on sprites\n * These are GUIs with attachToSprite: true\n */\n const attachedGuis = computed(() => {\n return guiService.getAttachedGuis();\n });\n\n /**\n * Check if attached GUIs should be displayed for this sprite\n * This is controlled by showAttachedGui/hideAttachedGui on the server\n */\n const shouldDisplayAttachedGui = computed(() => {\n return guiService.shouldDisplayAttachedGui(id());\n });\n\n const { \n x, \n y, \n tint, \n direction, \n animationName, \n animationCurrentIndex,\n emitParticleTrigger, \n particleName, \n graphics, \n hitbox,\n isConnected,\n graphicsSignals,\n flashTrigger\n } = object;\n\n /**\n * Flash configuration signals for dynamic options\n * These signals are updated when the flash trigger is activated with options\n */\n const flashType = signal<'alpha' | 'tint' | 'both'>('alpha');\n const flashDuration = signal(300);\n const flashCycles = signal(1);\n const flashAlpha = signal(0.3);\n const flashTint = signal(0xffffff);\n\n /**\n * Listen to flash trigger to update configuration dynamically\n * When flash is triggered with options, update the signals\n */\n on(flashTrigger, (data) => {\n if (data && typeof data === 'object') {\n if (data.type !== undefined) flashType.set(data.type);\n if (data.duration !== undefined) flashDuration.set(data.duration);\n if (data.cycles !== undefined) flashCycles.set(data.cycles);\n if (data.alpha !== undefined) flashAlpha.set(data.alpha);\n if (data.tint !== undefined) flashTint.set(data.tint);\n }\n });\n\n /**\n * Flash configuration for the sprite\n * \n * This configuration is used by the flash directive to create visual feedback effects.\n * The flash trigger is exposed through the object, allowing both server events and\n * client-side code to trigger flash animations. Options can be passed dynamically\n * through the trigger, which updates the reactive signals.\n */\n const flashConfig = computed(() => ({\n trigger: flashTrigger,\n type: flashType(),\n duration: flashDuration(),\n cycles: flashCycles(),\n alpha: flashAlpha(),\n tint: flashTint(),\n }));\n\n const particleSettings = client.particleSettings;\n\n const canControls = () => isMe() && getCanMoveValue(object)\n const keyboardControls = client.globalConfig.keyboardControls;\n\n const visible = computed(() => {\n if (object.isEvent()) {\n return true\n }\n return isConnected()\n });\n\n const controls = {\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Down })\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Up })\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Left })\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Right })\n },\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'action' })\n }\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n gamepad: {\n enabled: true\n }\n };\n\n const smoothX = animatedSignal(x(), {\n duration: isMe() ? 0 : 0\n });\n\n const smoothY = animatedSignal(y(), {\n duration: isMe() ? 0 : 0,\n });\n\n const z = computed(() => {\n return object.y() + object.z()\n });\n\n const realAnimationName = signal(animationName());\n\n const xSubscription = x.observable.subscribe((value) => {\n smoothX.set(value);\n });\n\n const ySubscription = y.observable.subscribe((value) => {\n smoothY.set(value);\n });\n \n const sheet = (graphicObject) => {\n return {\n definition: graphicObject,\n playing: realAnimationName(),\n params: {\n direction: direction()\n },\n onFinish() {\n animationCurrentIndex.update(index => index + 1)\n }\n };\n }\n\n const graphicScale = (graphicObject) => {\n const scale = graphicObject?.scale;\n if (Array.isArray(scale)) return scale;\n if (typeof scale === 'number') return [scale, scale];\n if (scale && typeof scale === 'object') {\n const x = typeof scale.x === 'number' ? scale.x : 1;\n const y = typeof scale.y === 'number' ? scale.y : x;\n return [x, y];\n }\n return undefined;\n }\n\n const shadowCaster = (graphicObject) => {\n const box = hitbox();\n const bounds = graphicBounds();\n const scale = graphicScale(graphicObject);\n const scaleY = Array.isArray(scale) && typeof scale[1] === 'number' ? Math.abs(scale[1]) : 1;\n const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32) * scaleY;\n\n return {\n enabled: shadowsEnabled,\n height,\n footAnchor: { x: 0.5, y: 1 },\n footOffset: { x: 0, y: 2 },\n alpha: 0.5,\n blur: 3.5,\n gradientPower: 2,\n hardness: 0.42,\n minLength: Math.max(6, (box?.h ?? 32) * 0.25),\n maxLength: Math.max(90, height * 1.8),\n contactAlpha: 0.3,\n contactScale: 0.3,\n };\n }\n\n const imageDimensions = signal({});\n const loadingImageDimensions = new Set();\n\n const toPositiveNumber = (value) => {\n const number = typeof value === 'number' ? value : parseFloat(value);\n return Number.isFinite(number) && number > 0 ? number : undefined;\n };\n\n const toFiniteNumber = (value, fallback = 0) => {\n const number = typeof value === 'number' ? value : parseFloat(value);\n return Number.isFinite(number) ? number : fallback;\n };\n\n const clampRatio = (value) => Math.min(1, Math.max(0, value));\n\n const normalizePair = (value, fallback = [1, 1]) => {\n if (Array.isArray(value)) {\n const x = toFiniteNumber(value[0], fallback[0]);\n const y = toFiniteNumber(value[1] ?? value[0], x);\n return [x, y];\n }\n if (typeof value === 'number') {\n return [value, value];\n }\n if (value && typeof value === 'object') {\n const x = toFiniteNumber(value.x, fallback[0]);\n const y = toFiniteNumber(value.y ?? value.x, x);\n return [x, y];\n }\n return fallback;\n };\n\n const normalizeAnchor = (value) => {\n if (!Array.isArray(value)) return undefined;\n const [x, y] = normalizePair(value, [0, 0]);\n return [clampRatio(x), clampRatio(y)];\n };\n\n const resolveImageSource = (image) => {\n if (typeof image === 'string') return image;\n if (typeof image?.default === 'string') return image.default;\n return undefined;\n };\n\n const parentTextureOptions = (graphicObject) => {\n const props = [\n 'width',\n 'height',\n 'framesHeight',\n 'framesWidth',\n 'rectWidth',\n 'rectHeight',\n 'offset',\n 'image',\n 'sound',\n 'spriteRealSize',\n 'scale',\n 'anchor',\n 'pivot',\n 'x',\n 'y',\n 'opacity'\n ];\n\n return props.reduce((options, prop) => {\n if (graphicObject?.[prop] !== undefined) {\n options[prop] = graphicObject[prop];\n }\n return options;\n }, {});\n };\n\n const resolveTextureOptions = (graphicObject) => {\n const textures = graphicObject?.textures ?? {};\n const texture =\n textures[realAnimationName()] ??\n textures[Animation.Stand] ??\n Object.values(textures)[0] ??\n {};\n\n return {\n ...parentTextureOptions(graphicObject),\n ...texture\n };\n };\n\n const resolveFirstAnimationFrame = (textureOptions) => {\n const animations = textureOptions?.animations;\n if (!animations) return {};\n\n try {\n const frames = typeof animations === 'function'\n ? animations({ direction: direction() })\n : animations;\n if (!Array.isArray(frames)) return {};\n const firstGroup = frames[0];\n return Array.isArray(firstGroup) ? firstGroup[0] ?? {} : firstGroup ?? {};\n }\n catch {\n return {};\n }\n };\n\n const optionValue = (prop, frame, textureOptions, graphicObject) => {\n return frame?.[prop] ?? textureOptions?.[prop] ?? graphicObject?.[prop];\n };\n\n const resolveFrameSize = (textureOptions, dimensions) => {\n const framesWidth = toPositiveNumber(textureOptions?.framesWidth) ?? 1;\n const framesHeight = toPositiveNumber(textureOptions?.framesHeight) ?? 1;\n const imageSource = resolveImageSource(textureOptions?.image);\n const loadedSize = imageSource ? dimensions[imageSource] : undefined;\n const fullWidth = toPositiveNumber(textureOptions?.width) ?? loadedSize?.width;\n const fullHeight = toPositiveNumber(textureOptions?.height) ?? loadedSize?.height;\n const width = toPositiveNumber(textureOptions?.rectWidth) ??\n toPositiveNumber(textureOptions?.spriteWidth) ??\n (fullWidth ? fullWidth / framesWidth : undefined);\n const height = toPositiveNumber(textureOptions?.rectHeight) ??\n toPositiveNumber(textureOptions?.spriteHeight) ??\n (fullHeight ? fullHeight / framesHeight : undefined);\n\n return {\n width,\n height\n };\n };\n\n const resolveHitboxAnchor = (spriteWidth, spriteHeight, realSize, box) => {\n if (!spriteWidth || !spriteHeight || !box) {\n return [0, 0];\n }\n\n const heightOfSprite = typeof realSize === 'number' ? realSize : realSize?.height;\n const resolvedHeight = toPositiveNumber(heightOfSprite) ?? spriteHeight;\n const gap = Math.max(0, (spriteHeight - resolvedHeight) / 2);\n const hitboxTopLeftX = clampRatio((spriteWidth - box.w) / 2 / spriteWidth);\n const hitboxTopLeftY = clampRatio((spriteHeight - box.h - gap) / spriteHeight);\n const hitboxCenterX = clampRatio(hitboxTopLeftX + box.w / 2 / spriteWidth);\n const hitboxCenterY = clampRatio(hitboxTopLeftY + box.h / 2 / spriteHeight);\n const footY = clampRatio((spriteHeight - gap) / spriteHeight);\n\n switch (box.anchorMode ?? 'top-left') {\n case 'center':\n return [hitboxCenterX, hitboxCenterY];\n case 'foot':\n return [hitboxCenterX, footY];\n case 'top-left':\n default:\n return [hitboxTopLeftX, hitboxTopLeftY];\n }\n };\n\n const loadImageDimensions = (image) => {\n const source = resolveImageSource(image);\n if (!source || imageDimensions()[source] || loadingImageDimensions.has(source)) {\n return;\n }\n\n loadingImageDimensions.add(source);\n Assets.load(source)\n .then((texture) => {\n const width = toPositiveNumber(texture?.width);\n const height = toPositiveNumber(texture?.height);\n if (!width || !height) return;\n\n imageDimensions.update((dimensions) => ({\n ...dimensions,\n [source]: { width, height }\n }));\n })\n .catch(() => {})\n .finally(() => {\n loadingImageDimensions.delete(source);\n });\n };\n\n effect(() => {\n const sources = new Set();\n\n graphicsSignals().forEach((graphicObject) => {\n const baseImage = resolveImageSource(graphicObject?.image);\n if (baseImage) sources.add(baseImage);\n\n Object.values(graphicObject?.textures ?? {}).forEach((textureOptions) => {\n const image = resolveImageSource(textureOptions?.image ?? graphicObject?.image);\n if (image) sources.add(image);\n });\n });\n\n sources.forEach((source) => loadImageDimensions(source));\n });\n\n const hitboxBounds = computed(() => {\n const box = hitbox();\n const width = box?.w ?? 0;\n const height = box?.h ?? 0;\n\n return {\n left: 0,\n top: 0,\n right: width,\n bottom: height,\n width,\n height,\n centerX: width / 2,\n centerY: height / 2\n };\n });\n\n const graphicBounds = computed(() => {\n const box = hitbox();\n const fallback = hitboxBounds();\n const dimensions = imageDimensions();\n const graphics = graphicsSignals();\n let bounds = null;\n\n graphics.forEach((graphicObject) => {\n const textureOptions = resolveTextureOptions(graphicObject);\n const frame = resolveFirstAnimationFrame(textureOptions);\n const size = resolveFrameSize(textureOptions, dimensions);\n const spriteWidth = size.width ?? box?.w;\n const spriteHeight = size.height ?? box?.h;\n\n if (!spriteWidth || !spriteHeight) {\n return;\n }\n\n const explicitAnchor = normalizeAnchor(optionValue('anchor', frame, textureOptions, graphicObject));\n const anchor = explicitAnchor ?? resolveHitboxAnchor(\n spriteWidth,\n spriteHeight,\n optionValue('spriteRealSize', frame, textureOptions, graphicObject),\n box\n );\n const scale = normalizePair(optionValue('scale', frame, textureOptions, graphicObject) ?? graphicScale(graphicObject));\n const x = toFiniteNumber(optionValue('x', frame, textureOptions, graphicObject), 0);\n const y = toFiniteNumber(optionValue('y', frame, textureOptions, graphicObject), 0);\n const leftEdge = -anchor[0] * spriteWidth * scale[0];\n const rightEdge = (1 - anchor[0]) * spriteWidth * scale[0];\n const topEdge = -anchor[1] * spriteHeight * scale[1];\n const bottomEdge = (1 - anchor[1]) * spriteHeight * scale[1];\n const graphic = {\n left: x + Math.min(leftEdge, rightEdge),\n top: y + Math.min(topEdge, bottomEdge),\n right: x + Math.max(leftEdge, rightEdge),\n bottom: y + Math.max(topEdge, bottomEdge)\n };\n\n bounds = bounds\n ? {\n left: Math.min(bounds.left, graphic.left),\n top: Math.min(bounds.top, graphic.top),\n right: Math.max(bounds.right, graphic.right),\n bottom: Math.max(bounds.bottom, graphic.bottom)\n }\n : graphic;\n });\n\n if (!bounds) {\n return fallback;\n }\n\n const width = bounds.right - bounds.left;\n const height = bounds.bottom - bounds.top;\n\n return {\n ...bounds,\n width,\n height,\n centerX: bounds.left + width / 2,\n centerY: bounds.top + height / 2\n };\n });\n\n // Combine animation change detection with movement state from smoothX/smoothY\n const movementAnimations = ['walk', 'stand'];\n const epsilon = 0; // movement threshold to consider the easing still running\n\n const stateX$ = smoothX.animatedState.observable;\n const stateY$ = smoothY.animatedState.observable;\n const animationName$ = animationName.observable;\n\n const moving$ = combineLatest([stateX$, stateY$]).pipe(\n map(([sx, sy]) => {\n const xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;\n const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;\n return !xFinished || !yFinished; // moving if X or Y is not finished\n }),\n startWith(false)\n );\n\n const animationChange$ = animationName$.pipe(\n startWith(animationName()),\n pairwise(),\n filter(([prev, curr]) => prev !== curr)\n );\n\n let beforeRemovePromise = null;\n let beforeRemoveTransitionValue = null;\n const resolveRemoveContext = () => {\n if (!object._removeTransition) return null;\n const value = object._removeTransition();\n if (!value || typeof value !== 'string') return null;\n try {\n const context = JSON.parse(value);\n if (!context || typeof context !== 'object' || !context.active) return null;\n context.__transitionValue = value;\n return context;\n }\n catch {\n return null;\n }\n };\n\n const withTimeout = (promise, timeoutMs = 0) => {\n if (!timeoutMs || timeoutMs <= 0) return promise;\n return Promise.race([\n promise,\n new Promise((resolve) => setTimeout(resolve, timeoutMs)),\n ]);\n };\n\n const runBeforeRemove = () => {\n const context = resolveRemoveContext();\n if (!context) return Promise.resolve();\n if (beforeRemovePromise && beforeRemoveTransitionValue === context.__transitionValue) {\n return beforeRemovePromise;\n }\n beforeRemoveTransitionValue = context.__transitionValue;\n beforeRemovePromise = withTimeout(\n lastValueFrom(hooks.callHooks(\"client-sprite-onBeforeRemove\", object, context)),\n context.timeoutMs\n );\n return beforeRemovePromise;\n };\n\n const removeTransitionSubscription = object._removeTransition?.observable?.subscribe(() => {\n if (resolveRemoveContext()) {\n runBeforeRemove();\n }\n });\n\n const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {\n if (curr == 'stand' && !isMoving) {\n realAnimationName.set(curr);\n }\n else if (curr == 'walk' && isMoving) {\n realAnimationName.set(curr);\n }\n else if (!movementAnimations.includes(curr)) {\n realAnimationName.set(curr);\n }\n if (!isMoving && object.animationIsPlaying && object.animationIsPlaying()) {\n if (movementAnimations.includes(curr)) {\n if (typeof object.resetAnimationState === 'function') {\n object.resetAnimationState();\n }\n }\n }\n });\n\n /**\n * Cleanup subscriptions and call hooks before sprite destruction.\n *\n * # Design\n * - Prevent memory leaks by unsubscribing from all local subscriptions created in this component.\n * - Execute destruction hooks to notify modules and scene map of sprite removal.\n *\n * @example\n * await onBeforeDestroy();\n */\n const waitForTemporaryAnimationEnd = (maxDuration = 1200) => {\n if (!object.animationIsPlaying || !object.animationIsPlaying()) {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n let finished = false;\n let timeout;\n let subscription;\n const finish = () => {\n if (finished) return;\n finished = true;\n clearTimeout(timeout);\n subscription?.unsubscribe();\n resolve();\n };\n timeout = setTimeout(finish, maxDuration);\n subscription = object.animationIsPlaying.observable.subscribe((isPlaying) => {\n if (!isPlaying) finish();\n });\n if (finished) subscription.unsubscribe();\n });\n };\n\n const onBeforeDestroy = async () => {\n await runBeforeRemove();\n await waitForTemporaryAnimationEnd();\n removeTransitionSubscription?.unsubscribe();\n animationMovementSubscription.unsubscribe();\n xSubscription.unsubscribe();\n ySubscription.unsubscribe();\n await lastValueFrom(hooks.callHooks(\"client-sprite-onDestroy\", object)) \n await lastValueFrom(hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, object))\n }\n\n mount((element) => {\n hooks.callHooks(\"client-sprite-onAdd\", object).subscribe()\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, object).subscribe()\n effect(() => {\n if (isCurrentPlayer()) {\n client.setKeyboardControls(element.directives.controls)\n }\n })\n })\n\n /**\n * Handle attached GUI finish event\n * \n * @param gui - The GUI instance\n * @param data - Data passed from the GUI component\n */\n const onAttachedGuiFinish = (gui, data) => {\n guiService.guiClose(gui.name, data);\n };\n\n /**\n * Handle attached GUI interaction event\n * \n * @param gui - The GUI instance\n * @param name - Interaction name\n * @param data - Interaction data\n */\n const onAttachedGuiInteraction = (gui, name, data) => {\n guiService.guiInteraction(gui.name, name, data);\n };\n\n tick(() => {\n hooks.callHooks(\"client-sprite-onUpdate\").subscribe()\n })\n</script>\n"],"mappings":";;;;;;;;;;;AAiBM,SAAI,UAAc,SAAA;CACP,SAAW,OAAA;CAEpB,MAAA,EAAA,QAAS,OADR,eAAA,OACQ,EAAA;CACjB,MAAI,SAAA,OAAA,eAAA;CACJ,MAAI,QAAS,OAAA,YAAA;CACb,MAAG,aAAgB,OAAO,MAAC;CACP,OAAO;CAC3B,MAAG,mBAAiB,OAAO;CAC3B,MAAM,oBAAgB,OAAA;CACtB,MAAK,YAAU,UAAa,OAAC,UAAW,aAAa,MAAA,IAAA;CACrD,MAAM,wBAAsB;EACxB,MAAE,WAAS,OAAA,eAAA;EACb,MAAA,gBAAA,WAAA,OAAA,UAAA,UAAA,IAAA,YAAA,KAAA;EACC,OAAK,SAAY,EAAE,MAAC,YACd,SAAA,QAAA,EAAA,MAA0B,YAC5B,WAAS,iBACP,WAAY,OAAA,UAAa,mBAAmB;CACrD;CACA,MAAM,OAAK,SAAA,eAA0B;CACrC,MAAM,iBAAI,eAAyB;EAC/B,MAAM,WAAE,OAAA,UAAA,WAAA;EACR,OAAI,QAAS,UAAA,SAAA,YAAA,UAAA,OAAA,UAAA,KAAA,CAAA;CACjB,CAAC;CACD,MAAE,sBAAA,SAAA;EACA,IAAA;;EAED,IAAM;EAEL,IAAM,OAAG,SAAa,cAAU,QAAA,OAAA,SAAA,YAAA,CAAA,KAAA,WAAA;;GAE1B,aAAG,KAAA;GACH,iBAAc,KAAA;EACpB,OAEO,IAAE,QAAS,OAAQ,SAAM,YAAS,KAAA,WAAA;GACnC,eAAc,KAAA;GAEd,aAAC,KAAiB,UAAQ,KAAA,IAAO,KAAW,QAAG,KAAA;GAC/C,iBAAiB,KAAI;EAC3B,OAEO;;GAED,aAAS,KAAA;GACT,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MAAA,KAAA,kBAAA,eAAA,EAAA,WAAA,EAAA,OAAA,eAAA,aAAA,UAAA,CAAA,EAAA,GAAA,EAAA,QAAA;GAAA,OAAA,eAAA,MAAA,UAAA,CAAA;GAAA;GAAA;GAAA;GAAA,cAAA,eAAA,aAAA,UAAA,CAAA;GAAA,OAAA;EAAA,CAAA,CAAA,CAAA,CAAA;EAAA,EAAA,kBAAA;GAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,KAAA,8BAAA,eAAA,EAAA,WAAA,EAAA,cAAA,WAAA,aAAA,GAAA,EAAA,WAAA,WAAA;GAAA;GAAA,GAAA,WAAA;EAAA,CAAA,CAAA,CAAA;EAAA,KAAA,eAAA,gBAAA,KAAA,gCAAA,EAAA,WAAA,MAAA,EAAA,YAAA,WAAA;GAAA,GAAA,YAAA,KAAA;GAAA,cAAA,YAAA;GAAA;GAAA,WAAA,SAAA;;GAEzB;GAAA,gBAAkB,MAAS,SAAA;IACzB,yBAAkB,aAAmB,MAAA,IAAe;GAClD;EAAE,CAAA,CAAA,CAAA,CAAA;CAAA,CAAA;AAEJ;AAEA,IAAM,iBAEN"}
1
+ {"version":3,"file":"character.ce.js","names":[],"sources":["../../src/components/character.ce"],"sourcesContent":["<Container x={smoothX} y={smoothY} zIndex={z} viewportFollow={shouldFollowCamera} controls onBeforeDestroy visible>\n @for (compConfig of normalizedComponentsBehind) {\n <Container>\n <compConfig.component object={sprite} ...compConfig.props />\n </Container>\n } \n <PlayerComponents object={sprite} position=\"bottom\" graphicBounds />\n <PlayerComponents object={sprite} position=\"left\" graphicBounds />\n <Particle emit={emitParticleTrigger} settings={particleSettings} zIndex={1000} name={particleName} />\n <Container>\n @for (graphicObj of renderedGraphics) {\n <Container scale={graphicScale(graphicObj)}>\n <Sprite \n sheet={sheet(graphicObj)} \n direction \n tint \n hitbox\n shadowCaster={shadowCaster(graphicObj)}\n flash={flashConfig}\n />\n </Container>\n }\n @for (eventComponent of resolvedEventComponents) {\n <Container dependencies={eventComponent.dependencies}>\n <eventComponent.component ...eventComponent.props />\n </Container>\n }\n </Container>\n <PlayerComponents object={sprite} position=\"center\" graphicBounds />\n <PlayerComponents object={sprite} position=\"right\" graphicBounds />\n <PlayerComponents object={sprite} position=\"top\" graphicBounds />\n @for (compConfig of normalizedComponentsInFront) {\n <Container dependencies={compConfig.dependencies}>\n <compConfig.component object={sprite} ...compConfig.props />\n </Container>\n }\n @for (attachedGui of attachedGuis) {\n @if (shouldDisplayAttachedGui) {\n <Container>\n <attachedGui.component ...attachedGui.data() dependencies={attachedGui.dependencies} object={sprite} onFinish={(data) => {\n onAttachedGuiFinish(attachedGui, data)\n }} onInteraction={(name, data) => {\n onAttachedGuiInteraction(attachedGui, name, data)\n }} />\n </Container>\n }\n }\n</Container>\n\n<script>\n import { signal, effect, mount, computed, tick, animatedSignal, on } from \"canvasengine\";\n import { Assets } from \"pixi.js\";\n\n import { lastValueFrom, combineLatest, pairwise, filter, map, startWith } from \"rxjs\";\n import { Particle } from \"@canvasengine/presets\";\n import { GameEngineToken, ModulesToken } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { inject } from \"../core/inject\"; \n import { Direction, Animation } from \"@rpgjs/common\";\n import { normalizeEventComponent } from \"../Game/EventComponentResolver\";\n import Hit from \"./effects/hit.ce\";\n import PlayerComponents from \"./player-components.ce\";\n import { RpgGui } from \"../Gui/Gui\";\n import { getCanMoveValue } from \"../utils/readPropValue\";\n import {\n getKeyboardControlBind,\n keyboardEventMatchesBind,\n resolveKeyboardActionInput,\n resolveKeyboardDirectionInput,\n } from \"../services/actionInput\";\n\n const { object, id } = defineProps();\n const sprite = object();\n\n const client = inject(RpgClientEngine);\n const hooks = inject(ModulesToken);\n const guiService = inject(RpgGui);\n\n const spritesheets = client.spritesheets;\n const componentsBehind = client.spriteComponentsBehind;\n const componentsInFront = client.spriteComponentsInFront;\n const readProp = (value) => typeof value === 'function' ? value() : value;\n const isCurrentPlayer = () => {\n const playerId = client.playerIdSignal();\n const currentPlayer = playerId ? client.sceneMap?.players?.()?.[playerId] : undefined;\n return readProp(id) === playerId\n || readProp(sprite?.id) === playerId\n || sprite === currentPlayer\n || sprite === client.sceneMap?.getCurrentPlayer?.();\n };\n const isMe = computed(isCurrentPlayer);\n const shadowsEnabled = computed(() => {\n const lighting = client.sceneMap?.lighting?.();\n return Boolean(lighting?.shadows?.enabled || (lighting?.spots?.length ?? 0) > 0);\n });\n\n /**\n * Normalize a single sprite component configuration\n * \n * Handles both direct component references and configuration objects with optional props and dependencies.\n * Extracts the component reference and creates a computed function that returns the props.\n * \n * ## Design\n * \n * Supports two formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...}, dependencies: (object) => [...] }`\n * \n * The normalization process:\n * - Extracts the actual component from either format\n * - Extracts dependencies function if provided\n * - Creates a computed function that returns props (static object or dynamic function result)\n * - Returns a normalized object with `component`, `props`, and `dependencies`\n * \n * @param comp - Component reference or configuration object\n * @returns Normalized component configuration with component, props, and dependencies\n * \n * @example\n * ```ts\n * // Direct component\n * normalizeComponent(ShadowComponent)\n * // => { component: ShadowComponent, props: {}, dependencies: undefined }\n * \n * // With static props\n * normalizeComponent({ component: LightHalo, props: { radius: 30 } })\n * // => { component: LightHalo, props: { radius: 30 }, dependencies: undefined }\n * \n * // With dynamic props and dependencies\n * normalizeComponent({ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * })\n * // => { component: HealthBar, props: {...}, dependencies: (object) => [...] }\n * ```\n */\n const normalizeComponent = (comp) => {\n let componentRef;\n let propsValue;\n let dependenciesFn;\n \n // If it's a direct component reference\n if (typeof comp === 'function' || (comp && typeof comp === 'object' && !comp.component)) {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n // If it's a configuration object with component and props\n else if (comp && typeof comp === 'object' && comp.component) {\n componentRef = comp.component;\n // Support both \"data\" (legacy) and \"props\" (new) for backward compatibility\n propsValue = comp.props !== undefined ? comp.props : comp.data;\n dependenciesFn = comp.dependencies;\n }\n // Fallback: treat as direct component\n else {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n \n // Return props directly (object or function), not as computed\n // The computed will be created in the template when needed\n return {\n component: componentRef,\n props: typeof propsValue === 'function' ? propsValue(sprite) : propsValue || {},\n dependencies: dependenciesFn ? dependenciesFn(sprite) : []\n };\n };\n\n /**\n * Normalize an array of sprite components\n * \n * Applies normalization to each component in the array using `normalizeComponent`.\n * \n * @param components - Array of component references or configuration objects\n * @returns Array of normalized component configurations\n */\n const normalizeComponents = (components) => {\n return components.map((comp) => normalizeComponent(comp));\n };\n\n\n /**\n * Normalized components to render behind sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * Supports multiple formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...} }`\n * 3. With dynamic props: `{ component: LightHalo, props: (object) => {...} }`\n * 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`\n * \n * Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).\n * The object is passed to the dependencies function to allow sprite-specific dependency resolution.\n * \n * @example\n * ```ts\n * // Direct component\n * componentsBehind: [ShadowComponent]\n * \n * // With static props\n * componentsBehind: [{ component: LightHalo, props: { radius: 30 } }]\n * \n * // With dynamic props and dependencies\n * componentsBehind: [{ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * }]\n * ```\n */\n const normalizedComponentsBehind = computed(() => {\n return normalizeComponents(componentsBehind());\n });\n\n /**\n * Normalized components to render in front of sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * See `normalizedComponentsBehind` for format details.\n * Components with dependencies will only be displayed when all dependencies are resolved.\n */\n const normalizedComponentsInFront = computed(() => {\n return normalizeComponents(componentsInFront());\n });\n\n const isEventSprite = () => {\n return typeof sprite?.isEvent === 'function'\n ? sprite.isEvent()\n : sprite?._type === 'event';\n };\n\n const resolvedEventComponents = computed(() => {\n if (!isEventSprite()) return [];\n const eventComponent = normalizeEventComponent(client.resolveEventComponent(sprite), sprite);\n return eventComponent ? [eventComponent] : [];\n });\n \n /**\n * Determine if the camera should follow this sprite\n * \n * The camera follows this sprite if:\n * - It's explicitly set as the camera follow target, OR\n * - It's the current player and no explicit target is set (default behavior)\n */\n const shouldFollowCamera = computed(() => {\n const cameraTargetId = client.cameraFollowTargetId();\n // If a target is explicitly set, only follow if this sprite is the target\n if (cameraTargetId !== null) {\n return id() === cameraTargetId;\n }\n // Otherwise, follow the current player (default behavior)\n return isMe();\n });\n\n /**\n * Get all attached GUI components that should be rendered on sprites\n * These are GUIs with attachToSprite: true\n */\n const attachedGuis = computed(() => {\n return guiService.getAttachedGuis();\n });\n\n /**\n * Check if attached GUIs should be displayed for this sprite\n * This is controlled by showAttachedGui/hideAttachedGui on the server\n */\n const shouldDisplayAttachedGui = computed(() => {\n return guiService.shouldDisplayAttachedGui(id());\n });\n\n const { \n x, \n y, \n tint, \n direction, \n animationName, \n animationCurrentIndex,\n emitParticleTrigger, \n particleName, \n graphics, \n hitbox,\n isConnected,\n graphicsSignals,\n flashTrigger\n } = sprite;\n\n const renderedGraphics = computed(() => {\n const eventComponent = resolvedEventComponents()[0];\n if (eventComponent && !eventComponent.renderGraphic) return [];\n return graphicsSignals();\n });\n\n /**\n * Flash configuration signals for dynamic options\n * These signals are updated when the flash trigger is activated with options\n */\n const flashType = signal<'alpha' | 'tint' | 'both'>('alpha');\n const flashDuration = signal(300);\n const flashCycles = signal(1);\n const flashAlpha = signal(0.3);\n const flashTint = signal(0xffffff);\n\n /**\n * Listen to flash trigger to update configuration dynamically\n * When flash is triggered with options, update the signals\n */\n on(flashTrigger, (data) => {\n if (data && typeof data === 'object') {\n if (data.type !== undefined) flashType.set(data.type);\n if (data.duration !== undefined) flashDuration.set(data.duration);\n if (data.cycles !== undefined) flashCycles.set(data.cycles);\n if (data.alpha !== undefined) flashAlpha.set(data.alpha);\n if (data.tint !== undefined) flashTint.set(data.tint);\n }\n });\n\n /**\n * Flash configuration for the sprite\n * \n * This configuration is used by the flash directive to create visual feedback effects.\n * The flash trigger is exposed through the object, allowing both server events and\n * client-side code to trigger flash animations. Options can be passed dynamically\n * through the trigger, which updates the reactive signals.\n */\n const flashConfig = computed(() => ({\n trigger: flashTrigger,\n type: flashType(),\n duration: flashDuration(),\n cycles: flashCycles(),\n alpha: flashAlpha(),\n tint: flashTint(),\n }));\n\n const particleSettings = client.particleSettings;\n\n const canControls = () => isMe() && getCanMoveValue(sprite)\n const keyboardControls = client.globalConfig.keyboardControls;\n const activeDirectionKeys = new Map();\n\n const resolveHeldDirection = () => {\n const directions = Array.from(activeDirectionKeys.values());\n return directions[directions.length - 1];\n };\n\n const resolveSpriteDirection = () => {\n const heldDirection = resolveHeldDirection();\n if (heldDirection) return heldDirection;\n if (typeof sprite.getDirection === 'function') return sprite.getDirection();\n if (typeof sprite.direction === 'function') return sprite.direction();\n return direction();\n };\n\n const withCurrentDirection = (payload) => {\n if (payload.action !== 'action') return payload;\n const data = payload.data && typeof payload.data === 'object'\n ? { ...payload.data }\n : {};\n return {\n ...payload,\n data: {\n ...data,\n direction: data.direction ?? resolveSpriteDirection(),\n },\n };\n };\n\n const resolveCurrentActionInput = () =>\n withCurrentDirection(\n resolveKeyboardActionInput(keyboardControls.action, client, sprite)\n );\n\n const playPredictedWalkAnimation = () => {\n if (sprite.animationFixed) return;\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) return;\n realAnimationName.set('walk');\n };\n\n const resumeHeldDirectionWalkAnimation = () => {\n if (!isCurrentPlayer()) return false;\n if (activeDirectionKeys.size === 0) return false;\n if (!canControls()) return false;\n if (sprite.animationFixed) return false;\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) return false;\n realAnimationName.set('walk');\n return true;\n };\n\n const processMovementInput = (input) => {\n if (!canControls()) return;\n client.processInput({ input });\n playPredictedWalkAnimation();\n };\n\n const actionBind = () => getKeyboardControlBind(keyboardControls.action);\n const keyboardEventId = (event) => `${event.keyCode}:${event.code}:${event.key}`;\n\n const handleNativeActionWhileMoving = (event) => {\n const inputDirection = resolveKeyboardDirectionInput(event, keyboardControls);\n if (inputDirection) {\n const keyId = keyboardEventId(event);\n if (event.type === 'keydown') {\n activeDirectionKeys.delete(keyId);\n activeDirectionKeys.set(keyId, inputDirection);\n resumeHeldDirectionWalkAnimation();\n }\n else {\n activeDirectionKeys.delete(keyId);\n }\n }\n\n if (!isCurrentPlayer()) return;\n if (event.type !== 'keydown' || event.repeat) return;\n if (activeDirectionKeys.size === 0) return;\n if (!keyboardEventMatchesBind(event, actionBind())) return;\n if (!canControls()) return;\n\n client.processAction(resolveCurrentActionInput());\n };\n\n const visible = computed(() => {\n if (sprite.isEvent()) {\n return true\n }\n return isConnected()\n });\n\n const controls = {\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n processMovementInput(Direction.Down)\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n processMovementInput(Direction.Up)\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n processMovementInput(Direction.Left)\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n processMovementInput(Direction.Right)\n },\n },\n action: {\n bind: getKeyboardControlBind(keyboardControls.action),\n keyDown() {\n if (canControls()) {\n client.processAction(resolveCurrentActionInput())\n }\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n gamepad: {\n enabled: true\n }\n };\n\n const smoothX = animatedSignal(x(), {\n duration: isMe() ? 0 : 0\n });\n\n const smoothY = animatedSignal(y(), {\n duration: isMe() ? 0 : 0,\n });\n\n const z = computed(() => {\n return sprite.y() + sprite.z()\n });\n\n const realAnimationName = signal(animationName());\n\n const xSubscription = x.observable.subscribe((value) => {\n smoothX.set(value);\n });\n\n const ySubscription = y.observable.subscribe((value) => {\n smoothY.set(value);\n });\n \n const sheet = (graphicObject) => {\n return {\n definition: graphicObject,\n playing: realAnimationName(),\n params: {\n direction: direction()\n },\n onFinish() {\n animationCurrentIndex.update(index => index + 1)\n }\n };\n }\n\n const graphicScale = (graphicObject) => {\n const scale = graphicObject?.scale;\n if (Array.isArray(scale)) return scale;\n if (typeof scale === 'number') return [scale, scale];\n if (scale && typeof scale === 'object') {\n const x = typeof scale.x === 'number' ? scale.x : 1;\n const y = typeof scale.y === 'number' ? scale.y : x;\n return [x, y];\n }\n return undefined;\n }\n\n const shadowCaster = (graphicObject) => {\n const box = hitbox();\n const bounds = graphicBounds();\n const scale = graphicScale(graphicObject);\n const scaleY = Array.isArray(scale) && typeof scale[1] === 'number' ? Math.abs(scale[1]) : 1;\n const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32) * scaleY;\n\n return {\n enabled: shadowsEnabled,\n height,\n footAnchor: { x: 0.5, y: 1 },\n footOffset: { x: 0, y: 2 },\n alpha: 0.5,\n blur: 3.5,\n gradientPower: 2,\n hardness: 0.42,\n minLength: Math.max(6, (box?.h ?? 32) * 0.25),\n maxLength: Math.max(90, height * 1.8),\n contactAlpha: 0.3,\n contactScale: 0.3,\n };\n }\n\n const imageDimensions = signal({});\n const loadingImageDimensions = new Set();\n\n const toPositiveNumber = (value) => {\n const number = typeof value === 'number' ? value : parseFloat(value);\n return Number.isFinite(number) && number > 0 ? number : undefined;\n };\n\n const toFiniteNumber = (value, fallback = 0) => {\n const number = typeof value === 'number' ? value : parseFloat(value);\n return Number.isFinite(number) ? number : fallback;\n };\n\n const clampRatio = (value) => Math.min(1, Math.max(0, value));\n\n const normalizePair = (value, fallback = [1, 1]) => {\n if (Array.isArray(value)) {\n const x = toFiniteNumber(value[0], fallback[0]);\n const y = toFiniteNumber(value[1] ?? value[0], x);\n return [x, y];\n }\n if (typeof value === 'number') {\n return [value, value];\n }\n if (value && typeof value === 'object') {\n const x = toFiniteNumber(value.x, fallback[0]);\n const y = toFiniteNumber(value.y ?? value.x, x);\n return [x, y];\n }\n return fallback;\n };\n\n const normalizeAnchor = (value) => {\n if (!Array.isArray(value)) return undefined;\n const [x, y] = normalizePair(value, [0, 0]);\n return [clampRatio(x), clampRatio(y)];\n };\n\n const resolveImageSource = (image) => {\n if (typeof image === 'string') return image;\n if (typeof image?.default === 'string') return image.default;\n return undefined;\n };\n\n const parentTextureOptions = (graphicObject) => {\n const props = [\n 'width',\n 'height',\n 'framesHeight',\n 'framesWidth',\n 'rectWidth',\n 'rectHeight',\n 'offset',\n 'image',\n 'sound',\n 'spriteRealSize',\n 'scale',\n 'anchor',\n 'pivot',\n 'x',\n 'y',\n 'opacity'\n ];\n\n return props.reduce((options, prop) => {\n if (graphicObject?.[prop] !== undefined) {\n options[prop] = graphicObject[prop];\n }\n return options;\n }, {});\n };\n\n const resolveTextureOptions = (graphicObject) => {\n const textures = graphicObject?.textures ?? {};\n const texture =\n textures[realAnimationName()] ??\n textures[Animation.Stand] ??\n Object.values(textures)[0] ??\n {};\n\n return {\n ...parentTextureOptions(graphicObject),\n ...texture\n };\n };\n\n const resolveFirstAnimationFrame = (textureOptions) => {\n const animations = textureOptions?.animations;\n if (!animations) return {};\n\n try {\n const frames = typeof animations === 'function'\n ? animations({ direction: direction() })\n : animations;\n if (!Array.isArray(frames)) return {};\n const firstGroup = frames[0];\n return Array.isArray(firstGroup) ? firstGroup[0] ?? {} : firstGroup ?? {};\n }\n catch {\n return {};\n }\n };\n\n const optionValue = (prop, frame, textureOptions, graphicObject) => {\n return frame?.[prop] ?? textureOptions?.[prop] ?? graphicObject?.[prop];\n };\n\n const resolveFrameSize = (textureOptions, dimensions) => {\n const framesWidth = toPositiveNumber(textureOptions?.framesWidth) ?? 1;\n const framesHeight = toPositiveNumber(textureOptions?.framesHeight) ?? 1;\n const imageSource = resolveImageSource(textureOptions?.image);\n const loadedSize = imageSource ? dimensions[imageSource] : undefined;\n const fullWidth = toPositiveNumber(textureOptions?.width) ?? loadedSize?.width;\n const fullHeight = toPositiveNumber(textureOptions?.height) ?? loadedSize?.height;\n const width = toPositiveNumber(textureOptions?.rectWidth) ??\n toPositiveNumber(textureOptions?.spriteWidth) ??\n (fullWidth ? fullWidth / framesWidth : undefined);\n const height = toPositiveNumber(textureOptions?.rectHeight) ??\n toPositiveNumber(textureOptions?.spriteHeight) ??\n (fullHeight ? fullHeight / framesHeight : undefined);\n\n return {\n width,\n height\n };\n };\n\n const resolveHitboxAnchor = (spriteWidth, spriteHeight, realSize, box) => {\n if (!spriteWidth || !spriteHeight || !box) {\n return [0, 0];\n }\n\n const heightOfSprite = typeof realSize === 'number' ? realSize : realSize?.height;\n const resolvedHeight = toPositiveNumber(heightOfSprite) ?? spriteHeight;\n const gap = Math.max(0, (spriteHeight - resolvedHeight) / 2);\n const hitboxTopLeftX = clampRatio((spriteWidth - box.w) / 2 / spriteWidth);\n const hitboxTopLeftY = clampRatio((spriteHeight - box.h - gap) / spriteHeight);\n const hitboxCenterX = clampRatio(hitboxTopLeftX + box.w / 2 / spriteWidth);\n const hitboxCenterY = clampRatio(hitboxTopLeftY + box.h / 2 / spriteHeight);\n const footY = clampRatio((spriteHeight - gap) / spriteHeight);\n\n switch (box.anchorMode ?? 'top-left') {\n case 'center':\n return [hitboxCenterX, hitboxCenterY];\n case 'foot':\n return [hitboxCenterX, footY];\n case 'top-left':\n default:\n return [hitboxTopLeftX, hitboxTopLeftY];\n }\n };\n\n const loadImageDimensions = (image) => {\n const source = resolveImageSource(image);\n if (!source || imageDimensions()[source] || loadingImageDimensions.has(source)) {\n return;\n }\n\n loadingImageDimensions.add(source);\n Assets.load(source)\n .then((texture) => {\n const width = toPositiveNumber(texture?.width);\n const height = toPositiveNumber(texture?.height);\n if (!width || !height) return;\n\n imageDimensions.update((dimensions) => ({\n ...dimensions,\n [source]: { width, height }\n }));\n })\n .catch(() => {})\n .finally(() => {\n loadingImageDimensions.delete(source);\n });\n };\n\n effect(() => {\n const sources = new Set();\n\n graphicsSignals().forEach((graphicObject) => {\n const baseImage = resolveImageSource(graphicObject?.image);\n if (baseImage) sources.add(baseImage);\n\n Object.values(graphicObject?.textures ?? {}).forEach((textureOptions) => {\n const image = resolveImageSource(textureOptions?.image ?? graphicObject?.image);\n if (image) sources.add(image);\n });\n });\n\n sources.forEach((source) => loadImageDimensions(source));\n });\n\n const hitboxBounds = computed(() => {\n const box = hitbox();\n const width = box?.w ?? 0;\n const height = box?.h ?? 0;\n\n return {\n left: 0,\n top: 0,\n right: width,\n bottom: height,\n width,\n height,\n centerX: width / 2,\n centerY: height / 2\n };\n });\n\n const graphicBounds = computed(() => {\n const box = hitbox();\n const fallback = hitboxBounds();\n const customEventComponent = resolvedEventComponents()[0];\n if (customEventComponent && !customEventComponent.renderGraphic) {\n return fallback;\n }\n const dimensions = imageDimensions();\n const graphics = graphicsSignals();\n let bounds = null;\n\n graphics.forEach((graphicObject) => {\n const textureOptions = resolveTextureOptions(graphicObject);\n const frame = resolveFirstAnimationFrame(textureOptions);\n const size = resolveFrameSize(textureOptions, dimensions);\n const spriteWidth = size.width ?? box?.w;\n const spriteHeight = size.height ?? box?.h;\n\n if (!spriteWidth || !spriteHeight) {\n return;\n }\n\n const explicitAnchor = normalizeAnchor(optionValue('anchor', frame, textureOptions, graphicObject));\n const anchor = explicitAnchor ?? resolveHitboxAnchor(\n spriteWidth,\n spriteHeight,\n optionValue('spriteRealSize', frame, textureOptions, graphicObject),\n box\n );\n const scale = normalizePair(optionValue('scale', frame, textureOptions, graphicObject) ?? graphicScale(graphicObject));\n const x = toFiniteNumber(optionValue('x', frame, textureOptions, graphicObject), 0);\n const y = toFiniteNumber(optionValue('y', frame, textureOptions, graphicObject), 0);\n const leftEdge = -anchor[0] * spriteWidth * scale[0];\n const rightEdge = (1 - anchor[0]) * spriteWidth * scale[0];\n const topEdge = -anchor[1] * spriteHeight * scale[1];\n const bottomEdge = (1 - anchor[1]) * spriteHeight * scale[1];\n const graphic = {\n left: x + Math.min(leftEdge, rightEdge),\n top: y + Math.min(topEdge, bottomEdge),\n right: x + Math.max(leftEdge, rightEdge),\n bottom: y + Math.max(topEdge, bottomEdge)\n };\n\n bounds = bounds\n ? {\n left: Math.min(bounds.left, graphic.left),\n top: Math.min(bounds.top, graphic.top),\n right: Math.max(bounds.right, graphic.right),\n bottom: Math.max(bounds.bottom, graphic.bottom)\n }\n : graphic;\n });\n\n if (!bounds) {\n return fallback;\n }\n\n const width = bounds.right - bounds.left;\n const height = bounds.bottom - bounds.top;\n\n return {\n ...bounds,\n width,\n height,\n centerX: bounds.left + width / 2,\n centerY: bounds.top + height / 2\n };\n });\n\n // Combine animation change detection with movement state from smoothX/smoothY\n const movementAnimations = ['walk', 'stand'];\n const epsilon = 0; // movement threshold to consider the easing still running\n\n const stateX$ = smoothX.animatedState.observable;\n const stateY$ = smoothY.animatedState.observable;\n const animationName$ = animationName.observable;\n\n const moving$ = combineLatest([stateX$, stateY$]).pipe(\n map(([sx, sy]) => {\n const xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;\n const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;\n return !xFinished || !yFinished; // moving if X or Y is not finished\n }),\n startWith(false)\n );\n\n const animationChange$ = animationName$.pipe(\n startWith(animationName()),\n pairwise(),\n filter(([prev, curr]) => prev !== curr)\n );\n\n let beforeRemovePromise = null;\n let beforeRemoveTransitionValue = null;\n const resolveRemoveContext = () => {\n if (!sprite._removeTransition) return null;\n const value = sprite._removeTransition();\n if (!value || typeof value !== 'string') return null;\n try {\n const context = JSON.parse(value);\n if (!context || typeof context !== 'object' || !context.active) return null;\n context.__transitionValue = value;\n return context;\n }\n catch {\n return null;\n }\n };\n\n const withTimeout = (promise, timeoutMs = 0) => {\n if (!timeoutMs || timeoutMs <= 0) return promise;\n return Promise.race([\n promise,\n new Promise((resolve) => setTimeout(resolve, timeoutMs)),\n ]);\n };\n\n const runBeforeRemove = () => {\n const context = resolveRemoveContext();\n if (!context) return Promise.resolve();\n if (beforeRemovePromise && beforeRemoveTransitionValue === context.__transitionValue) {\n return beforeRemovePromise;\n }\n beforeRemoveTransitionValue = context.__transitionValue;\n beforeRemovePromise = withTimeout(\n lastValueFrom(hooks.callHooks(\"client-sprite-onBeforeRemove\", sprite, context)),\n context.timeoutMs\n );\n return beforeRemovePromise;\n };\n\n const removeTransitionSubscription = sprite._removeTransition?.observable?.subscribe(() => {\n if (resolveRemoveContext()) {\n runBeforeRemove();\n }\n });\n\n const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {\n const isMovementAnimation = movementAnimations.includes(curr);\n const isTemporaryAnimationPlaying =\n sprite.animationIsPlaying && sprite.animationIsPlaying();\n\n if (sprite.animationFixed && isMovementAnimation && isTemporaryAnimationPlaying) {\n return;\n }\n\n if (curr == 'stand' && !isMoving) {\n if (!resumeHeldDirectionWalkAnimation()) {\n realAnimationName.set(curr);\n }\n }\n else if (curr == 'walk' && isMoving) {\n realAnimationName.set(curr);\n }\n else if (!isMovementAnimation) {\n realAnimationName.set(curr);\n }\n if (!isMoving && isTemporaryAnimationPlaying) {\n if (isMovementAnimation) {\n if (typeof sprite.resetAnimationState === 'function') {\n sprite.resetAnimationState();\n }\n }\n }\n });\n\n const resumeWalkSubscriptions = [\n sprite._canMove,\n sprite._animationFixed,\n sprite.animationIsPlaying,\n ]\n .filter(signal => signal?.observable)\n .map(signal => signal.observable.subscribe(() => {\n resumeHeldDirectionWalkAnimation();\n }));\n\n /**\n * Cleanup subscriptions and call hooks before sprite destruction.\n *\n * # Design\n * - Prevent memory leaks by unsubscribing from all local subscriptions created in this component.\n * - Execute destruction hooks to notify modules and scene map of sprite removal.\n *\n * @example\n * await onBeforeDestroy();\n */\n const waitForTemporaryAnimationEnd = (maxDuration = 1200) => {\n if (!sprite.animationIsPlaying || !sprite.animationIsPlaying()) {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n let finished = false;\n let timeout;\n let subscription;\n const finish = () => {\n if (finished) return;\n finished = true;\n clearTimeout(timeout);\n subscription?.unsubscribe();\n resolve();\n };\n timeout = setTimeout(finish, maxDuration);\n subscription = sprite.animationIsPlaying.observable.subscribe((isPlaying) => {\n if (!isPlaying) finish();\n });\n if (finished) subscription.unsubscribe();\n });\n };\n\n const onBeforeDestroy = async () => {\n await runBeforeRemove();\n await waitForTemporaryAnimationEnd();\n if (typeof document !== 'undefined') {\n document.removeEventListener('keydown', handleNativeActionWhileMoving);\n document.removeEventListener('keyup', handleNativeActionWhileMoving);\n }\n removeTransitionSubscription?.unsubscribe();\n animationMovementSubscription.unsubscribe();\n resumeWalkSubscriptions.forEach(subscription => subscription.unsubscribe());\n xSubscription.unsubscribe();\n ySubscription.unsubscribe();\n await lastValueFrom(hooks.callHooks(\"client-sprite-onDestroy\", sprite)) \n await lastValueFrom(hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, sprite))\n }\n\n mount((element) => {\n if (typeof document !== 'undefined') {\n document.addEventListener('keydown', handleNativeActionWhileMoving);\n document.addEventListener('keyup', handleNativeActionWhileMoving);\n }\n hooks.callHooks(\"client-sprite-onAdd\", sprite).subscribe()\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, sprite).subscribe()\n effect(() => {\n if (isCurrentPlayer()) {\n client.setKeyboardControls(element.directives.controls)\n }\n })\n })\n\n /**\n * Handle attached GUI finish event\n * \n * @param gui - The GUI instance\n * @param data - Data passed from the GUI component\n */\n const onAttachedGuiFinish = (gui, data) => {\n guiService.guiClose(gui.name, data);\n };\n\n /**\n * Handle attached GUI interaction event\n * \n * @param gui - The GUI instance\n * @param name - Interaction name\n * @param data - Interaction data\n */\n const onAttachedGuiInteraction = (gui, name, data) => {\n guiService.guiInteraction(gui.name, name, data);\n };\n\n tick(() => {\n hooks.callHooks(\"client-sprite-onUpdate\").subscribe()\n })\n</script>\n"],"mappings":";;;;;;;;;;;;;AAmBM,SAAG,UAAA,SAAA;CACQ,SAAA,OAAA;CAET,MAAE,EAAA,QAAc,OADpB,eAAA,OACwB,EAAA;CAC5B,MAAM,SAAC,OAAU;CACjB,MAAM,SAAG,OAAA,eAA4B;CACrC,MAAM,QAAE,OAAS,YAAA;CACjB,MAAI,aAAA,OAAA,MAAA;CACS,OAAA;CACb,MAAG,mBAAiB,OAAQ;CAC5B,MAAG,oBAAuB,OAAE;CAC5B,MAAG,YAAA,UAAyB,OAAO,UAAU,aAAM,MAAa,IAAE;CAClE,MAAM,wBAAgB;EAClB,MAAC,WAAU,OAAa,eAAY;EACpC,MAAG,gBAAW,WAAkB,OAAQ,UAAG,UAAiB,IAAC,YAAA,KAAA;EAC7D,OAAE,SAAS,EAAA,MAAA,YACb,SAAA,QAAA,EAAA,MAAA,YACM,WAAc,iBACb,WAAA,OAAA,UAA0B,mBAAA;CACnC;CACA,MAAM,OAAG,SAAY,eAAa;CAClC,MAAM,iBAAI,eAAoB;EAC1B,MAAM,WAAC,OAAgB,UAAW,WAAI;EACtC,OAAM,QAAA,UAAA,SAAyB,YAAa,UAAU,OAAA,UAAA,KAAA,CAAA;CAC1D,CAAC;CACD,MAAM,sBAAW,SAAA;EACb,IAAA;EACF,IAAA;EACA,IAAA;EAED,IAAM,OAAA,SAAA,cAAA,QAAA,OAAA,SAAA,YAAA,CAAA,KAAA,WAAA;GACC,eAAW;GACX,aAAY,KAAA;;EAElB,OAEO,IAAE,QAAA,OAAiB,SAAA,YAAqB,KAAC,WAAa;GACvD,eAAG,KAAiB;GAEpB,aAAa,KAAC,UAAY,KAAA,IAAa,KAAM,QAAC,KAAA;GAC9C,iBAAG,KAAA;EACT,OAEO;GACD,eAAG;GACH,aAAC,KAAA;GACL,iBAAA,KAAA;EACA;EAGA,OAAO;;GAEH,O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A,EAAA,WAAA,EAAA,OAAA,eAAA,aAAA,UAAA,CAAA,EAAA,GAAA,EAAA,QAAA;GAAA,OAAA,eAAA,MAAA,UAAA,CAAA;GAAA;GAAA;GAAA;GAAA,cAAA,eAAA,aAAA,UAAA,CAAA;GAAA,OAAA;EAAA,CAAA,CAAA,CAAA,GAAA,KAAA,0BAAA,mBAAA,EAAA,WAAA,EAAA,cAAA,eAAA,aAAA,GAAA,EAAA,eAAA,WAAA,eAAA,KAAA,CAAA,CAAA,CAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,KAAA,8BAAA,eAAA,EAAA,WAAA,EAAA,cAAA,WAAA,aAAA,GAAA,EAAA,WAAA,WAAA;GAAA,QAAA;GAAA,GAAA,WAAA;EAAA,CAAA,CAAA,CAAA;EAAA,KAAA,eAAA,gBAAA,KAAA,gCAAA,EAAA,WAAA,MAAA,EAAA,YAAA,WAAA;GAAA,GAAA,YAAA,KAAA;GAAA,cAAA,YAAA;GAAA,QAAA;GAAA,WAAA,SAAA;IACnB,oBAAoB,aAAA,IAAA;;;IAEpB,yBAAC,aAAA,MAAA,IAAA;GACL;EAAI,CAAC,CAAC,CAAC,CAAA;CAAA,CACD;AACN;AAEA,IAAK,iBAAA"}
@@ -4,14 +4,15 @@ import { Container, Graphics, Text, computed, cond, h, useDefineProps, useProps
4
4
  function component($$props) {
5
5
  useProps($$props);
6
6
  const { object, current, max, style, text } = useDefineProps($$props)();
7
+ const sprite = object();
7
8
  const read = (prop, fallback) => prop ? prop() : fallback;
8
9
  const toNumber = (value, fallback = 0) => {
9
- const resolved = resolveDynamicValue(value, object);
10
+ const resolved = resolveDynamicValue(value, sprite);
10
11
  const num = typeof resolved === "number" ? resolved : parseFloat(resolved);
11
12
  return Number.isFinite(num) ? num : fallback;
12
13
  };
13
14
  const toColor = (value, fallback) => {
14
- const resolved = resolveDynamicValue(value, object);
15
+ const resolved = resolveDynamicValue(value, sprite);
15
16
  if (typeof resolved === "number") return resolved;
16
17
  if (typeof resolved === "string" && resolved.startsWith("#")) return parseInt(resolved.slice(1), 16);
17
18
  return resolved ?? fallback;
@@ -38,7 +39,7 @@ function component($$props) {
38
39
  const template = labelTemplate();
39
40
  if (template == null || template === "") return "";
40
41
  const value = String(template).replace(/\{\$current\}/g, String(currentValue())).replace(/\{\$max\}/g, String(maxValue())).replace(/\{\$percent\}/g, String(Math.round(percent() * 100)));
41
- return String(resolveDynamicValue(value, object) ?? "");
42
+ return String(resolveDynamicValue(value, sprite) ?? "");
42
43
  });
43
44
  const labelSize = computed(() => toNumber(config().fontSize, 10));
44
45
  const hasLabel = computed(() => labelText().length > 0);