@rpgjs/client 5.0.0-beta.13 → 5.0.0-beta.15
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 +15 -0
- package/dist/Game/Map.js +15 -4
- package/dist/Game/Map.js.map +1 -1
- package/dist/Game/Object.js +4 -3
- package/dist/Game/Object.js.map +1 -1
- package/dist/RpgClientEngine.d.ts +4 -0
- package/dist/RpgClientEngine.js +22 -4
- package/dist/RpgClientEngine.js.map +1 -1
- package/dist/components/character.ce.js +2 -2
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js +54 -26
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/event-layer.ce.js +42 -3
- package/dist/components/scenes/event-layer.ce.js.map +1 -1
- package/dist/services/loadMap.d.ts +3 -0
- package/dist/services/loadMap.js.map +1 -1
- package/package.json +3 -3
- package/src/Game/Map.ts +37 -4
- package/src/Game/Object.ts +4 -3
- package/src/RpgClientEngine.ts +28 -4
- package/src/components/character.ce +2 -2
- package/src/components/scenes/canvas.ce +56 -24
- package/src/components/scenes/event-layer.ce +54 -2
- package/src/services/loadMap.ts +3 -1
|
@@ -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 viewportFollow={shouldFollowCamera}\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 } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { inject } from \"../core/inject\"; \n import { Direction, Animation } from \"@rpgjs/common\";\n import { normalizeEventComponent } from \"../Game/EventComponentResolver\";\n import Hit from \"./effects/hit.ce\";\n import PlayerComponents from \"./player-components.ce\";\n import 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 Boolean(lighting?.shadows?.enabled || (lighting?.spots?.length ?? 0) > 0);\n });\n\n /**\n * Normalize a single sprite component configuration\n * \n * Handles both direct component references and configuration objects with optional props and dependencies.\n * Extracts the component reference and creates a computed function that returns the props.\n * \n * ## Design\n * \n * Supports two formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...}, dependencies: (object) => [...] }`\n * \n * The normalization process:\n * - Extracts the actual component from either format\n * - Extracts dependencies function if provided\n * - Creates a computed function that returns props (static object or dynamic function result)\n * - Returns a normalized object with `component`, `props`, and `dependencies`\n * \n * @param comp - Component reference or configuration object\n * @returns Normalized component configuration with component, props, and dependencies\n * \n * @example\n * ```ts\n * // Direct component\n * normalizeComponent(ShadowComponent)\n * // => { component: ShadowComponent, props: {}, dependencies: undefined }\n * \n * // With static props\n * normalizeComponent({ component: LightHalo, props: { radius: 30 } })\n * // => { component: LightHalo, props: { radius: 30 }, dependencies: undefined }\n * \n * // With dynamic props and dependencies\n * normalizeComponent({ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * })\n * // => { component: HealthBar, props: {...}, dependencies: (object) => [...] }\n * ```\n */\n const normalizeComponent = (comp) => {\n let componentRef;\n let propsValue;\n let dependenciesFn;\n \n // If it's a direct component reference\n if (typeof comp === 'function' || (comp && typeof comp === 'object' && !comp.component)) {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n // If it's a configuration object with component and props\n else if (comp && typeof comp === 'object' && comp.component) {\n componentRef = comp.component;\n // Support both \"data\" (legacy) and \"props\" (new) for backward compatibility\n propsValue = comp.props !== undefined ? comp.props : comp.data;\n dependenciesFn = comp.dependencies;\n }\n // Fallback: treat as direct component\n else {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n \n // Return props directly (object or function), not as computed\n // The computed will be created in the template when needed\n return {\n component: componentRef,\n props: typeof propsValue === 'function' ? propsValue(sprite) : propsValue || {},\n dependencies: dependenciesFn ? dependenciesFn(sprite) : []\n };\n };\n\n /**\n * Normalize an array of sprite components\n * \n * Applies normalization to each component in the array using `normalizeComponent`.\n * \n * @param components - Array of component references or configuration objects\n * @returns Array of normalized component configurations\n */\n const normalizeComponents = (components) => {\n return components.map((comp) => normalizeComponent(comp));\n };\n\n\n /**\n * Normalized components to render behind sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * Supports multiple formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...} }`\n * 3. With dynamic props: `{ component: LightHalo, props: (object) => {...} }`\n * 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`\n * \n * Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).\n * The object is passed to the dependencies function to allow sprite-specific dependency resolution.\n * \n * @example\n * ```ts\n * // Direct component\n * componentsBehind: [ShadowComponent]\n * \n * // With static props\n * componentsBehind: [{ component: LightHalo, props: { radius: 30 } }]\n * \n * // With dynamic props and dependencies\n * componentsBehind: [{ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * }]\n * ```\n */\n const normalizedComponentsBehind = computed(() => {\n return normalizeComponents(componentsBehind());\n });\n\n /**\n * Normalized components to render in front of sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * See `normalizedComponentsBehind` for format details.\n * Components with dependencies will only be displayed when all dependencies are resolved.\n */\n const normalizedComponentsInFront = computed(() => {\n return normalizeComponents(componentsInFront());\n });\n\n const isEventSprite = () => {\n return typeof sprite?.isEvent === 'function'\n ? sprite.isEvent()\n : sprite?._type === 'event';\n };\n\n const resolvedEventComponents = computed(() => {\n if (!isEventSprite()) return [];\n const eventComponent = normalizeEventComponent(client.resolveEventComponent(sprite), sprite);\n return eventComponent ? [eventComponent] : [];\n });\n \n /**\n * Determine if the camera should follow this sprite\n * \n * The camera follows this sprite if:\n * - It's explicitly set as the camera follow target, OR\n * - It's the current player and no explicit target is set (default behavior)\n */\n const shouldFollowCamera = computed(() => {\n const cameraTargetId = client.cameraFollowTargetId();\n // If a target is explicitly set, only follow if this sprite is the target\n if (cameraTargetId !== null) {\n return id() === cameraTargetId;\n }\n // Otherwise, follow the current player (default behavior)\n return isMe();\n });\n\n /**\n * Get all attached GUI components that should be rendered on sprites\n * These are GUIs with attachToSprite: true\n */\n const attachedGuis = computed(() => {\n return guiService.getAttachedGuis();\n });\n\n /**\n * Check if attached GUIs should be displayed for this sprite\n * This is controlled by showAttachedGui/hideAttachedGui on the server\n */\n const shouldDisplayAttachedGui = computed(() => {\n return guiService.shouldDisplayAttachedGui(id());\n });\n\n const { \n x, \n y, \n tint, \n direction, \n animationName, \n animationCurrentIndex,\n emitParticleTrigger, \n particleName, \n graphics, \n hitbox,\n isConnected,\n graphicsSignals,\n flashTrigger\n } = sprite;\n\n const renderedGraphics = computed(() => {\n const eventComponent = resolvedEventComponents()[0];\n if (eventComponent && !eventComponent.renderGraphic) return [];\n return graphicsSignals();\n });\n\n /**\n * Flash configuration signals for dynamic options\n * These signals are updated when the flash trigger is activated with options\n */\n const flashType = signal<'alpha' | 'tint' | 'both'>('alpha');\n const flashDuration = signal(300);\n const flashCycles = signal(1);\n const flashAlpha = signal(0.3);\n const flashTint = signal(0xffffff);\n\n /**\n * Listen to flash trigger to update configuration dynamically\n * When flash is triggered with options, update the signals\n */\n on(flashTrigger, (data) => {\n if (data && typeof data === 'object') {\n if (data.type !== undefined) flashType.set(data.type);\n if (data.duration !== undefined) flashDuration.set(data.duration);\n if (data.cycles !== undefined) flashCycles.set(data.cycles);\n if (data.alpha !== undefined) flashAlpha.set(data.alpha);\n if (data.tint !== undefined) flashTint.set(data.tint);\n }\n });\n\n /**\n * Flash configuration for the sprite\n * \n * This configuration is used by the flash directive to create visual feedback effects.\n * The flash trigger is exposed through the object, allowing both server events and\n * client-side code to trigger flash animations. Options can be passed dynamically\n * through the trigger, which updates the reactive signals.\n */\n const flashConfig = computed(() => ({\n trigger: flashTrigger,\n type: flashType(),\n duration: flashDuration(),\n cycles: flashCycles(),\n alpha: flashAlpha(),\n tint: flashTint(),\n }));\n\n const particleSettings = client.particleSettings;\n\n const canControls = () => isMe() && getCanMoveValue(sprite)\n const keyboardControls = client.globalConfig.keyboardControls;\n const activeDirectionKeys = new Map();\n\n const resolveHeldDirection = () => {\n const directions = Array.from(activeDirectionKeys.values());\n return directions[directions.length - 1];\n };\n\n const resolveSpriteDirection = () => {\n const heldDirection = resolveHeldDirection();\n if (heldDirection) return heldDirection;\n if (typeof sprite.getDirection === 'function') return sprite.getDirection();\n if (typeof sprite.direction === 'function') return sprite.direction();\n return direction();\n };\n\n const 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) return;\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) return;\n realAnimationName.set('walk');\n };\n\n const resumeHeldDirectionWalkAnimation = () => {\n if (!isCurrentPlayer()) return false;\n if (activeDirectionKeys.size === 0) return false;\n if (!canControls()) return false;\n if (sprite.animationFixed) return false;\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) return false;\n realAnimationName.set('walk');\n return true;\n };\n\n const processMovementInput = (input) => {\n if (!canControls()) return;\n client.processInput({ input });\n playPredictedWalkAnimation();\n };\n\n const 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 processMovementInput(Direction.Down)\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n processMovementInput(Direction.Up)\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n processMovementInput(Direction.Left)\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n processMovementInput(Direction.Right)\n },\n },\n action: {\n bind: getKeyboardControlBind(keyboardControls.action),\n keyDown() {\n if (canControls()) {\n client.processAction(resolveCurrentActionInput())\n }\n },\n },\n dash: {\n bind: keyboardControls.dash,\n keyDown() {\n processDashInput()\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n gamepad: {\n enabled: true\n }\n };\n\n const smoothX = animatedSignal(x(), {\n duration: isMe() ? 0 : 0\n });\n\n const smoothY = animatedSignal(y(), {\n duration: isMe() ? 0 : 0,\n });\n\n const z = computed(() => {\n return sprite.y() + sprite.z()\n });\n\n const realAnimationName = signal(animationName());\n\n const xSubscription = x.observable.subscribe((value) => {\n smoothX.set(value);\n });\n\n const ySubscription = y.observable.subscribe((value) => {\n smoothY.set(value);\n });\n \n const sheet = (graphicObject) => {\n return {\n definition: graphicObject,\n playing: realAnimationName(),\n params: {\n direction: direction()\n },\n onFinish() {\n animationCurrentIndex.update(index => index + 1)\n }\n };\n }\n\n const graphicScale = (graphicObject) => {\n const scale = graphicObject?.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 xSubscription.unsubscribe();\n ySubscription.unsubscribe();\n await lastValueFrom(hooks.callHooks(\"client-sprite-onDestroy\", sprite)) \n await lastValueFrom(hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, sprite))\n }\n\n mount((element) => {\n if (typeof document !== 'undefined') {\n document.addEventListener('keydown', handleNativeActionWhileMoving);\n document.addEventListener('keyup', handleNativeActionWhileMoving);\n }\n hooks.callHooks(\"client-sprite-onAdd\", sprite).subscribe()\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, sprite).subscribe()\n effect(() => {\n if (isCurrentPlayer()) {\n client.setKeyboardControls(element.directives.controls)\n }\n })\n })\n\n /**\n * Handle attached GUI finish event\n * \n * @param gui - The GUI instance\n * @param data - Data passed from the GUI component\n */\n const 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\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CAAA;GAAA,OAAA;EAAA,CAAA,CAAA,CAAA,GAAA,KAAA,0BAAA,mBAAA,EAAA,WAAA,EAAA,cAAA,eAAA,aAAA,GAAA,EAAA,eAAA,WAAA,eAAA,KAAA,CAAA,CAAA,CAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,KAAA,8BAAA,eAAA,EAAA,WAAA,EAAA,cAAA,WAAA,aAAA,GAAA,EAAA,WAAA,WAAA;GAAA,QAAA;GAAA,GAAA,WAAA;EAAA,CAAA,CAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,QAAA;GAAA;GAAA;EAAA,CAAA;EAAA,KAAA,eAAA,gBAAA,KAAA,gCAAA,EAAA,WAAA,MAAA,EAAA,YAAA,WAAA;GAAA,GAAA,YAAA,KAAA;GAAA,cAAA,YAAA;GAAA,QAAA;GAAA,WAAA,YAAA;GAAA,WAAA,MAAA,cAAA;IACZ,oBAAc,aAAA,MAAA,SAAA;GACd;GAAK,gBAAA,MAAA,SAAA;IACL,yBAAM,aAAA,MAAA,IAAA;GACN;EAAA,CAAA,CAAA,CAAO,CAAC;CAAC,CACA;AACV"}
|
|
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 viewportFollow={shouldFollowCamera}\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 { 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\n const resolveHeldDirection = () => {\n const directions = Array.from(activeDirectionKeys.values());\n return directions[directions.length - 1];\n };\n\n const resolveSpriteDirection = () => {\n const heldDirection = resolveHeldDirection();\n if (heldDirection) return heldDirection;\n if (typeof sprite.getDirection === 'function') return sprite.getDirection();\n if (typeof sprite.direction === 'function') return sprite.direction();\n return direction();\n };\n\n const 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) return;\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) return;\n realAnimationName.set('walk');\n };\n\n const resumeHeldDirectionWalkAnimation = () => {\n if (!isCurrentPlayer()) return false;\n if (activeDirectionKeys.size === 0) return false;\n if (!canControls()) return false;\n if (sprite.animationFixed) return false;\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) return false;\n realAnimationName.set('walk');\n return true;\n };\n\n const processMovementInput = (input) => {\n if (!canControls()) return;\n client.processInput({ input });\n playPredictedWalkAnimation();\n };\n\n const 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 processMovementInput(Direction.Down)\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n processMovementInput(Direction.Up)\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n processMovementInput(Direction.Left)\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n processMovementInput(Direction.Right)\n },\n },\n action: {\n bind: getKeyboardControlBind(keyboardControls.action),\n keyDown() {\n if (canControls()) {\n client.processAction(resolveCurrentActionInput())\n }\n },\n },\n dash: {\n bind: keyboardControls.dash,\n keyDown() {\n processDashInput()\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n gamepad: {\n enabled: true\n }\n };\n\n const smoothX = animatedSignal(x(), {\n duration: isMe() ? 0 : 0\n });\n\n const smoothY = animatedSignal(y(), {\n duration: isMe() ? 0 : 0,\n });\n\n const z = computed(() => {\n return sprite.y() + sprite.z()\n });\n\n const realAnimationName = signal(animationName());\n\n const xSubscription = x.observable.subscribe((value) => {\n smoothX.set(value);\n });\n\n const ySubscription = y.observable.subscribe((value) => {\n smoothY.set(value);\n });\n \n const sheet = (graphicObject) => {\n return {\n definition: graphicObject,\n playing: realAnimationName(),\n params: {\n direction: direction()\n },\n onFinish() {\n animationCurrentIndex.update(index => index + 1)\n }\n };\n }\n\n const graphicScale = (graphicObject) => {\n const scale = graphicObject?.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 xSubscription.unsubscribe();\n ySubscription.unsubscribe();\n await lastValueFrom(hooks.callHooks(\"client-sprite-onDestroy\", sprite)) \n await lastValueFrom(hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, sprite))\n }\n\n mount((element) => {\n if (typeof document !== 'undefined') {\n document.addEventListener('keydown', handleNativeActionWhileMoving);\n document.addEventListener('keyup', handleNativeActionWhileMoving);\n }\n hooks.callHooks(\"client-sprite-onAdd\", sprite).subscribe()\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, sprite).subscribe()\n effect(() => {\n if (isCurrentPlayer()) {\n client.setKeyboardControls(element.directives.controls)\n }\n })\n })\n\n /**\n * Handle attached GUI finish event\n * \n * @param gui - The GUI instance\n * @param data - Data passed from the GUI component\n */\n const 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":";;;;;;;;;;;;;;AAoBG,SAAA,UAAA,SAAA;CACiB,SAAQ,OAAQ;CAEjC,MAAS,EAAI,QAAE,OADU,eAAQ,OACG,EAAA;CACvC,MAAG,SAAS,OAAA;CACZ,MAAK,SAAK,OAAW,eAAG;CACxB,MAAM,QAAC,OAAU,YAAO;CACxB,MAAM,aAAS,OAAA,MAAA;CACE,OAAM;CACvB,MAAM,mBAAa,OAAA;CACnB,MAAM,oBAAQ,OAAA;CACd,MAAM,YAAI,UAAA,OAAA,UAAA,aAAA,MAAA,IAAA;CACV,MAAM,wBAAkB;EACpB,MAAM,WAAO,OAAW,eAAA;EACxB,MAAK,gBAAA,WAAA,OAAA,UAAA,UAAA,IAAA,YAAA,KAAA;EACL,OAAI,SAAS,EAAA,MAAA,YACb,SAAA,QAAA,EAAA,MAAA,YACM,WAAA,iBACH,WAAU,OAAY,UAAE,mBAA2B;CAC1D;CACA,MAAM,OAAE,SAAS,eAAA;CACjB,MAAI,iBAAA,eAAA;EACA,MAAA,WAAS,OAAA,UAAA,WAAA;EACV,OAAA,4BAAiC,QAAU;CAC9C,CAAC;CACD,MAAG,sBAAyB,SAAQ;EACjC,IAAK;EACJ,IAAC;EACD,IAAG;EAEL,IAAA,OAAA,SAAA,cAAA,QAAA,OAAA,SAAA,YAAA,CAAA,KAAA,WAAA;GACC,eAAA;GACC,aAAc,KAAA;GACd,iBAAqB,KAAA;EACrB,OAED,IAAA,QAAA,OAAA,SAAA,YAAA,KAAA,WAAA;GACK,eAAe,KAAA;GAEhB,aAAS,KAAA,UAAA,KAAA,IAAA,KAAA,QAAA,KAAA;GACR,iBAAa,KAAS;EAC1B,OAEK;GACD,eAAI;GACJ,aAAS,KAAA;GACb,iBAAA,KAAA;EACF;E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AAA;GAAA;GAAA;GAAA,cAAA,eAAA,aAAA,UAAA,CAAA;GAAA,OAAA;EAAA,CAAA,CAAA,CAAA,GAAA,KAAA,0BAAA,mBAAA,EAAA,WAAA,EAAA,cAAA,eAAA,aAAA,GAAA,EAAA,eAAA,WAAA,eAAA,KAAA,CAAA,CAAA,CAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,KAAA,8BAAA,eAAA,EAAA,WAAA,EAAA,cAAA,WAAA,aAAA,GAAA,EAAA,WAAA,WAAA;GAAA,QAAA;GAAA,GAAA,WAAA;EAAA,CAAA,CAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,QAAA;GAAA;GAAA;EAAA,CAAA;EAAA,KAAA,eAAA,gBAAA,KAAA,gCAAA,EAAA,WAAA,MAAA,EAAA,YAAA,WAAA;GAAA,GAAA,YAAA,KAAA;GAAA,cAAA,YAAA;GAAA,QAAA;GAAA,WAAA,YAAA;GAAA,WAAA,MAAA,cAAA;IACZ,oBAAc,aAAA,MAAA,SAAA;GACd;GAAK,gBAAA,MAAA,SAAA;IACL,yBAAM,aAAA,MAAA,IAAA;GACN;EAAA,CAAA,CAAA,CAAO,CAAC;CAAC,CACA;AACV"}
|
|
@@ -2,6 +2,7 @@ import { inject } from "../../core/inject.js";
|
|
|
2
2
|
import { RpgGui } from "../../Gui/Gui.js";
|
|
3
3
|
import { RpgClientEngine } from "../../RpgClientEngine.js";
|
|
4
4
|
import { Canvas, Container, Viewport, computed, cond, effect, h, loop, useDefineProps, useProps } from "canvasengine";
|
|
5
|
+
import { shouldRenderLightingShadows } from "@rpgjs/common";
|
|
5
6
|
import { NightAmbiant, SpriteShadows } from "@canvasengine/presets";
|
|
6
7
|
//#region src/components/scenes/canvas.ce
|
|
7
8
|
function component($$props) {
|
|
@@ -47,11 +48,19 @@ function component($$props) {
|
|
|
47
48
|
const NIGHT_SPOT_MIN_INTENSITY = 1;
|
|
48
49
|
const SHADOW_SPOT_RADIUS_SCALE = 12;
|
|
49
50
|
const SHADOW_SPOT_MIN_RADIUS = 480;
|
|
50
|
-
const
|
|
51
|
+
const toFiniteNumber = (value, fallback = null) => {
|
|
52
|
+
const number = Number(value);
|
|
53
|
+
return Number.isFinite(number) ? number : fallback;
|
|
54
|
+
};
|
|
55
|
+
const clampNumber = (value, min, max) => Math.max(min, Math.min(max, value));
|
|
51
56
|
const nightSpotRadius = (radius) => Math.max(radius * NIGHT_SPOT_RADIUS_SCALE, NIGHT_SPOT_MIN_RADIUS);
|
|
52
57
|
const shadowSpotRadius = (radius) => Math.max(radius * SHADOW_SPOT_RADIUS_SCALE, SHADOW_SPOT_MIN_RADIUS);
|
|
53
58
|
const nightSpotIntensity = (intensity, fallback) => Math.max(intensity ?? fallback, NIGHT_SPOT_MIN_INTENSITY);
|
|
54
|
-
const
|
|
59
|
+
const shadowLightIntensity = (intensity, fallback = 1) => {
|
|
60
|
+
const value = Number(intensity ?? fallback);
|
|
61
|
+
return Number.isFinite(value) ? Math.max(0, value) : fallback;
|
|
62
|
+
};
|
|
63
|
+
const shadowSpotIntensity = (intensity) => shadowLightIntensity(intensity, 1);
|
|
55
64
|
const lightingAmbient = computed(() => {
|
|
56
65
|
return (lighting?.())?.ambient ?? {};
|
|
57
66
|
});
|
|
@@ -71,9 +80,6 @@ function component($$props) {
|
|
|
71
80
|
};
|
|
72
81
|
});
|
|
73
82
|
});
|
|
74
|
-
const hasLightSpots = computed(() => {
|
|
75
|
-
return ((lighting?.())?.spots?.length ?? 0) > 0;
|
|
76
|
-
});
|
|
77
83
|
const lightingDarkness = computed(() => {
|
|
78
84
|
const darkness = lightingAmbient().darkness;
|
|
79
85
|
return typeof darkness === "number" ? darkness : 0;
|
|
@@ -99,28 +105,57 @@ function component($$props) {
|
|
|
99
105
|
const scale = Number(data?.params?.scale ?? 1) || 1;
|
|
100
106
|
const mapWidth = width * scale;
|
|
101
107
|
const mapHeight = height * scale;
|
|
108
|
+
const projectionBase = Math.max(1, mapWidth, mapHeight);
|
|
102
109
|
return {
|
|
103
|
-
x: -
|
|
104
|
-
y: -
|
|
110
|
+
x: -projectionBase * 24,
|
|
111
|
+
y: -projectionBase * 24,
|
|
105
112
|
z: 520,
|
|
106
|
-
radius:
|
|
113
|
+
radius: projectionBase * 160,
|
|
107
114
|
intensity: .85,
|
|
108
115
|
shadowWeight: lightingDarkness() > 0 ? 2.2 : 1,
|
|
109
116
|
enabled: true
|
|
110
117
|
};
|
|
111
118
|
};
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
119
|
+
const normalizeSunDirection = (sun) => {
|
|
120
|
+
const x = toFiniteNumber(sun?.x, null);
|
|
121
|
+
const y = toFiniteNumber(sun?.y, null);
|
|
122
|
+
if (x !== null && y !== null && Math.hypot(x, y) > .001) return {
|
|
123
|
+
x,
|
|
124
|
+
y
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
x: -.45,
|
|
128
|
+
y: -1
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
const defaultSunAmbientLight = () => {
|
|
116
132
|
const state = lighting?.();
|
|
133
|
+
if (!state?.sun || state.sun.enabled === false) return null;
|
|
117
134
|
const defaultSun = defaultSunLight();
|
|
118
135
|
const sun = {
|
|
119
136
|
...defaultSun,
|
|
120
|
-
...state
|
|
121
|
-
|
|
137
|
+
...state.sun,
|
|
138
|
+
intensity: shadowLightIntensity(state.sun.intensity, defaultSun.intensity),
|
|
139
|
+
shadowWeight: state.sun.shadowWeight ?? defaultSun.shadowWeight
|
|
122
140
|
};
|
|
123
|
-
|
|
141
|
+
if (sun.intensity <= 0) return null;
|
|
142
|
+
const direction = normalizeSunDirection(sun);
|
|
143
|
+
const shadowWeight = clampNumber(toFiniteNumber(sun.shadowWeight, lightingDarkness() > 0 ? 1.35 : 1) ?? 1, 0, 4);
|
|
144
|
+
const length = clampNumber(30 + sun.intensity * 38 * Math.max(.75, shadowWeight), 30, 86);
|
|
145
|
+
return {
|
|
146
|
+
x: direction.x,
|
|
147
|
+
y: direction.y,
|
|
148
|
+
z: toFiniteNumber(sun.z, 520) ?? 520,
|
|
149
|
+
intensity: clampNumber(sun.intensity, 0, 2),
|
|
150
|
+
shadowWeight,
|
|
151
|
+
length
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
const shadowState = computed(() => {
|
|
155
|
+
return (lighting?.())?.shadows ?? null;
|
|
156
|
+
});
|
|
157
|
+
const shadowLights = computed(() => {
|
|
158
|
+
return ((lighting?.())?.spots ?? []).map((spot) => {
|
|
124
159
|
const radius = spot.radius ?? 180;
|
|
125
160
|
return {
|
|
126
161
|
x: spot.x,
|
|
@@ -128,26 +163,19 @@ function component($$props) {
|
|
|
128
163
|
z: 170,
|
|
129
164
|
radius: shadowSpotRadius(radius),
|
|
130
165
|
intensity: shadowSpotIntensity(spot.intensity),
|
|
131
|
-
shadowWeight:
|
|
166
|
+
shadowWeight: 1,
|
|
132
167
|
enabled: true
|
|
133
168
|
};
|
|
134
169
|
});
|
|
135
|
-
return [...sun.enabled === false || sun.intensity <= 0 ? [] : [sun], ...spotLights];
|
|
136
170
|
});
|
|
137
171
|
const shadowAmbientLight = computed(() => {
|
|
138
172
|
const shadows = shadowState();
|
|
139
173
|
if (shadows?.ambientLight === null || shadows?.ambientLight?.enabled === false) return null;
|
|
140
|
-
return shadows?.ambientLight ??
|
|
141
|
-
x: -.18,
|
|
142
|
-
y: -1,
|
|
143
|
-
z: 420,
|
|
144
|
-
intensity: .32,
|
|
145
|
-
shadowWeight: 1
|
|
146
|
-
};
|
|
174
|
+
return shadows?.ambientLight ?? defaultSunAmbientLight();
|
|
147
175
|
});
|
|
148
176
|
const shadowEnabled = computed(() => {
|
|
149
|
-
const
|
|
150
|
-
return Boolean((
|
|
177
|
+
const state = lighting?.();
|
|
178
|
+
return Boolean(shouldRenderLightingShadows(state) && (shadowLights().length > 0 || shadowAmbientLight()));
|
|
151
179
|
});
|
|
152
180
|
const shadowMode = computed(() => shadowState()?.mode ?? "strongest");
|
|
153
181
|
const shadowUpdateHz = computed(() => shadowState()?.updateHz ?? 60);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.ce.js","names":[],"sources":["../../../src/components/scenes/canvas.ce"],"sourcesContent":["<Canvas width={engine.width} height={engine.height}>\n <Viewport worldWidth worldHeight clamp sortableChildren={true}>\n @if (lightingAmbientEnabled()) {\n <NightAmbiant\n spots={nightLights}\n darkness={lightingDarknessProps}\n haze={lightingHaze}\n />\n }\n @if (shadowEnabled()) {\n <SpriteShadows\n lights={shadowLights}\n ambientLight={shadowAmbientLight}\n minInfluence={shadowMinInfluence}\n falloffPower={shadowFalloffPower}\n mode={shadowMode}\n updateHz={shadowUpdateHz}\n scanHz={shadowScanHz}\n cullToViewport={shadowCullToViewport}\n shadowColor={shadowColor}\n />\n }\n <SceneMap />\n </Viewport>\n @for (gui of guiList) {\n <Container\n positionType=\"absolute\"\n top={0}\n left={0}\n right={0}\n bottom={0}\n width={engine.width}\n height={engine.height}\n >\n @if (gui.display) {\n <gui.component data={gui.data} dependencies={gui.dependencies} guiOpenId={gui.openId} onFinish={(data, guiOpenId) => {\n onGuiFinish(gui, data, guiOpenId)\n }} onInteraction={(name, data) => {\n onGuiInteraction(gui, name, data)\n }} /> \n }\n </Container>\n }\n</Canvas>\n\n<script>\n import { computed, effect } from \"canvasengine\";\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { RpgGui } from \"../../Gui/Gui\";\n import { NightAmbiant, SpriteShadows } from '@canvasengine/presets'\n\n const engine = inject(RpgClientEngine);\n const SceneMap = engine.sceneMapComponent;\n const guiService = inject(RpgGui);\n const sceneData = engine.sceneMap.data\n const lighting = engine.sceneMap.lighting\n const guiList = computed(() => {\n return Object.values(guiService.gui()).filter((gui) => !gui.attachToSprite)\n })\n const worldWidth = computed(() => {\n const data = sceneData?.()\n const scale = Number(data?.params?.scale ?? 1) || 1\n return Number(data?.width ?? data?.params?.width ?? 2048) * scale\n })\n const worldHeight = computed(() => {\n const data = sceneData?.()\n const scale = Number(data?.params?.scale ?? 1) || 1\n return Number(data?.height ?? data?.params?.height ?? 2048) * scale\n })\n\n effect(() => {\n if (sceneData() && !sceneData().component) {\n throw new Error(\"Warning ! You need to define a component for the scene. Use provideLoadMap() to define a component for the scene.\")\n }\n })\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 onGuiFinish = (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 const onGuiInteraction = (gui, name, data) => {\n guiService.guiInteraction(gui.name, name, data)\n }\n\n const clamp = {\n direction: \"all\"\n }\n const NIGHT_SPOT_RADIUS_SCALE = 4.25\n const NIGHT_SPOT_MIN_RADIUS = 170\n const NIGHT_SPOT_MIN_INTENSITY = 1\n const SHADOW_SPOT_RADIUS_SCALE = 12\n const SHADOW_SPOT_MIN_RADIUS = 480\n const SHADOW_SPOT_MIN_INTENSITY = 1.35\n\n const nightSpotRadius = (radius) => Math.max(radius * NIGHT_SPOT_RADIUS_SCALE, NIGHT_SPOT_MIN_RADIUS)\n const shadowSpotRadius = (radius) => Math.max(radius * SHADOW_SPOT_RADIUS_SCALE, SHADOW_SPOT_MIN_RADIUS)\n const nightSpotIntensity = (intensity, fallback) => Math.max(intensity ?? fallback, NIGHT_SPOT_MIN_INTENSITY)\n const shadowSpotIntensity = (intensity) => Math.max(intensity ?? 1.3, SHADOW_SPOT_MIN_INTENSITY)\n\n const lightingAmbient = computed(() => {\n const state = lighting?.()\n return state?.ambient ?? {}\n })\n\n const nightLights = computed(() => {\n const state = lighting?.()\n return (state?.spots ?? []).map((spot, index) => {\n const radius = spot.radius ?? 180\n return {\n x: spot.x,\n y: spot.y,\n radius: nightSpotRadius(radius),\n intensity: nightSpotIntensity(spot.intensity, index === 0 ? 1 : 0.92),\n flicker: spot.flicker,\n flickerSpeed: spot.flickerSpeed ?? 14,\n pulse: spot.pulse,\n pulseSpeed: spot.pulseSpeed,\n phase: spot.phase,\n }\n })\n })\n const hasLightSpots = computed(() => {\n const state = lighting?.()\n return (state?.spots?.length ?? 0) > 0\n })\n\n const lightingDarkness = computed(() => {\n const darkness = lightingAmbient().darkness\n return typeof darkness === \"number\" ? darkness : 0\n })\n\n const lightingAmbientEnabled = computed(() => {\n const state = lighting?.()\n return Boolean(state && lightingDarkness() > 0)\n })\n\n const lightingDarknessProps = computed(() => ({\n opacity: lightingDarkness(),\n color: lightingAmbient().darkColor ?? \"#080a12\",\n }))\n const lightingHaze = computed(() => ({\n color: lightingAmbient().fogColor ?? \"#12182a\",\n radius: lightingAmbient().fogRadius ?? 0.44,\n softness: lightingAmbient().fogSoftness ?? 0.3,\n opacity: lightingAmbient().fogOpacity ?? 0.35,\n }))\n\n const defaultSunLight = () => {\n const data = sceneData?.()\n const width = Number(data?.width ?? data?.params?.width ?? 2048)\n const height = Number(data?.height ?? data?.params?.height ?? 2048)\n const scale = Number(data?.params?.scale ?? 1) || 1\n const mapWidth = width * scale\n const mapHeight = height * scale\n\n return {\n x: -mapWidth * 0.35,\n y: -mapHeight * 0.45,\n z: 520,\n radius: Math.max(mapWidth, mapHeight) * 2.5,\n intensity: 0.85,\n shadowWeight: lightingDarkness() > 0 ? 2.2 : 1,\n enabled: true,\n }\n }\n\n const shadowState = computed(() => {\n const state = lighting?.()\n return state?.shadows ?? null\n })\n\n const shadowLights = computed(() => {\n const state = lighting?.()\n const defaultSun = defaultSunLight()\n const sun = {\n ...defaultSun,\n ...(state?.sun ?? {}),\n shadowWeight: state?.sun?.shadowWeight ?? defaultSun.shadowWeight,\n }\n const spotLights = (state?.spots ?? []).map((spot) => {\n const radius = spot.radius ?? 180\n return {\n x: spot.x,\n y: spot.y,\n z: 170,\n radius: shadowSpotRadius(radius),\n intensity: shadowSpotIntensity(spot.intensity),\n shadowWeight: 2.4,\n enabled: true,\n }\n })\n\n return [\n ...((sun.enabled === false || sun.intensity <= 0) ? [] : [sun]),\n ...spotLights,\n ]\n })\n\n const shadowAmbientLight = computed(() => {\n const shadows = shadowState()\n if (shadows?.ambientLight === null || shadows?.ambientLight?.enabled === false) {\n return null\n }\n return shadows?.ambientLight ?? { x: -0.18, y: -1, z: 420, intensity: 0.32, shadowWeight: 1 }\n })\n\n const shadowEnabled = computed(() => {\n const shadows = shadowState()\n return Boolean((shadows?.enabled || hasLightSpots()) && (shadowLights().length > 0 || shadowAmbientLight()))\n })\n\n const shadowMode = computed(() => shadowState()?.mode ?? \"strongest\")\n const shadowUpdateHz = computed(() => shadowState()?.updateHz ?? 60)\n const shadowScanHz = computed(() => shadowState()?.scanHz ?? 8)\n const shadowCullToViewport = computed(() => shadowState()?.cullToViewport ?? true)\n const shadowMinInfluence = computed(() => shadowState()?.minInfluence ?? 0.24)\n const shadowFalloffPower = computed(() => shadowState()?.falloffPower ?? 0.85)\n const shadowColor = computed(() => shadowState()?.shadowColor ?? \"#05070d\")\n</script>\n"],"mappings":";;;;;;AAaM,SAAE,UAAc,SAAA;CACA,SAAA,OAAA;CACE,eAAA,OAAA;CAChB,MAAA,SAAU,OAAA,eAAc;CAChC,MAAM,WAAU,OAAA;CAChB,MAAM,aAAE,OAAgB,MAAA;CACxB,MAAM,YAAE,OAAa,SAAW;CAChC,MAAM,WAAC,OAAA,SAAA;CACP,MAAI,UAAA,eAAA;EACA,OAAC,OAAU,OAAA,WAAA,IAAA,CAAA,EAAA,QAAA,QAAA,CAAA,IAAA,cAAA;CACf,CAAC;CACD,MAAM,aA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A,GAAA,CAAA,EAAA,UAAA;EAAA;EAAA;EAAA;EAAA,kBAAA;CAAA,GAAA;EAAA,KAAA,eAAA,uBAAA,CAAA,SAAA,EAAA,cAAA;GAAA,OAAA;GAAA,UAAA;GAAA,MAAA;EAAA,CAAA,CAAA;EAAA,KAAA,eAAA,cAAA,CAAA,SAAA,EAAA,eAAA;GAAA,QAAA;GAAA,cAAA;GAAA,cAAA;GAAA,cAAA;GAAA,MAAA;GAAA,UAAA;GAAA,QAAA;GAAA,gBAAA;GAAA;EAAA,CAAA,CAAA;EAAA,EAAA,QAAA;CAAA,CAAA,GAAA,KAAA,UAAA,QAAA,EAAA,WAAA;EAAA,cAAA;EAAA,KAAA;EAAA,MAAA;EAAA,OAAA;EAAA,QAAA;EAAA,OAAA,OAAA;EAAA,QAAA,OAAA;CAAA,GAAA,KAAA,IAAA,eAAA,EAAA,IAAA,WAAA;EAAA,MAAA,IAAA;EAAA,cAAA,IAAA;EAAA,WAAA,IAAA;EAAA,WAAA,MAAA,cAAA;;EAEM;EAAA,gBAAc,MAAa,SAAE;GAC3B,iBAAmB,KAAA,MAAA,IAAA;EACnB;CAAC,CAAA,CAAA,CAAA,CAAK,CAAC,CACd;;AAGC,IAAM,iBAAmB"}
|
|
1
|
+
{"version":3,"file":"canvas.ce.js","names":[],"sources":["../../../src/components/scenes/canvas.ce"],"sourcesContent":["<Canvas width={engine.width} height={engine.height}>\n <Viewport worldWidth worldHeight clamp sortableChildren={true}>\n @if (lightingAmbientEnabled()) {\n <NightAmbiant\n spots={nightLights}\n darkness={lightingDarknessProps}\n haze={lightingHaze}\n />\n }\n @if (shadowEnabled()) {\n <SpriteShadows\n lights={shadowLights}\n ambientLight={shadowAmbientLight}\n minInfluence={shadowMinInfluence}\n falloffPower={shadowFalloffPower}\n mode={shadowMode}\n updateHz={shadowUpdateHz}\n scanHz={shadowScanHz}\n cullToViewport={shadowCullToViewport}\n shadowColor={shadowColor}\n />\n }\n <SceneMap />\n </Viewport>\n @for (gui of guiList) {\n <Container\n positionType=\"absolute\"\n top={0}\n left={0}\n right={0}\n bottom={0}\n width={engine.width}\n height={engine.height}\n >\n @if (gui.display) {\n <gui.component data={gui.data} dependencies={gui.dependencies} guiOpenId={gui.openId} onFinish={(data, guiOpenId) => {\n onGuiFinish(gui, data, guiOpenId)\n }} onInteraction={(name, data) => {\n onGuiInteraction(gui, name, data)\n }} /> \n }\n </Container>\n }\n</Canvas>\n\n<script>\n import { computed, effect } from \"canvasengine\";\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { RpgGui } from \"../../Gui/Gui\";\n import { NightAmbiant, SpriteShadows } from '@canvasengine/presets'\n import { shouldRenderLightingShadows } from \"@rpgjs/common\";\n\n const engine = inject(RpgClientEngine);\n const SceneMap = engine.sceneMapComponent;\n const guiService = inject(RpgGui);\n const sceneData = engine.sceneMap.data\n const lighting = engine.sceneMap.lighting\n const guiList = computed(() => {\n return Object.values(guiService.gui()).filter((gui) => !gui.attachToSprite)\n })\n const worldWidth = computed(() => {\n const data = sceneData?.()\n const scale = Number(data?.params?.scale ?? 1) || 1\n return Number(data?.width ?? data?.params?.width ?? 2048) * scale\n })\n const worldHeight = computed(() => {\n const data = sceneData?.()\n const scale = Number(data?.params?.scale ?? 1) || 1\n return Number(data?.height ?? data?.params?.height ?? 2048) * scale\n })\n\n effect(() => {\n if (sceneData() && !sceneData().component) {\n throw new Error(\"Warning ! You need to define a component for the scene. Use provideLoadMap() to define a component for the scene.\")\n }\n })\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 onGuiFinish = (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 const onGuiInteraction = (gui, name, data) => {\n guiService.guiInteraction(gui.name, name, data)\n }\n\n const clamp = {\n direction: \"all\"\n }\n const NIGHT_SPOT_RADIUS_SCALE = 4.25\n const NIGHT_SPOT_MIN_RADIUS = 170\n const NIGHT_SPOT_MIN_INTENSITY = 1\n const SHADOW_SPOT_RADIUS_SCALE = 12\n const SHADOW_SPOT_MIN_RADIUS = 480\n\n const toFiniteNumber = (value, fallback = null) => {\n const number = Number(value)\n return Number.isFinite(number) ? number : fallback\n }\n const clampNumber = (value, min, max) => Math.max(min, Math.min(max, value))\n const nightSpotRadius = (radius) => Math.max(radius * NIGHT_SPOT_RADIUS_SCALE, NIGHT_SPOT_MIN_RADIUS)\n const shadowSpotRadius = (radius) => Math.max(radius * SHADOW_SPOT_RADIUS_SCALE, SHADOW_SPOT_MIN_RADIUS)\n const nightSpotIntensity = (intensity, fallback) => Math.max(intensity ?? fallback, NIGHT_SPOT_MIN_INTENSITY)\n const shadowLightIntensity = (intensity, fallback = 1) => {\n const value = Number(intensity ?? fallback)\n return Number.isFinite(value) ? Math.max(0, value) : fallback\n }\n const shadowSpotIntensity = (intensity) => shadowLightIntensity(intensity, 1)\n\n const lightingAmbient = computed(() => {\n const state = lighting?.()\n return state?.ambient ?? {}\n })\n\n const nightLights = computed(() => {\n const state = lighting?.()\n return (state?.spots ?? []).map((spot, index) => {\n const radius = spot.radius ?? 180\n return {\n x: spot.x,\n y: spot.y,\n radius: nightSpotRadius(radius),\n intensity: nightSpotIntensity(spot.intensity, index === 0 ? 1 : 0.92),\n flicker: spot.flicker,\n flickerSpeed: spot.flickerSpeed ?? 14,\n pulse: spot.pulse,\n pulseSpeed: spot.pulseSpeed,\n phase: spot.phase,\n }\n })\n })\n const lightingDarkness = computed(() => {\n const darkness = lightingAmbient().darkness\n return typeof darkness === \"number\" ? darkness : 0\n })\n\n const lightingAmbientEnabled = computed(() => {\n const state = lighting?.()\n return Boolean(state && lightingDarkness() > 0)\n })\n\n const lightingDarknessProps = computed(() => ({\n opacity: lightingDarkness(),\n color: lightingAmbient().darkColor ?? \"#080a12\",\n }))\n const lightingHaze = computed(() => ({\n color: lightingAmbient().fogColor ?? \"#12182a\",\n radius: lightingAmbient().fogRadius ?? 0.44,\n softness: lightingAmbient().fogSoftness ?? 0.3,\n opacity: lightingAmbient().fogOpacity ?? 0.35,\n }))\n\n const defaultSunLight = () => {\n const data = sceneData?.()\n const width = Number(data?.width ?? data?.params?.width ?? 2048)\n const height = Number(data?.height ?? data?.params?.height ?? 2048)\n const scale = Number(data?.params?.scale ?? 1) || 1\n const mapWidth = width * scale\n const mapHeight = height * scale\n const projectionBase = Math.max(1, mapWidth, mapHeight)\n\n return {\n x: -projectionBase * 24,\n y: -projectionBase * 24,\n z: 520,\n radius: projectionBase * 160,\n intensity: 0.85,\n shadowWeight: lightingDarkness() > 0 ? 2.2 : 1,\n enabled: true,\n }\n }\n\n const normalizeSunDirection = (sun) => {\n const x = toFiniteNumber(sun?.x, null)\n const y = toFiniteNumber(sun?.y, null)\n if (x !== null && y !== null && Math.hypot(x, y) > 0.001) {\n return { x, y }\n }\n return { x: -0.45, y: -1 }\n }\n\n const defaultSunAmbientLight = () => {\n const state = lighting?.()\n if (!state?.sun || state.sun.enabled === false) return null\n\n const defaultSun = defaultSunLight()\n const sun = {\n ...defaultSun,\n ...state.sun,\n intensity: shadowLightIntensity(state.sun.intensity, defaultSun.intensity),\n shadowWeight: state.sun.shadowWeight ?? defaultSun.shadowWeight,\n }\n if (sun.intensity <= 0) return null\n\n const direction = normalizeSunDirection(sun)\n const shadowWeight = clampNumber(toFiniteNumber(sun.shadowWeight, lightingDarkness() > 0 ? 1.35 : 1) ?? 1, 0, 4)\n const length = clampNumber(30 + sun.intensity * 38 * Math.max(0.75, shadowWeight), 30, 86)\n\n return {\n x: direction.x,\n y: direction.y,\n z: toFiniteNumber(sun.z, 520) ?? 520,\n intensity: clampNumber(sun.intensity, 0, 2),\n shadowWeight,\n length,\n }\n }\n\n const shadowState = computed(() => {\n const state = lighting?.()\n return state?.shadows ?? null\n })\n\n const shadowLights = computed(() => {\n const state = lighting?.()\n const spotLights = (state?.spots ?? []).map((spot) => {\n const radius = spot.radius ?? 180\n return {\n x: spot.x,\n y: spot.y,\n z: 170,\n radius: shadowSpotRadius(radius),\n intensity: shadowSpotIntensity(spot.intensity),\n shadowWeight: 1,\n enabled: true,\n }\n })\n\n return spotLights\n })\n\n const shadowAmbientLight = computed(() => {\n const shadows = shadowState()\n if (shadows?.ambientLight === null || shadows?.ambientLight?.enabled === false) {\n return null\n }\n return shadows?.ambientLight ?? defaultSunAmbientLight()\n })\n\n const shadowEnabled = computed(() => {\n const state = lighting?.()\n return Boolean(shouldRenderLightingShadows(state) && (shadowLights().length > 0 || shadowAmbientLight()))\n })\n\n const shadowMode = computed(() => shadowState()?.mode ?? \"strongest\")\n const shadowUpdateHz = computed(() => shadowState()?.updateHz ?? 60)\n const shadowScanHz = computed(() => shadowState()?.scanHz ?? 8)\n const shadowCullToViewport = computed(() => shadowState()?.cullToViewport ?? true)\n const shadowMinInfluence = computed(() => shadowState()?.minInfluence ?? 0.24)\n const shadowFalloffPower = computed(() => shadowState()?.falloffPower ?? 0.85)\n const shadowColor = computed(() => shadowState()?.shadowColor ?? \"#05070d\")\n</script>\n"],"mappings":";;;;;;;AAcM,SAAE,UAAc,SAAA;CACR,SAAU,OAAA;CACN,eAAc,OAAA;CACxB,MAAM,SAAE,OAAY,eAAA;CAC5B,MAAM,WAAE,OAAgB;CACxB,MAAM,aAAa,OAAE,MAAW;CAChC,MAAM,YAAC,OAAA,SAAA;CACP,MAAI,WAAA,OAAA,SAAA;CACJ,MAAK,UAAU,eAAA;EACX,OAAA,OAAQ,OAAA,WAAA,IAAA,CAAA,EAAA,QAAA,QAAA,CAAA,IAAA,cAAA;CACZ,CAAC;CACD,MAAM,aAAC,eAAA;EACH,MAAI,OAAA,YAAc;EAClB,MAAI,QAAM,OAAA,MAAA,QAAA,SAAA,CAAA,KAAA;EACV,OAAI,OAAO,MAAA,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AA;EAAA,WAAA,IAAA;EAAA,WAAA,MAAA,cAAA;GACzG,YAAS,KAAA,MAAgB,SAAK;;;GAE7B,iBAAA,KAAA,MAAA,IAAA;EACF;CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACU;AACb;AAEA,IAAA,iBAAY"}
|
|
@@ -1,16 +1,55 @@
|
|
|
1
1
|
import { inject } from "../../core/inject.js";
|
|
2
2
|
import { RpgClientEngine } from "../../RpgClientEngine.js";
|
|
3
3
|
import __ce_component$1 from "../character.ce.js";
|
|
4
|
-
import { Container, h, loop, useDefineProps, useProps } from "canvasengine";
|
|
4
|
+
import { Container, effect, h, loop, mount, useDefineProps, useProps } from "canvasengine";
|
|
5
5
|
//#region src/components/scenes/event-layer.ce
|
|
6
6
|
function component($$props) {
|
|
7
7
|
useProps($$props);
|
|
8
8
|
const defineProps = useDefineProps($$props);
|
|
9
9
|
const engine = inject(RpgClientEngine);
|
|
10
|
-
const { children } = defineProps();
|
|
10
|
+
const { children, pixiChildren } = defineProps({ pixiChildren: { default: [] } });
|
|
11
|
+
const readValue = (value) => typeof value === "function" ? value() : value;
|
|
12
|
+
let rootContainer = null;
|
|
13
|
+
let mountedPixiChildren = [];
|
|
11
14
|
const players = engine.sceneMap.players;
|
|
12
15
|
const events = engine.sceneMap.events;
|
|
13
|
-
|
|
16
|
+
const getPixiChildren = () => {
|
|
17
|
+
const value = readValue(pixiChildren);
|
|
18
|
+
return Array.isArray(value) ? value.filter(Boolean) : [];
|
|
19
|
+
};
|
|
20
|
+
const syncPixiChildren = () => {
|
|
21
|
+
if (!rootContainer) return;
|
|
22
|
+
const nextPixiChildren = getPixiChildren();
|
|
23
|
+
mountedPixiChildren.forEach((child) => {
|
|
24
|
+
if (!nextPixiChildren.includes(child) && child.parent === rootContainer) rootContainer.removeChild(child);
|
|
25
|
+
});
|
|
26
|
+
nextPixiChildren.forEach((child) => {
|
|
27
|
+
if (child.parent === rootContainer) return;
|
|
28
|
+
if (child.parent) child.parent.removeChild(child);
|
|
29
|
+
rootContainer.addChild(child);
|
|
30
|
+
});
|
|
31
|
+
mountedPixiChildren = nextPixiChildren;
|
|
32
|
+
};
|
|
33
|
+
const detachPixiChildren = () => {
|
|
34
|
+
if (!rootContainer) return;
|
|
35
|
+
mountedPixiChildren.forEach((child) => {
|
|
36
|
+
if (child.parent === rootContainer) rootContainer.removeChild(child);
|
|
37
|
+
});
|
|
38
|
+
mountedPixiChildren = [];
|
|
39
|
+
};
|
|
40
|
+
effect(() => {
|
|
41
|
+
readValue(pixiChildren);
|
|
42
|
+
syncPixiChildren();
|
|
43
|
+
});
|
|
44
|
+
mount((element) => {
|
|
45
|
+
rootContainer = element.componentInstance;
|
|
46
|
+
syncPixiChildren();
|
|
47
|
+
return detachPixiChildren;
|
|
48
|
+
});
|
|
49
|
+
return h(Container, {
|
|
50
|
+
sortableChildren: true,
|
|
51
|
+
onBeforeDestroy: detachPixiChildren
|
|
52
|
+
}, [
|
|
14
53
|
loop(events, (event, id) => h(__ce_component$1, {
|
|
15
54
|
id,
|
|
16
55
|
object: event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-layer.ce.js","names":[],"sources":["../../../src/components/scenes/event-layer.ce"],"sourcesContent":["<Container sortableChildren={true}>\n @for ((event,id) of events) {\n <Character id={id} object={event} />\n }\n\n @for ((player,id) of players) {\n <Character id={id} object={player} />\n }\n\n @for (child of children) {\n <child />\n }\n</Container>\n\n<script>\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import Character from \"../character.ce\";\n import LightHalo from \"../prebuilt/light-halo.ce\";\n \n const engine = inject(RpgClientEngine);\n const { children } = defineProps()\n \n const players = engine.sceneMap.players\n const events = engine.sceneMap.events\n</script>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-layer.ce.js","names":[],"sources":["../../../src/components/scenes/event-layer.ce"],"sourcesContent":["<Container sortableChildren={true} onBeforeDestroy={detachPixiChildren}>\n @for ((event,id) of events) {\n <Character id={id} object={event} />\n }\n\n @for ((player,id) of players) {\n <Character id={id} object={player} />\n }\n\n @for (child of children) {\n <child />\n }\n</Container>\n\n<script>\n import { effect, mount } from \"canvasengine\";\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import Character from \"../character.ce\";\n import LightHalo from \"../prebuilt/light-halo.ce\";\n \n const engine = inject(RpgClientEngine);\n const { children, pixiChildren } = defineProps({\n pixiChildren: {\n default: []\n }\n })\n const readValue = (value) => typeof value === \"function\" ? value() : value\n let rootContainer = null\n let mountedPixiChildren = []\n \n const players = engine.sceneMap.players\n const events = engine.sceneMap.events\n\n const getPixiChildren = () => {\n const value = readValue(pixiChildren)\n return Array.isArray(value) ? value.filter(Boolean) : []\n }\n\n const syncPixiChildren = () => {\n if (!rootContainer) return\n const nextPixiChildren = getPixiChildren()\n mountedPixiChildren.forEach((child) => {\n if (!nextPixiChildren.includes(child) && child.parent === rootContainer) {\n rootContainer.removeChild(child)\n }\n })\n nextPixiChildren.forEach((child) => {\n if (child.parent === rootContainer) return\n if (child.parent) {\n child.parent.removeChild(child)\n }\n rootContainer.addChild(child)\n })\n mountedPixiChildren = nextPixiChildren\n }\n\n const detachPixiChildren = () => {\n if (!rootContainer) return\n mountedPixiChildren.forEach((child) => {\n if (child.parent === rootContainer) {\n rootContainer.removeChild(child)\n }\n })\n mountedPixiChildren = []\n }\n\n effect(() => {\n readValue(pixiChildren)\n syncPixiChildren()\n })\n\n mount((element) => {\n rootContainer = element.componentInstance\n syncPixiChildren()\n return detachPixiChildren\n })\n</script>\n"],"mappings":";;;;;AASK,SAAU,UAAI,SAAU;CACb,SAAA,OAAA;CACZ,MAAA,cAAA,eAAA,OAAA;CACF,MAAS,SAAA,OAAA,eAAA;kDAEV,cAAM,EACH,SAAS,CAAA,EACT,EACJ,CAAC;CACD,MAAI,aAAO,UAAkB,OAAC,UAAa,aAAA,MAAA,IAAA;CAC3C,IAAI,gBAAgB;CACpB,IAAE,sB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ken";
|
|
3
4
|
/**
|
|
4
5
|
* Represents the structure of map data that should be returned by the load map callback.
|
|
@@ -25,6 +26,8 @@ type MapData = {
|
|
|
25
26
|
}>;
|
|
26
27
|
/** Optional map identifier, defaults to the mapId parameter if not provided */
|
|
27
28
|
id?: string;
|
|
29
|
+
/** Optional initial lighting state for the loaded map */
|
|
30
|
+
lighting?: LightingState | null;
|
|
28
31
|
};
|
|
29
32
|
/**
|
|
30
33
|
* Callback function type for loading map data.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadMap.js","names":[],"sources":["../../src/services/loadMap.ts"],"sourcesContent":["import { Context, inject } from \"@signe/di\";\nimport { UpdateMapToken, UpdateMapService } from \"@rpgjs/common\";\n\nexport const LoadMapToken = 'LoadMapToken'\n\n/**\n * Represents the structure of map data that should be returned by the load map callback.\n * This interface defines all the properties that can be provided when loading a custom map.\n * \n * @interface MapData\n */\ntype MapData = {\n /** Raw map data that will be passed to the map component */\n data: any;\n /** CanvasEngine component that will render the map */\n component: any;\n /** Optional map width in pixels, used for viewport calculations */\n width?: number;\n /** Optional map height in pixels, used for viewport calculations */\n height?: number;\n /** Optional map events data (NPCs, interactive objects, etc.) */\n events?: any;\n /** Optional named positions, for example Tiled point objects used by changeMap(\"map\", \"name\") */\n positions?: Record<string, { x: number; y: number; z?: number }>;\n /** Optional map identifier, defaults to the mapId parameter if not provided */\n id?: string;\n}\n\n/**\n * Callback function type for loading map data.\n * This function receives a map ID and should return either a MapData object directly\n * or a Promise that resolves to a MapData object.\n * \n * @callback LoadMapOptions\n * @param {string} mapId - The identifier of the map to load\n * @returns {Promise<MapData> | MapData} The map data object or a promise resolving to it\n */\nexport type LoadMapOptions = (mapId: string) => Promise<MapData> | MapData \n\nexport class LoadMapService {\n private updateMapService: UpdateMapService;\n\n constructor(private context: Context, private options: LoadMapOptions) {\n if (context['side'] === 'server') {\n return\n }\n this.updateMapService = inject(context, UpdateMapToken);\n }\n\n async load(mapId: string) {\n const map = await this.options(mapId.replace('map-', ''))\n await this.updateMapService.update(map);\n return map;\n }\n}\n\n/**\n * Creates a dependency injection configuration for custom map loading on the client side.\n * \n * This function allows you to customize how maps are loaded and displayed by providing\n * a callback that defines custom map data and rendering components. It's designed to work\n * with the RPG-JS dependency injection system and enables integration of custom map formats\n * like Tiled TMX files or any other map data structure.\n * \n * The function sets up the necessary service providers for map loading, including:\n * - UpdateMapToken: Handles map updates in the client context\n * - LoadMapToken: Provides the LoadMapService with your custom loading logic\n * \n * **Design Concept:**\n * The function follows the provider pattern, creating a modular way to inject custom\n * map loading behavior into the RPG-JS client engine. It separates the concern of\n * map data fetching from map rendering, allowing developers to focus on their specific\n * map format while leveraging the engine's rendering capabilities.\n * \n * @param {LoadMapOptions} options - Callback function that handles map loading logic\n * @returns {Array<Object>} Array of dependency injection provider configurations\n * \n * @example\n * ```typescript\n * import { provideLoadMap } from '@rpgjs/client'\n * import { createModule } from '@rpgjs/common'\n * import MyTiledMapComponent from './MyTiledMapComponent.ce'\n * \n * // Basic usage with JSON map data\n * export function provideCustomMap() {\n * return createModule(\"CustomMap\", [\n * provideLoadMap(async (mapId) => {\n * const response = await fetch(`/maps/${mapId}.json`)\n * const mapData = await response.json()\n * \n * return {\n * data: mapData,\n * component: MyTiledMapComponent,\n * width: mapData.width,\n * height: mapData.height,\n * events: mapData.events\n * }\n * })\n * ])\n * }\n * \n * // Advanced usage with Tiled TMX files\n * export function provideTiledMap() {\n * return createModule(\"TiledMap\", [\n * provideLoadMap(async (mapId) => {\n * // Load TMX file\n * const tmxResponse = await fetch(`/tiled/${mapId}.tmx`)\n * const tmxData = await tmxResponse.text()\n * \n * // Parse TMX data (using a TMX parser)\n * const parsedMap = parseTMX(tmxData)\n * \n * return {\n * data: parsedMap,\n * component: TiledMapRenderer,\n * width: parsedMap.width * parsedMap.tilewidth,\n * height: parsedMap.height * parsedMap.tileheight,\n * events: parsedMap.objectGroups?.find(g => g.name === 'events')?.objects\n * }\n * })\n * ])\n * }\n * \n * // Synchronous usage for static maps\n * export function provideStaticMap() {\n * return createModule(\"StaticMap\", [\n * provideLoadMap((mapId) => {\n * const staticMaps = {\n * 'town': { tiles: [...], npcs: [...] },\n * 'dungeon': { tiles: [...], monsters: [...] }\n * }\n * \n * return {\n * data: staticMaps[mapId],\n * component: StaticMapComponent,\n * width: 800,\n * height: 600\n * }\n * })\n * ])\n * }\n * ```\n * \n * @since 4.0.0\n * @see {@link LoadMapOptions} for callback function signature\n * @see {@link MapData} for return data structure\n */\nexport function provideLoadMap(options: LoadMapOptions) {\n return [\n {\n provide: UpdateMapToken,\n useFactory: (context: Context) => {\n if (context['side'] === 'client') {\n console.warn('UpdateMapToken is not overridden')\n }\n return\n },\n },\n {\n provide: LoadMapToken,\n useFactory: (context: Context) => new LoadMapService(context, options),\n },\n ];\n}\n"],"mappings":";;;AAGA,IAAa,eAAe;
|
|
1
|
+
{"version":3,"file":"loadMap.js","names":[],"sources":["../../src/services/loadMap.ts"],"sourcesContent":["import { Context, inject } from \"@signe/di\";\nimport { UpdateMapToken, UpdateMapService, type LightingState } from \"@rpgjs/common\";\n\nexport const LoadMapToken = 'LoadMapToken'\n\n/**\n * Represents the structure of map data that should be returned by the load map callback.\n * This interface defines all the properties that can be provided when loading a custom map.\n * \n * @interface MapData\n */\ntype MapData = {\n /** Raw map data that will be passed to the map component */\n data: any;\n /** CanvasEngine component that will render the map */\n component: any;\n /** Optional map width in pixels, used for viewport calculations */\n width?: number;\n /** Optional map height in pixels, used for viewport calculations */\n height?: number;\n /** Optional map events data (NPCs, interactive objects, etc.) */\n events?: any;\n /** Optional named positions, for example Tiled point objects used by changeMap(\"map\", \"name\") */\n positions?: Record<string, { x: number; y: number; z?: number }>;\n /** Optional map identifier, defaults to the mapId parameter if not provided */\n id?: string;\n /** Optional initial lighting state for the loaded map */\n lighting?: LightingState | null;\n}\n\n/**\n * Callback function type for loading map data.\n * This function receives a map ID and should return either a MapData object directly\n * or a Promise that resolves to a MapData object.\n * \n * @callback LoadMapOptions\n * @param {string} mapId - The identifier of the map to load\n * @returns {Promise<MapData> | MapData} The map data object or a promise resolving to it\n */\nexport type LoadMapOptions = (mapId: string) => Promise<MapData> | MapData \n\nexport class LoadMapService {\n private updateMapService: UpdateMapService;\n\n constructor(private context: Context, private options: LoadMapOptions) {\n if (context['side'] === 'server') {\n return\n }\n this.updateMapService = inject(context, UpdateMapToken);\n }\n\n async load(mapId: string) {\n const map = await this.options(mapId.replace('map-', ''))\n await this.updateMapService.update(map);\n return map;\n }\n}\n\n/**\n * Creates a dependency injection configuration for custom map loading on the client side.\n * \n * This function allows you to customize how maps are loaded and displayed by providing\n * a callback that defines custom map data and rendering components. It's designed to work\n * with the RPG-JS dependency injection system and enables integration of custom map formats\n * like Tiled TMX files or any other map data structure.\n * \n * The function sets up the necessary service providers for map loading, including:\n * - UpdateMapToken: Handles map updates in the client context\n * - LoadMapToken: Provides the LoadMapService with your custom loading logic\n * \n * **Design Concept:**\n * The function follows the provider pattern, creating a modular way to inject custom\n * map loading behavior into the RPG-JS client engine. It separates the concern of\n * map data fetching from map rendering, allowing developers to focus on their specific\n * map format while leveraging the engine's rendering capabilities.\n * \n * @param {LoadMapOptions} options - Callback function that handles map loading logic\n * @returns {Array<Object>} Array of dependency injection provider configurations\n * \n * @example\n * ```typescript\n * import { provideLoadMap } from '@rpgjs/client'\n * import { createModule } from '@rpgjs/common'\n * import MyTiledMapComponent from './MyTiledMapComponent.ce'\n * \n * // Basic usage with JSON map data\n * export function provideCustomMap() {\n * return createModule(\"CustomMap\", [\n * provideLoadMap(async (mapId) => {\n * const response = await fetch(`/maps/${mapId}.json`)\n * const mapData = await response.json()\n * \n * return {\n * data: mapData,\n * component: MyTiledMapComponent,\n * width: mapData.width,\n * height: mapData.height,\n * events: mapData.events\n * }\n * })\n * ])\n * }\n * \n * // Advanced usage with Tiled TMX files\n * export function provideTiledMap() {\n * return createModule(\"TiledMap\", [\n * provideLoadMap(async (mapId) => {\n * // Load TMX file\n * const tmxResponse = await fetch(`/tiled/${mapId}.tmx`)\n * const tmxData = await tmxResponse.text()\n * \n * // Parse TMX data (using a TMX parser)\n * const parsedMap = parseTMX(tmxData)\n * \n * return {\n * data: parsedMap,\n * component: TiledMapRenderer,\n * width: parsedMap.width * parsedMap.tilewidth,\n * height: parsedMap.height * parsedMap.tileheight,\n * events: parsedMap.objectGroups?.find(g => g.name === 'events')?.objects\n * }\n * })\n * ])\n * }\n * \n * // Synchronous usage for static maps\n * export function provideStaticMap() {\n * return createModule(\"StaticMap\", [\n * provideLoadMap((mapId) => {\n * const staticMaps = {\n * 'town': { tiles: [...], npcs: [...] },\n * 'dungeon': { tiles: [...], monsters: [...] }\n * }\n * \n * return {\n * data: staticMaps[mapId],\n * component: StaticMapComponent,\n * width: 800,\n * height: 600\n * }\n * })\n * ])\n * }\n * ```\n * \n * @since 4.0.0\n * @see {@link LoadMapOptions} for callback function signature\n * @see {@link MapData} for return data structure\n */\nexport function provideLoadMap(options: LoadMapOptions) {\n return [\n {\n provide: UpdateMapToken,\n useFactory: (context: Context) => {\n if (context['side'] === 'client') {\n console.warn('UpdateMapToken is not overridden')\n }\n return\n },\n },\n {\n provide: LoadMapToken,\n useFactory: (context: Context) => new LoadMapService(context, options),\n },\n ];\n}\n"],"mappings":";;;AAGA,IAAa,eAAe;AAsC5B,IAAa,iBAAb,MAA4B;CAG1B,YAAY,SAA0B,SAAiC;EAAnD,KAAA,UAAA;EAA0B,KAAA,UAAA;EAC5C,IAAI,QAAQ,YAAY,UACtB;EAEF,KAAK,mBAAmB,OAAO,SAAS,cAAc;CACxD;CAEA,MAAM,KAAK,OAAe;EACxB,MAAM,MAAM,MAAM,KAAK,QAAQ,MAAM,QAAQ,QAAQ,EAAE,CAAC;EACxD,MAAM,KAAK,iBAAiB,OAAO,GAAG;EACtC,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FA,SAAgB,eAAe,SAAyB;CACtD,OAAO,CACL;EACE,SAAS;EACT,aAAa,YAAqB;GAChC,IAAI,QAAQ,YAAY,UACtB,QAAQ,KAAK,kCAAkC;EAGnD;CACF,GACA;EACE,SAAS;EACT,aAAa,YAAqB,IAAI,eAAe,SAAS,OAAO;CACvE,CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpgjs/client",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.15",
|
|
4
4
|
"description": "RPGJS is a framework for creating RPG/MMORPG games",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"pixi.js": "^8.9.2"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@rpgjs/common": "5.0.0-beta.
|
|
26
|
-
"@rpgjs/server": "5.0.0-beta.
|
|
25
|
+
"@rpgjs/common": "5.0.0-beta.14",
|
|
26
|
+
"@rpgjs/server": "5.0.0-beta.15",
|
|
27
27
|
"@rpgjs/ui-css": "5.0.0-beta.12",
|
|
28
28
|
"@signe/di": "3.0.1",
|
|
29
29
|
"@signe/room": "3.0.1",
|