@rpgjs/client 5.0.0-beta.1 → 5.0.0-beta.3
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/LICENSE +19 -0
- package/dist/Game/Map.js +2 -2
- package/dist/Game/Object.js.map +1 -1
- package/dist/Gui/Gui.js.map +1 -1
- package/dist/Gui/NotificationManager.js.map +1 -1
- package/dist/RpgClientEngine.js +2 -1
- package/dist/RpgClientEngine.js.map +1 -1
- package/dist/Sound.js.map +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.127.0}/helpers/decorate.js +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.127.0}/helpers/decorateMetadata.js +1 -1
- package/dist/components/animations/animation.ce.js +2 -4
- package/dist/components/animations/animation.ce.js.map +1 -1
- package/dist/components/animations/hit.ce.js +17 -24
- package/dist/components/animations/hit.ce.js.map +1 -1
- package/dist/components/character.ce.js +75 -222
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/dynamics/text.ce.js +14 -25
- package/dist/components/dynamics/text.ce.js.map +1 -1
- package/dist/components/gui/box.ce.js +4 -7
- package/dist/components/gui/box.ce.js.map +1 -1
- package/dist/components/gui/dialogbox/index.ce.js +37 -54
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
- package/dist/components/gui/gameover.ce.js +36 -61
- package/dist/components/gui/gameover.ce.js.map +1 -1
- package/dist/components/gui/hud/hud.ce.js +18 -28
- package/dist/components/gui/hud/hud.ce.js.map +1 -1
- package/dist/components/gui/menu/equip-menu.ce.js +108 -163
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/exit-menu.ce.js +4 -4
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/items-menu.ce.js +47 -66
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/main-menu.ce.js +58 -77
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/options-menu.ce.js +3 -3
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/skills-menu.ce.js +10 -16
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
- package/dist/components/gui/mobile/mobile.ce.js +3 -3
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
- package/dist/components/gui/notification/notification.ce.js +13 -19
- package/dist/components/gui/notification/notification.ce.js.map +1 -1
- package/dist/components/gui/save-load.ce.js +68 -247
- package/dist/components/gui/save-load.ce.js.map +1 -1
- package/dist/components/gui/shop/shop.ce.js +84 -123
- package/dist/components/gui/shop/shop.ce.js.map +1 -1
- package/dist/components/gui/title-screen.ce.js +38 -65
- package/dist/components/gui/title-screen.ce.js.map +1 -1
- package/dist/components/prebuilt/hp-bar.ce.js +39 -43
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
- package/dist/components/prebuilt/light-halo.ce.js +33 -58
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js +11 -19
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/draw-map.ce.js +20 -25
- package/dist/components/scenes/draw-map.ce.js.map +1 -1
- package/dist/components/scenes/event-layer.ce.js +4 -4
- package/dist/components/scenes/event-layer.ce.js.map +1 -1
- package/dist/core/setup.js.map +1 -1
- package/dist/module.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +27 -27
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
- package/dist/services/keyboardControls.js.map +1 -1
- package/dist/services/mmorpg.js +2 -1
- package/dist/services/mmorpg.js.map +1 -1
- package/package.json +7 -8
- 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
|
@@ -7,99 +7,72 @@ import { PrebuiltGui } from "@rpgjs/common";
|
|
|
7
7
|
function component($$props) {
|
|
8
8
|
useProps($$props);
|
|
9
9
|
const defineProps = useDefineProps($$props);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return t;
|
|
17
|
-
};
|
|
18
|
-
return __assign.apply(this, arguments);
|
|
19
|
-
};
|
|
20
|
-
var engine = inject(RpgClientEngine);
|
|
21
|
-
var guiService = inject(RpgGui);
|
|
22
|
-
var keyboardControls = engine.globalConfig.keyboardControls;
|
|
23
|
-
var _a = defineProps({
|
|
24
|
-
entries: { default: function() {
|
|
25
|
-
return [];
|
|
26
|
-
} },
|
|
27
|
-
saveLoad: { default: function() {
|
|
28
|
-
return {};
|
|
29
|
-
} },
|
|
10
|
+
const engine = inject(RpgClientEngine);
|
|
11
|
+
const guiService = inject(RpgGui);
|
|
12
|
+
const keyboardControls = engine.globalConfig.keyboardControls;
|
|
13
|
+
const { data, onInteraction } = defineProps({
|
|
14
|
+
entries: { default: () => [] },
|
|
15
|
+
saveLoad: { default: () => ({}) },
|
|
30
16
|
localActions: { default: false }
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
});
|
|
18
|
+
const { entries, title, subtitle, version, saveLoad, localActions } = data();
|
|
19
|
+
const defaultEntries = [{
|
|
34
20
|
id: "start",
|
|
35
21
|
label: "Start"
|
|
36
22
|
}, {
|
|
37
23
|
id: "load",
|
|
38
24
|
label: "Load"
|
|
39
25
|
}];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return resolveProp(subtitle) || "";
|
|
48
|
-
});
|
|
49
|
-
var versionText = computed(function() {
|
|
50
|
-
return resolveProp(version) || "";
|
|
51
|
-
});
|
|
52
|
-
var localActionsEnabled = computed(function() {
|
|
53
|
-
return resolveProp(localActions) === true;
|
|
54
|
-
});
|
|
55
|
-
var entryList = computed(function() {
|
|
56
|
-
var list = resolveProp(entries);
|
|
26
|
+
const resolveProp = (value) => typeof value === "function" ? value() : value;
|
|
27
|
+
const titleText = computed(() => resolveProp(title) || "RPG");
|
|
28
|
+
const subtitleText = computed(() => resolveProp(subtitle) || "");
|
|
29
|
+
const versionText = computed(() => resolveProp(version) || "");
|
|
30
|
+
const localActionsEnabled = computed(() => resolveProp(localActions) === true);
|
|
31
|
+
const entryList = computed(() => {
|
|
32
|
+
const list = resolveProp(entries);
|
|
57
33
|
if (Array.isArray(list) && list.length) return list;
|
|
58
34
|
return defaultEntries;
|
|
59
35
|
});
|
|
60
|
-
|
|
36
|
+
const isEntryDisabled = (entry) => {
|
|
61
37
|
if (!entry) return true;
|
|
62
38
|
if (entry.disabled) return true;
|
|
63
39
|
if (entry.enabled === false) return true;
|
|
64
40
|
return false;
|
|
65
41
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return entryList().map(
|
|
69
|
-
return isEntryDisabled(entry) ? null : index;
|
|
70
|
-
}).filter(function(value) {
|
|
71
|
-
return value !== null;
|
|
72
|
-
});
|
|
42
|
+
const selectedEntry = signal(0);
|
|
43
|
+
const selectableIndexes = computed(() => {
|
|
44
|
+
return entryList().map((entry, index) => isEntryDisabled(entry) ? null : index).filter((value) => value !== null);
|
|
73
45
|
});
|
|
74
|
-
effect(
|
|
75
|
-
|
|
46
|
+
effect(() => {
|
|
47
|
+
const available = selectableIndexes();
|
|
76
48
|
if (!available.length) return;
|
|
77
|
-
|
|
49
|
+
const current = selectedEntry();
|
|
78
50
|
if (!available.includes(current)) selectedEntry.set(available[0]);
|
|
79
51
|
});
|
|
80
|
-
|
|
81
|
-
|
|
52
|
+
const moveSelection = (delta) => {
|
|
53
|
+
const available = selectableIndexes();
|
|
82
54
|
if (!available.length) return;
|
|
83
|
-
|
|
84
|
-
|
|
55
|
+
const current = selectedEntry();
|
|
56
|
+
const nextIndex = (Math.max(0, available.indexOf(current)) + delta + available.length) % available.length;
|
|
85
57
|
selectedEntry.set(available[nextIndex]);
|
|
86
58
|
};
|
|
87
|
-
|
|
88
|
-
|
|
59
|
+
const triggerSelect = (index) => {
|
|
60
|
+
const entry = entryList()[index];
|
|
89
61
|
if (!entry || isEntryDisabled(entry)) return;
|
|
90
62
|
if (localActionsEnabled()) {
|
|
91
63
|
if (entry.id === "start") guiService.hide(PrebuiltGui.TitleScreen);
|
|
92
64
|
if (entry.id === "load") {
|
|
93
|
-
|
|
94
|
-
|
|
65
|
+
const config = resolveProp(saveLoad) || {};
|
|
66
|
+
const slots = Array.isArray(config.slots) ? config.slots : [
|
|
95
67
|
null,
|
|
96
68
|
null,
|
|
97
69
|
null
|
|
98
70
|
];
|
|
99
|
-
guiService.display(PrebuiltGui.Save,
|
|
71
|
+
guiService.display(PrebuiltGui.Save, {
|
|
72
|
+
...config,
|
|
100
73
|
mode: config.mode || "load",
|
|
101
74
|
slots
|
|
102
|
-
})
|
|
75
|
+
});
|
|
103
76
|
}
|
|
104
77
|
}
|
|
105
78
|
if (onInteraction) onInteraction("select", {
|
|
@@ -114,12 +87,12 @@ function component($$props) {
|
|
|
114
87
|
triggerSelect(index);
|
|
115
88
|
};
|
|
116
89
|
}
|
|
117
|
-
|
|
90
|
+
const controls = signal({
|
|
118
91
|
up: {
|
|
119
92
|
repeat: true,
|
|
120
93
|
bind: keyboardControls.up,
|
|
121
94
|
throttle: 150,
|
|
122
|
-
keyDown
|
|
95
|
+
keyDown() {
|
|
123
96
|
if (guiService.isDisplaying(PrebuiltGui.Save)) return;
|
|
124
97
|
moveSelection(-1);
|
|
125
98
|
}
|
|
@@ -128,14 +101,14 @@ function component($$props) {
|
|
|
128
101
|
repeat: true,
|
|
129
102
|
bind: keyboardControls.down,
|
|
130
103
|
throttle: 150,
|
|
131
|
-
keyDown
|
|
104
|
+
keyDown() {
|
|
132
105
|
if (guiService.isDisplaying(PrebuiltGui.Save)) return;
|
|
133
106
|
moveSelection(1);
|
|
134
107
|
}
|
|
135
108
|
},
|
|
136
109
|
action: {
|
|
137
110
|
bind: keyboardControls.action,
|
|
138
|
-
keyDown
|
|
111
|
+
keyDown() {
|
|
139
112
|
if (guiService.isDisplaying(PrebuiltGui.Save)) return;
|
|
140
113
|
triggerSelect(selectedEntry());
|
|
141
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title-screen.ce.js","names":[],"sources":["../../../src/components/gui/title-screen.ce"],"sourcesContent":["<DOMContainer width=\"100%\" height=\"100%\">\n <div class=\"rpg-ui-title-screen rpg-anim-fade-in\">\n <div class=\"rpg-ui-title-screen-header rpg-anim-float\">\n <div class=\"rpg-ui-title-screen-title\">{titleText()}</div>\n @if (subtitleText()) {\n <div class=\"rpg-ui-title-screen-subtitle\">{subtitleText()}</div>\n }\n </div>\n <Navigation tabindex={selectedEntry} controls={controls}>\n <div class=\"rpg-ui-menu rpg-ui-title-screen-menu rpg-anim-slide-up\">\n @for ((entry,index) of entryList()) {\n <div\n class=\"rpg-ui-menu-item\"\n class={{disabled: isEntryDisabled(entry)}}\n data-selected={selectedEntry() === index ? \"true\" : \"false\"}\n tabindex={index}\n click={selectEntry(index)}\n >{entry.label}</div>\n }\n </div>\n </Navigation>\n @if (versionText()) {\n <div class=\"rpg-ui-title-screen-version\">{versionText()}</div>\n }\n </div>\n</DOMContainer>\n\n<script>\n import { signal, computed, effect } from \"canvasengine\";\n import { PrebuiltGui } from \"@rpgjs/common\";\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { RpgGui } from \"../../Gui/Gui\";\n\n const engine = inject(RpgClientEngine);\n const guiService = inject(RpgGui);\n const keyboardControls = engine.globalConfig.keyboardControls;\n\n const { data, onInteraction } = defineProps({\n entries: {\n default: () => []\n },\n saveLoad: {\n default: () => ({})\n },\n localActions: {\n default: false\n }\n });\n\n const { entries, title, subtitle, version, saveLoad, localActions } = data();\n\n const defaultEntries = [\n { id: \"start\", label: \"Start\" },\n { id: \"load\", label: \"Load\" }\n ];\n\n const resolveProp = (value) => typeof value === \"function\" ? value() : value;\n const titleText = computed(() => resolveProp(title) || \"RPG\");\n const subtitleText = computed(() => resolveProp(subtitle) || \"\");\n const versionText = computed(() => resolveProp(version) || \"\");\n const localActionsEnabled = computed(() => resolveProp(localActions) === true);\n\n const entryList = computed(() => {\n const list = resolveProp(entries);\n if (Array.isArray(list) && list.length) return list;\n return defaultEntries;\n });\n\n const isEntryDisabled = (entry) => {\n if (!entry) return true;\n if (entry.disabled) return true;\n if (entry.enabled === false) return true;\n return false;\n };\n\n const selectedEntry = signal(0);\n const selectableIndexes = computed(() => {\n const list = entryList();\n return list\n .map((entry, index) => (isEntryDisabled(entry) ? null : index))\n .filter((value) => value !== null);\n });\n\n effect(() => {\n const available = selectableIndexes();\n if (!available.length) return;\n const current = selectedEntry();\n if (!available.includes(current)) {\n selectedEntry.set(available[0]);\n }\n });\n\n const moveSelection = (delta) => {\n const available = selectableIndexes();\n if (!available.length) return;\n const current = selectedEntry();\n const currentIndex = Math.max(0, available.indexOf(current));\n const nextIndex = (currentIndex + delta + available.length) % available.length;\n selectedEntry.set(available[nextIndex]);\n };\n\n const triggerSelect = (index) => {\n const list = entryList();\n const entry = list[index];\n if (!entry || isEntryDisabled(entry)) return;\n if (localActionsEnabled()) {\n if (entry.id === \"start\") {\n guiService.hide(PrebuiltGui.TitleScreen);\n }\n if (entry.id === \"load\") {\n const config = resolveProp(saveLoad) || {};\n const slots = Array.isArray(config.slots) ? config.slots : [null, null, null];\n guiService.display(PrebuiltGui.Save, {\n ...config,\n mode: config.mode || \"load\",\n slots\n });\n }\n }\n if (onInteraction) {\n onInteraction(\"select\", { id: entry.id, index, entry });\n }\n };\n\n function selectEntry(index) {\n return function() {\n selectedEntry.set(index);\n triggerSelect(index);\n };\n }\n\n const controls = signal({\n up: {\n repeat: true,\n bind: keyboardControls.up,\n throttle: 150,\n keyDown() {\n if (guiService.isDisplaying(PrebuiltGui.Save)) return;\n moveSelection(-1);\n }\n },\n down: {\n repeat: true,\n bind: keyboardControls.down,\n throttle: 150,\n keyDown() {\n if (guiService.isDisplaying(PrebuiltGui.Save)) return;\n moveSelection(1);\n }\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (guiService.isDisplaying(PrebuiltGui.Save)) return;\n triggerSelect(selectedEntry());\n }\n },\n gamepad: {\n enabled: true\n }\n });\n</script>\n"],"mappings":";;;;;;AAYM,SAAwB,UAAQ,SAAS;AACxB,UAAS,QAAQ;CAChC,MAAM,cAAc,eAAW,QAAA;CAC/B,
|
|
1
|
+
{"version":3,"file":"title-screen.ce.js","names":[],"sources":["../../../src/components/gui/title-screen.ce"],"sourcesContent":["<DOMContainer width=\"100%\" height=\"100%\">\n <div class=\"rpg-ui-title-screen rpg-anim-fade-in\">\n <div class=\"rpg-ui-title-screen-header rpg-anim-float\">\n <div class=\"rpg-ui-title-screen-title\">{titleText()}</div>\n @if (subtitleText()) {\n <div class=\"rpg-ui-title-screen-subtitle\">{subtitleText()}</div>\n }\n </div>\n <Navigation tabindex={selectedEntry} controls={controls}>\n <div class=\"rpg-ui-menu rpg-ui-title-screen-menu rpg-anim-slide-up\">\n @for ((entry,index) of entryList()) {\n <div\n class=\"rpg-ui-menu-item\"\n class={{disabled: isEntryDisabled(entry)}}\n data-selected={selectedEntry() === index ? \"true\" : \"false\"}\n tabindex={index}\n click={selectEntry(index)}\n >{entry.label}</div>\n }\n </div>\n </Navigation>\n @if (versionText()) {\n <div class=\"rpg-ui-title-screen-version\">{versionText()}</div>\n }\n </div>\n</DOMContainer>\n\n<script>\n import { signal, computed, effect } from \"canvasengine\";\n import { PrebuiltGui } from \"@rpgjs/common\";\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { RpgGui } from \"../../Gui/Gui\";\n\n const engine = inject(RpgClientEngine);\n const guiService = inject(RpgGui);\n const keyboardControls = engine.globalConfig.keyboardControls;\n\n const { data, onInteraction } = defineProps({\n entries: {\n default: () => []\n },\n saveLoad: {\n default: () => ({})\n },\n localActions: {\n default: false\n }\n });\n\n const { entries, title, subtitle, version, saveLoad, localActions } = data();\n\n const defaultEntries = [\n { id: \"start\", label: \"Start\" },\n { id: \"load\", label: \"Load\" }\n ];\n\n const resolveProp = (value) => typeof value === \"function\" ? value() : value;\n const titleText = computed(() => resolveProp(title) || \"RPG\");\n const subtitleText = computed(() => resolveProp(subtitle) || \"\");\n const versionText = computed(() => resolveProp(version) || \"\");\n const localActionsEnabled = computed(() => resolveProp(localActions) === true);\n\n const entryList = computed(() => {\n const list = resolveProp(entries);\n if (Array.isArray(list) && list.length) return list;\n return defaultEntries;\n });\n\n const isEntryDisabled = (entry) => {\n if (!entry) return true;\n if (entry.disabled) return true;\n if (entry.enabled === false) return true;\n return false;\n };\n\n const selectedEntry = signal(0);\n const selectableIndexes = computed(() => {\n const list = entryList();\n return list\n .map((entry, index) => (isEntryDisabled(entry) ? null : index))\n .filter((value) => value !== null);\n });\n\n effect(() => {\n const available = selectableIndexes();\n if (!available.length) return;\n const current = selectedEntry();\n if (!available.includes(current)) {\n selectedEntry.set(available[0]);\n }\n });\n\n const moveSelection = (delta) => {\n const available = selectableIndexes();\n if (!available.length) return;\n const current = selectedEntry();\n const currentIndex = Math.max(0, available.indexOf(current));\n const nextIndex = (currentIndex + delta + available.length) % available.length;\n selectedEntry.set(available[nextIndex]);\n };\n\n const triggerSelect = (index) => {\n const list = entryList();\n const entry = list[index];\n if (!entry || isEntryDisabled(entry)) return;\n if (localActionsEnabled()) {\n if (entry.id === \"start\") {\n guiService.hide(PrebuiltGui.TitleScreen);\n }\n if (entry.id === \"load\") {\n const config = resolveProp(saveLoad) || {};\n const slots = Array.isArray(config.slots) ? config.slots : [null, null, null];\n guiService.display(PrebuiltGui.Save, {\n ...config,\n mode: config.mode || \"load\",\n slots\n });\n }\n }\n if (onInteraction) {\n onInteraction(\"select\", { id: entry.id, index, entry });\n }\n };\n\n function selectEntry(index) {\n return function() {\n selectedEntry.set(index);\n triggerSelect(index);\n };\n }\n\n const controls = signal({\n up: {\n repeat: true,\n bind: keyboardControls.up,\n throttle: 150,\n keyDown() {\n if (guiService.isDisplaying(PrebuiltGui.Save)) return;\n moveSelection(-1);\n }\n },\n down: {\n repeat: true,\n bind: keyboardControls.down,\n throttle: 150,\n keyDown() {\n if (guiService.isDisplaying(PrebuiltGui.Save)) return;\n moveSelection(1);\n }\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (guiService.isDisplaying(PrebuiltGui.Save)) return;\n triggerSelect(selectedEntry());\n }\n },\n gamepad: {\n enabled: true\n }\n });\n</script>\n"],"mappings":"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"}
|
|
@@ -2,83 +2,79 @@ import { Container, Graphics, animatedSignal, computed, effect, h, useDefineProp
|
|
|
2
2
|
//#region src/components/prebuilt/hp-bar.ce
|
|
3
3
|
function component($$props) {
|
|
4
4
|
useProps($$props);
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return (_b = (_a = object.hpSignal) === null || _a === void 0 ? void 0 : _a.call(object)) !== null && _b !== void 0 ? _b : 0;
|
|
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;
|
|
21
20
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return (_c = ((_b = (_a = object._param) === null || _a === void 0 ? void 0 : _a.call(object)) !== null && _b !== void 0 ? _b : {}).maxHp) !== null && _c !== void 0 ? _c : 100;
|
|
21
|
+
const maxHp = computed(() => {
|
|
22
|
+
return (object._param?.() ?? {}).maxHp ?? 100;
|
|
25
23
|
});
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const hpPercent = computed(() => {
|
|
25
|
+
const max = maxHp();
|
|
28
26
|
if (max <= 0) return 0;
|
|
29
|
-
|
|
27
|
+
const percent = currentHp() / max;
|
|
30
28
|
return Math.max(0, Math.min(1, percent));
|
|
31
29
|
});
|
|
32
|
-
|
|
30
|
+
const animatedPercent = animatedSignal(hpPercent(), {
|
|
33
31
|
duration: 300,
|
|
34
32
|
easing: "easeOutCubic"
|
|
35
33
|
});
|
|
36
|
-
effect(
|
|
37
|
-
|
|
34
|
+
effect(() => {
|
|
35
|
+
const newPercent = hpPercent();
|
|
38
36
|
animatedPercent.set(newPercent);
|
|
39
37
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var percent = animatedPercent();
|
|
48
|
-
var width = maxFillWidth * percent;
|
|
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;
|
|
49
45
|
if (percent > 0 && width < innerRadius * 2) return innerRadius * 2;
|
|
50
46
|
return Math.max(0, width);
|
|
51
47
|
});
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
const hpColorHex = computed(() => {
|
|
49
|
+
const percent = hpPercent();
|
|
54
50
|
if (percent > .6) return 4906624;
|
|
55
51
|
else if (percent > .3) return 16436245;
|
|
56
52
|
else if (percent > .15) return 16486972;
|
|
57
53
|
else return 15680580;
|
|
58
54
|
});
|
|
59
|
-
|
|
55
|
+
const drawShadow = (g) => {
|
|
60
56
|
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
61
57
|
g.fill({
|
|
62
58
|
color: shadowColor,
|
|
63
59
|
alpha: .3
|
|
64
60
|
});
|
|
65
61
|
};
|
|
66
|
-
|
|
62
|
+
const drawBackground = (g) => {
|
|
67
63
|
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
68
64
|
g.fill({
|
|
69
65
|
color: bgColor,
|
|
70
66
|
alpha: .9
|
|
71
67
|
});
|
|
72
68
|
};
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const drawFill = (g) => {
|
|
70
|
+
const width = fillWidth();
|
|
75
71
|
if (width > 0) {
|
|
76
72
|
g.roundRect(padding, padding, width, fillHeight, innerRadius);
|
|
77
73
|
g.fill({ color: hpColorHex() });
|
|
78
74
|
}
|
|
79
75
|
};
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
const drawHighlight = (g) => {
|
|
77
|
+
const width = fillWidth();
|
|
82
78
|
if (width > 0) {
|
|
83
79
|
g.roundRect(padding, padding, width, highlightHeight, innerRadius);
|
|
84
80
|
g.fill({
|
|
@@ -87,7 +83,7 @@ function component($$props) {
|
|
|
87
83
|
});
|
|
88
84
|
}
|
|
89
85
|
};
|
|
90
|
-
|
|
86
|
+
const drawBorder = (g) => {
|
|
91
87
|
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
92
88
|
g.stroke({
|
|
93
89
|
color: borderColor,
|
|
@@ -1 +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;AACsB,UAAC,QAAY;CAEhC,
|
|
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;AACsB,UAAC,QAAY;CAEhC,MAAS,EAAA,WADe,eAAe,QACL,EAAA;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,EAAA;CAC/B,MAAI,SAAA,OAAA;CACJ,MAAG,YAAA,eAAA;AACC,SAAA,OAAA,YAAA,IAAA;GACF;;AAGE,UADU,OAAY,UAAG,IAAW,EAAA,EACtB,SAAO;GACvB;CACF,MAAC,YAAA,eAAA;EACG,MAAG,MAAK,OAAW;AACpB,MAAA,OAAS,EACX,QAAA;EACG,MAAM,UAAU,WAAC,GAAA;AAClB,SAAQ,KAAK,IAAE,GAAA,KAAU,IAAC,GAAA,QAAA,CAAA;GAC5B;CACD,MAAM,kBAAkB,eAAe,WAAE,EAAA;EACtC,UAAS;EACX,QAAA;EACA,CAAC;AACF,cAAY;EACV,MAAA,aAAS,WAAA;;GAEV;CACD,MAAM,WAAW,gBAAgB;;EAEjC,GAAO,CAAC,YAAW;;CAEnB,MAAM,YAAY,eAAI;EACnB,MAAA,UAAA,iBAAA;EACC,MAAM,QAAQ,eAAI;AAElB,MAAA,UAAc,KAAK,QAAO,cAAW,EACnC,QAAS,cAAI;AAEf,SAAM,KAAM,IAAI,GAAG,MAAI;GAC3B;;EAEI,MAAM,UAAQ,WAAY;AAC9B,MAAM,UAAY,GAAA,QAAA;WAGZ,UAAe,GAAA,QAAA;WAGR,UAAI,IAAA,QAAA;;GAMjB;;AAEI,IAAA,UAAY,GAAE,GAAA,UAAA,WAAA,aAAA;AAClB,IAAM,KAAA;GAAA,OAAc;GAAQ,OAAA;GAAA,CAAA;;CAE5B,MAAM,kBAAgB,MAAA;AACnB,IAAA,UAAW,GAAA,GAAA,UAAA,WAAA,aAAA;AACV,IAAE,KAAK;GAAE,OAAO;GAAE,OAAA;GAAA,CAAA;;CAEtB,MAAI,YAAa,MAAO;EACxB,MAAM,QAAY,WAAW;;AAErB,KAAC,UAAQ,SAAA,SAAA,OAAA,YAAA,YAAA;AACX,KAAA,KAAA,EAAW,OAAE,YAAa,EAAA,CAAO;;;CAGvC,MAAM,iBAAiB,MAAM;;AAEzB,MAAI,QAAQ,GAAG;AAChB,KAAA,UAAY,SAAA,SAAA,OAAA,iBAAA,YAAA;AACP,KAAE,KAAK;IAAE,OAAK;IAAA,OAAA;IAAA,CAAA;;;CAGtB,MAAM,cAAS,MAAO;;AAEpB,IAAA,OAAA;GACM,OAAI;GACJ,OAAA;GACN,OAAA;GACG,CAAC;;WAEJ,EAAA,WAAA;EAAA,GAAA,SAAA;EAAA,GAAA,SAAA;EAAA,EAAA;EAAA,EAAA,UAAA;GAAA,MAAA;GAAA,GAAA;GAAA,GAAA;GAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,gBAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,UAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,eAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,YAAA,CAAA;EAAA,CAAA,CAAA"}
|
|
@@ -3,67 +3,44 @@ import { BlurFilter } from "pixi.js";
|
|
|
3
3
|
//#region src/components/prebuilt/light-halo.ce
|
|
4
4
|
function component($$props) {
|
|
5
5
|
useProps($$props);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _a;
|
|
21
|
-
return (_a = opacityVariation === null || opacityVariation === void 0 ? void 0 : opacityVariation()) !== null && _a !== void 0 ? _a : .3;
|
|
22
|
-
});
|
|
23
|
-
var getSizeSpeed = computed(function() {
|
|
24
|
-
var _a;
|
|
25
|
-
return (_a = sizeSpeed === null || sizeSpeed === void 0 ? void 0 : sizeSpeed()) !== null && _a !== void 0 ? _a : .002;
|
|
26
|
-
});
|
|
27
|
-
var getOpacitySpeed = computed(function() {
|
|
28
|
-
var _a;
|
|
29
|
-
return (_a = opacitySpeed === null || opacitySpeed === void 0 ? void 0 : opacitySpeed()) !== null && _a !== void 0 ? _a : .003;
|
|
30
|
-
});
|
|
31
|
-
var getLightColor = computed(function() {
|
|
32
|
-
var _a;
|
|
33
|
-
return (_a = lightColor === null || lightColor === void 0 ? void 0 : lightColor()) !== null && _a !== void 0 ? _a : 16777130;
|
|
34
|
-
});
|
|
35
|
-
var time = signal(0);
|
|
36
|
-
var currentRadius = computed(function() {
|
|
37
|
-
var t = time();
|
|
38
|
-
var base = getBaseRadius();
|
|
39
|
-
var variation = getRadiusVariation();
|
|
40
|
-
var speed = getSizeSpeed();
|
|
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();
|
|
41
20
|
return base + (Math.sin(t * speed) + Math.sin(t * speed * 1.5) * .5) / 1.5 * variation;
|
|
42
21
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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;
|
|
50
29
|
return Math.max(0, Math.min(1, base + fade * variation + flicker));
|
|
51
30
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
var blurFilter = new BlurFilter({
|
|
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({
|
|
60
37
|
strength: 20,
|
|
61
38
|
quality: 3
|
|
62
39
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
40
|
+
const drawHalo = (g) => {
|
|
41
|
+
const radius = currentRadius();
|
|
42
|
+
const opacity = currentOpacity();
|
|
43
|
+
const color = getLightColor();
|
|
67
44
|
if (opacity <= 0 || radius <= 0) return;
|
|
68
45
|
g.blendMode = "add";
|
|
69
46
|
g.filters = [blurFilter];
|
|
@@ -78,10 +55,8 @@ function component($$props) {
|
|
|
78
55
|
alpha: opacity * .5
|
|
79
56
|
});
|
|
80
57
|
};
|
|
81
|
-
tick(
|
|
82
|
-
time.update(
|
|
83
|
-
return t + 1;
|
|
84
|
-
});
|
|
58
|
+
tick(() => {
|
|
59
|
+
time.update((t) => t + 1);
|
|
85
60
|
});
|
|
86
61
|
return h(Container, {
|
|
87
62
|
x: position.x,
|
|
@@ -1 +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;AACqB,UAAA,QAAA;CAEhB,
|
|
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;AACqB,UAAA,QAAA;CAEhB,MAAM,EAAG,QAAQ,YAAO,iBAAsB,aAAa,kBAAI,WAAA,cAAA,eADpE,eAAA,QACoE,EAAA;CACtE,MAAG,gBAAmB,eAAa,cAAe,IAAG,GAAI;CACzD,MAAE,qBAAA,eAAA,mBAAA,IAAA,GAAA;CACF,MAAI,iBAAkB,eAAa,eAAe,IAAA,GAAQ;CAC1D,MAAI,sBAAwB,eAAU,oBAAyB,IAAI,GAAI;CACvE,MAAI,eAAiB,eAAe,aAAE,IAAe,KAAI;CACzD,MAAI,kBAAiB,eAAiB,gBAAe,IAAK,KAAO;CACjE,MAAI,gBAAiB,eAAgB,cAAC,IAAiB,SAAG;CAC1D,MAAI,OAAS,OAAO,EAAC;CACrB,MAAI,gBAAiB,eAAgB;EACjC,MAAA,IAAU,MAAM;EAClB,MAAA,OAAA,eAAA;EACF,MAAO,YAAA,oBAAA;EACL,MAAO,QAAA,cAAA;AAKP,SAAS,QAHM,KAAA,IAAA,IAAA,MAEC,GADL,KAAA,IAAA,IAAA,QAAA,IAAA,GAAA,MACK,MACP;GACT;CACF,MAAE,iBAAA,eAAA;EACE,MAAA,IAAA,MAAa;;EAEb,MAAM,YAAY,qBAAA;EACnB,MAAM,QAAK,iBAAQ;;EAItB,MAAM,WAAA,KAAoB,QAAC,GAAU,MAAK;AAC1C,SAAM,KAAA,IAAc,GAAG,KAAA,IAAS,GAAG,OAAG,OAAY,YAAW,QAAA,CAAA;GAC7D;CACA,MAAM,SAAA,OAAe;CACrB,MAAM,WAAA,gBAA2B;EACjC,GAAM,QAAA,CAAA,IAAc;;EAEnB,EAAE;CACH,MAAG,aAAU,IAAA,WAAA;EAAA,UAAA;EAAA,SAAA;EAAA,CAAA;CACb,MAAM,YAAY,MAAI;;EAElB,MAAK,UAAW,gBAAa;EACjC,MAAU,QAAG,eAAS;kCAEpB;AAEC,IAAA,YAAc;AAEjB,IAAM,UAAA,CAAA,WAAgB;AAGpB,IAAA,OAAM,GAAA,GAAW,OAAC;AAClB,IAAA,KAAM;GACP;GACI,OAAQ;GACX,CAAA;AAEA,IAAA,OAAM,GAAA,GAAA,SAAiB,GAAO;AAC/B,IAAA,KAAA;GACO,OAAO;GACb,OAAA,UAAA;;;AAGF,YAAW;AACR,OAAA,QAAW,MAAO,IAAA,EAAA;GACnB;AAEM,QADY,EAAE,WAAW;EAAE,GAAG,SAAA;EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,UAAA,EAAA,MAAA,UAAA,CAAA,CACpB"}
|
|
@@ -8,31 +8,23 @@ import { delay } from "@rpgjs/common";
|
|
|
8
8
|
function component($$props) {
|
|
9
9
|
useProps($$props);
|
|
10
10
|
useDefineProps($$props);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return Object.values(guiService.gui()).filter(
|
|
16
|
-
return !gui.attachToSprite;
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
var worldWidth = computed(function() {
|
|
20
|
-
var _a;
|
|
21
|
-
return (_a = sceneData()) === null || _a === void 0 ? void 0 : _a.width;
|
|
22
|
-
});
|
|
23
|
-
var worldHeight = computed(function() {
|
|
24
|
-
var _a;
|
|
25
|
-
return (_a = sceneData()) === null || _a === void 0 ? void 0 : _a.height;
|
|
11
|
+
const engine = inject(RpgClientEngine);
|
|
12
|
+
const guiService = inject(RpgGui);
|
|
13
|
+
const sceneData = engine.sceneMap.data;
|
|
14
|
+
const guiList = computed(() => {
|
|
15
|
+
return Object.values(guiService.gui()).filter((gui) => !gui.attachToSprite);
|
|
26
16
|
});
|
|
27
|
-
|
|
17
|
+
const worldWidth = computed(() => sceneData()?.width);
|
|
18
|
+
const worldHeight = computed(() => sceneData()?.height);
|
|
19
|
+
effect(() => {
|
|
28
20
|
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.");
|
|
29
21
|
});
|
|
30
|
-
|
|
31
|
-
delay(
|
|
22
|
+
const onGuiFinish = (gui, data) => {
|
|
23
|
+
delay(() => {
|
|
32
24
|
guiService.guiClose(gui.name, data);
|
|
33
25
|
});
|
|
34
26
|
};
|
|
35
|
-
|
|
27
|
+
const onGuiInteraction = (gui, name, data) => {
|
|
36
28
|
guiService.guiInteraction(gui.name, name, data);
|
|
37
29
|
};
|
|
38
30
|
return h(Canvas, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.ce.js","names":[],"sources":["../../../src/components/scenes/canvas.ce"],"sourcesContent":["<Canvas width={engine.width} height={engine.height}>\n <Viewport worldWidth worldHeight clamp sortableChildren={true}>\n @if (sceneData) {\n <SceneMap />\n }\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 { signal, 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\n const engine = inject(RpgClientEngine);\n const guiService = inject(RpgGui);\n const sceneData = engine.sceneMap.data\n const guiList = computed(() => {\n return Object.values(guiService.gui()).filter((gui) => !gui.attachToSprite)\n })\n const worldWidth = computed(() => sceneData()?.width)\n const worldHeight = computed(() => sceneData()?.height)\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</script>\n"],"mappings":";;;;;;;AAaM,SAAS,UAAA,SAAA;AACP,UAAA,QAAA;AACS,gBAAA,QAAA;CACf,
|
|
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 (sceneData) {\n <SceneMap />\n }\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 { signal, 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\n const engine = inject(RpgClientEngine);\n const guiService = inject(RpgGui);\n const sceneData = engine.sceneMap.data\n const guiList = computed(() => {\n return Object.values(guiService.gui()).filter((gui) => !gui.attachToSprite)\n })\n const worldWidth = computed(() => sceneData()?.width)\n const worldHeight = computed(() => sceneData()?.height)\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</script>\n"],"mappings":";;;;;;;AAaM,SAAS,UAAA,SAAA;AACP,UAAA,QAAA;AACS,gBAAA,QAAA;CACf,MAAA,SAAA,OAAA,gBAAA;CACF,MAAE,aAAM,OAAA,OAAA;;CAER,MAAC,UAAM,eAAA;AACL,SAAS,OAAO,OAAC,WAAiB,KAAE,CAAI,CAAC,QAAC,QAAa,CAAA,IAAA,eAAA;GACvD;CACF,MAAE,aAAS,eAAuB,WAAO,EAAA,MAAA;CACzC,MAAE,cAAgB,eAAiB,WAAE,EAAA,OAAA;AACrC,cAAW;AACT,MAAM,WAAW,IAAI,CAAC,WAAQ,CAAA,UAAA,OAAA,IAAA,MAAA,oHAAA;GAG9B;CACF,MAAE,eAAkB,KAAM,SAAS;AACjC,cAAc;AACZ,cAAc,SAAO,IAAA,MAAW,KAAO;IACxC;;CAEH,MAAE,oBAAoB,KAAS,MAAM,SAAS;;;AAWzC,QALF,EAAA,QAAA;EAAA,OAAA,OAAA;EAAA,QAAA,OAAA;EAAA,EAAA,CAAA,EAAA,UAAA;EAAA;EAAA;EAAA,OAAA,EAFC,WAAS,OAEV;EAAA,kBAAA;EAAA,EAAA,KAAA,iBAAA,EAAA,YAAA,CAAA,CAAA,EAAA,KAAA,UAAA,QAAA,EAAA,WAAA,EAAA,SAAA,QAAA,EAAA,KAAA,IAAA,eAAA,EAAA,IAAA,WAAA;EAAA,MAAA,IAAA;EAAA,cAAA,IAAA;EAAA,WAAA,SAAA;;;EAEK,gBAAoB,MAAO,SAAE;AACzB,oBAAI,KAAA,MAAA,KAAA;;EACV,CAAA,CAAA,CAAU,CAAC,CAAA,CACZ"}
|