@rpgjs/client 5.0.0-beta.22 → 5.0.0-beta.23
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.
- package/CHANGELOG.md +9 -0
- package/dist/Game/Object.d.ts +1 -0
- package/dist/Game/Object.js +10 -0
- package/dist/Game/Object.js.map +1 -1
- package/dist/RpgClientEngine.d.ts +2 -0
- package/dist/RpgClientEngine.js +15 -6
- package/dist/RpgClientEngine.js.map +1 -1
- package/dist/components/character-hitbox.d.ts +13 -0
- package/dist/components/character-hitbox.js +38 -0
- package/dist/components/character-hitbox.js.map +1 -0
- package/dist/components/character-hitbox.spec.d.ts +1 -0
- package/dist/components/character.ce.js +29 -27
- package/dist/components/character.ce.js.map +1 -1
- package/dist/services/standalone.d.ts +6 -1
- package/dist/services/standalone.js +35 -17
- package/dist/services/standalone.js.map +1 -1
- package/dist/utils/syncHitbox.d.ts +1 -0
- package/dist/utils/syncHitbox.js +69 -0
- package/dist/utils/syncHitbox.js.map +1 -0
- package/dist/utils/syncHitbox.spec.d.ts +1 -0
- package/package.json +3 -3
- package/src/Game/Object.spec.ts +44 -4
- package/src/Game/Object.ts +19 -0
- package/src/RpgClientEngine.ts +19 -6
- package/src/components/character-hitbox.spec.ts +33 -0
- package/src/components/character-hitbox.ts +72 -0
- package/src/components/character.ce +40 -39
- package/src/services/standalone.spec.ts +47 -0
- package/src/services/standalone.ts +53 -20
- package/src/utils/syncHitbox.spec.ts +79 -0
- package/src/utils/syncHitbox.ts +104 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type CharacterHitbox = {
|
|
2
|
+
w: number;
|
|
3
|
+
h: number;
|
|
4
|
+
anchorMode?: "top-left" | "center" | "foot";
|
|
5
|
+
};
|
|
6
|
+
export declare const toPositiveNumber: (value: unknown) => number | undefined;
|
|
7
|
+
export declare const scaleHitboxForGraphicDisplay: (box: CharacterHitbox | null | undefined, scale: [number, number]) => CharacterHitbox | null;
|
|
8
|
+
export declare const resolveHitboxAnchor: (spriteWidth: number | undefined, spriteHeight: number | undefined, realSize: number | {
|
|
9
|
+
height?: number;
|
|
10
|
+
} | undefined, box: CharacterHitbox | null | undefined) => [number, number];
|
|
11
|
+
export declare const resolveScaledHitboxAnchor: (spriteWidth: number | undefined, spriteHeight: number | undefined, realSize: number | {
|
|
12
|
+
height?: number;
|
|
13
|
+
} | undefined, box: CharacterHitbox | null | undefined, scale: [number, number]) => [number, number];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/components/character-hitbox.ts
|
|
2
|
+
var toPositiveNumber = (value) => {
|
|
3
|
+
const number = typeof value === "number" ? value : parseFloat(String(value));
|
|
4
|
+
return Number.isFinite(number) && number > 0 ? number : void 0;
|
|
5
|
+
};
|
|
6
|
+
var clampRatio = (value) => Math.min(1, Math.max(0, value));
|
|
7
|
+
var scaleHitboxForGraphicDisplay = (box, scale) => {
|
|
8
|
+
if (!box) return null;
|
|
9
|
+
const scaleX = Math.abs(toPositiveNumber(scale[0]) ?? 1);
|
|
10
|
+
const scaleY = Math.abs(toPositiveNumber(scale[1]) ?? scaleX);
|
|
11
|
+
return {
|
|
12
|
+
...box,
|
|
13
|
+
w: box.w / scaleX,
|
|
14
|
+
h: box.h / scaleY
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
var resolveHitboxAnchor = (spriteWidth, spriteHeight, realSize, box) => {
|
|
18
|
+
if (!spriteWidth || !spriteHeight || !box) return [0, 0];
|
|
19
|
+
const resolvedHeight = toPositiveNumber(typeof realSize === "number" ? realSize : realSize?.height) ?? spriteHeight;
|
|
20
|
+
const gap = Math.max(0, (spriteHeight - resolvedHeight) / 2);
|
|
21
|
+
const hitboxTopLeftX = clampRatio((spriteWidth - box.w) / 2 / spriteWidth);
|
|
22
|
+
const hitboxTopLeftY = clampRatio((spriteHeight - box.h - gap) / spriteHeight);
|
|
23
|
+
const hitboxCenterX = clampRatio(hitboxTopLeftX + box.w / 2 / spriteWidth);
|
|
24
|
+
const hitboxCenterY = clampRatio(hitboxTopLeftY + box.h / 2 / spriteHeight);
|
|
25
|
+
const footY = clampRatio((spriteHeight - gap) / spriteHeight);
|
|
26
|
+
switch (box.anchorMode ?? "top-left") {
|
|
27
|
+
case "center": return [hitboxCenterX, hitboxCenterY];
|
|
28
|
+
case "foot": return [hitboxCenterX, footY];
|
|
29
|
+
default: return [hitboxTopLeftX, hitboxTopLeftY];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var resolveScaledHitboxAnchor = (spriteWidth, spriteHeight, realSize, box, scale) => {
|
|
33
|
+
return resolveHitboxAnchor(spriteWidth, spriteHeight, realSize, scaleHitboxForGraphicDisplay(box, scale));
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { resolveScaledHitboxAnchor, scaleHitboxForGraphicDisplay, toPositiveNumber };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=character-hitbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"character-hitbox.js","names":[],"sources":["../../src/components/character-hitbox.ts"],"sourcesContent":["export type CharacterHitbox = {\n w: number;\n h: number;\n anchorMode?: \"top-left\" | \"center\" | \"foot\";\n};\n\nexport const toPositiveNumber = (value: unknown): number | undefined => {\n const number = typeof value === \"number\" ? value : parseFloat(String(value));\n return Number.isFinite(number) && number > 0 ? number : undefined;\n};\n\nconst clampRatio = (value: number): number => Math.min(1, Math.max(0, value));\n\nexport const scaleHitboxForGraphicDisplay = (\n box: CharacterHitbox | null | undefined,\n scale: [number, number],\n): CharacterHitbox | null => {\n if (!box) return null;\n const scaleX = Math.abs(toPositiveNumber(scale[0]) ?? 1);\n const scaleY = Math.abs(toPositiveNumber(scale[1]) ?? scaleX);\n\n return {\n ...box,\n w: box.w / scaleX,\n h: box.h / scaleY,\n };\n};\n\nexport const resolveHitboxAnchor = (\n spriteWidth: number | undefined,\n spriteHeight: number | undefined,\n realSize: number | { height?: number } | undefined,\n box: CharacterHitbox | null | undefined,\n): [number, number] => {\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\nexport const resolveScaledHitboxAnchor = (\n spriteWidth: number | undefined,\n spriteHeight: number | undefined,\n realSize: number | { height?: number } | undefined,\n box: CharacterHitbox | null | undefined,\n scale: [number, number],\n): [number, number] => {\n return resolveHitboxAnchor(\n spriteWidth,\n spriteHeight,\n realSize,\n scaleHitboxForGraphicDisplay(box, scale),\n );\n};\n"],"mappings":";AAMA,IAAa,oBAAoB,UAAuC;CACtE,MAAM,SAAS,OAAO,UAAU,WAAW,QAAQ,WAAW,OAAO,KAAK,CAAC;CAC3E,OAAO,OAAO,SAAS,MAAM,KAAK,SAAS,IAAI,SAAS,KAAA;AAC1D;AAEA,IAAM,cAAc,UAA0B,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;AAE5E,IAAa,gCACX,KACA,UAC2B;CAC3B,IAAI,CAAC,KAAK,OAAO;CACjB,MAAM,SAAS,KAAK,IAAI,iBAAiB,MAAM,EAAE,KAAK,CAAC;CACvD,MAAM,SAAS,KAAK,IAAI,iBAAiB,MAAM,EAAE,KAAK,MAAM;CAE5D,OAAO;EACL,GAAG;EACH,GAAG,IAAI,IAAI;EACX,GAAG,IAAI,IAAI;CACb;AACF;AAEA,IAAa,uBACX,aACA,cACA,UACA,QACqB;CACrB,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,KACpC,OAAO,CAAC,GAAG,CAAC;CAId,MAAM,iBAAiB,iBADA,OAAO,aAAa,WAAW,WAAW,UAAU,MACrB,KAAK;CAC3D,MAAM,MAAM,KAAK,IAAI,IAAI,eAAe,kBAAkB,CAAC;CAC3D,MAAM,iBAAiB,YAAY,cAAc,IAAI,KAAK,IAAI,WAAW;CACzE,MAAM,iBAAiB,YAAY,eAAe,IAAI,IAAI,OAAO,YAAY;CAC7E,MAAM,gBAAgB,WAAW,iBAAiB,IAAI,IAAI,IAAI,WAAW;CACzE,MAAM,gBAAgB,WAAW,iBAAiB,IAAI,IAAI,IAAI,YAAY;CAC1E,MAAM,QAAQ,YAAY,eAAe,OAAO,YAAY;CAE5D,QAAQ,IAAI,cAAc,YAA1B;EACE,KAAK,UACH,OAAO,CAAC,eAAe,aAAa;EACtC,KAAK,QACH,OAAO,CAAC,eAAe,KAAK;EAE9B,SACE,OAAO,CAAC,gBAAgB,cAAc;CAC1C;AACF;AAEA,IAAa,6BACX,aACA,cACA,UACA,KACA,UACqB;CACrB,OAAO,oBACL,aACA,cACA,UACA,6BAA6B,KAAK,KAAK,CACzC;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,6 +5,7 @@ import { RpgGui } from "../Gui/Gui.js";
|
|
|
5
5
|
import { normalizeEventComponent } from "../Game/EventComponentResolver.js";
|
|
6
6
|
import { RpgClientEngine } from "../RpgClientEngine.js";
|
|
7
7
|
import { applyCameraFollow, clearCameraFollowPlugins, ownsCameraFollowRevision } from "../services/cameraFollow.js";
|
|
8
|
+
import { resolveScaledHitboxAnchor, scaleHitboxForGraphicDisplay, toPositiveNumber } from "./character-hitbox.js";
|
|
8
9
|
import __ce_component$1 from "./player-components.ce.js";
|
|
9
10
|
import __ce_component$2 from "./interaction-components.ce.js";
|
|
10
11
|
import { Container, Sprite, animatedSignal, computed, cond, effect, h, loop, mount, on, signal, tick, useDefineEmits, useDefineProps, useProps } from "canvasengine";
|
|
@@ -395,7 +396,7 @@ function component($$props) {
|
|
|
395
396
|
};
|
|
396
397
|
};
|
|
397
398
|
const graphicScale = (graphicObject) => {
|
|
398
|
-
const scale = graphicObject?.
|
|
399
|
+
const scale = graphicObject?.scale;
|
|
399
400
|
if (Array.isArray(scale)) return scale;
|
|
400
401
|
if (typeof scale === "number") return [scale, scale];
|
|
401
402
|
if (scale && typeof scale === "object") {
|
|
@@ -403,12 +404,28 @@ function component($$props) {
|
|
|
403
404
|
return [x, typeof scale.y === "number" ? scale.y : x];
|
|
404
405
|
}
|
|
405
406
|
};
|
|
407
|
+
const graphicContainerScale = (graphicObject) => {
|
|
408
|
+
const scale = graphicObject?.displayScale;
|
|
409
|
+
if (Array.isArray(scale)) return scale;
|
|
410
|
+
if (typeof scale === "number") return [scale, scale];
|
|
411
|
+
if (scale && typeof scale === "object") {
|
|
412
|
+
const x = typeof scale.x === "number" ? scale.x : 1;
|
|
413
|
+
return [x, typeof scale.y === "number" ? scale.y : x];
|
|
414
|
+
}
|
|
415
|
+
return [1, 1];
|
|
416
|
+
};
|
|
417
|
+
const multiplyScale = (left, right) => {
|
|
418
|
+
const a = normalizePair(left);
|
|
419
|
+
const b = normalizePair(right);
|
|
420
|
+
return [a[0] * b[0], a[1] * b[1]];
|
|
421
|
+
};
|
|
422
|
+
const graphicHitbox = (graphicObject) => {
|
|
423
|
+
return scaleHitboxForGraphicDisplay(hitbox(), graphicEffectiveScale(graphicObject));
|
|
424
|
+
};
|
|
406
425
|
const shadowCaster = (graphicObject) => {
|
|
407
426
|
const box = hitbox();
|
|
408
427
|
const bounds = graphicBounds();
|
|
409
|
-
const
|
|
410
|
-
const scaleY = Array.isArray(scale) && typeof scale[1] === "number" ? Math.abs(scale[1]) : 1;
|
|
411
|
-
const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32) * scaleY;
|
|
428
|
+
const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32);
|
|
412
429
|
return {
|
|
413
430
|
enabled: shadowsEnabled,
|
|
414
431
|
height,
|
|
@@ -432,10 +449,6 @@ function component($$props) {
|
|
|
432
449
|
};
|
|
433
450
|
const imageDimensions = signal({});
|
|
434
451
|
const loadingImageDimensions = /* @__PURE__ */ new Set();
|
|
435
|
-
const toPositiveNumber = (value) => {
|
|
436
|
-
const number = typeof value === "number" ? value : parseFloat(value);
|
|
437
|
-
return Number.isFinite(number) && number > 0 ? number : void 0;
|
|
438
|
-
};
|
|
439
452
|
const toFiniteNumber = (value, fallback = 0) => {
|
|
440
453
|
const number = typeof value === "number" ? value : parseFloat(value);
|
|
441
454
|
return Number.isFinite(number) ? number : fallback;
|
|
@@ -508,6 +521,10 @@ function component($$props) {
|
|
|
508
521
|
const optionValue = (prop, frame, textureOptions, graphicObject) => {
|
|
509
522
|
return frame?.[prop] ?? textureOptions?.[prop] ?? graphicObject?.[prop];
|
|
510
523
|
};
|
|
524
|
+
const graphicEffectiveScale = (graphicObject) => {
|
|
525
|
+
const textureOptions = resolveTextureOptions(graphicObject);
|
|
526
|
+
return multiplyScale(normalizePair(optionValue("scale", resolveFirstAnimationFrame(textureOptions), textureOptions, graphicObject) ?? graphicScale(graphicObject)), graphicContainerScale(graphicObject));
|
|
527
|
+
};
|
|
511
528
|
const resolveFrameSize = (textureOptions, dimensions) => {
|
|
512
529
|
const framesWidth = toPositiveNumber(textureOptions?.framesWidth) ?? 1;
|
|
513
530
|
const framesHeight = toPositiveNumber(textureOptions?.framesHeight) ?? 1;
|
|
@@ -520,21 +537,6 @@ function component($$props) {
|
|
|
520
537
|
height: toPositiveNumber(textureOptions?.rectHeight) ?? toPositiveNumber(textureOptions?.spriteHeight) ?? (fullHeight ? fullHeight / framesHeight : void 0)
|
|
521
538
|
};
|
|
522
539
|
};
|
|
523
|
-
const resolveHitboxAnchor = (spriteWidth, spriteHeight, realSize, box) => {
|
|
524
|
-
if (!spriteWidth || !spriteHeight || !box) return [0, 0];
|
|
525
|
-
const resolvedHeight = toPositiveNumber(typeof realSize === "number" ? realSize : realSize?.height) ?? spriteHeight;
|
|
526
|
-
const gap = Math.max(0, (spriteHeight - resolvedHeight) / 2);
|
|
527
|
-
const hitboxTopLeftX = clampRatio((spriteWidth - box.w) / 2 / spriteWidth);
|
|
528
|
-
const hitboxTopLeftY = clampRatio((spriteHeight - box.h - gap) / spriteHeight);
|
|
529
|
-
const hitboxCenterX = clampRatio(hitboxTopLeftX + box.w / 2 / spriteWidth);
|
|
530
|
-
const hitboxCenterY = clampRatio(hitboxTopLeftY + box.h / 2 / spriteHeight);
|
|
531
|
-
const footY = clampRatio((spriteHeight - gap) / spriteHeight);
|
|
532
|
-
switch (box.anchorMode ?? "top-left") {
|
|
533
|
-
case "center": return [hitboxCenterX, hitboxCenterY];
|
|
534
|
-
case "foot": return [hitboxCenterX, footY];
|
|
535
|
-
default: return [hitboxTopLeftX, hitboxTopLeftY];
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
540
|
const loadImageDimensions = (image) => {
|
|
539
541
|
const source = resolveImageSource(image);
|
|
540
542
|
if (!source || imageDimensions()[source] || loadingImageDimensions.has(source)) return;
|
|
@@ -596,8 +598,8 @@ function component($$props) {
|
|
|
596
598
|
const spriteWidth = size.width ?? box?.w;
|
|
597
599
|
const spriteHeight = size.height ?? box?.h;
|
|
598
600
|
if (!spriteWidth || !spriteHeight) return;
|
|
599
|
-
const
|
|
600
|
-
const
|
|
601
|
+
const scale = graphicEffectiveScale(graphicObject);
|
|
602
|
+
const anchor = normalizeAnchor(optionValue("anchor", frame, textureOptions, graphicObject)) ?? resolveScaledHitboxAnchor(spriteWidth, spriteHeight, optionValue("spriteRealSize", frame, textureOptions, graphicObject), box, scale);
|
|
601
603
|
const x = toFiniteNumber(optionValue("x", frame, textureOptions, graphicObject), 0);
|
|
602
604
|
const y = toFiniteNumber(optionValue("y", frame, textureOptions, graphicObject), 0);
|
|
603
605
|
const leftEdge = -anchor[0] * spriteWidth * scale[0];
|
|
@@ -837,11 +839,11 @@ function component($$props) {
|
|
|
837
839
|
zIndex: 1e3,
|
|
838
840
|
name: particleName
|
|
839
841
|
}),
|
|
840
|
-
h(Container, null, [loop(renderedGraphics, (graphicObj) => h(Container, { scale: computed(() =>
|
|
842
|
+
h(Container, null, [loop(renderedGraphics, (graphicObj) => h(Container, { scale: computed(() => graphicContainerScale(graphicObj)) }, h(Sprite, {
|
|
841
843
|
sheet: computed(() => sheet(graphicObj)),
|
|
842
844
|
direction,
|
|
843
845
|
tint,
|
|
844
|
-
hitbox,
|
|
846
|
+
hitbox: computed(() => graphicHitbox(graphicObj)),
|
|
845
847
|
shadowCaster: computed(() => shadowCaster(graphicObj)),
|
|
846
848
|
flash: flashConfig
|
|
847
849
|
}))), loop(resolvedEventComponents, (eventComponent) => h(Container, { dependencies: eventComponent.dependencies }, h(eventComponent.component, eventComponent.props)))]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"character.ce.js","names":[],"sources":["../../src/components/character.ce"],"sourcesContent":["<Container\n x={smoothX}\n y={smoothY}\n zIndex={z}\n controls\n onBeforeDestroy\n visible\n cursor={interactionCursor}\n pointerover={interactionPointerOver}\n pointerout={interactionPointerOut}\n pointerdown={interactionPointerDown}\n pointerup={interactionPointerUp}\n pointermove={interactionPointerMove}\n click={interactionClick}\n>\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 <InteractionComponents\n object={sprite}\n bounds={graphicBounds}\n hitboxBounds={hitboxBounds}\n graphicBounds={graphicBounds}\n />\n @for (attachedGui of attachedGuis) {\n @if (shouldDisplayAttachedGui) {\n <Container>\n <attachedGui.component ...attachedGui.data() dependencies={attachedGui.dependencies} object={sprite} guiOpenId={attachedGui.openId} onFinish={(data, guiOpenId) => {\n onAttachedGuiFinish(attachedGui, data, guiOpenId)\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, shouldRenderLightingShadows } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { applyCameraFollow, clearCameraFollowPlugins, ownsCameraFollowRevision } from \"../services/cameraFollow\";\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 InteractionComponents from \"./interaction-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 shouldRenderLightingShadows(lighting);\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 const activeControlDirections = new Map();\n const activeControlDirectionReleaseTimers = new Map();\n const CONTROL_DIRECTION_RELEASE_GRACE_MS = 160;\n\n const hasHeldDirection = () =>\n activeDirectionKeys.size > 0 || activeControlDirections.size > 0;\n\n const publishMobileDebug = (type, payload = {}) => {\n const target = typeof window !== \"undefined\" ? window : globalThis;\n if (!target.__RPGJS_MOBILE_DEBUG__) return;\n const event = {\n source: \"character\",\n type,\n time: Date.now(),\n isCurrentPlayer: isCurrentPlayer(),\n animationName: animationName(),\n realAnimationName: realAnimationName?.(),\n activeKeyboardDirections: Array.from(activeDirectionKeys.values()),\n activeControlDirections: Array.from(activeControlDirections.values()),\n heldDirection: resolveHeldDirection(),\n canControls: canControls(),\n x: x(),\n y: y(),\n ...payload\n };\n target.__RPGJS_MOBILE_DEBUG_EVENTS__ = [\n ...(target.__RPGJS_MOBILE_DEBUG_EVENTS__ || []).slice(-199),\n event\n ];\n target.__RPGJS_MOBILE_DEBUG_LAST__ = event;\n };\n\n const resolveHeldDirection = () => {\n const directions = [\n ...Array.from(activeDirectionKeys.values()),\n ...Array.from(activeControlDirections.values()),\n ];\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 directionToDashVector = (currentDirection) => {\n switch (currentDirection) {\n case Direction.Left:\n return { x: -1, y: 0 };\n case Direction.Right:\n return { x: 1, y: 0 };\n case Direction.Up:\n return { x: 0, y: -1 };\n case Direction.Down:\n default:\n return { x: 0, y: 1 };\n }\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) {\n publishMobileDebug(\"walk:skip\", { reason: \"animationFixed\" });\n return;\n }\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) {\n publishMobileDebug(\"walk:skip\", { reason: \"animationIsPlaying\" });\n return;\n }\n realAnimationName.set('walk');\n publishMobileDebug(\"walk:set\", { reason: \"predicted\" });\n };\n\n const resumeHeldDirectionWalkAnimation = () => {\n if (!isCurrentPlayer()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"notCurrentPlayer\" });\n return false;\n }\n if (!hasHeldDirection()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"noHeldDirection\" });\n return false;\n }\n if (!canControls()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"cannotControl\" });\n return false;\n }\n if (sprite.animationFixed) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"animationFixed\" });\n return false;\n }\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"animationIsPlaying\" });\n return false;\n }\n realAnimationName.set('walk');\n publishMobileDebug(\"walk:set\", { reason: \"resumeHeldDirection\" });\n return true;\n };\n\n const processMovementInput = (input) => {\n if (!canControls()) return;\n publishMobileDebug(\"movement:input\", { input });\n client.processInput({ input });\n playPredictedWalkAnimation();\n };\n\n const activateControlDirection = (name, directionInput) => {\n const releaseTimer = activeControlDirectionReleaseTimers.get(name);\n if (releaseTimer) {\n clearTimeout(releaseTimer);\n activeControlDirectionReleaseTimers.delete(name);\n }\n activeControlDirections.delete(name);\n activeControlDirections.set(name, directionInput);\n publishMobileDebug(\"control:activate\", { name, directionInput });\n resumeHeldDirectionWalkAnimation();\n };\n\n const releaseControlDirection = (name) => {\n const previousTimer = activeControlDirectionReleaseTimers.get(name);\n if (previousTimer) clearTimeout(previousTimer);\n activeControlDirectionReleaseTimers.set(name, setTimeout(() => {\n activeControlDirectionReleaseTimers.delete(name);\n activeControlDirections.delete(name);\n publishMobileDebug(\"control:release\", { name });\n if (!hasHeldDirection() && animationName() === 'stand') {\n realAnimationName.set('stand');\n publishMobileDebug(\"stand:set\", { reason: \"controlRelease\" });\n }\n }, CONTROL_DIRECTION_RELEASE_GRACE_MS));\n };\n\n const processDashInput = () => {\n if (!canControls()) return;\n client.processDash({\n direction: directionToDashVector(resolveSpriteDirection()),\n });\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 activateControlDirection('down', Direction.Down)\n processMovementInput(Direction.Down)\n },\n keyUp() {\n releaseControlDirection('down')\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n activateControlDirection('up', Direction.Up)\n processMovementInput(Direction.Up)\n },\n keyUp() {\n releaseControlDirection('up')\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n activateControlDirection('left', Direction.Left)\n processMovementInput(Direction.Left)\n },\n keyUp() {\n releaseControlDirection('left')\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n activateControlDirection('right', Direction.Right)\n processMovementInput(Direction.Right)\n },\n keyUp() {\n releaseControlDirection('right')\n },\n },\n action: {\n bind: getKeyboardControlBind(keyboardControls.action),\n keyDown() {\n if (canControls()) {\n client.processAction(resolveCurrentActionInput())\n }\n },\n },\n dash: {\n bind: keyboardControls.dash,\n keyDown() {\n processDashInput()\n },\n },\n back: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n joystick: {\n enabled: true,\n directionMapping: {\n top: 'up',\n bottom: 'down',\n left: 'left',\n right: 'right',\n top_left: ['up', 'left'],\n top_right: ['up', 'right'],\n bottom_left: ['down', 'left'],\n bottom_right: ['down', 'right']\n },\n moveInterval: 50,\n threshold: 0.1\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 const box = hitbox?.()\n return sprite.y() + (box?.h ?? 0) + 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?.displayScale ?? 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 const interactionBounds = () => ({\n bounds: graphicBounds(),\n hitbox: hitboxBounds(),\n graphic: graphicBounds()\n });\n\n const interactionCursor = computed(() =>\n client.interactions.cursorFor(sprite, interactionBounds())\n );\n\n const handleInteraction = (type) => (event) => {\n client.updatePointerFromInteractionEvent(event);\n client.interactions.handle(sprite, type, {\n event,\n bounds: interactionBounds()\n });\n };\n\n const interactionPointerOver = handleInteraction('pointerover');\n const interactionPointerOut = handleInteraction('pointerout');\n const interactionPointerDown = handleInteraction('pointerdown');\n const interactionPointerUp = handleInteraction('pointerup');\n const interactionPointerMove = handleInteraction('pointermove');\n const interactionClick = handleInteraction('click');\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) {\n realAnimationName.set(curr);\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 activeControlDirectionReleaseTimers.forEach(timer => clearTimeout(timer));\n activeControlDirectionReleaseTimers.clear();\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 let appliedCameraFollowRevision = null;\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 effect(() => {\n const followRevision = client.cameraFollowRevision();\n if (!shouldFollowCamera()) {\n appliedCameraFollowRevision = null;\n return;\n }\n\n const smoothMove = client.cameraFollowSmoothMove;\n const viewport = element.props.context?.viewport;\n const target = element.componentInstance;\n if (!viewport || !target) {\n appliedCameraFollowRevision = null;\n return;\n }\n\n const appliedCameraFollow = applyCameraFollow({\n viewport,\n target,\n smoothMove,\n followRevision,\n isCurrentRevision: (revision) => client.cameraFollowRevision() === revision,\n shouldFollowCamera\n });\n appliedCameraFollowRevision = appliedCameraFollow ? followRevision : null;\n })\n\n return () => {\n if (ownsCameraFollowRevision(appliedCameraFollowRevision, client.cameraFollowRevision())) {\n clearCameraFollowPlugins(element.props.context?.viewport);\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 normalizeOpenId = (value) => {\n const resolved = typeof value === \"function\" ? value() : value;\n return typeof resolved === \"string\" && resolved.length > 0 ? resolved : undefined;\n };\n\n const onAttachedGuiFinish = (gui, data, guiOpenId) => {\n const completedOpenId = normalizeOpenId(guiOpenId);\n const currentOpenId = normalizeOpenId(gui.openId);\n if (completedOpenId && currentOpenId && completedOpenId !== currentOpenId) return;\n guiService.guiClose(gui.name, data, completedOpenId ?? currentOpenId);\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":";;;;;;;;;;;;;;;AAqBG,SAAA,UAAiB,SAAc;CAChB,SAAA,OAAqB;CACpC,MAAS,cAAA,eAAA,OAAA;CACY,eAAkB,OAAA;CACnC,MAAA,EAAS,QAAQ,OAAA,YAAa;CACrC,MAAM,SAAS,OAAA;CACf,MAAM,SAAS,OAAO,eAAa;CACnC,MAAM,QAAI,OAAS,YAAA;CACnB,MAAM,aAAQ,OAAA,MAAA;CACJ,OAAA;CACV,MAAM,mBAAkB,OAAA;CACxB,MAAM,oBAAW,OAAW;CAC5B,MAAM,YAAG,UAAA,OAAA,UAAA,aAAA,MAAA,IAAA;CACT,MAAM,wBAAW;EACb,MAAA,WAAA,OAAA,eAAA;EACA,MAAM,gBAAe,WAAG,OAAA,UAAyB,UAAA,IAAA,YAAA,KAAA;EACjD,OAAG,SAAU,EAAA,MAAA,YACR,SAAA,QAAe,EAAA,MAAY,YAC5B,WAAS,iBACb,WAAA,OAAA,UAAA,mBAAA;CACJ;CACA,MAAG,OAAA,SAAiB,eAAgB;CACpC,MAAG,iBAAiB,eAAgB;EACjC,MAAA,WAAiB,OAAQ,UAAQ,WAAa;EAC9C,OAAK,4BAAc,QAAA;CACtB,CAAC;CACD,MAAM,sBAAsB,SAAQ;EAChC,IAAE;EACJ,IAAA;EACC,IAAA;EAEC,IAAA,OAAQ,SAAA,cAAa,QAAA,OAAA,SAAA,YAAA,CAAA,KAAA,WAAA;GACrB,eAAc;GACd,aAAe,KAAA;GAChB,iBAAA,KAAA;EACA,OAEI,IAAA,QAAS,OAAA,SAAA,Y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CAAC,CAAA,CAAA,CAAA;CAAA,CACG;AACR;AAEA,IAAM,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"character.ce.js","names":[],"sources":["../../src/components/character.ce"],"sourcesContent":["<Container\n x={smoothX}\n y={smoothY}\n zIndex={z}\n controls\n onBeforeDestroy\n visible\n cursor={interactionCursor}\n pointerover={interactionPointerOver}\n pointerout={interactionPointerOut}\n pointerdown={interactionPointerDown}\n pointerup={interactionPointerUp}\n pointermove={interactionPointerMove}\n click={interactionClick}\n>\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={graphicContainerScale(graphicObj)}>\n <Sprite \n sheet={sheet(graphicObj)} \n direction \n tint \n hitbox={graphicHitbox(graphicObj)}\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 <InteractionComponents\n object={sprite}\n bounds={graphicBounds}\n hitboxBounds={hitboxBounds}\n graphicBounds={graphicBounds}\n />\n @for (attachedGui of attachedGuis) {\n @if (shouldDisplayAttachedGui) {\n <Container>\n <attachedGui.component ...attachedGui.data() dependencies={attachedGui.dependencies} object={sprite} guiOpenId={attachedGui.openId} onFinish={(data, guiOpenId) => {\n onAttachedGuiFinish(attachedGui, data, guiOpenId)\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, shouldRenderLightingShadows } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { applyCameraFollow, clearCameraFollowPlugins, ownsCameraFollowRevision } from \"../services/cameraFollow\";\n import { resolveScaledHitboxAnchor, scaleHitboxForGraphicDisplay, toPositiveNumber } from \"./character-hitbox\";\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 InteractionComponents from \"./interaction-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 shouldRenderLightingShadows(lighting);\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 const activeControlDirections = new Map();\n const activeControlDirectionReleaseTimers = new Map();\n const CONTROL_DIRECTION_RELEASE_GRACE_MS = 160;\n\n const hasHeldDirection = () =>\n activeDirectionKeys.size > 0 || activeControlDirections.size > 0;\n\n const publishMobileDebug = (type, payload = {}) => {\n const target = typeof window !== \"undefined\" ? window : globalThis;\n if (!target.__RPGJS_MOBILE_DEBUG__) return;\n const event = {\n source: \"character\",\n type,\n time: Date.now(),\n isCurrentPlayer: isCurrentPlayer(),\n animationName: animationName(),\n realAnimationName: realAnimationName?.(),\n activeKeyboardDirections: Array.from(activeDirectionKeys.values()),\n activeControlDirections: Array.from(activeControlDirections.values()),\n heldDirection: resolveHeldDirection(),\n canControls: canControls(),\n x: x(),\n y: y(),\n ...payload\n };\n target.__RPGJS_MOBILE_DEBUG_EVENTS__ = [\n ...(target.__RPGJS_MOBILE_DEBUG_EVENTS__ || []).slice(-199),\n event\n ];\n target.__RPGJS_MOBILE_DEBUG_LAST__ = event;\n };\n\n const resolveHeldDirection = () => {\n const directions = [\n ...Array.from(activeDirectionKeys.values()),\n ...Array.from(activeControlDirections.values()),\n ];\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 directionToDashVector = (currentDirection) => {\n switch (currentDirection) {\n case Direction.Left:\n return { x: -1, y: 0 };\n case Direction.Right:\n return { x: 1, y: 0 };\n case Direction.Up:\n return { x: 0, y: -1 };\n case Direction.Down:\n default:\n return { x: 0, y: 1 };\n }\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) {\n publishMobileDebug(\"walk:skip\", { reason: \"animationFixed\" });\n return;\n }\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) {\n publishMobileDebug(\"walk:skip\", { reason: \"animationIsPlaying\" });\n return;\n }\n realAnimationName.set('walk');\n publishMobileDebug(\"walk:set\", { reason: \"predicted\" });\n };\n\n const resumeHeldDirectionWalkAnimation = () => {\n if (!isCurrentPlayer()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"notCurrentPlayer\" });\n return false;\n }\n if (!hasHeldDirection()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"noHeldDirection\" });\n return false;\n }\n if (!canControls()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"cannotControl\" });\n return false;\n }\n if (sprite.animationFixed) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"animationFixed\" });\n return false;\n }\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"animationIsPlaying\" });\n return false;\n }\n realAnimationName.set('walk');\n publishMobileDebug(\"walk:set\", { reason: \"resumeHeldDirection\" });\n return true;\n };\n\n const processMovementInput = (input) => {\n if (!canControls()) return;\n publishMobileDebug(\"movement:input\", { input });\n client.processInput({ input });\n playPredictedWalkAnimation();\n };\n\n const activateControlDirection = (name, directionInput) => {\n const releaseTimer = activeControlDirectionReleaseTimers.get(name);\n if (releaseTimer) {\n clearTimeout(releaseTimer);\n activeControlDirectionReleaseTimers.delete(name);\n }\n activeControlDirections.delete(name);\n activeControlDirections.set(name, directionInput);\n publishMobileDebug(\"control:activate\", { name, directionInput });\n resumeHeldDirectionWalkAnimation();\n };\n\n const releaseControlDirection = (name) => {\n const previousTimer = activeControlDirectionReleaseTimers.get(name);\n if (previousTimer) clearTimeout(previousTimer);\n activeControlDirectionReleaseTimers.set(name, setTimeout(() => {\n activeControlDirectionReleaseTimers.delete(name);\n activeControlDirections.delete(name);\n publishMobileDebug(\"control:release\", { name });\n if (!hasHeldDirection() && animationName() === 'stand') {\n realAnimationName.set('stand');\n publishMobileDebug(\"stand:set\", { reason: \"controlRelease\" });\n }\n }, CONTROL_DIRECTION_RELEASE_GRACE_MS));\n };\n\n const processDashInput = () => {\n if (!canControls()) return;\n client.processDash({\n direction: directionToDashVector(resolveSpriteDirection()),\n });\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 activateControlDirection('down', Direction.Down)\n processMovementInput(Direction.Down)\n },\n keyUp() {\n releaseControlDirection('down')\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n activateControlDirection('up', Direction.Up)\n processMovementInput(Direction.Up)\n },\n keyUp() {\n releaseControlDirection('up')\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n activateControlDirection('left', Direction.Left)\n processMovementInput(Direction.Left)\n },\n keyUp() {\n releaseControlDirection('left')\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n activateControlDirection('right', Direction.Right)\n processMovementInput(Direction.Right)\n },\n keyUp() {\n releaseControlDirection('right')\n },\n },\n action: {\n bind: getKeyboardControlBind(keyboardControls.action),\n keyDown() {\n if (canControls()) {\n client.processAction(resolveCurrentActionInput())\n }\n },\n },\n dash: {\n bind: keyboardControls.dash,\n keyDown() {\n processDashInput()\n },\n },\n back: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n joystick: {\n enabled: true,\n directionMapping: {\n top: 'up',\n bottom: 'down',\n left: 'left',\n right: 'right',\n top_left: ['up', 'left'],\n top_right: ['up', 'right'],\n bottom_left: ['down', 'left'],\n bottom_right: ['down', 'right']\n },\n moveInterval: 50,\n threshold: 0.1\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 const box = hitbox?.()\n return sprite.y() + (box?.h ?? 0) + 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 graphicContainerScale = (graphicObject) => {\n const scale = graphicObject?.displayScale;\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 [1, 1];\n }\n\n const multiplyScale = (left, right) => {\n const a = normalizePair(left);\n const b = normalizePair(right);\n return [a[0] * b[0], a[1] * b[1]];\n }\n\n const graphicHitbox = (graphicObject) => {\n const box = hitbox();\n const scale = graphicEffectiveScale(graphicObject);\n return scaleHitboxForGraphicDisplay(box, scale);\n }\n\n const shadowCaster = (graphicObject) => {\n const box = hitbox();\n const bounds = graphicBounds();\n const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32);\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 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 graphicEffectiveScale = (graphicObject) => {\n const textureOptions = resolveTextureOptions(graphicObject);\n const frame = resolveFirstAnimationFrame(textureOptions);\n const spriteScale = normalizePair(optionValue('scale', frame, textureOptions, graphicObject) ?? graphicScale(graphicObject));\n return multiplyScale(spriteScale, graphicContainerScale(graphicObject));\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 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 scale = graphicEffectiveScale(graphicObject);\n const explicitAnchor = normalizeAnchor(optionValue('anchor', frame, textureOptions, graphicObject));\n const anchor = explicitAnchor ?? resolveScaledHitboxAnchor(\n spriteWidth,\n spriteHeight,\n optionValue('spriteRealSize', frame, textureOptions, graphicObject),\n box,\n scale\n );\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 const interactionBounds = () => ({\n bounds: graphicBounds(),\n hitbox: hitboxBounds(),\n graphic: graphicBounds()\n });\n\n const interactionCursor = computed(() =>\n client.interactions.cursorFor(sprite, interactionBounds())\n );\n\n const handleInteraction = (type) => (event) => {\n client.updatePointerFromInteractionEvent(event);\n client.interactions.handle(sprite, type, {\n event,\n bounds: interactionBounds()\n });\n };\n\n const interactionPointerOver = handleInteraction('pointerover');\n const interactionPointerOut = handleInteraction('pointerout');\n const interactionPointerDown = handleInteraction('pointerdown');\n const interactionPointerUp = handleInteraction('pointerup');\n const interactionPointerMove = handleInteraction('pointermove');\n const interactionClick = handleInteraction('click');\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) {\n realAnimationName.set(curr);\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 activeControlDirectionReleaseTimers.forEach(timer => clearTimeout(timer));\n activeControlDirectionReleaseTimers.clear();\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 let appliedCameraFollowRevision = null;\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 effect(() => {\n const followRevision = client.cameraFollowRevision();\n if (!shouldFollowCamera()) {\n appliedCameraFollowRevision = null;\n return;\n }\n\n const smoothMove = client.cameraFollowSmoothMove;\n const viewport = element.props.context?.viewport;\n const target = element.componentInstance;\n if (!viewport || !target) {\n appliedCameraFollowRevision = null;\n return;\n }\n\n const appliedCameraFollow = applyCameraFollow({\n viewport,\n target,\n smoothMove,\n followRevision,\n isCurrentRevision: (revision) => client.cameraFollowRevision() === revision,\n shouldFollowCamera\n });\n appliedCameraFollowRevision = appliedCameraFollow ? followRevision : null;\n })\n\n return () => {\n if (ownsCameraFollowRevision(appliedCameraFollowRevision, client.cameraFollowRevision())) {\n clearCameraFollowPlugins(element.props.context?.viewport);\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 normalizeOpenId = (value) => {\n const resolved = typeof value === \"function\" ? value() : value;\n return typeof resolved === \"string\" && resolved.length > 0 ? resolved : undefined;\n };\n\n const onAttachedGuiFinish = (gui, data, guiOpenId) => {\n const completedOpenId = normalizeOpenId(guiOpenId);\n const currentOpenId = normalizeOpenId(gui.openId);\n if (completedOpenId && currentOpenId && completedOpenId !== currentOpenId) return;\n guiService.guiClose(gui.name, data, completedOpenId ?? currentOpenId);\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":";;;;;;;;;;;;;;;;AAsBG,SAAS,UAAM,SAAA;CACN,SAAA,OAAA;CACJ,MAAE,cAAc,eAAkB,OAAA;CAClB,eAAA,OAAsB;CACtC,MAAC,EAAM,QAAA,OAAA,YAAA;CACf,MAAM,SAAS,OAAO;CACtB,MAAM,SAAI,OAAS,eAAA;CACnB,MAAM,QAAQ,OAAA,YAAA;CACd,MAAM,aAAY,OAAA,MAAc;CACtB,OAAc;CACxB,MAAM,mBAAW,OAAW;CAC5B,MAAM,oBAAG,OAAA;CACT,MAAM,YAAW,UAAA,OAAA,UAAA,aAAA,MAAA,IAAA;CACjB,MAAI,wBAAA;EACA,MAAM,WAAA,OAAkB,eAAA;EACxB,MAAG,gBAAU,WAAc,OAAA,UAAe,UAAa,IAAA,YAAA,KAAA;EACvD,OAAK,SAAA,EAAA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AAA,YAAA;GAAA,QAAA;GAAA,WAAA,YAAA;GAAA,WAAA,MAAA,cAAA;;GAExC;GAAG,gBAAgB,MAAA,SAAc;IACjC,yBAAM,aAAA,MAAA,IAAA;GACR;EAAA,CAAA,CAAA,CAAA,CAAA;CAAA,CAAA;AAEA;AAEA,IAAM,iBAAS"}
|
|
@@ -13,6 +13,9 @@ declare class BridgeWebsocket extends AbstractWebsocket {
|
|
|
13
13
|
private room;
|
|
14
14
|
private socket;
|
|
15
15
|
private socketRoom?;
|
|
16
|
+
private roomId;
|
|
17
|
+
private query?;
|
|
18
|
+
private readonly privateId;
|
|
16
19
|
private listeners;
|
|
17
20
|
private rooms;
|
|
18
21
|
private serverInstance;
|
|
@@ -38,7 +41,7 @@ declare class BridgeWebsocket extends AbstractWebsocket {
|
|
|
38
41
|
* await websocket.reconnect()
|
|
39
42
|
* ```
|
|
40
43
|
*/
|
|
41
|
-
updateProperties(
|
|
44
|
+
updateProperties({ room, query }: SocketUpdateProperties): void;
|
|
42
45
|
/**
|
|
43
46
|
* Reconnect the client to the current Party room
|
|
44
47
|
*
|
|
@@ -57,6 +60,8 @@ declare class BridgeWebsocket extends AbstractWebsocket {
|
|
|
57
60
|
* ```
|
|
58
61
|
*/
|
|
59
62
|
reconnect(listeners?: (data: any) => void): Promise<void>;
|
|
63
|
+
private connectToRoom;
|
|
64
|
+
private normalizeQuery;
|
|
60
65
|
private detachCurrentSocket;
|
|
61
66
|
getServer(): any;
|
|
62
67
|
getSocket(): any;
|
|
@@ -13,14 +13,15 @@ var BridgeWebsocket = class extends AbstractWebsocket {
|
|
|
13
13
|
this.context = context;
|
|
14
14
|
this.server = server;
|
|
15
15
|
this.mode = "standalone";
|
|
16
|
+
this.roomId = "lobby-1";
|
|
17
|
+
this.privateId = "player-client-id";
|
|
16
18
|
this.listeners = [];
|
|
17
19
|
this.rooms = {
|
|
18
20
|
partyFn: async (roomId) => {
|
|
19
|
-
|
|
20
|
-
const server = new this.server(
|
|
21
|
+
const room = new ServerIo(roomId, this.rooms);
|
|
22
|
+
const server = new this.server(room);
|
|
21
23
|
await server.onStart();
|
|
22
24
|
await server.subRoom.onStart();
|
|
23
|
-
this.context.set("server", server);
|
|
24
25
|
return server;
|
|
25
26
|
},
|
|
26
27
|
env: {}
|
|
@@ -37,20 +38,8 @@ var BridgeWebsocket = class extends AbstractWebsocket {
|
|
|
37
38
|
}
|
|
38
39
|
async _connection(listeners) {
|
|
39
40
|
this.detachCurrentSocket();
|
|
40
|
-
|
|
41
|
-
this.socket = new ClientIo(this.serverInstance, "player-client-id");
|
|
42
|
-
const url = new URL("http://localhost");
|
|
43
|
-
const request = new Request(url.toString(), {
|
|
44
|
-
method: "GET",
|
|
45
|
-
headers: { "Content-Type": "application/json" }
|
|
46
|
-
});
|
|
41
|
+
await this.connectToRoom();
|
|
47
42
|
listeners?.(this.socket);
|
|
48
|
-
this.room.clients.set(this.socket.id, this.socket);
|
|
49
|
-
this.socketRoom = this.room;
|
|
50
|
-
this.listeners.forEach(({ handler }) => {
|
|
51
|
-
this.socket.addEventListener("message", handler);
|
|
52
|
-
});
|
|
53
|
-
await this.serverInstance.onConnect(this.socket.conn, { request });
|
|
54
43
|
return this.socket;
|
|
55
44
|
}
|
|
56
45
|
on(key, callback) {
|
|
@@ -99,7 +88,10 @@ var BridgeWebsocket = class extends AbstractWebsocket {
|
|
|
99
88
|
* await websocket.reconnect()
|
|
100
89
|
* ```
|
|
101
90
|
*/
|
|
102
|
-
updateProperties(
|
|
91
|
+
updateProperties({ room, query }) {
|
|
92
|
+
this.roomId = room;
|
|
93
|
+
this.query = query;
|
|
94
|
+
}
|
|
103
95
|
/**
|
|
104
96
|
* Reconnect the client to the current Party room
|
|
105
97
|
*
|
|
@@ -122,6 +114,32 @@ var BridgeWebsocket = class extends AbstractWebsocket {
|
|
|
122
114
|
listeners?.(socket);
|
|
123
115
|
});
|
|
124
116
|
}
|
|
117
|
+
async connectToRoom() {
|
|
118
|
+
if (this.serverInstance?.room?.id !== this.roomId) {
|
|
119
|
+
const party = await this.room.context.parties.main.get(this.roomId);
|
|
120
|
+
this.serverInstance = party.server;
|
|
121
|
+
this.context.set("server", this.serverInstance);
|
|
122
|
+
this.room = this.serverInstance.room;
|
|
123
|
+
} else this.serverInstance = this.context.get("server");
|
|
124
|
+
this.socket = new ClientIo(this.serverInstance, this.privateId);
|
|
125
|
+
const url = new URL("http://localhost");
|
|
126
|
+
const query = this.normalizeQuery(this.query);
|
|
127
|
+
if (query) for (const [key, value] of Object.entries(query)) url.searchParams.set(key, value);
|
|
128
|
+
const request = new Request(url.toString(), {
|
|
129
|
+
method: "GET",
|
|
130
|
+
headers: { "Content-Type": "application/json" }
|
|
131
|
+
});
|
|
132
|
+
this.room.clients.set(this.socket.id, this.socket);
|
|
133
|
+
this.socketRoom = this.room;
|
|
134
|
+
this.listeners.forEach(({ handler }) => {
|
|
135
|
+
this.socket.addEventListener("message", handler);
|
|
136
|
+
});
|
|
137
|
+
await this.serverInstance.onConnect(this.socket.conn, { request });
|
|
138
|
+
}
|
|
139
|
+
normalizeQuery(query) {
|
|
140
|
+
if (!query) return;
|
|
141
|
+
return Object.fromEntries(Object.entries(query).filter((entry) => typeof entry[1] === "string"));
|
|
142
|
+
}
|
|
125
143
|
detachCurrentSocket() {
|
|
126
144
|
if (!this.socket) return;
|
|
127
145
|
this.listeners.forEach(({ handler }) => {
|