@rpgjs/client 5.0.0-alpha.9 → 5.0.0-beta.10
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 +37 -0
- package/LICENSE +19 -0
- package/dist/Game/AnimationManager.d.ts +8 -0
- package/dist/Game/AnimationManager.js +35 -0
- package/dist/Game/AnimationManager.js.map +1 -0
- package/dist/Game/AnimationManager.spec.d.ts +1 -0
- package/dist/Game/Event.d.ts +1 -1
- package/dist/Game/Event.js +12 -0
- package/dist/Game/Event.js.map +1 -0
- package/dist/Game/Map.d.ts +31 -2
- package/dist/Game/Map.js +138 -0
- package/dist/Game/Map.js.map +1 -0
- package/dist/Game/Object.d.ts +189 -0
- package/dist/Game/Object.js +255 -0
- package/dist/Game/Object.js.map +1 -0
- package/dist/Game/Player.d.ts +1 -1
- package/dist/Game/Player.js +12 -0
- package/dist/Game/Player.js.map +1 -0
- package/dist/Gui/Gui.d.ts +192 -7
- package/dist/Gui/Gui.js +475 -0
- package/dist/Gui/Gui.js.map +1 -0
- package/dist/Gui/Gui.spec.d.ts +1 -0
- package/dist/Gui/NotificationManager.d.ts +23 -0
- package/dist/Gui/NotificationManager.js +49 -0
- package/dist/Gui/NotificationManager.js.map +1 -0
- package/dist/Resource.d.ts +97 -0
- package/dist/Resource.js +133 -0
- package/dist/Resource.js.map +1 -0
- package/dist/RpgClient.d.ts +295 -13
- package/dist/RpgClientEngine.d.ts +671 -15
- package/dist/RpgClientEngine.js +1442 -0
- package/dist/RpgClientEngine.js.map +1 -0
- package/dist/Sound.d.ts +199 -0
- package/dist/Sound.js +167 -0
- package/dist/Sound.js.map +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/decorate.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/decorateMetadata.js +6 -0
- package/dist/components/animations/animation.ce.js +23 -0
- package/dist/components/animations/animation.ce.js.map +1 -0
- package/dist/components/animations/hit.ce.js +64 -0
- package/dist/components/animations/hit.ce.js.map +1 -0
- package/dist/components/animations/index.d.ts +4 -0
- package/dist/components/animations/index.js +11 -0
- package/dist/components/animations/index.js.map +1 -0
- package/dist/components/character.ce.js +572 -0
- package/dist/components/character.ce.js.map +1 -0
- package/dist/components/dynamics/bar.ce.js +96 -0
- package/dist/components/dynamics/bar.ce.js.map +1 -0
- package/dist/components/dynamics/image.ce.js +23 -0
- package/dist/components/dynamics/image.ce.js.map +1 -0
- package/dist/components/dynamics/parse-value.d.ts +4 -0
- package/dist/components/dynamics/parse-value.js +63 -0
- package/dist/components/dynamics/parse-value.js.map +1 -0
- 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 +83 -0
- package/dist/components/dynamics/shape.ce.js.map +1 -0
- package/dist/components/dynamics/text.ce.js +50 -0
- package/dist/components/dynamics/text.ce.js.map +1 -0
- package/dist/components/gui/box.ce.js +26 -0
- package/dist/components/gui/box.ce.js.map +1 -0
- package/dist/components/gui/dialogbox/index.ce.js +198 -0
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -0
- package/dist/components/gui/gameover.ce.js +169 -0
- package/dist/components/gui/gameover.ce.js.map +1 -0
- package/dist/components/gui/hud/hud.ce.js +83 -0
- package/dist/components/gui/hud/hud.ce.js.map +1 -0
- package/dist/components/gui/index.d.ts +15 -3
- package/dist/components/gui/index.js +14 -0
- package/dist/components/gui/menu/equip-menu.ce.js +427 -0
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/exit-menu.ce.js +55 -0
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/items-menu.ce.js +326 -0
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/main-menu.ce.js +399 -0
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/options-menu.ce.js +49 -0
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/skills-menu.ce.js +102 -0
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -0
- package/dist/components/gui/mobile/index.d.ts +8 -0
- package/dist/components/gui/mobile/index.js +21 -0
- package/dist/components/gui/mobile/index.js.map +1 -0
- package/dist/components/gui/mobile/mobile.ce.js +79 -0
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -0
- package/dist/components/gui/notification/notification.ce.js +62 -0
- package/dist/components/gui/notification/notification.ce.js.map +1 -0
- package/dist/components/gui/save-load.ce.js +211 -0
- package/dist/components/gui/save-load.ce.js.map +1 -0
- package/dist/components/gui/shop/shop.ce.js +614 -0
- package/dist/components/gui/shop/shop.ce.js.map +1 -0
- package/dist/components/gui/title-screen.ce.js +164 -0
- package/dist/components/gui/title-screen.ce.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +4 -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 +188 -0
- package/dist/components/player-components.ce.js.map +1 -0
- package/dist/components/prebuilt/hp-bar.ce.js +113 -0
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -0
- package/dist/components/prebuilt/index.d.ts +19 -0
- package/dist/components/prebuilt/index.js +2 -0
- package/dist/components/prebuilt/light-halo.ce.js +70 -0
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -0
- package/dist/components/scenes/canvas.ce.js +196 -0
- package/dist/components/scenes/canvas.ce.js.map +1 -0
- package/dist/components/scenes/draw-map.ce.js +79 -0
- package/dist/components/scenes/draw-map.ce.js.map +1 -0
- package/dist/components/scenes/event-layer.ce.js +29 -0
- package/dist/components/scenes/event-layer.ce.js.map +1 -0
- package/dist/core/inject.js +18 -0
- package/dist/core/inject.js.map +1 -0
- package/dist/core/setup.js +16 -0
- package/dist/core/setup.js.map +1 -0
- 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/index.d.ts +16 -1
- package/dist/index.js +45 -14
- package/dist/module.d.ts +43 -4
- package/dist/module.js +179 -0
- package/dist/module.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js +167 -0
- package/dist/node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js +239 -0
- package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js +13 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js +696 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js +44 -0
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js +241 -0
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/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 +115 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +401 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3756 -0
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -0
- package/dist/presets/animation.d.ts +31 -0
- package/dist/presets/animation.js +39 -0
- package/dist/presets/animation.js.map +1 -0
- package/dist/presets/faceset.d.ts +30 -0
- package/dist/presets/faceset.js +51 -0
- package/dist/presets/faceset.js.map +1 -0
- package/dist/presets/icon.d.ts +20 -0
- package/dist/presets/icon.js +15 -0
- package/dist/presets/icon.js.map +1 -0
- package/dist/presets/index.d.ts +123 -0
- package/dist/presets/index.js +17 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/lpc.d.ts +89 -0
- package/dist/presets/lpc.js +98 -0
- package/dist/presets/lpc.js.map +1 -0
- package/dist/presets/rmspritesheet.js +42 -0
- package/dist/presets/rmspritesheet.js.map +1 -0
- package/dist/services/AbstractSocket.d.ts +9 -5
- package/dist/services/AbstractSocket.js +11 -0
- package/dist/services/AbstractSocket.js.map +1 -0
- package/dist/services/keyboardControls.d.ts +15 -0
- package/dist/services/keyboardControls.js +23 -0
- package/dist/services/keyboardControls.js.map +1 -0
- package/dist/services/loadMap.d.ts +6 -0
- package/dist/services/loadMap.js +123 -0
- package/dist/services/loadMap.js.map +1 -0
- package/dist/services/mmorpg.d.ts +21 -9
- package/dist/services/mmorpg.js +136 -0
- package/dist/services/mmorpg.js.map +1 -0
- package/dist/services/save.d.ts +19 -0
- package/dist/services/save.js +77 -0
- package/dist/services/save.js.map +1 -0
- package/dist/services/save.spec.d.ts +1 -0
- package/dist/services/standalone.d.ts +67 -7
- package/dist/services/standalone.js +168 -0
- package/dist/services/standalone.js.map +1 -0
- package/dist/utils/getEntityProp.d.ts +39 -0
- package/dist/utils/getEntityProp.js +53 -0
- package/dist/utils/getEntityProp.js.map +1 -0
- package/dist/utils/getEntityProp.spec.d.ts +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 +14 -11
- package/src/Game/AnimationManager.spec.ts +30 -0
- package/src/Game/AnimationManager.ts +33 -0
- package/src/Game/Event.ts +1 -1
- package/src/Game/Map.ts +184 -3
- package/src/Game/Object.ts +409 -14
- package/src/Game/Player.ts +1 -1
- package/src/Gui/Gui.spec.ts +273 -0
- package/src/Gui/Gui.ts +566 -23
- package/src/Gui/NotificationManager.ts +69 -0
- package/src/Resource.ts +149 -0
- package/src/RpgClient.ts +309 -14
- package/src/RpgClientEngine.ts +1790 -63
- package/src/Sound.ts +253 -0
- package/src/components/{effects → animations}/animation.ce +3 -6
- package/src/components/{effects → animations}/index.ts +1 -1
- package/src/components/character.ce +801 -59
- package/src/components/dynamics/bar.ce +87 -0
- package/src/components/dynamics/image.ce +20 -0
- package/src/components/dynamics/parse-value.spec.ts +83 -0
- package/src/components/dynamics/parse-value.ts +154 -0
- 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 +89 -0
- package/src/components/dynamics/text.ce +68 -0
- package/src/components/gui/box.ce +17 -0
- package/src/components/gui/dialogbox/index.ce +213 -187
- package/src/components/gui/gameover.ce +158 -0
- package/src/components/gui/hud/hud.ce +61 -0
- package/src/components/gui/index.ts +30 -4
- package/src/components/gui/menu/equip-menu.ce +410 -0
- package/src/components/gui/menu/exit-menu.ce +41 -0
- package/src/components/gui/menu/items-menu.ce +317 -0
- package/src/components/gui/menu/main-menu.ce +294 -0
- package/src/components/gui/menu/options-menu.ce +35 -0
- package/src/components/gui/menu/skills-menu.ce +83 -0
- package/src/components/gui/mobile/index.ts +24 -0
- package/src/components/gui/mobile/mobile.ce +80 -0
- package/src/components/gui/notification/notification.ce +51 -0
- package/src/components/gui/save-load.ce +208 -0
- package/src/components/gui/shop/shop.ce +493 -0
- package/src/components/gui/title-screen.ce +163 -0
- package/src/components/index.ts +3 -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 +221 -0
- package/src/components/prebuilt/hp-bar.ce +255 -0
- package/src/components/prebuilt/index.ts +24 -0
- package/src/components/prebuilt/light-halo.ce +148 -0
- package/src/components/scenes/canvas.ce +185 -21
- package/src/components/scenes/draw-map.ce +55 -21
- package/src/components/scenes/event-layer.ce +8 -2
- package/src/components/scenes/transition.ce +60 -0
- package/src/core/setup.ts +2 -2
- package/src/decorators/spritesheet.ts +8 -0
- package/src/index.ts +17 -2
- package/src/module.ts +132 -10
- package/src/presets/animation.ts +46 -0
- package/src/presets/faceset.ts +60 -0
- package/src/presets/icon.ts +17 -0
- package/src/presets/index.ts +9 -1
- package/src/presets/lpc.ts +108 -0
- package/src/services/AbstractSocket.ts +10 -2
- package/src/services/keyboardControls.ts +20 -0
- package/src/services/loadMap.ts +3 -1
- package/src/services/mmorpg.ts +106 -12
- package/src/services/save.spec.ts +127 -0
- package/src/services/save.ts +103 -0
- package/src/services/standalone.ts +110 -18
- package/src/utils/getEntityProp.spec.ts +96 -0
- package/src/utils/getEntityProp.ts +88 -0
- package/src/utils/readPropValue.ts +16 -0
- package/vite.config.ts +4 -2
- package/dist/Game/EffectManager.d.ts +0 -5
- package/dist/components/effects/index.d.ts +0 -4
- package/dist/index.js.map +0 -1
- package/dist/index10.js +0 -8
- package/dist/index10.js.map +0 -1
- package/dist/index11.js +0 -10
- package/dist/index11.js.map +0 -1
- package/dist/index12.js +0 -8
- package/dist/index12.js.map +0 -1
- package/dist/index13.js +0 -17
- package/dist/index13.js.map +0 -1
- package/dist/index14.js +0 -107
- package/dist/index14.js.map +0 -1
- package/dist/index15.js +0 -50
- package/dist/index15.js.map +0 -1
- package/dist/index16.js +0 -191
- package/dist/index16.js.map +0 -1
- package/dist/index17.js +0 -9
- package/dist/index17.js.map +0 -1
- package/dist/index18.js +0 -387
- package/dist/index18.js.map +0 -1
- package/dist/index19.js +0 -31
- package/dist/index19.js.map +0 -1
- package/dist/index2.js +0 -181
- package/dist/index2.js.map +0 -1
- package/dist/index20.js +0 -24
- package/dist/index20.js.map +0 -1
- package/dist/index21.js +0 -2421
- package/dist/index21.js.map +0 -1
- package/dist/index22.js +0 -114
- package/dist/index22.js.map +0 -1
- package/dist/index23.js +0 -109
- package/dist/index23.js.map +0 -1
- package/dist/index24.js +0 -71
- package/dist/index24.js.map +0 -1
- package/dist/index25.js +0 -21
- package/dist/index25.js.map +0 -1
- package/dist/index26.js +0 -41
- package/dist/index26.js.map +0 -1
- package/dist/index27.js +0 -5
- package/dist/index27.js.map +0 -1
- package/dist/index28.js +0 -322
- package/dist/index28.js.map +0 -1
- package/dist/index29.js +0 -27
- package/dist/index29.js.map +0 -1
- package/dist/index3.js +0 -87
- package/dist/index3.js.map +0 -1
- package/dist/index30.js +0 -11
- package/dist/index30.js.map +0 -1
- package/dist/index31.js +0 -11
- package/dist/index31.js.map +0 -1
- package/dist/index32.js +0 -174
- package/dist/index32.js.map +0 -1
- package/dist/index33.js +0 -501
- package/dist/index33.js.map +0 -1
- package/dist/index34.js +0 -12
- package/dist/index34.js.map +0 -1
- package/dist/index35.js +0 -4403
- package/dist/index35.js.map +0 -1
- package/dist/index36.js +0 -316
- package/dist/index36.js.map +0 -1
- package/dist/index37.js +0 -61
- package/dist/index37.js.map +0 -1
- package/dist/index38.js +0 -20
- package/dist/index38.js.map +0 -1
- package/dist/index39.js +0 -20
- package/dist/index39.js.map +0 -1
- package/dist/index4.js +0 -67
- package/dist/index4.js.map +0 -1
- package/dist/index5.js +0 -16
- package/dist/index5.js.map +0 -1
- package/dist/index6.js +0 -17
- package/dist/index6.js.map +0 -1
- package/dist/index7.js +0 -39
- package/dist/index7.js.map +0 -1
- package/dist/index8.js +0 -108
- package/dist/index8.js.map +0 -1
- package/dist/index9.js +0 -76
- package/dist/index9.js.map +0 -1
- package/src/Game/EffectManager.ts +0 -20
- package/src/components/gui/dialogbox/itemMenu.ce +0 -23
- package/src/components/gui/dialogbox/selection.ce +0 -67
- /package/src/components/{effects → animations}/hit.ce +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Container, Graphics, animatedSignal, computed, effect, h, useDefineProps, useProps } from "canvasengine";
|
|
2
|
+
//#region src/components/prebuilt/hp-bar.ce
|
|
3
|
+
function component($$props) {
|
|
4
|
+
useProps($$props);
|
|
5
|
+
const { object } = useDefineProps($$props)();
|
|
6
|
+
const barWidth = 50;
|
|
7
|
+
const barHeight = 8;
|
|
8
|
+
const borderRadius = 4;
|
|
9
|
+
const innerRadius = 3;
|
|
10
|
+
const padding = 1;
|
|
11
|
+
const bgColor = 1450302;
|
|
12
|
+
const shadowColor = 0;
|
|
13
|
+
const borderColor = 4871528;
|
|
14
|
+
const maxFillWidth = barWidth - padding * 2;
|
|
15
|
+
const fillHeight = barHeight - padding * 2;
|
|
16
|
+
const highlightHeight = Math.floor(fillHeight / 2);
|
|
17
|
+
const hitbox = object.hitbox;
|
|
18
|
+
const currentHp = computed(() => {
|
|
19
|
+
return object.hpSignal?.() ?? 0;
|
|
20
|
+
});
|
|
21
|
+
const maxHp = computed(() => {
|
|
22
|
+
return (object._param?.() ?? {}).maxHp ?? 100;
|
|
23
|
+
});
|
|
24
|
+
const hpPercent = computed(() => {
|
|
25
|
+
const max = maxHp();
|
|
26
|
+
if (max <= 0) return 0;
|
|
27
|
+
const percent = currentHp() / max;
|
|
28
|
+
return Math.max(0, Math.min(1, percent));
|
|
29
|
+
});
|
|
30
|
+
const animatedPercent = animatedSignal(hpPercent(), {
|
|
31
|
+
duration: 300,
|
|
32
|
+
easing: "easeOutCubic"
|
|
33
|
+
});
|
|
34
|
+
effect(() => {
|
|
35
|
+
const newPercent = hpPercent();
|
|
36
|
+
animatedPercent.set(newPercent);
|
|
37
|
+
});
|
|
38
|
+
const position = computed(() => ({
|
|
39
|
+
x: hitbox().w / 2 - barWidth / 2,
|
|
40
|
+
y: -barHeight - 8
|
|
41
|
+
}));
|
|
42
|
+
const fillWidth = computed(() => {
|
|
43
|
+
const percent = animatedPercent();
|
|
44
|
+
const width = maxFillWidth * percent;
|
|
45
|
+
if (percent > 0 && width < innerRadius * 2) return innerRadius * 2;
|
|
46
|
+
return Math.max(0, width);
|
|
47
|
+
});
|
|
48
|
+
const hpColorHex = computed(() => {
|
|
49
|
+
const percent = hpPercent();
|
|
50
|
+
if (percent > .6) return 4906624;
|
|
51
|
+
else if (percent > .3) return 16436245;
|
|
52
|
+
else if (percent > .15) return 16486972;
|
|
53
|
+
else return 15680580;
|
|
54
|
+
});
|
|
55
|
+
const drawShadow = (g) => {
|
|
56
|
+
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
57
|
+
g.fill({
|
|
58
|
+
color: shadowColor,
|
|
59
|
+
alpha: .3
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const drawBackground = (g) => {
|
|
63
|
+
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
64
|
+
g.fill({
|
|
65
|
+
color: bgColor,
|
|
66
|
+
alpha: .9
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
const drawFill = (g) => {
|
|
70
|
+
const width = fillWidth();
|
|
71
|
+
if (width > 0) {
|
|
72
|
+
g.roundRect(padding, padding, width, fillHeight, innerRadius);
|
|
73
|
+
g.fill({ color: hpColorHex() });
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const drawHighlight = (g) => {
|
|
77
|
+
const width = fillWidth();
|
|
78
|
+
if (width > 0) {
|
|
79
|
+
g.roundRect(padding, padding, width, highlightHeight, innerRadius);
|
|
80
|
+
g.fill({
|
|
81
|
+
color: 16777215,
|
|
82
|
+
alpha: .25
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const drawBorder = (g) => {
|
|
87
|
+
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
88
|
+
g.stroke({
|
|
89
|
+
color: borderColor,
|
|
90
|
+
width: 1,
|
|
91
|
+
alpha: .7
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
return [, h(Container, {
|
|
95
|
+
x: position.x,
|
|
96
|
+
y: position.y
|
|
97
|
+
}, [
|
|
98
|
+
h(Graphics, {
|
|
99
|
+
draw: drawShadow,
|
|
100
|
+
x: 1,
|
|
101
|
+
y: 1
|
|
102
|
+
}),
|
|
103
|
+
h(Graphics, { draw: drawBackground }),
|
|
104
|
+
h(Graphics, { draw: drawFill }),
|
|
105
|
+
h(Graphics, { draw: drawHighlight }),
|
|
106
|
+
h(Graphics, { draw: drawBorder })
|
|
107
|
+
])];
|
|
108
|
+
}
|
|
109
|
+
var __ce_component = component;
|
|
110
|
+
//#endregion
|
|
111
|
+
export { __ce_component as default };
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=hp-bar.ce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hp-bar.ce.js","names":[],"sources":["../../../src/components/prebuilt/hp-bar.ce"],"sourcesContent":["<!-- \n HP Bar Component\n \n A beautiful, animated health bar component for displaying player HP above sprites.\n Features a gradient color based on HP level, smooth animations, and modern styling.\n \n ## Design\n \n The bar changes color dynamically based on HP percentage:\n - Green (#4ade80) when HP > 60% - Healthy state\n - Yellow (#facc15) when HP 30-60% - Caution state \n - Orange (#fb923c) when HP 15-30% - Danger state\n - Red (#ef4444) when HP < 15% - Critical state\n \n @example\n ```ts\n import HpBar from './hp-bar.ce';\n \n // In module configuration\n export default defineModule<RpgClient>({\n sprite: {\n componentsInFront: [HpBar]\n }\n })\n ```\n-->\n\n<Container x={position.x} y={position.y}>\n <!-- Background shadow for depth effect -->\n <Graphics draw={drawShadow} x={1} y={1} />\n \n <!-- Main background -->\n <Graphics draw={drawBackground} />\n \n <!-- HP fill bar -->\n <Graphics draw={drawFill} />\n \n <!-- Highlight overlay for 3D effect -->\n <Graphics draw={drawHighlight} />\n \n <!-- Border frame -->\n <Graphics draw={drawBorder} />\n</Container>\n\n<script>\nimport { computed, animatedSignal, effect } from \"canvasengine\";\n\nconst { object } = defineProps();\n\n// ====================\n// Configuration\n// ====================\n\n/** Total width of the HP bar in pixels */\nconst barWidth = 50;\n\n/** Total height of the HP bar in pixels */\nconst barHeight = 8;\n\n/** Border radius for rounded corners */\nconst borderRadius = 4;\n\n/** Inner border radius for the fill bar */\nconst innerRadius = 3;\n\n/** Padding between background and fill */\nconst padding = 1;\n\n/** Background color (dark theme) */\nconst bgColor = 0x16213e;\n\n/** Shadow color */\nconst shadowColor = 0x000000;\n\n/** Border color */\nconst borderColor = 0x4a5568;\n\n// ====================\n// Calculated dimensions\n// ====================\n\n/** Maximum fill width */\nconst maxFillWidth = barWidth - (padding * 2);\n\n/** Fill height */\nconst fillHeight = barHeight - (padding * 2);\n\n/** Highlight height (half of fill) */\nconst highlightHeight = Math.floor(fillHeight / 2);\n\n// ====================\n// Reactive HP values\n// ====================\n\n/** Gets hitbox dimensions for positioning */\nconst hitbox = object.hitbox;\n\n/**\n * Gets the current HP value from the player object\n * Uses hpSignal which is synchronized from the server\n */\nconst currentHp = computed(() => {\n return object.hpSignal?.() ?? 0;\n});\n\n/**\n * Gets the maximum HP value from player parameters\n * Reads from _param.maxHp which contains calculated stats\n */\nconst maxHp = computed(() => {\n const params = object._param?.() ?? {};\n return params.maxHp ?? 100;\n});\n\n/**\n * Calculates HP percentage (0 to 1)\n */\nconst hpPercent = computed(() => {\n const max = maxHp();\n if (max <= 0) return 0;\n const percent = currentHp() / max;\n return Math.max(0, Math.min(1, percent));\n});\n\n// ====================\n// Animated values\n// ====================\n\n/**\n * Animated percentage for smooth bar transitions\n */\nconst animatedPercent = animatedSignal(hpPercent(), {\n duration: 300,\n easing: 'easeOutCubic'\n});\n\n// Update animated value when HP changes\neffect(() => {\n const newPercent = hpPercent();\n animatedPercent.set(newPercent);\n});\n\n// ====================\n// Visual calculations\n// ====================\n\n/**\n * Position of the bar relative to the sprite\n */\nconst position = computed(() => ({\n x: (hitbox().w / 2) - (barWidth / 2),\n y: -barHeight - 8\n}));\n\n/**\n * Current width of the HP fill based on animated percentage\n */\nconst fillWidth = computed(() => {\n const percent = animatedPercent();\n const width = maxFillWidth * percent;\n // Ensure minimum visible width when HP > 0\n if (percent > 0 && width < innerRadius * 2) {\n return innerRadius * 2;\n }\n return Math.max(0, width);\n});\n\n/**\n * Determines HP bar color based on current HP percentage\n * Returns hex color number for PixiJS\n * \n * ## Color Thresholds\n * - Green (0x4ade80): HP > 60% - Healthy\n * - Yellow (0xfacc15): HP 30-60% - Caution\n * - Orange (0xfb923c): HP 15-30% - Danger\n * - Red (0xef4444): HP < 15% - Critical\n */\nconst hpColorHex = computed(() => {\n const percent = hpPercent();\n \n if (percent > 0.6) {\n return 0x4ade80; // Green - healthy\n } else if (percent > 0.3) {\n return 0xfacc15; // Yellow - caution\n } else if (percent > 0.15) {\n return 0xfb923c; // Orange - danger\n } else {\n return 0xef4444; // Red - critical\n }\n});\n\n// ====================\n// Drawing functions\n// ====================\n\n/**\n * Draws the shadow behind the HP bar for depth effect\n */\nconst drawShadow = (g) => {\n g.roundRect(0, 0, barWidth, barHeight, borderRadius);\n g.fill({ color: shadowColor, alpha: 0.3 });\n};\n\n/**\n * Draws the main background of the HP bar\n */\nconst drawBackground = (g) => {\n g.roundRect(0, 0, barWidth, barHeight, borderRadius);\n g.fill({ color: bgColor, alpha: 0.9 });\n};\n\n/**\n * Draws the HP fill bar with dynamic color\n */\nconst drawFill = (g) => {\n const width = fillWidth();\n if (width > 0) {\n g.roundRect(padding, padding, width, fillHeight, innerRadius);\n g.fill({ color: hpColorHex() });\n }\n};\n\n/**\n * Draws the highlight overlay for 3D effect\n */\nconst drawHighlight = (g) => {\n const width = fillWidth();\n if (width > 0) {\n g.roundRect(padding, padding, width, highlightHeight, innerRadius);\n g.fill({ color: 0xffffff, alpha: 0.25 });\n }\n};\n\n/**\n * Draws the border frame around the HP bar\n * \n * Uses PixiJS Graphics API to create a rounded rectangle stroke\n * that serves as a visual border for the bar.\n * \n * @param g - PixiJS Graphics object\n * \n * @example\n * ```html\n * <Graphics draw={drawBorder} />\n * ```\n */\nconst drawBorder = (g) => {\n g.roundRect(0, 0, barWidth, barHeight, borderRadius);\n g.stroke({ \n color: borderColor, \n width: 1,\n alpha: 0.7\n });\n};\n</script>\n"],"mappings":";;AAOC,SAAA,UAAA,SAAA;CACsB,SAAC,OAAY;CAEhC,MAAS,EAAA,WADe,eAAe,OACN,EAAC;CACtC,MAAI,WAAS;CACb,MAAI,YAAc;CAClB,MAAC,eAAA;CACD,MAAG,cAAA;CACH,MAAK,UAAA;CACL,MAAE,UAAa;CACf,MAAC,cAAA;CACD,MAAK,cAAU;CACf,MAAE,eAAe,WAAa,UAAW;CACzC,MAAI,aAAQ,YAAA,UAAA;CACZ,MAAM,kBAAkB,KAAE,MAAK,aAAA,CAAA;CAC/B,MAAI,SAAA,OAAA;CACJ,MAAG,YAAA,eAAA;EACC,OAAA,OAAA,WAAA,KAAA;CACJ,CAAC;;EAGG,QADU,OAAY,SAAG,KAAW,CAAA,GACtB,SAAO;CACzB,CAAC;CACD,MAAC,YAAA,eAAA;EACG,MAAG,MAAK,MAAU;EACnB,IAAA,OAAS,GACX,OAAA;EACG,MAAM,UAAU,UAAC,IAAA;EAClB,OAAQ,KAAK,IAAE,GAAA,KAAU,IAAC,GAAA,OAAA,CAAA;CAC7B,CAAC;CACD,MAAM,kBAAkB,eAAe,UAAE,GAAA;EACtC,UAAS;EACX,QAAA;CACD,CAAC;CACD,aAAY;EACV,MAAA,aAAS,UAAA;;CAEX,CAAC;CACD,MAAM,WAAW,gBAAgB;;EAEjC,GAAO,CAAC,YAAW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AAA,EAAA,MAAA,WAAA,CAAA;CAAA,CAAA,CAAA;AAEA;AAEC,IAAM,iBAEH"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prebuilt sprite components for common UI elements
|
|
3
|
+
*
|
|
4
|
+
* This module exports ready-to-use components that can be attached
|
|
5
|
+
* to sprites using componentsInFront or componentsBehind configuration.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { HpBar } from '@rpgjs/client/components/prebuilt';
|
|
10
|
+
*
|
|
11
|
+
* export default defineModule<RpgClient>({
|
|
12
|
+
* sprite: {
|
|
13
|
+
* componentsInFront: [HpBar]
|
|
14
|
+
* }
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export { default as HpBar } from './hp-bar.ce';
|
|
19
|
+
export { default as LightHalo } from './light-halo.ce';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Container, Graphics, computed, h, signal, tick, useDefineProps, useProps } from "canvasengine";
|
|
2
|
+
import { BlurFilter } from "pixi.js";
|
|
3
|
+
//#region src/components/prebuilt/light-halo.ce
|
|
4
|
+
function component($$props) {
|
|
5
|
+
useProps($$props);
|
|
6
|
+
const { object, baseRadius, radiusVariation, baseOpacity, opacityVariation, sizeSpeed, opacitySpeed, lightColor } = useDefineProps($$props)();
|
|
7
|
+
const getBaseRadius = computed(() => baseRadius?.() ?? 30);
|
|
8
|
+
const getRadiusVariation = computed(() => radiusVariation?.() ?? 10);
|
|
9
|
+
const getBaseOpacity = computed(() => baseOpacity?.() ?? .6);
|
|
10
|
+
const getOpacityVariation = computed(() => opacityVariation?.() ?? .3);
|
|
11
|
+
const getSizeSpeed = computed(() => sizeSpeed?.() ?? .002);
|
|
12
|
+
const getOpacitySpeed = computed(() => opacitySpeed?.() ?? .003);
|
|
13
|
+
const getLightColor = computed(() => lightColor?.() ?? 16777130);
|
|
14
|
+
const time = signal(0);
|
|
15
|
+
const currentRadius = computed(() => {
|
|
16
|
+
const t = time();
|
|
17
|
+
const base = getBaseRadius();
|
|
18
|
+
const variation = getRadiusVariation();
|
|
19
|
+
const speed = getSizeSpeed();
|
|
20
|
+
return base + (Math.sin(t * speed) + Math.sin(t * speed * 1.5) * .5) / 1.5 * variation;
|
|
21
|
+
});
|
|
22
|
+
const currentOpacity = computed(() => {
|
|
23
|
+
const t = time();
|
|
24
|
+
const base = getBaseOpacity();
|
|
25
|
+
const variation = getOpacityVariation();
|
|
26
|
+
const speed = getOpacitySpeed();
|
|
27
|
+
const fade = Math.sin(t * speed);
|
|
28
|
+
const flicker = (Math.random() - .5) * .1;
|
|
29
|
+
return Math.max(0, Math.min(1, base + fade * variation + flicker));
|
|
30
|
+
});
|
|
31
|
+
const hitbox = object.hitbox;
|
|
32
|
+
const position = computed(() => ({
|
|
33
|
+
x: hitbox().w / 2,
|
|
34
|
+
y: hitbox().h / 2
|
|
35
|
+
}));
|
|
36
|
+
const blurFilter = new BlurFilter({
|
|
37
|
+
strength: 20,
|
|
38
|
+
quality: 3
|
|
39
|
+
});
|
|
40
|
+
const drawHalo = (g) => {
|
|
41
|
+
const radius = currentRadius();
|
|
42
|
+
const opacity = currentOpacity();
|
|
43
|
+
const color = getLightColor();
|
|
44
|
+
if (opacity <= 0 || radius <= 0) return;
|
|
45
|
+
g.blendMode = "add";
|
|
46
|
+
g.filters = [blurFilter];
|
|
47
|
+
g.circle(0, 0, radius);
|
|
48
|
+
g.fill({
|
|
49
|
+
color,
|
|
50
|
+
alpha: opacity
|
|
51
|
+
});
|
|
52
|
+
g.circle(0, 0, radius * .4);
|
|
53
|
+
g.fill({
|
|
54
|
+
color: 16777215,
|
|
55
|
+
alpha: opacity * .5
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
tick(() => {
|
|
59
|
+
time.update((t) => t + 1);
|
|
60
|
+
});
|
|
61
|
+
return h(Container, {
|
|
62
|
+
x: position.x,
|
|
63
|
+
y: position.y
|
|
64
|
+
}, h(Graphics, { draw: drawHalo }));
|
|
65
|
+
}
|
|
66
|
+
var __ce_component = component;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { __ce_component as default };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=light-halo.ce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light-halo.ce.js","names":[],"sources":["../../../src/components/prebuilt/light-halo.ce"],"sourcesContent":["<Container x={position.x} y={position.y}>\n <Graphics draw={drawHalo} />\n</Container>\n\n<script>\nimport { computed, signal, tick, mount } from \"canvasengine\";\nimport { BlurFilter } from \"pixi.js\";\n\n/**\n * Component props for LightHalo\n * \n * All props are signals (even static ones) and must be read with `()`.\n * Props are optional and will use default values if not provided.\n * \n * @property {Object} object - The sprite object (required)\n * @property {number|Signal<number>} [baseRadius] - Base radius of the light halo in pixels (default: 30)\n * @property {number|Signal<number>} [radiusVariation] - Radius variation range (halo will pulse between baseRadius ± radiusVariation) (default: 10)\n * @property {number|Signal<number>} [baseOpacity] - Base opacity of the light halo (0 to 1) (default: 0.6)\n * @property {number|Signal<number>} [opacityVariation] - Opacity variation range (halo will fade between baseOpacity ± opacityVariation) (default: 0.3)\n * @property {number|Signal<number>} [sizeSpeed] - Animation speed for size pulsing (higher = faster) (default: 0.002)\n * @property {number|Signal<number>} [opacitySpeed] - Animation speed for opacity fading (higher = faster) (default: 0.003)\n * @property {number|Signal<number>} [lightColor] - Color of the light halo (hex value, warm yellow-white by default: 0xffffaa)\n */\nconst { \n object, \n baseRadius,\n radiusVariation,\n baseOpacity,\n opacityVariation,\n sizeSpeed,\n opacitySpeed,\n lightColor\n} = defineProps();\n\n// ====================\n// Props with default values\n// ====================\n\nconst getBaseRadius = computed(() => baseRadius?.() ?? 30);\nconst getRadiusVariation = computed(() => radiusVariation?.() ?? 10);\nconst getBaseOpacity = computed(() => baseOpacity?.() ?? 0.6);\nconst getOpacityVariation = computed(() => opacityVariation?.() ?? 0.3);\nconst getSizeSpeed = computed(() => sizeSpeed?.() ?? 0.002);\nconst getOpacitySpeed = computed(() => opacitySpeed?.() ?? 0.003);\nconst getLightColor = computed(() => lightColor?.() ?? 0xffffaa);\n\n// ====================\n// Animation state\n// ====================\n\n/** Time counter for animations */\nconst time = signal(0);\n\n/**\n * Current radius of the halo with pulsing animation\n * Uses multiple sine waves for more organic movement\n */\nconst currentRadius = computed(() => {\n const t = time();\n const base = getBaseRadius();\n const variation = getRadiusVariation();\n const speed = getSizeSpeed();\n \n // Combine two sine waves for less predictable pulsing\n const pulse1 = Math.sin(t * speed);\n const pulse2 = Math.sin(t * speed * 1.5) * 0.5;\n const combinedPulse = (pulse1 + pulse2) / 1.5;\n \n return base + (combinedPulse * variation);\n});\n\n/**\n * Current opacity of the halo with fading animation\n * Includes a subtle flicker effect\n */\nconst currentOpacity = computed(() => {\n const t = time();\n const base = getBaseOpacity();\n const variation = getOpacityVariation();\n const speed = getOpacitySpeed();\n \n // Main breathing cycle\n const fade = Math.sin(t * speed);\n \n // Subtle high-frequency flicker (candle-like)\n const flicker = (Math.random() - 0.5) * 0.1;\n \n return Math.max(0, Math.min(1, base + (fade * variation) + flicker));\n});\n\n// ====================\n// Position calculations\n// ====================\n\nconst hitbox = object.hitbox;\n\nconst position = computed(() => ({\n x: hitbox().w / 2,\n y: hitbox().h / 2\n}));\n\n// ====================\n// Drawing function\n// ====================\n\n// Create filters once to avoid recreation on every frame\nconst blurFilter = new BlurFilter({ strength: 20, quality: 3 });\n\n/**\n * Draws the light halo effect with realistic diffusion\n */\nconst drawHalo = (g) => {\n const radius = currentRadius();\n const opacity = currentOpacity();\n const color = getLightColor();\n \n if (opacity <= 0 || radius <= 0) return;\n\n // Set blend mode to ADD for glowing light effect\n g.blendMode = 'add';\n \n // Apply blur filter for soft light diffusion\n g.filters = [blurFilter];\n \n // Draw main light source\n // The blur filter will spread this out into a nice gradient\n g.circle(0, 0, radius);\n g.fill({ \n color: color, \n alpha: opacity \n });\n \n // Draw a smaller, brighter core\n g.circle(0, 0, radius * 0.4);\n g.fill({ \n color: 0xffffff, \n alpha: opacity * 0.5 \n });\n};\n\n// ====================\n// Animation loop\n// ====================\ntick(() => {\n time.update(t => t + 1);\n});\n</script>\n\n"],"mappings":";;;AAQE,SAAA,UAAA,SAAA;CACqB,SAAA,OAAA;CAEhB,MAAM,EAAG,QAAQ,YAAO,iBAAsB,aAAa,kBAAI,WAAA,cAAA,eADpE,eAAA,OACoE,EAAA;CACtE,MAAG,gBAAmB,eAAa,aAAe,KAAG,EAAI;CACzD,MAAE,qBAAA,eAAA,kBAAA,KAAA,EAAA;CACF,MAAI,iBAAkB,eAAa,cAAe,KAAA,EAAQ;CAC1D,MAAI,sBAAwB,eAAU,mBAAmB,KAAU,EAAG;CACtE,MAAI,eAAiB,eAAe,YAAE,KAAe,IAAI;CACzD,MAAI,kBAAiB,eAAiB,eAAe,KAAK,IAAA;CAC1D,MAAI,gBAAiB,eAAgB,aAAC,KAAiB,QAAG;CAC1D,MAAI,OAAS,OAAO,CAAC;CACrB,MAAI,gBAAiB,eAAgB;EACjC,MAAA,IAAU,KAAA;EACZ,MAAA,OAAA,cAAA;EACF,MAAO,YAAA,mBAAA;EACL,MAAO,QAAA,aAAA;EAKP,OAAS,QAHM,KAAA,IAAA,IAAA,KAEC,IADL,KAAA,IAAA,IAAA,QAAA,GAAA,IAAA,MACK,MACP;CACX,CAAC;CACD,MAAE,iBAAA,eAAA;EACE,MAAA,IAAA,KAAa;;EAEb,MAAM,YAAY,oBAAA;EACnB,MAAM,QAAK,gBAAQ;;EAItB,MAAM,WAAA,KAAoB,OAAC,IAAU,MAAK;EAC1C,OAAM,KAAA,IAAc,GAAG,KAAA,IAAS,GAAG,OAAG,OAAY,YAAW,OAAA,CAAA;CAC7D,CAAA;CACA,MAAM,SAAA,OAAe;CACrB,MAAM,WAAA,gBAA2B;EACjC,GAAM,OAAA,EAAA,IAAc;;CAEpB,EAAE;CACF,MAAG,aAAU,IAAA,WAAA;EAAA,UAAA;EAAA,SAAA;CAAA,CAAA;CACb,MAAM,YAAY,MAAI;;EAElB,MAAK,UAAW,eAAa;EACjC,MAAU,QAAG,cAAS;mCAEpB;EAEC,EAAA,YAAc;EAEjB,EAAM,UAAA,CAAA,UAAgB;EAGpB,EAAA,OAAM,GAAA,GAAW,MAAC;EAClB,EAAA,KAAM;GACP;GACI,OAAQ;EACX,CAAA;EAEA,EAAA,OAAM,GAAA,GAAA,SAAiB,EAAM;EAC9B,EAAA,KAAA;GACO,OAAO;GACb,OAAA,UAAA;;CAEF;CACA,WAAW;EACR,KAAA,QAAW,MAAO,IAAA,CAAA;CACrB,CAAC;CAEO,OADY,EAAE,WAAW;EAAE,GAAG,SAAA;EAAA,GAAA,SAAA;CAAA,GAAA,EAAA,UAAA,EAAA,MAAA,SAAA,CAAA,CACpB;AAChB;AAEA,IAAM,iBAEE"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { inject } from "../../core/inject.js";
|
|
2
|
+
import __ce_component$1 from "./draw-map.ce.js";
|
|
3
|
+
import { RpgGui } from "../../Gui/Gui.js";
|
|
4
|
+
import { RpgClientEngine } from "../../RpgClientEngine.js";
|
|
5
|
+
import { Canvas, Container, Viewport, computed, cond, effect, h, loop, useDefineProps, useProps } from "canvasengine";
|
|
6
|
+
import { NightAmbiant, SpriteShadows } from "@canvasengine/presets";
|
|
7
|
+
import { delay } from "@rpgjs/common";
|
|
8
|
+
//#region src/components/scenes/canvas.ce
|
|
9
|
+
function component($$props) {
|
|
10
|
+
useProps($$props);
|
|
11
|
+
useDefineProps($$props);
|
|
12
|
+
const engine = inject(RpgClientEngine);
|
|
13
|
+
const guiService = inject(RpgGui);
|
|
14
|
+
const sceneData = engine.sceneMap.data;
|
|
15
|
+
const lighting = engine.sceneMap.lighting;
|
|
16
|
+
const guiList = computed(() => {
|
|
17
|
+
return Object.values(guiService.gui()).filter((gui) => !gui.attachToSprite);
|
|
18
|
+
});
|
|
19
|
+
const worldWidth = computed(() => {
|
|
20
|
+
const data = sceneData?.();
|
|
21
|
+
const scale = Number(data?.params?.scale ?? 1) || 1;
|
|
22
|
+
return Number(data?.width ?? data?.params?.width ?? 2048) * scale;
|
|
23
|
+
});
|
|
24
|
+
const worldHeight = computed(() => {
|
|
25
|
+
const data = sceneData?.();
|
|
26
|
+
const scale = Number(data?.params?.scale ?? 1) || 1;
|
|
27
|
+
return Number(data?.height ?? data?.params?.height ?? 2048) * scale;
|
|
28
|
+
});
|
|
29
|
+
effect(() => {
|
|
30
|
+
if (sceneData() && !sceneData().component) throw new Error("Warning ! You need to define a component for the scene. Use provideLoadMap() to define a component for the scene.");
|
|
31
|
+
});
|
|
32
|
+
const onGuiFinish = (gui, data) => {
|
|
33
|
+
delay(() => {
|
|
34
|
+
guiService.guiClose(gui.name, data);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const onGuiInteraction = (gui, name, data) => {
|
|
38
|
+
guiService.guiInteraction(gui.name, name, data);
|
|
39
|
+
};
|
|
40
|
+
const clamp = { direction: "all" };
|
|
41
|
+
const NIGHT_SPOT_RADIUS_SCALE = 4.25;
|
|
42
|
+
const NIGHT_SPOT_MIN_RADIUS = 170;
|
|
43
|
+
const NIGHT_SPOT_MIN_INTENSITY = 1;
|
|
44
|
+
const SHADOW_SPOT_RADIUS_SCALE = 12;
|
|
45
|
+
const SHADOW_SPOT_MIN_RADIUS = 480;
|
|
46
|
+
const SHADOW_SPOT_MIN_INTENSITY = 1.35;
|
|
47
|
+
const nightSpotRadius = (radius) => Math.max(radius * NIGHT_SPOT_RADIUS_SCALE, NIGHT_SPOT_MIN_RADIUS);
|
|
48
|
+
const shadowSpotRadius = (radius) => Math.max(radius * SHADOW_SPOT_RADIUS_SCALE, SHADOW_SPOT_MIN_RADIUS);
|
|
49
|
+
const nightSpotIntensity = (intensity, fallback) => Math.max(intensity ?? fallback, NIGHT_SPOT_MIN_INTENSITY);
|
|
50
|
+
const shadowSpotIntensity = (intensity) => Math.max(intensity ?? 1.3, SHADOW_SPOT_MIN_INTENSITY);
|
|
51
|
+
const lightingAmbient = computed(() => {
|
|
52
|
+
return (lighting?.())?.ambient ?? {};
|
|
53
|
+
});
|
|
54
|
+
const nightLights = computed(() => {
|
|
55
|
+
return ((lighting?.())?.spots ?? []).map((spot, index) => {
|
|
56
|
+
const radius = spot.radius ?? 180;
|
|
57
|
+
return {
|
|
58
|
+
x: spot.x,
|
|
59
|
+
y: spot.y,
|
|
60
|
+
radius: nightSpotRadius(radius),
|
|
61
|
+
intensity: nightSpotIntensity(spot.intensity, index === 0 ? 1 : .92),
|
|
62
|
+
flicker: spot.flicker,
|
|
63
|
+
flickerSpeed: spot.flickerSpeed ?? 14,
|
|
64
|
+
pulse: spot.pulse,
|
|
65
|
+
pulseSpeed: spot.pulseSpeed,
|
|
66
|
+
phase: spot.phase
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
const hasLightSpots = computed(() => {
|
|
71
|
+
return ((lighting?.())?.spots?.length ?? 0) > 0;
|
|
72
|
+
});
|
|
73
|
+
const lightingDarkness = computed(() => {
|
|
74
|
+
const darkness = lightingAmbient().darkness;
|
|
75
|
+
return typeof darkness === "number" ? darkness : 0;
|
|
76
|
+
});
|
|
77
|
+
const lightingAmbientEnabled = computed(() => {
|
|
78
|
+
const state = lighting?.();
|
|
79
|
+
return Boolean(state && lightingDarkness() > 0);
|
|
80
|
+
});
|
|
81
|
+
const lightingDarknessProps = computed(() => ({
|
|
82
|
+
opacity: lightingDarkness(),
|
|
83
|
+
color: lightingAmbient().darkColor ?? "#080a12"
|
|
84
|
+
}));
|
|
85
|
+
const lightingHaze = computed(() => ({
|
|
86
|
+
color: lightingAmbient().fogColor ?? "#12182a",
|
|
87
|
+
radius: lightingAmbient().fogRadius ?? .44,
|
|
88
|
+
softness: lightingAmbient().fogSoftness ?? .3,
|
|
89
|
+
opacity: lightingAmbient().fogOpacity ?? .35
|
|
90
|
+
}));
|
|
91
|
+
const defaultSunLight = () => {
|
|
92
|
+
const data = sceneData?.();
|
|
93
|
+
const width = Number(data?.width ?? data?.params?.width ?? 2048);
|
|
94
|
+
const height = Number(data?.height ?? data?.params?.height ?? 2048);
|
|
95
|
+
const scale = Number(data?.params?.scale ?? 1) || 1;
|
|
96
|
+
const mapWidth = width * scale;
|
|
97
|
+
const mapHeight = height * scale;
|
|
98
|
+
return {
|
|
99
|
+
x: -mapWidth * .35,
|
|
100
|
+
y: -mapHeight * .45,
|
|
101
|
+
z: 520,
|
|
102
|
+
radius: Math.max(mapWidth, mapHeight) * 2.5,
|
|
103
|
+
intensity: .85,
|
|
104
|
+
shadowWeight: lightingDarkness() > 0 ? 2.2 : 1,
|
|
105
|
+
enabled: true
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
const shadowState = computed(() => {
|
|
109
|
+
return (lighting?.())?.shadows ?? null;
|
|
110
|
+
});
|
|
111
|
+
const shadowLights = computed(() => {
|
|
112
|
+
const state = lighting?.();
|
|
113
|
+
const defaultSun = defaultSunLight();
|
|
114
|
+
const sun = {
|
|
115
|
+
...defaultSun,
|
|
116
|
+
...state?.sun ?? {},
|
|
117
|
+
shadowWeight: state?.sun?.shadowWeight ?? defaultSun.shadowWeight
|
|
118
|
+
};
|
|
119
|
+
const spotLights = (state?.spots ?? []).map((spot) => {
|
|
120
|
+
const radius = spot.radius ?? 180;
|
|
121
|
+
return {
|
|
122
|
+
x: spot.x,
|
|
123
|
+
y: spot.y,
|
|
124
|
+
z: 170,
|
|
125
|
+
radius: shadowSpotRadius(radius),
|
|
126
|
+
intensity: shadowSpotIntensity(spot.intensity),
|
|
127
|
+
shadowWeight: 2.4,
|
|
128
|
+
enabled: true
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
return [...sun.enabled === false || sun.intensity <= 0 ? [] : [sun], ...spotLights];
|
|
132
|
+
});
|
|
133
|
+
const shadowAmbientLight = computed(() => {
|
|
134
|
+
const shadows = shadowState();
|
|
135
|
+
if (shadows?.ambientLight === null || shadows?.ambientLight?.enabled === false) return null;
|
|
136
|
+
return shadows?.ambientLight ?? {
|
|
137
|
+
x: -.18,
|
|
138
|
+
y: -1,
|
|
139
|
+
z: 420,
|
|
140
|
+
intensity: .32,
|
|
141
|
+
shadowWeight: 1
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
const shadowEnabled = computed(() => {
|
|
145
|
+
const shadows = shadowState();
|
|
146
|
+
return Boolean((shadows?.enabled || hasLightSpots()) && (shadowLights().length > 0 || shadowAmbientLight()));
|
|
147
|
+
});
|
|
148
|
+
const shadowMode = computed(() => shadowState()?.mode ?? "strongest");
|
|
149
|
+
const shadowUpdateHz = computed(() => shadowState()?.updateHz ?? 60);
|
|
150
|
+
const shadowScanHz = computed(() => shadowState()?.scanHz ?? 8);
|
|
151
|
+
const shadowCullToViewport = computed(() => shadowState()?.cullToViewport ?? true);
|
|
152
|
+
const shadowMinInfluence = computed(() => shadowState()?.minInfluence ?? .24);
|
|
153
|
+
const shadowFalloffPower = computed(() => shadowState()?.falloffPower ?? .85);
|
|
154
|
+
const shadowColor = computed(() => shadowState()?.shadowColor ?? "#05070d");
|
|
155
|
+
return h(Canvas, {
|
|
156
|
+
width: engine.width,
|
|
157
|
+
height: engine.height
|
|
158
|
+
}, [h(Viewport, {
|
|
159
|
+
worldWidth,
|
|
160
|
+
worldHeight,
|
|
161
|
+
clamp,
|
|
162
|
+
sortableChildren: true
|
|
163
|
+
}, [
|
|
164
|
+
cond(computed(() => lightingAmbientEnabled()), () => h(NightAmbiant, {
|
|
165
|
+
spots: nightLights,
|
|
166
|
+
darkness: lightingDarknessProps,
|
|
167
|
+
haze: lightingHaze
|
|
168
|
+
})),
|
|
169
|
+
cond(computed(() => shadowEnabled()), () => h(SpriteShadows, {
|
|
170
|
+
lights: shadowLights,
|
|
171
|
+
ambientLight: shadowAmbientLight,
|
|
172
|
+
minInfluence: shadowMinInfluence,
|
|
173
|
+
falloffPower: shadowFalloffPower,
|
|
174
|
+
mode: shadowMode,
|
|
175
|
+
updateHz: shadowUpdateHz,
|
|
176
|
+
scanHz: shadowScanHz,
|
|
177
|
+
cullToViewport: shadowCullToViewport,
|
|
178
|
+
shadowColor
|
|
179
|
+
})),
|
|
180
|
+
h(__ce_component$1)
|
|
181
|
+
]), loop(guiList, (gui) => h(Container, { display: "flex" }, cond(gui.display, () => h(gui.component, {
|
|
182
|
+
data: gui.data,
|
|
183
|
+
dependencies: gui.dependencies,
|
|
184
|
+
onFinish: (data) => {
|
|
185
|
+
onGuiFinish(gui, data);
|
|
186
|
+
},
|
|
187
|
+
onInteraction: (name, data) => {
|
|
188
|
+
onGuiInteraction(gui, name, data);
|
|
189
|
+
}
|
|
190
|
+
}))))]);
|
|
191
|
+
}
|
|
192
|
+
var __ce_component = component;
|
|
193
|
+
//#endregion
|
|
194
|
+
export { __ce_component as default };
|
|
195
|
+
|
|
196
|
+
//# sourceMappingURL=canvas.ce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas.ce.js","names":[],"sources":["../../../src/components/scenes/canvas.ce"],"sourcesContent":["<Canvas width={engine.width} height={engine.height}>\n <Viewport worldWidth worldHeight clamp sortableChildren={true}>\n @if (lightingAmbientEnabled()) {\n <NightAmbiant\n spots={nightLights}\n darkness={lightingDarknessProps}\n haze={lightingHaze}\n />\n }\n @if (shadowEnabled()) {\n <SpriteShadows\n lights={shadowLights}\n ambientLight={shadowAmbientLight}\n minInfluence={shadowMinInfluence}\n falloffPower={shadowFalloffPower}\n mode={shadowMode}\n updateHz={shadowUpdateHz}\n scanHz={shadowScanHz}\n cullToViewport={shadowCullToViewport}\n shadowColor={shadowColor}\n />\n }\n <SceneMap />\n </Viewport>\n @for (gui of guiList) {\n <Container display=\"flex\">\n @if (gui.display) {\n <gui.component data={gui.data} dependencies={gui.dependencies} onFinish={(data) => {\n onGuiFinish(gui, data)\n }} onInteraction={(name, data) => {\n onGuiInteraction(gui, name, data)\n }} /> \n }\n </Container>\n }\n</Canvas>\n\n<script>\n import { computed, effect } from \"canvasengine\";\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import SceneMap from './draw-map.ce'\n import { RpgGui } from \"../../Gui/Gui\";\n import { delay } from \"@rpgjs/common\";\n import { NightAmbiant, SpriteShadows } from '@canvasengine/presets'\n\n const engine = inject(RpgClientEngine);\n const guiService = inject(RpgGui);\n const sceneData = engine.sceneMap.data\n const lighting = engine.sceneMap.lighting\n const guiList = computed(() => {\n return Object.values(guiService.gui()).filter((gui) => !gui.attachToSprite)\n })\n const worldWidth = computed(() => {\n const data = sceneData?.()\n const scale = Number(data?.params?.scale ?? 1) || 1\n return Number(data?.width ?? data?.params?.width ?? 2048) * scale\n })\n const worldHeight = computed(() => {\n const data = sceneData?.()\n const scale = Number(data?.params?.scale ?? 1) || 1\n return Number(data?.height ?? data?.params?.height ?? 2048) * scale\n })\n\n effect(() => {\n if (sceneData() && !sceneData().component) {\n throw new Error(\"Warning ! You need to define a component for the scene. Use provideLoadMap() to define a component for the scene.\")\n }\n })\n\n const onGuiFinish = (gui, data) => {\n delay(() => {\n guiService.guiClose(gui.name, data)\n })\n }\n\n const onGuiInteraction = (gui, name, data) => {\n guiService.guiInteraction(gui.name, name, data)\n }\n\n const clamp = {\n direction: \"all\"\n }\n const NIGHT_SPOT_RADIUS_SCALE = 4.25\n const NIGHT_SPOT_MIN_RADIUS = 170\n const NIGHT_SPOT_MIN_INTENSITY = 1\n const SHADOW_SPOT_RADIUS_SCALE = 12\n const SHADOW_SPOT_MIN_RADIUS = 480\n const SHADOW_SPOT_MIN_INTENSITY = 1.35\n\n const nightSpotRadius = (radius) => Math.max(radius * NIGHT_SPOT_RADIUS_SCALE, NIGHT_SPOT_MIN_RADIUS)\n const shadowSpotRadius = (radius) => Math.max(radius * SHADOW_SPOT_RADIUS_SCALE, SHADOW_SPOT_MIN_RADIUS)\n const nightSpotIntensity = (intensity, fallback) => Math.max(intensity ?? fallback, NIGHT_SPOT_MIN_INTENSITY)\n const shadowSpotIntensity = (intensity) => Math.max(intensity ?? 1.3, SHADOW_SPOT_MIN_INTENSITY)\n\n const lightingAmbient = computed(() => {\n const state = lighting?.()\n return state?.ambient ?? {}\n })\n\n const nightLights = computed(() => {\n const state = lighting?.()\n return (state?.spots ?? []).map((spot, index) => {\n const radius = spot.radius ?? 180\n return {\n x: spot.x,\n y: spot.y,\n radius: nightSpotRadius(radius),\n intensity: nightSpotIntensity(spot.intensity, index === 0 ? 1 : 0.92),\n flicker: spot.flicker,\n flickerSpeed: spot.flickerSpeed ?? 14,\n pulse: spot.pulse,\n pulseSpeed: spot.pulseSpeed,\n phase: spot.phase,\n }\n })\n })\n const hasLightSpots = computed(() => {\n const state = lighting?.()\n return (state?.spots?.length ?? 0) > 0\n })\n\n const lightingDarkness = computed(() => {\n const darkness = lightingAmbient().darkness\n return typeof darkness === \"number\" ? darkness : 0\n })\n\n const lightingAmbientEnabled = computed(() => {\n const state = lighting?.()\n return Boolean(state && lightingDarkness() > 0)\n })\n\n const lightingDarknessProps = computed(() => ({\n opacity: lightingDarkness(),\n color: lightingAmbient().darkColor ?? \"#080a12\",\n }))\n const lightingHaze = computed(() => ({\n color: lightingAmbient().fogColor ?? \"#12182a\",\n radius: lightingAmbient().fogRadius ?? 0.44,\n softness: lightingAmbient().fogSoftness ?? 0.3,\n opacity: lightingAmbient().fogOpacity ?? 0.35,\n }))\n\n const defaultSunLight = () => {\n const data = sceneData?.()\n const width = Number(data?.width ?? data?.params?.width ?? 2048)\n const height = Number(data?.height ?? data?.params?.height ?? 2048)\n const scale = Number(data?.params?.scale ?? 1) || 1\n const mapWidth = width * scale\n const mapHeight = height * scale\n\n return {\n x: -mapWidth * 0.35,\n y: -mapHeight * 0.45,\n z: 520,\n radius: Math.max(mapWidth, mapHeight) * 2.5,\n intensity: 0.85,\n shadowWeight: lightingDarkness() > 0 ? 2.2 : 1,\n enabled: true,\n }\n }\n\n const shadowState = computed(() => {\n const state = lighting?.()\n return state?.shadows ?? null\n })\n\n const shadowLights = computed(() => {\n const state = lighting?.()\n const defaultSun = defaultSunLight()\n const sun = {\n ...defaultSun,\n ...(state?.sun ?? {}),\n shadowWeight: state?.sun?.shadowWeight ?? defaultSun.shadowWeight,\n }\n const spotLights = (state?.spots ?? []).map((spot) => {\n const radius = spot.radius ?? 180\n return {\n x: spot.x,\n y: spot.y,\n z: 170,\n radius: shadowSpotRadius(radius),\n intensity: shadowSpotIntensity(spot.intensity),\n shadowWeight: 2.4,\n enabled: true,\n }\n })\n\n return [\n ...((sun.enabled === false || sun.intensity <= 0) ? [] : [sun]),\n ...spotLights,\n ]\n })\n\n const shadowAmbientLight = computed(() => {\n const shadows = shadowState()\n if (shadows?.ambientLight === null || shadows?.ambientLight?.enabled === false) {\n return null\n }\n return shadows?.ambientLight ?? { x: -0.18, y: -1, z: 420, intensity: 0.32, shadowWeight: 1 }\n })\n\n const shadowEnabled = computed(() => {\n const shadows = shadowState()\n return Boolean((shadows?.enabled || hasLightSpots()) && (shadowLights().length > 0 || shadowAmbientLight()))\n })\n\n const shadowMode = computed(() => shadowState()?.mode ?? \"strongest\")\n const shadowUpdateHz = computed(() => shadowState()?.updateHz ?? 60)\n const shadowScanHz = computed(() => shadowState()?.scanHz ?? 8)\n const shadowCullToViewport = computed(() => shadowState()?.cullToViewport ?? true)\n const shadowMinInfluence = computed(() => shadowState()?.minInfluence ?? 0.24)\n const shadowFalloffPower = computed(() => shadowState()?.falloffPower ?? 0.85)\n const shadowColor = computed(() => shadowState()?.shadowColor ?? \"#05070d\")\n</script>\n"],"mappings":";;;;;;;;AAeM,SAAQ,UAAU,SAAA;CACN,SAAc,OAAA;CACJ,eAAA,OAAA;CACpB,MAAA,SAAe,OAAC,eAAoB;CAC5C,MAAM,aAAa,OAAE,MAAW;CAChC,MAAM,YAAC,OAAA,SAAA;CACP,MAAI,WAAA,OAAA,SAAA;CACJ,MAAK,UAAU,eAAA;EACX,OAAA,OAAQ,OAAA,WAAA,IAAA,CAAA,EAAA,Q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QAAA;GAAA,cAAA;GAAA,cAAA;GAAA,cAAA;GAAA,MAAA;GAAA,UAAA;GAAA,QAAA;GAAA,gBAAA;GAAA;EAAA,CAAA,CAAA;EAAA,EAAA,gBAAA;CAAA,CAAA,GAAA,KAAA,UAAA,QAAA,EAAA,WAAA,EAAA,SAAA,OAAA,GAAA,KAAA,IAAA,eAAA,EAAA,IAAA,WAAA;EAAA,MAAA,IAAA;EAAA,cAAA,IAAA;EAAA,WAAA,SAAA;GACnB,YAAa,KAAA,IAAA;EACb;EAAG,gBAAG,MAAA,SAAA;GACP,iBAAU,KAAA,MAAA,IAAA;EACT;CAAA,CAAA,CAAA,CAAK,CAAC,CAAC,CACE;AACf;AAEE,IAAM,iBAEF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { inject } from "../../core/inject.js";
|
|
2
|
+
import { RpgClientEngine } from "../../RpgClientEngine.js";
|
|
3
|
+
import { Container, computed, cond, h, loop, useDefineProps, useProps } from "canvasengine";
|
|
4
|
+
import { Weather } from "@canvasengine/presets";
|
|
5
|
+
//#region src/components/scenes/draw-map.ce
|
|
6
|
+
function component($$props) {
|
|
7
|
+
useProps($$props);
|
|
8
|
+
useDefineProps($$props);
|
|
9
|
+
const engine = inject(RpgClientEngine);
|
|
10
|
+
const componentAnimations = engine.componentAnimations;
|
|
11
|
+
const map = engine.sceneMap?.data;
|
|
12
|
+
const sceneComponent = computed(() => map()?.component);
|
|
13
|
+
const mapParams = map()?.params;
|
|
14
|
+
const weather = engine.sceneMap.weather;
|
|
15
|
+
const backgroundMusic = {
|
|
16
|
+
src: mapParams?.backgroundMusic,
|
|
17
|
+
autoplay: true,
|
|
18
|
+
loop: true
|
|
19
|
+
};
|
|
20
|
+
const backgroundAmbientSound = {
|
|
21
|
+
src: mapParams?.backgroundAmbientSound,
|
|
22
|
+
autoplay: true,
|
|
23
|
+
loop: true
|
|
24
|
+
};
|
|
25
|
+
const shakeConfig = {
|
|
26
|
+
trigger: engine.mapShakeTrigger,
|
|
27
|
+
intensity: 10,
|
|
28
|
+
duration: 500,
|
|
29
|
+
frequency: 10,
|
|
30
|
+
direction: "both"
|
|
31
|
+
};
|
|
32
|
+
const weatherProps = computed(() => {
|
|
33
|
+
const state = weather?.();
|
|
34
|
+
if (!state) return null;
|
|
35
|
+
if (![
|
|
36
|
+
"rain",
|
|
37
|
+
"snow",
|
|
38
|
+
"fog",
|
|
39
|
+
"cloud"
|
|
40
|
+
].includes(state.effect)) return null;
|
|
41
|
+
const params = state.params ?? {};
|
|
42
|
+
return {
|
|
43
|
+
effect: state.effect,
|
|
44
|
+
speed: params.speed,
|
|
45
|
+
windDirection: params.windDirection,
|
|
46
|
+
windStrength: params.windStrength,
|
|
47
|
+
density: params.density,
|
|
48
|
+
maxDrops: params.maxDrops,
|
|
49
|
+
height: params.height,
|
|
50
|
+
scale: params.scale,
|
|
51
|
+
sunIntensity: params.sunIntensity,
|
|
52
|
+
sunAngle: params.sunAngle,
|
|
53
|
+
raySpread: params.raySpread,
|
|
54
|
+
rayTwinkle: params.rayTwinkle,
|
|
55
|
+
rayTwinkleSpeed: params.rayTwinkleSpeed,
|
|
56
|
+
zIndex: params.zIndex ?? 1e3,
|
|
57
|
+
alpha: params.alpha,
|
|
58
|
+
blendMode: params.blendMode
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
return h(Container, {
|
|
62
|
+
sound: backgroundMusic,
|
|
63
|
+
shake: shakeConfig,
|
|
64
|
+
freeze: engine.gamePause
|
|
65
|
+
}, [
|
|
66
|
+
h(Container, { sound: backgroundAmbientSound }),
|
|
67
|
+
cond(computed(() => map() && sceneComponent()), () => h(sceneComponent(), {
|
|
68
|
+
data: computed(() => map().data),
|
|
69
|
+
params: computed(() => map().params)
|
|
70
|
+
})),
|
|
71
|
+
loop(componentAnimations, (componentAnimation) => h(Container, null, loop(componentAnimation.current, (animation) => h(componentAnimation.component, animation)))),
|
|
72
|
+
cond(computed(() => weatherProps()), () => h(Weather, weatherProps()))
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
var __ce_component = component;
|
|
76
|
+
//#endregion
|
|
77
|
+
export { __ce_component as default };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=draw-map.ce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draw-map.ce.js","names":[],"sources":["../../../src/components/scenes/draw-map.ce"],"sourcesContent":["<Container sound={backgroundMusic} shake={shakeConfig} freeze={engine.gamePause}>\n <Container sound={backgroundAmbientSound} />\n\n @if (map() && sceneComponent()) {\n <sceneComponent() data={map().data} params={map().params} />\n }\n\n @for (componentAnimation of componentAnimations) {\n <Container>\n @for (animation of componentAnimation.current) {\n <componentAnimation.component ...animation />\n }\n </Container>\n }\n\n @if (weatherProps()) {\n <Weather ...weatherProps() />\n }\n</Container>\n\n<script>\n import { computed } from 'canvasengine'\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { Weather } from '@canvasengine/presets'\n\n const engine = inject(RpgClientEngine);\n const componentAnimations = engine.componentAnimations\n const map = engine.sceneMap?.data\n const sceneComponent = computed(() => map()?.component)\n const mapParams = map()?.params\n const weather = engine.sceneMap.weather\n const backgroundMusic = { src: mapParams?.backgroundMusic, autoplay: true, loop: true }\n const backgroundAmbientSound = { src: mapParams?.backgroundAmbientSound, autoplay: true, loop: true }\n\n const shakeConfig = {\n trigger: engine.mapShakeTrigger,\n intensity: 10,\n duration: 500,\n frequency: 10,\n direction: 'both'\n }\n\n const weatherProps = computed(() => {\n const state = weather?.()\n if (!state) {\n return null\n }\n const validEffects = ['rain', 'snow', 'fog', 'cloud']\n if (!validEffects.includes(state.effect)) {\n return null\n }\n const params = state.params ?? {}\n return {\n effect: state.effect,\n speed: params.speed,\n windDirection: params.windDirection,\n windStrength: params.windStrength,\n density: params.density,\n maxDrops: params.maxDrops,\n height: params.height,\n scale: params.scale,\n sunIntensity: params.sunIntensity,\n sunAngle: params.sunAngle,\n raySpread: params.raySpread,\n rayTwinkle: params.rayTwinkle,\n rayTwinkleSpeed: params.rayTwinkleSpeed,\n zIndex: params.zIndex ?? 1000,\n alpha: params.alpha,\n blendMode: params.blendMode,\n }\n })\n</script>\n"],"mappings":";;;;;AASM,SAAM,UAAa,SAAA;CAChB,SAAmB,OAAW;CACjC,eAAA,OAAA;CACA,MAAA,SAAS,OAAA,eAAA;CACf,MAAE,sBAAA,OAAA;;CAEF,MAAM,iBAAiB,eAAA,IAAA,GAAA,SAAA;CACvB,MAAK,YAAW,IAAA,GAAA;CAChB,MAAE,UAAA,OAAA,SAAA;CACF,MAAE,kBAAS;EAAA,KAAA,WAAA;EAAA,UAAA;EAAA,MAAA;CAAA;;;;;;CAEX,MAAC,cAAM;EACH,SAAS,OAAA;EACT,WAAS;EACT,UAAS;EACT,WAAS;;CAEb;CACA,MAAI,eAAM,eAAsB;EAC5B,MAAM,QAAM,UAAO;EACnB,IAAA,CAAK,OACL,OAAM;EAGN,IAAA,CAAK;GADiB;GAAQ;GAAC;GAAW;EACpC,EAAA,SAAA,MAA2B,MAAK,GAAA,OAAA;EAGtC,MAAE,SAAS,MAAO,UAAA,CAAA;EAClB,OAAE;GACA,QAAU,MAAG;GACb,OAAS,OAAI;GACb,eAAgB,OAAA;GAClB,cAAA,OAAA;;GAEA,UAAM,OAAe;GACnB,QAAM,OAAQ;GACZ,OAAG,OAAO;GACV,cAAO,OAAA;GACT,UAAA,OAAA;GACA,WAAM,OAAc;GAClB,YAAG,OAAa;GAChB,iBAAO,OAAA;GACT,QAAA,OAAA,UAAA;GACA,OAAM,OAAS;GACf,WAAO,OAAA;EACT;CACJ,CAAC;CAEO,OADA,EAAc,WAAQ;EAAA,OAAA;EAAa,OAAA;EAAA,QAAA,OAAA;CAAA,GAAA;EAAA,EAAA,WAAA,EAAA,OAAA,uBAAA,CAAA;EAAA,KAAA,eAAA,IAAA,KAAA,eAAA,CAAA,SAAA,EAAA,eAAA,GAAA;GAAA,MAAA,eAAA,IAAA,EAAA,IAAA;GAAA,QAAA,eAAA,IAAA,EAAA,MAAA;EAAA,CAAA,CAAA;EAAA,KAAA,sBAAA,uBAAA,EAAA,WAAA,MAAA,KAAA,mBAAA,UAAA,cAAA,EAAA,mBAAA,WAAA,SAAA,CAAA,CAAA,CAAA;EAAA,KAAA,eAAA,aAAA,CAAA,SAAA,EAAA,SAAA,aAAA,CAAA,CAAA;CAAA,CACnC;AACF;AAEA,IAAE,iBAEA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { inject } from "../../core/inject.js";
|
|
2
|
+
import { RpgClientEngine } from "../../RpgClientEngine.js";
|
|
3
|
+
import __ce_component$1 from "../character.ce.js";
|
|
4
|
+
import { Container, h, loop, useDefineProps, useProps } from "canvasengine";
|
|
5
|
+
//#region src/components/scenes/event-layer.ce
|
|
6
|
+
function component($$props) {
|
|
7
|
+
useProps($$props);
|
|
8
|
+
const defineProps = useDefineProps($$props);
|
|
9
|
+
const engine = inject(RpgClientEngine);
|
|
10
|
+
const { children } = defineProps();
|
|
11
|
+
const players = engine.sceneMap.players;
|
|
12
|
+
const events = engine.sceneMap.events;
|
|
13
|
+
return h(Container, { sortableChildren: true }, [
|
|
14
|
+
loop(events, (event, id) => h(__ce_component$1, {
|
|
15
|
+
id,
|
|
16
|
+
object: event
|
|
17
|
+
})),
|
|
18
|
+
loop(players, (player, id) => h(__ce_component$1, {
|
|
19
|
+
id,
|
|
20
|
+
object: player
|
|
21
|
+
})),
|
|
22
|
+
loop(children, (child) => h(child))
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
var __ce_component = component;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { __ce_component as default };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=event-layer.ce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-layer.ce.js","names":[],"sources":["../../../src/components/scenes/event-layer.ce"],"sourcesContent":["<Container sortableChildren={true}>\n @for ((event,id) of events) {\n <Character id={id} object={event} />\n }\n\n @for ((player,id) of players) {\n <Character id={id} object={player} />\n }\n\n @for (child of children) {\n <child />\n }\n</Container>\n\n<script>\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import Character from \"../character.ce\";\n import LightHalo from \"../prebuilt/light-halo.ce\";\n \n const engine = inject(RpgClientEngine);\n const { children } = defineProps()\n \n const players = engine.sceneMap.players\n const events = engine.sceneMap.events\n</script>\n"],"mappings":";;;;;;CASmB,SAAU,OAAA;CACrB,MAAM,cAAE,eAAA,OAAA;CACZ,MAAA,SAAA,OAAA,eAAA;CACJ,MAAE,EAAA,aAAS,YAAA;;CAEX,MAAC,SAAM,OAAA,SAAA;CAEH,OADgB,EAAE,WAAW,EAAC,kBAAY,KAAA,GAAA;EAAA,KAAA,SAAA,OAAA,OAAA,EAAA,kBAAA;GAAA;GAAA,QAAA;EAAA,CAAA,CAAA;EAAA,KAAA,UAAA,QAAA,OAAA,EAAA,kBAAA;GAAA;GAAA,QAAA;EAAA,CAAA,CAAA;EAAA,KAAA,WAAA,UAAA,EAAA,KAAA,CAAA;CAAA,CACjC;AACT;AAEF,IAAA,iBAEQ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { inject as inject$1 } from "../node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js";
|
|
2
|
+
//#region src/core/inject.ts
|
|
3
|
+
var context = null;
|
|
4
|
+
function inject(service, _context) {
|
|
5
|
+
const c = _context ?? context;
|
|
6
|
+
if (!c) throw new Error("Context is not set. use setInject() to set the context");
|
|
7
|
+
return inject$1(c, service);
|
|
8
|
+
}
|
|
9
|
+
function setInject(_context) {
|
|
10
|
+
context = _context;
|
|
11
|
+
}
|
|
12
|
+
function clearInject() {
|
|
13
|
+
context = null;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { clearInject, context, inject, setInject };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=inject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject.js","names":[],"sources":["../../src/core/inject.ts"],"sourcesContent":["import { Context, inject as injector } from \"@signe/di\";\n\nexport let context: Context | null = null\n\nexport function inject<T>(service: (new (...args: any[]) => T) | string, _context?: Context): T {\n const c = _context ?? context\n if (!c) throw new Error(\"Context is not set. use setInject() to set the context\");\n return injector(c, service);\n}\n\nexport function setInject(_context: Context) {\n context = _context;\n}\n\nexport function clearInject() {\n context = null\n}"],"mappings":";;AAEA,IAAW,UAA0B;AAErC,SAAgB,OAAU,SAA+C,UAAuB;CAC5F,MAAM,IAAI,YAAY;CACtB,IAAI,CAAC,GAAG,MAAM,IAAI,MAAM,wDAAwD;CAChF,OAAO,SAAS,GAAG,OAAO;AAC9B;AAEA,SAAgB,UAAU,UAAmB;CACzC,UAAU;AACd;AAEA,SAAgB,cAAc;CAC1B,UAAU;AACd"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context, inject, injector } from "../node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js";
|
|
2
|
+
import { setInject } from "./inject.js";
|
|
3
|
+
import { RpgClientEngine } from "../RpgClientEngine.js";
|
|
4
|
+
//#region src/core/setup.ts
|
|
5
|
+
async function startGame(options) {
|
|
6
|
+
const context = new Context();
|
|
7
|
+
context["side"] = "client";
|
|
8
|
+
setInject(context);
|
|
9
|
+
await injector(context, options.providers);
|
|
10
|
+
await inject(context, RpgClientEngine).start();
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { startGame };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","names":[],"sources":["../../src/core/setup.ts"],"sourcesContent":["import { Context, FactoryProvider, findProvider, findProviders, inject, injector, Providers } from \"@signe/di\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { setInject } from \"./inject\";\n\ninterface SetupOptions {\n providers: Providers;\n}\n\n\nexport async function startGame(options: SetupOptions) {\n const context = new Context();\n context['side'] = 'client'\n setInject(context);\n\n await injector(context, options.providers);\n\n const engine = inject<RpgClientEngine>(context, RpgClientEngine);\n await engine.start();\n return context;\n}\n"],"mappings":";;;;AASA,eAAsB,UAAU,SAAuB;CACrD,MAAM,UAAU,IAAI,QAAQ;CAC5B,QAAQ,UAAU;CAClB,UAAU,OAAO;CAEjB,MAAM,SAAS,SAAS,QAAQ,SAAS;CAGzC,MADe,OAAwB,SAAS,eAC1C,EAAO,MAAM;CACnB,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Spritesheet(options?: Record<string, any>): (target: any) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/decorators/spritesheet.ts
|
|
2
|
+
function Spritesheet(options = {}) {
|
|
3
|
+
return (target) => {
|
|
4
|
+
Object.assign(target, options);
|
|
5
|
+
if (target.prototype) Object.assign(target.prototype, options);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { Spritesheet };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=spritesheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spritesheet.js","names":[],"sources":["../../src/decorators/spritesheet.ts"],"sourcesContent":["export function Spritesheet(options: Record<string, any> = {}) {\n return (target: any) => {\n Object.assign(target, options);\n if (target.prototype) {\n Object.assign(target.prototype, options);\n }\n };\n}\n"],"mappings":";AAAA,SAAgB,YAAY,UAA+B,CAAC,GAAG;CAC7D,QAAQ,WAAgB;EACtB,OAAO,OAAO,QAAQ,OAAO;EAC7B,IAAI,OAAO,WACT,OAAO,OAAO,OAAO,WAAW,OAAO;CAE3C;AACF"}
|