@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
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Direction, RpgActionInput, RpgActionName } from '@rpgjs/common';
|
|
2
|
+
export type KeyboardActionDataResolver<TClient = any, TSprite = any> = (client: TClient, sprite: TSprite) => any;
|
|
3
|
+
export interface KeyboardActionConfig<TClient = any, TSprite = any> {
|
|
4
|
+
bind: any;
|
|
5
|
+
action?: RpgActionName;
|
|
6
|
+
data?: any | KeyboardActionDataResolver<TClient, TSprite>;
|
|
7
|
+
}
|
|
8
|
+
export declare function normalizeActionInput(action: RpgActionName, data?: any): RpgActionInput;
|
|
9
|
+
export declare function normalizeActionInput(action: RpgActionInput): RpgActionInput;
|
|
10
|
+
export declare function isKeyboardActionConfig(value: any): value is KeyboardActionConfig;
|
|
11
|
+
export declare function getKeyboardControlBind(control: any): any;
|
|
12
|
+
export declare function keyboardEventMatchesBind(event: KeyboardEvent, bind: any): boolean;
|
|
13
|
+
export declare function resolveKeyboardActionInput(control: any, client: any, sprite: any, defaultAction?: RpgActionName): RpgActionInput;
|
|
14
|
+
export declare function resolveKeyboardDirectionInput(event: KeyboardEvent, keyboardControls: any): Direction | undefined;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Direction } from "@rpgjs/common";
|
|
2
|
+
//#region src/services/actionInput.ts
|
|
3
|
+
function normalizeActionInput(action, data) {
|
|
4
|
+
if (typeof action === "object") return action;
|
|
5
|
+
return data === void 0 ? { action } : {
|
|
6
|
+
action,
|
|
7
|
+
data
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function isKeyboardActionConfig(value) {
|
|
11
|
+
return value !== null && typeof value === "object" && Object.prototype.hasOwnProperty.call(value, "bind");
|
|
12
|
+
}
|
|
13
|
+
function getKeyboardControlBind(control) {
|
|
14
|
+
return isKeyboardActionConfig(control) ? control.bind : control;
|
|
15
|
+
}
|
|
16
|
+
var KEY_CODE_NAMES = {
|
|
17
|
+
32: "space",
|
|
18
|
+
27: "escape",
|
|
19
|
+
37: "left",
|
|
20
|
+
38: "up",
|
|
21
|
+
39: "right",
|
|
22
|
+
40: "down"
|
|
23
|
+
};
|
|
24
|
+
var normalizeKeyboardName = (value) => {
|
|
25
|
+
if (typeof value !== "string") return void 0;
|
|
26
|
+
const normalized = value.toLowerCase();
|
|
27
|
+
if (normalized === " " || normalized === "spacebar" || normalized === "space") return "space";
|
|
28
|
+
if (normalized.startsWith("arrow")) return normalized.slice(5);
|
|
29
|
+
return normalized;
|
|
30
|
+
};
|
|
31
|
+
function keyboardEventMatchesBind(event, bind) {
|
|
32
|
+
if (Array.isArray(bind)) return bind.some((item) => keyboardEventMatchesBind(event, item));
|
|
33
|
+
if (typeof bind === "number") return event.keyCode === bind;
|
|
34
|
+
const expected = normalizeKeyboardName(bind);
|
|
35
|
+
if (!expected) return false;
|
|
36
|
+
return normalizeKeyboardName(event.key) === expected || normalizeKeyboardName(event.code) === expected || KEY_CODE_NAMES[event.keyCode] === expected;
|
|
37
|
+
}
|
|
38
|
+
function resolveKeyboardActionInput(control, client, sprite, defaultAction = "action") {
|
|
39
|
+
if (!isKeyboardActionConfig(control)) return { action: defaultAction };
|
|
40
|
+
const action = control.action ?? defaultAction;
|
|
41
|
+
const data = typeof control.data === "function" ? control.data(client, sprite) : control.data;
|
|
42
|
+
return data === void 0 ? { action } : {
|
|
43
|
+
action,
|
|
44
|
+
data
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function resolveKeyboardDirectionInput(event, keyboardControls) {
|
|
48
|
+
const directions = [
|
|
49
|
+
[keyboardControls?.up, Direction.Up],
|
|
50
|
+
[keyboardControls?.down, Direction.Down],
|
|
51
|
+
[keyboardControls?.left, Direction.Left],
|
|
52
|
+
[keyboardControls?.right, Direction.Right]
|
|
53
|
+
];
|
|
54
|
+
for (const [control, direction] of directions) if (keyboardEventMatchesBind(event, getKeyboardControlBind(control))) return direction;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { getKeyboardControlBind, isKeyboardActionConfig, keyboardEventMatchesBind, normalizeActionInput, resolveKeyboardActionInput, resolveKeyboardDirectionInput };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=actionInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionInput.js","names":[],"sources":["../../src/services/actionInput.ts"],"sourcesContent":["import { Direction, type RpgActionInput, type RpgActionName } from \"@rpgjs/common\";\n\nexport type KeyboardActionDataResolver<TClient = any, TSprite = any> = (\n client: TClient,\n sprite: TSprite,\n) => any;\n\nexport interface KeyboardActionConfig<TClient = any, TSprite = any> {\n bind: any;\n action?: RpgActionName;\n data?: any | KeyboardActionDataResolver<TClient, TSprite>;\n}\n\nexport function normalizeActionInput(action: RpgActionName, data?: any): RpgActionInput;\nexport function normalizeActionInput(action: RpgActionInput): RpgActionInput;\nexport function normalizeActionInput(action: RpgActionName | RpgActionInput, data?: any): RpgActionInput {\n if (typeof action === \"object\") {\n return action;\n }\n return data === undefined\n ? { action }\n : { action, data };\n}\n\nexport function isKeyboardActionConfig(value: any): value is KeyboardActionConfig {\n return value !== null\n && typeof value === \"object\"\n && Object.prototype.hasOwnProperty.call(value, \"bind\");\n}\n\nexport function getKeyboardControlBind(control: any): any {\n return isKeyboardActionConfig(control) ? control.bind : control;\n}\n\nconst KEY_CODE_NAMES: Record<number, string> = {\n 32: \"space\",\n 27: \"escape\",\n 37: \"left\",\n 38: \"up\",\n 39: \"right\",\n 40: \"down\",\n};\n\nconst normalizeKeyboardName = (value: unknown): string | undefined => {\n if (typeof value !== \"string\") return undefined;\n const normalized = value.toLowerCase();\n if (\n normalized === \" \" ||\n normalized === \"spacebar\" ||\n normalized === \"space\"\n ) {\n return \"space\";\n }\n if (normalized.startsWith(\"arrow\")) {\n return normalized.slice(\"arrow\".length);\n }\n return normalized;\n};\n\nexport function keyboardEventMatchesBind(\n event: KeyboardEvent,\n bind: any\n): boolean {\n if (Array.isArray(bind)) {\n return bind.some(item => keyboardEventMatchesBind(event, item));\n }\n\n if (typeof bind === \"number\") {\n return event.keyCode === bind;\n }\n\n const expected = normalizeKeyboardName(bind);\n if (!expected) return false;\n\n return (\n normalizeKeyboardName(event.key) === expected ||\n normalizeKeyboardName(event.code) === expected ||\n KEY_CODE_NAMES[event.keyCode] === expected\n );\n}\n\nexport function resolveKeyboardActionInput(\n control: any,\n client: any,\n sprite: any,\n defaultAction: RpgActionName = \"action\",\n): RpgActionInput {\n if (!isKeyboardActionConfig(control)) {\n return { action: defaultAction };\n }\n\n const action = control.action ?? defaultAction;\n const data = typeof control.data === \"function\"\n ? control.data(client, sprite)\n : control.data;\n\n return data === undefined\n ? { action }\n : { action, data };\n}\n\nexport function resolveKeyboardDirectionInput(\n event: KeyboardEvent,\n keyboardControls: any\n): Direction | undefined {\n const directions: Array<[any, Direction]> = [\n [keyboardControls?.up, Direction.Up],\n [keyboardControls?.down, Direction.Down],\n [keyboardControls?.left, Direction.Left],\n [keyboardControls?.right, Direction.Right],\n ];\n\n for (const [control, direction] of directions) {\n if (keyboardEventMatchesBind(event, getKeyboardControlBind(control))) {\n return direction;\n }\n }\n\n return undefined;\n}\n"],"mappings":";;AAeA,SAAgB,qBAAqB,QAAwC,MAA4B;CACvG,IAAI,OAAO,WAAW,UACpB,OAAO;CAET,OAAO,SAAS,KAAA,IACZ,EAAE,OAAO,IACT;EAAE;EAAQ;CAAK;AACrB;AAEA,SAAgB,uBAAuB,OAA2C;CAChF,OAAO,UAAU,QACZ,OAAO,UAAU,YACjB,OAAO,UAAU,eAAe,KAAK,OAAO,MAAM;AACzD;AAEA,SAAgB,uBAAuB,SAAmB;CACxD,OAAO,uBAAuB,OAAO,IAAI,QAAQ,OAAO;AAC1D;AAEA,IAAM,iBAAyC;CAC7C,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAM,yBAAyB,UAAuC;CACpE,IAAI,OAAO,UAAU,UAAU,OAAO,KAAA;CACtC,MAAM,aAAa,MAAM,YAAY;CACrC,IACE,eAAe,OACf,eAAe,cACf,eAAe,SAEf,OAAO;CAET,IAAI,WAAW,WAAW,OAAO,GAC/B,OAAO,WAAW,MAAM,CAAc;CAExC,OAAO;AACT;AAEA,SAAgB,yBACd,OACA,MACS;CACT,IAAI,MAAM,QAAQ,IAAI,GACpB,OAAO,KAAK,MAAK,SAAQ,yBAAyB,OAAO,IAAI,CAAC;CAGhE,IAAI,OAAO,SAAS,UAClB,OAAO,MAAM,YAAY;CAG3B,MAAM,WAAW,sBAAsB,IAAI;CAC3C,IAAI,CAAC,UAAU,OAAO;CAEtB,OACE,sBAAsB,MAAM,GAAG,MAAM,YACrC,sBAAsB,MAAM,IAAI,MAAM,YACtC,eAAe,MAAM,aAAa;AAEtC;AAEA,SAAgB,2BACd,SACA,QACA,QACA,gBAA+B,UACf;CAChB,IAAI,CAAC,uBAAuB,OAAO,GACjC,OAAO,EAAE,QAAQ,cAAc;CAGjC,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,OAAO,OAAO,QAAQ,SAAS,aACjC,QAAQ,KAAK,QAAQ,MAAM,IAC3B,QAAQ;CAEZ,OAAO,SAAS,KAAA,IACZ,EAAE,OAAO,IACT;EAAE;EAAQ;CAAK;AACrB;AAEA,SAAgB,8BACd,OACA,kBACuB;CACvB,MAAM,aAAsC;EAC1C,CAAC,kBAAkB,IAAI,UAAU,EAAE;EACnC,CAAC,kBAAkB,MAAM,UAAU,IAAI;EACvC,CAAC,kBAAkB,MAAM,UAAU,IAAI;EACvC,CAAC,kBAAkB,OAAO,UAAU,KAAK;CAC3C;CAEA,KAAK,MAAM,CAAC,SAAS,cAAc,YACjC,IAAI,yBAAyB,OAAO,uBAAuB,OAAO,CAAC,GACjE,OAAO;AAKb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export declare const DEFAULT_CAMERA_FOLLOW_TIME = 1000;
|
|
2
|
+
export declare const DEFAULT_CAMERA_FOLLOW_EASE = "easeInOutSine";
|
|
3
|
+
export declare const CAMERA_FOLLOW_EASES: readonly ["linear", "easeInQuad", "easeOutQuad", "easeInOutQuad", "easeInCubic", "easeOutCubic", "easeInOutCubic", "easeInQuart", "easeOutQuart", "easeInOutQuart", "easeInQuint", "easeOutQuint", "easeInOutQuint", "easeInSine", "easeOutSine", "easeInOutSine", "easeInExpo", "easeOutExpo", "easeInOutExpo", "easeInCirc", "easeOutCirc", "easeInOutCirc", "easeInElastic", "easeOutElastic", "easeInOutElastic", "easeInBack", "easeOutBack", "easeInOutBack", "easeInBounce", "easeOutBounce", "easeInOutBounce"];
|
|
4
|
+
export type CameraFollowEase = typeof CAMERA_FOLLOW_EASES[number];
|
|
5
|
+
export type CameraFollowSmoothMoveOptions = {
|
|
6
|
+
/** Enable or disable the smooth transition when options are sent as an object. */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
/** Duration of the transition to the new camera target, in milliseconds. */
|
|
9
|
+
time?: number;
|
|
10
|
+
/** pixi-viewport easing name, for example "easeInOutQuad". */
|
|
11
|
+
ease?: CameraFollowEase;
|
|
12
|
+
/** Continuous follow speed after the transition. 0 keeps the target centered instantly. */
|
|
13
|
+
speed?: number;
|
|
14
|
+
/** Continuous follow acceleration after the transition. */
|
|
15
|
+
acceleration?: number | null;
|
|
16
|
+
/** Center radius where the followed target can move without moving the viewport. */
|
|
17
|
+
radius?: number | null;
|
|
18
|
+
};
|
|
19
|
+
export type CameraFollowSmoothMove = boolean | CameraFollowSmoothMoveOptions;
|
|
20
|
+
export type CameraFollowTarget = {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
destroyed?: boolean;
|
|
24
|
+
} | null | undefined;
|
|
25
|
+
export type CameraFollowPosition = {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
29
|
+
export interface CameraFollowApplyContext {
|
|
30
|
+
viewport: any;
|
|
31
|
+
target: CameraFollowTarget;
|
|
32
|
+
smoothMove: CameraFollowSmoothMove;
|
|
33
|
+
followRevision: number;
|
|
34
|
+
isCurrentRevision: (revision: number) => boolean;
|
|
35
|
+
shouldFollowCamera: () => boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare const smoothMoveEnabled: (smoothMove: CameraFollowSmoothMove) => boolean;
|
|
38
|
+
export declare const cameraFollowAnimationOptions: (smoothMove: CameraFollowSmoothMove) => {
|
|
39
|
+
time: number;
|
|
40
|
+
ease: "easeInOutSine" | "linear" | "easeInQuad" | "easeOutQuad" | "easeInOutQuad" | "easeInCubic" | "easeOutCubic" | "easeInOutCubic" | "easeInQuart" | "easeOutQuart" | "easeInOutQuart" | "easeInQuint" | "easeOutQuint" | "easeInOutQuint" | "easeInSine" | "easeOutSine" | "easeInExpo" | "easeOutExpo" | "easeInOutExpo" | "easeInCirc" | "easeOutCirc" | "easeInOutCirc" | "easeInElastic" | "easeOutElastic" | "easeInOutElastic" | "easeInBack" | "easeOutBack" | "easeInOutBack" | "easeInBounce" | "easeOutBounce" | "easeInOutBounce";
|
|
41
|
+
} | null;
|
|
42
|
+
export declare const cameraFollowOptions: (smoothMove: CameraFollowSmoothMove) => {
|
|
43
|
+
speed?: number;
|
|
44
|
+
acceleration?: number | null;
|
|
45
|
+
radius?: number | null;
|
|
46
|
+
} | undefined;
|
|
47
|
+
export declare const clearCameraFollowPlugins: (viewport: any) => void;
|
|
48
|
+
export declare const ownsCameraFollowRevision: (appliedRevision: number | null, currentRevision: number) => boolean;
|
|
49
|
+
export declare const readCameraFollowPosition: (target: CameraFollowTarget) => CameraFollowPosition | null;
|
|
50
|
+
export declare const followCameraInstantly: (viewport: any, target: CameraFollowTarget, smoothMove: CameraFollowSmoothMove) => boolean;
|
|
51
|
+
export declare const applyCameraFollow: ({ viewport, target, smoothMove, followRevision, isCurrentRevision, shouldFollowCamera, }: CameraFollowApplyContext) => boolean;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
//#region src/services/cameraFollow.ts
|
|
2
|
+
var DEFAULT_CAMERA_FOLLOW_TIME = 1e3;
|
|
3
|
+
var DEFAULT_CAMERA_FOLLOW_EASE = "easeInOutSine";
|
|
4
|
+
var CAMERA_FOLLOW_EASES = [
|
|
5
|
+
"linear",
|
|
6
|
+
"easeInQuad",
|
|
7
|
+
"easeOutQuad",
|
|
8
|
+
"easeInOutQuad",
|
|
9
|
+
"easeInCubic",
|
|
10
|
+
"easeOutCubic",
|
|
11
|
+
"easeInOutCubic",
|
|
12
|
+
"easeInQuart",
|
|
13
|
+
"easeOutQuart",
|
|
14
|
+
"easeInOutQuart",
|
|
15
|
+
"easeInQuint",
|
|
16
|
+
"easeOutQuint",
|
|
17
|
+
"easeInOutQuint",
|
|
18
|
+
"easeInSine",
|
|
19
|
+
"easeOutSine",
|
|
20
|
+
"easeInOutSine",
|
|
21
|
+
"easeInExpo",
|
|
22
|
+
"easeOutExpo",
|
|
23
|
+
"easeInOutExpo",
|
|
24
|
+
"easeInCirc",
|
|
25
|
+
"easeOutCirc",
|
|
26
|
+
"easeInOutCirc",
|
|
27
|
+
"easeInElastic",
|
|
28
|
+
"easeOutElastic",
|
|
29
|
+
"easeInOutElastic",
|
|
30
|
+
"easeInBack",
|
|
31
|
+
"easeOutBack",
|
|
32
|
+
"easeInOutBack",
|
|
33
|
+
"easeInBounce",
|
|
34
|
+
"easeOutBounce",
|
|
35
|
+
"easeInOutBounce"
|
|
36
|
+
];
|
|
37
|
+
var finiteNumber = (value, fallback) => {
|
|
38
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
39
|
+
};
|
|
40
|
+
var isCameraFollowEase = (value) => {
|
|
41
|
+
return typeof value === "string" && CAMERA_FOLLOW_EASES.includes(value);
|
|
42
|
+
};
|
|
43
|
+
var smoothMoveEnabled = (smoothMove) => {
|
|
44
|
+
if (smoothMove === false) return false;
|
|
45
|
+
if (typeof smoothMove === "object" && smoothMove !== null && smoothMove.enabled === false) return false;
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
48
|
+
var cameraFollowAnimationOptions = (smoothMove) => {
|
|
49
|
+
if (!smoothMoveEnabled(smoothMove)) return null;
|
|
50
|
+
const options = typeof smoothMove === "object" && smoothMove !== null ? smoothMove : {};
|
|
51
|
+
return {
|
|
52
|
+
time: Math.max(0, finiteNumber(options.time, DEFAULT_CAMERA_FOLLOW_TIME)),
|
|
53
|
+
ease: isCameraFollowEase(options.ease) ? options.ease : DEFAULT_CAMERA_FOLLOW_EASE
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
var cameraFollowOptions = (smoothMove) => {
|
|
57
|
+
if (typeof smoothMove !== "object" || smoothMove === null) return void 0;
|
|
58
|
+
const options = {};
|
|
59
|
+
if (typeof smoothMove.speed === "number" && Number.isFinite(smoothMove.speed)) options.speed = Math.max(0, smoothMove.speed);
|
|
60
|
+
if (typeof smoothMove.acceleration === "number" && Number.isFinite(smoothMove.acceleration)) options.acceleration = Math.max(0, smoothMove.acceleration);
|
|
61
|
+
else if (smoothMove.acceleration === null) options.acceleration = null;
|
|
62
|
+
if (typeof smoothMove.radius === "number" && Number.isFinite(smoothMove.radius)) options.radius = Math.max(0, smoothMove.radius);
|
|
63
|
+
else if (smoothMove.radius === null) options.radius = null;
|
|
64
|
+
return Object.keys(options).length > 0 ? options : void 0;
|
|
65
|
+
};
|
|
66
|
+
var clearCameraFollowPlugins = (viewport) => {
|
|
67
|
+
viewport?.plugins?.remove?.("animate");
|
|
68
|
+
viewport?.plugins?.remove?.("follow");
|
|
69
|
+
};
|
|
70
|
+
var ownsCameraFollowRevision = (appliedRevision, currentRevision) => {
|
|
71
|
+
return appliedRevision !== null && appliedRevision === currentRevision;
|
|
72
|
+
};
|
|
73
|
+
var readCameraFollowPosition = (target) => {
|
|
74
|
+
if (!target) return null;
|
|
75
|
+
try {
|
|
76
|
+
if (target.destroyed) return null;
|
|
77
|
+
const x = target.x;
|
|
78
|
+
const y = target.y;
|
|
79
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return null;
|
|
80
|
+
return {
|
|
81
|
+
x,
|
|
82
|
+
y
|
|
83
|
+
};
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var createCameraFollowTarget = (target, initialPosition) => {
|
|
89
|
+
let lastPosition = initialPosition;
|
|
90
|
+
const readPosition = () => {
|
|
91
|
+
const nextPosition = readCameraFollowPosition(target);
|
|
92
|
+
if (nextPosition) lastPosition = nextPosition;
|
|
93
|
+
return lastPosition;
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
get x() {
|
|
97
|
+
return readPosition().x;
|
|
98
|
+
},
|
|
99
|
+
get y() {
|
|
100
|
+
return readPosition().y;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
var followCameraInstantly = (viewport, target, smoothMove) => {
|
|
105
|
+
const position = readCameraFollowPosition(target);
|
|
106
|
+
if (!position) return false;
|
|
107
|
+
const followTarget = createCameraFollowTarget(target, position);
|
|
108
|
+
const followOptions = cameraFollowOptions(smoothMove);
|
|
109
|
+
if (followOptions) viewport.follow(followTarget, followOptions);
|
|
110
|
+
else viewport.follow(followTarget);
|
|
111
|
+
return true;
|
|
112
|
+
};
|
|
113
|
+
var applyCameraFollow = ({ viewport, target, smoothMove, followRevision, isCurrentRevision, shouldFollowCamera }) => {
|
|
114
|
+
clearCameraFollowPlugins(viewport);
|
|
115
|
+
const position = readCameraFollowPosition(target);
|
|
116
|
+
if (!position) return false;
|
|
117
|
+
const animationOptions = cameraFollowAnimationOptions(smoothMove);
|
|
118
|
+
if (!animationOptions || animationOptions.time <= 0) return followCameraInstantly(viewport, target, smoothMove);
|
|
119
|
+
viewport.animate({
|
|
120
|
+
position,
|
|
121
|
+
time: animationOptions.time,
|
|
122
|
+
ease: animationOptions.ease,
|
|
123
|
+
callbackOnComplete: () => {
|
|
124
|
+
if (!isCurrentRevision(followRevision) || !shouldFollowCamera()) return;
|
|
125
|
+
if (!readCameraFollowPosition(target)) return;
|
|
126
|
+
followCameraInstantly(viewport, target, smoothMove);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return true;
|
|
130
|
+
};
|
|
131
|
+
//#endregion
|
|
132
|
+
export { applyCameraFollow, clearCameraFollowPlugins, ownsCameraFollowRevision };
|
|
133
|
+
|
|
134
|
+
//# sourceMappingURL=cameraFollow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraFollow.js","names":[],"sources":["../../src/services/cameraFollow.ts"],"sourcesContent":["export const DEFAULT_CAMERA_FOLLOW_TIME = 1000;\nexport const DEFAULT_CAMERA_FOLLOW_EASE = \"easeInOutSine\";\n\nexport const CAMERA_FOLLOW_EASES = [\n \"linear\",\n \"easeInQuad\",\n \"easeOutQuad\",\n \"easeInOutQuad\",\n \"easeInCubic\",\n \"easeOutCubic\",\n \"easeInOutCubic\",\n \"easeInQuart\",\n \"easeOutQuart\",\n \"easeInOutQuart\",\n \"easeInQuint\",\n \"easeOutQuint\",\n \"easeInOutQuint\",\n \"easeInSine\",\n \"easeOutSine\",\n \"easeInOutSine\",\n \"easeInExpo\",\n \"easeOutExpo\",\n \"easeInOutExpo\",\n \"easeInCirc\",\n \"easeOutCirc\",\n \"easeInOutCirc\",\n \"easeInElastic\",\n \"easeOutElastic\",\n \"easeInOutElastic\",\n \"easeInBack\",\n \"easeOutBack\",\n \"easeInOutBack\",\n \"easeInBounce\",\n \"easeOutBounce\",\n \"easeInOutBounce\",\n] as const;\n\nexport type CameraFollowEase = typeof CAMERA_FOLLOW_EASES[number];\n\nexport type CameraFollowSmoothMoveOptions = {\n /** Enable or disable the smooth transition when options are sent as an object. */\n enabled?: boolean;\n /** Duration of the transition to the new camera target, in milliseconds. */\n time?: number;\n /** pixi-viewport easing name, for example \"easeInOutQuad\". */\n ease?: CameraFollowEase;\n /** Continuous follow speed after the transition. 0 keeps the target centered instantly. */\n speed?: number;\n /** Continuous follow acceleration after the transition. */\n acceleration?: number | null;\n /** Center radius where the followed target can move without moving the viewport. */\n radius?: number | null;\n};\n\nexport type CameraFollowSmoothMove = boolean | CameraFollowSmoothMoveOptions;\n\nexport type CameraFollowTarget = {\n x: number;\n y: number;\n destroyed?: boolean;\n} | null | undefined;\n\nexport type CameraFollowPosition = {\n x: number;\n y: number;\n};\n\nexport interface CameraFollowApplyContext {\n viewport: any;\n target: CameraFollowTarget;\n smoothMove: CameraFollowSmoothMove;\n followRevision: number;\n isCurrentRevision: (revision: number) => boolean;\n shouldFollowCamera: () => boolean;\n}\n\nconst finiteNumber = (value: unknown, fallback: number) => {\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n};\n\nconst isCameraFollowEase = (value: unknown): value is CameraFollowEase => {\n return typeof value === \"string\" && (CAMERA_FOLLOW_EASES as readonly string[]).includes(value);\n};\n\nexport const smoothMoveEnabled = (smoothMove: CameraFollowSmoothMove) => {\n if (smoothMove === false) return false;\n if (typeof smoothMove === \"object\" && smoothMove !== null && smoothMove.enabled === false) {\n return false;\n }\n return true;\n};\n\nexport const cameraFollowAnimationOptions = (\n smoothMove: CameraFollowSmoothMove\n) => {\n if (!smoothMoveEnabled(smoothMove)) return null;\n const options = typeof smoothMove === \"object\" && smoothMove !== null ? smoothMove : {};\n return {\n time: Math.max(0, finiteNumber(options.time, DEFAULT_CAMERA_FOLLOW_TIME)),\n ease: isCameraFollowEase(options.ease) ? options.ease : DEFAULT_CAMERA_FOLLOW_EASE,\n };\n};\n\nexport const cameraFollowOptions = (smoothMove: CameraFollowSmoothMove) => {\n if (typeof smoothMove !== \"object\" || smoothMove === null) return undefined;\n const options: { speed?: number; acceleration?: number | null; radius?: number | null } = {};\n if (typeof smoothMove.speed === \"number\" && Number.isFinite(smoothMove.speed)) {\n options.speed = Math.max(0, smoothMove.speed);\n }\n if (typeof smoothMove.acceleration === \"number\" && Number.isFinite(smoothMove.acceleration)) {\n options.acceleration = Math.max(0, smoothMove.acceleration);\n } else if (smoothMove.acceleration === null) {\n options.acceleration = null;\n }\n if (typeof smoothMove.radius === \"number\" && Number.isFinite(smoothMove.radius)) {\n options.radius = Math.max(0, smoothMove.radius);\n } else if (smoothMove.radius === null) {\n options.radius = null;\n }\n return Object.keys(options).length > 0 ? options : undefined;\n};\n\nexport const clearCameraFollowPlugins = (viewport: any) => {\n viewport?.plugins?.remove?.(\"animate\");\n viewport?.plugins?.remove?.(\"follow\");\n};\n\nexport const ownsCameraFollowRevision = (\n appliedRevision: number | null,\n currentRevision: number\n) => {\n return appliedRevision !== null && appliedRevision === currentRevision;\n};\n\nexport const readCameraFollowPosition = (\n target: CameraFollowTarget\n): CameraFollowPosition | null => {\n if (!target) return null;\n\n try {\n if (target.destroyed) return null;\n const x = target.x;\n const y = target.y;\n if (!Number.isFinite(x) || !Number.isFinite(y)) return null;\n return { x, y };\n } catch {\n return null;\n }\n};\n\nconst createCameraFollowTarget = (\n target: CameraFollowTarget,\n initialPosition: CameraFollowPosition\n) => {\n let lastPosition = initialPosition;\n\n const readPosition = () => {\n const nextPosition = readCameraFollowPosition(target);\n if (nextPosition) {\n lastPosition = nextPosition;\n }\n return lastPosition;\n };\n\n return {\n get x() {\n return readPosition().x;\n },\n get y() {\n return readPosition().y;\n },\n };\n};\n\nexport const followCameraInstantly = (\n viewport: any,\n target: CameraFollowTarget,\n smoothMove: CameraFollowSmoothMove\n) => {\n const position = readCameraFollowPosition(target);\n if (!position) return false;\n\n const followTarget = createCameraFollowTarget(target, position);\n const followOptions = cameraFollowOptions(smoothMove);\n if (followOptions) {\n viewport.follow(followTarget, followOptions);\n } else {\n viewport.follow(followTarget);\n }\n return true;\n};\n\nexport const applyCameraFollow = ({\n viewport,\n target,\n smoothMove,\n followRevision,\n isCurrentRevision,\n shouldFollowCamera,\n}: CameraFollowApplyContext) => {\n clearCameraFollowPlugins(viewport);\n\n const position = readCameraFollowPosition(target);\n if (!position) return false;\n\n const animationOptions = cameraFollowAnimationOptions(smoothMove);\n if (!animationOptions || animationOptions.time <= 0) {\n return followCameraInstantly(viewport, target, smoothMove);\n }\n\n viewport.animate({\n position,\n time: animationOptions.time,\n ease: animationOptions.ease,\n callbackOnComplete: () => {\n if (!isCurrentRevision(followRevision) || !shouldFollowCamera()) return;\n if (!readCameraFollowPosition(target)) return;\n followCameraInstantly(viewport, target, smoothMove);\n },\n });\n return true;\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { RpgActionInput, RpgActionName } from '@rpgjs/common';
|
|
2
|
+
import { RpgClientEngine } from '../RpgClientEngine';
|
|
3
|
+
export type RpgInteractionEventName = "pointerenter" | "pointerleave" | "pointerover" | "pointerout" | "pointerdown" | "pointerup" | "pointermove" | "click" | "dragstart" | "dragmove" | "drop" | "cancel";
|
|
4
|
+
export type RpgInteractionPosition = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
export type RpgInteractionBounds = {
|
|
9
|
+
left: number;
|
|
10
|
+
top: number;
|
|
11
|
+
right: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
centerX: number;
|
|
16
|
+
centerY: number;
|
|
17
|
+
contains(point: RpgInteractionPosition | null | undefined): boolean;
|
|
18
|
+
};
|
|
19
|
+
export type RpgInteractionBoundsSet = {
|
|
20
|
+
bounds?: RpgInteractionBounds;
|
|
21
|
+
hitbox?: RpgInteractionBounds;
|
|
22
|
+
graphic?: RpgInteractionBounds;
|
|
23
|
+
[key: string]: RpgInteractionBounds | undefined;
|
|
24
|
+
};
|
|
25
|
+
export type RpgInteractionTile = {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
worldX: number;
|
|
29
|
+
worldY: number;
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
33
|
+
export type RpgInteractionState = {
|
|
34
|
+
hovered: boolean;
|
|
35
|
+
pressed: boolean;
|
|
36
|
+
selected: boolean;
|
|
37
|
+
dragging: boolean;
|
|
38
|
+
data: Record<string, any>;
|
|
39
|
+
overlays: Record<string, RpgInteractionOverlay>;
|
|
40
|
+
};
|
|
41
|
+
export type RpgInteractionOverlay = {
|
|
42
|
+
component: any;
|
|
43
|
+
props?: Record<string, any>;
|
|
44
|
+
};
|
|
45
|
+
export type RpgInteractionMatcher = string | ((ctx: RpgInteractionMatcherContext) => boolean);
|
|
46
|
+
export type RpgInteractionMatcherContext = {
|
|
47
|
+
client: RpgClientEngine;
|
|
48
|
+
target: any;
|
|
49
|
+
sprite: any;
|
|
50
|
+
};
|
|
51
|
+
export type RpgInteractionHandler = (ctx: RpgInteractionContext) => void;
|
|
52
|
+
export type RpgInteractionBehavior = {
|
|
53
|
+
component?: any;
|
|
54
|
+
props?: Record<string, any> | ((ctx: RpgInteractionContext) => Record<string, any>);
|
|
55
|
+
dependencies?: any[] | ((ctx: RpgInteractionContext) => any[]);
|
|
56
|
+
cursor?: string | ((ctx: RpgInteractionContext) => string | undefined);
|
|
57
|
+
hitTest?: (ctx: RpgInteractionContext) => boolean;
|
|
58
|
+
pointerenter?: RpgInteractionHandler;
|
|
59
|
+
pointerleave?: RpgInteractionHandler;
|
|
60
|
+
pointerover?: RpgInteractionHandler;
|
|
61
|
+
pointerout?: RpgInteractionHandler;
|
|
62
|
+
pointerdown?: RpgInteractionHandler;
|
|
63
|
+
pointerup?: RpgInteractionHandler;
|
|
64
|
+
pointermove?: RpgInteractionHandler;
|
|
65
|
+
click?: RpgInteractionHandler;
|
|
66
|
+
dragstart?: RpgInteractionHandler;
|
|
67
|
+
dragmove?: RpgInteractionHandler;
|
|
68
|
+
drop?: RpgInteractionHandler;
|
|
69
|
+
cancel?: RpgInteractionHandler;
|
|
70
|
+
};
|
|
71
|
+
export type RpgInteractionComponentEntry = {
|
|
72
|
+
component: any;
|
|
73
|
+
props: Record<string, any>;
|
|
74
|
+
dependencies: any[];
|
|
75
|
+
};
|
|
76
|
+
export type RpgInteractionContext = {
|
|
77
|
+
client: RpgClientEngine;
|
|
78
|
+
target: any;
|
|
79
|
+
sprite: any;
|
|
80
|
+
event?: any;
|
|
81
|
+
behavior: RpgInteractionBehavior;
|
|
82
|
+
behaviorId: string;
|
|
83
|
+
pointer: {
|
|
84
|
+
screen(): RpgInteractionPosition | null;
|
|
85
|
+
world(): RpgInteractionPosition | null;
|
|
86
|
+
tile(): RpgInteractionTile | null;
|
|
87
|
+
};
|
|
88
|
+
bounds(kind?: string): RpgInteractionBounds;
|
|
89
|
+
state: {
|
|
90
|
+
value(): RpgInteractionState;
|
|
91
|
+
get<T = any>(key: string): T | undefined;
|
|
92
|
+
set(key: string, value: any): void;
|
|
93
|
+
patch(patch: Partial<Omit<RpgInteractionState, "data" | "overlays">>): void;
|
|
94
|
+
};
|
|
95
|
+
overlay: {
|
|
96
|
+
render(component: any, props?: Record<string, any>): void;
|
|
97
|
+
update(props?: Record<string, any>): void;
|
|
98
|
+
clear(): void;
|
|
99
|
+
};
|
|
100
|
+
select(selected?: boolean): void;
|
|
101
|
+
action(action: RpgActionName, data?: any): void;
|
|
102
|
+
action(input: RpgActionInput): void;
|
|
103
|
+
cancel(): void;
|
|
104
|
+
};
|
|
105
|
+
type InteractionEventInput = {
|
|
106
|
+
event?: any;
|
|
107
|
+
bounds?: RpgInteractionBoundsSet;
|
|
108
|
+
};
|
|
109
|
+
export declare class RpgClientInteractions {
|
|
110
|
+
private client;
|
|
111
|
+
private registrations;
|
|
112
|
+
private states;
|
|
113
|
+
private activeDrag?;
|
|
114
|
+
private nextId;
|
|
115
|
+
constructor(client: RpgClientEngine);
|
|
116
|
+
use(matcher: RpgInteractionMatcher, behavior: RpgInteractionBehavior | any): () => void;
|
|
117
|
+
getState(sprite: any): RpgInteractionState;
|
|
118
|
+
getRenderedComponents(sprite: any, bounds?: RpgInteractionBoundsSet): RpgInteractionComponentEntry[];
|
|
119
|
+
cursorFor(sprite: any, bounds?: RpgInteractionBoundsSet): string | undefined;
|
|
120
|
+
handle(sprite: any, type: RpgInteractionEventName, input?: InteractionEventInput): void;
|
|
121
|
+
handlePointerMove(event?: any): void;
|
|
122
|
+
handlePointerUp(event?: any): void;
|
|
123
|
+
cancelDrag(event?: any): void;
|
|
124
|
+
private getMatches;
|
|
125
|
+
private matches;
|
|
126
|
+
private createContext;
|
|
127
|
+
private callHandler;
|
|
128
|
+
private passesHitTest;
|
|
129
|
+
private isDraggable;
|
|
130
|
+
private defaultComponentProps;
|
|
131
|
+
private resolveProps;
|
|
132
|
+
private resolveDependencies;
|
|
133
|
+
private getSpriteId;
|
|
134
|
+
private patchState;
|
|
135
|
+
private patchStateData;
|
|
136
|
+
private patchOverlay;
|
|
137
|
+
private updateOverlay;
|
|
138
|
+
private clearOverlay;
|
|
139
|
+
private getPointerTile;
|
|
140
|
+
}
|
|
141
|
+
export declare function hoverPopover(component: any, props?: Record<string, any>): RpgInteractionBehavior;
|
|
142
|
+
export declare function selectable(options?: {
|
|
143
|
+
cursor?: string;
|
|
144
|
+
onSelect?: RpgInteractionHandler;
|
|
145
|
+
}): RpgInteractionBehavior;
|
|
146
|
+
export declare function draggable(options?: {
|
|
147
|
+
cursor?: string;
|
|
148
|
+
start?: RpgInteractionHandler;
|
|
149
|
+
move?: RpgInteractionHandler;
|
|
150
|
+
drop?: RpgInteractionHandler;
|
|
151
|
+
cancel?: RpgInteractionHandler;
|
|
152
|
+
}): RpgInteractionBehavior;
|
|
153
|
+
export declare function dragToTile(options: {
|
|
154
|
+
action?: RpgActionName;
|
|
155
|
+
data?: (ctx: RpgInteractionContext) => any;
|
|
156
|
+
onDrop?: RpgInteractionHandler;
|
|
157
|
+
cursor?: string;
|
|
158
|
+
}): RpgInteractionBehavior;
|
|
159
|
+
export {};
|