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