@rpgjs/client 5.0.0-beta.10 → 5.0.0-beta.12
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 +21 -0
- package/dist/Game/AnimationManager.d.ts +1 -0
- package/dist/Game/AnimationManager.js +3 -0
- package/dist/Game/AnimationManager.js.map +1 -1
- package/dist/Game/ClientVisuals.d.ts +61 -0
- package/dist/Game/ClientVisuals.js +96 -0
- package/dist/Game/ClientVisuals.js.map +1 -0
- package/dist/Game/ClientVisuals.spec.d.ts +1 -0
- package/dist/Game/EventComponentResolver.d.ts +16 -0
- package/dist/Game/EventComponentResolver.js +52 -0
- package/dist/Game/EventComponentResolver.js.map +1 -0
- package/dist/Game/EventComponentResolver.spec.d.ts +1 -0
- package/dist/Game/Map.js +9 -0
- package/dist/Game/Map.js.map +1 -1
- package/dist/Game/Object.js +2 -2
- package/dist/Game/Object.js.map +1 -1
- package/dist/Game/Object.spec.d.ts +1 -0
- package/dist/Game/ProjectileManager.d.ts +98 -0
- package/dist/Game/ProjectileManager.js +196 -0
- package/dist/Game/ProjectileManager.js.map +1 -0
- package/dist/Game/ProjectileManager.spec.d.ts +1 -0
- package/dist/RpgClient.d.ts +117 -13
- package/dist/RpgClientEngine.d.ts +82 -4
- package/dist/RpgClientEngine.js +296 -51
- package/dist/RpgClientEngine.js.map +1 -1
- package/dist/components/animations/fx.ce.js +58 -0
- package/dist/components/animations/fx.ce.js.map +1 -0
- package/dist/components/animations/hit.ce.js.map +1 -1
- package/dist/components/animations/index.d.ts +1 -0
- package/dist/components/animations/index.js +3 -1
- package/dist/components/animations/index.js.map +1 -1
- package/dist/components/character.ce.js +140 -40
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/dynamics/bar.ce.js +4 -3
- package/dist/components/dynamics/bar.ce.js.map +1 -1
- package/dist/components/dynamics/image.ce.js +2 -1
- package/dist/components/dynamics/image.ce.js.map +1 -1
- package/dist/components/dynamics/shape.ce.js +3 -2
- package/dist/components/dynamics/shape.ce.js.map +1 -1
- package/dist/components/dynamics/text.ce.js +9 -8
- package/dist/components/dynamics/text.ce.js.map +1 -1
- package/dist/components/gui/dialogbox/index.ce.js +3 -2
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
- package/dist/components/gui/gameover.ce.js +3 -2
- package/dist/components/gui/gameover.ce.js.map +1 -1
- package/dist/components/gui/hud/hud.ce.js.map +1 -1
- package/dist/components/gui/menu/equip-menu.ce.js +2 -1
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/exit-menu.ce.js +2 -1
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/items-menu.ce.js +3 -2
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/main-menu.ce.js +3 -2
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
- package/dist/components/gui/notification/notification.ce.js.map +1 -1
- package/dist/components/gui/save-load.ce.js +2 -1
- package/dist/components/gui/save-load.ce.js.map +1 -1
- package/dist/components/gui/shop/shop.ce.js +3 -2
- package/dist/components/gui/shop/shop.ce.js.map +1 -1
- package/dist/components/gui/title-screen.ce.js +3 -2
- package/dist/components/gui/title-screen.ce.js.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +1 -0
- package/dist/components/player-components.ce.js +11 -10
- package/dist/components/player-components.ce.js.map +1 -1
- package/dist/components/prebuilt/hp-bar.ce.js +4 -3
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
- package/dist/components/prebuilt/light-halo.ce.js +2 -1
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js +12 -4
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/draw-map.ce.js +6 -3
- package/dist/components/scenes/draw-map.ce.js.map +1 -1
- package/dist/components/scenes/event-layer.ce.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +10 -5
- package/dist/module.js +18 -0
- package/dist/module.js.map +1 -1
- package/dist/services/actionInput.d.ts +14 -0
- package/dist/services/actionInput.js +59 -0
- package/dist/services/actionInput.js.map +1 -0
- package/dist/services/actionInput.spec.d.ts +1 -0
- package/dist/services/mmorpg-connection.d.ts +5 -0
- package/dist/services/mmorpg-connection.js +50 -0
- package/dist/services/mmorpg-connection.js.map +1 -0
- package/dist/services/mmorpg-connection.spec.d.ts +1 -0
- package/dist/services/mmorpg.d.ts +10 -4
- package/dist/services/mmorpg.js +48 -30
- package/dist/services/mmorpg.js.map +1 -1
- package/dist/services/pointerContext.d.ts +11 -0
- package/dist/services/pointerContext.js +48 -0
- package/dist/services/pointerContext.js.map +1 -0
- package/dist/services/pointerContext.spec.d.ts +1 -0
- package/dist/services/standalone-message.d.ts +1 -0
- package/dist/services/standalone-message.js +9 -0
- package/dist/services/standalone-message.js.map +1 -0
- package/dist/services/standalone.d.ts +3 -1
- package/dist/services/standalone.js +34 -15
- package/dist/services/standalone.js.map +1 -1
- package/dist/services/standalone.spec.d.ts +1 -0
- package/dist/utils/mapId.d.ts +1 -0
- package/dist/utils/mapId.js +6 -0
- package/dist/utils/mapId.js.map +1 -0
- package/package.json +7 -7
- package/src/Game/AnimationManager.ts +4 -0
- package/src/Game/ClientVisuals.spec.ts +56 -0
- package/src/Game/ClientVisuals.ts +184 -0
- package/src/Game/EventComponentResolver.spec.ts +84 -0
- package/src/Game/EventComponentResolver.ts +74 -0
- package/src/Game/Map.ts +10 -0
- package/src/Game/Object.spec.ts +46 -0
- package/src/Game/Object.ts +2 -2
- package/src/Game/ProjectileManager.spec.ts +449 -0
- package/src/Game/ProjectileManager.ts +346 -0
- package/src/RpgClient.ts +130 -15
- package/src/RpgClientEngine.ts +405 -69
- package/src/components/animations/fx.ce +101 -0
- package/src/components/animations/index.ts +4 -2
- package/src/components/character.ce +185 -40
- package/src/components/dynamics/bar.ce +4 -3
- package/src/components/dynamics/image.ce +2 -1
- package/src/components/dynamics/shape.ce +3 -2
- package/src/components/dynamics/text.ce +9 -8
- package/src/components/gui/dialogbox/index.ce +3 -2
- package/src/components/gui/gameover.ce +2 -1
- package/src/components/gui/menu/equip-menu.ce +2 -1
- package/src/components/gui/menu/exit-menu.ce +2 -1
- package/src/components/gui/menu/items-menu.ce +3 -2
- package/src/components/gui/menu/main-menu.ce +2 -1
- package/src/components/gui/save-load.ce +2 -1
- package/src/components/gui/shop/shop.ce +3 -2
- package/src/components/gui/title-screen.ce +2 -1
- package/src/components/index.ts +2 -1
- package/src/components/player-components.ce +11 -10
- package/src/components/prebuilt/hp-bar.ce +4 -3
- package/src/components/prebuilt/light-halo.ce +2 -2
- package/src/components/scenes/canvas.ce +10 -2
- package/src/components/scenes/draw-map.ce +17 -3
- package/src/index.ts +4 -0
- package/src/module.ts +24 -0
- package/src/services/actionInput.spec.ts +155 -0
- package/src/services/actionInput.ts +120 -0
- package/src/services/mmorpg-connection.spec.ts +99 -0
- package/src/services/mmorpg-connection.ts +69 -0
- package/src/services/mmorpg.ts +60 -34
- package/src/services/pointerContext.spec.ts +36 -0
- package/src/services/pointerContext.ts +84 -0
- package/src/services/standalone-message.ts +7 -0
- package/src/services/standalone.spec.ts +34 -0
- package/src/services/standalone.ts +42 -12
- package/src/utils/mapId.ts +2 -0
|
@@ -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":"
|
|
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 import { getKeyboardControlBind } from \"../../services/actionInput\";\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: getKeyboardControlBind(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":";;;;;;;AAaM,SAAS,UAAS,SAAQ;CACT,SAAM,OAAU;CAC/B,MAAM,cAAU,eAAe,OAAA;CAC/B,MAAM,SAAS,OAAO,eAAa;CAC3C,MAAM,aAAa,OAAG,MAAM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AAA,EAAA,OAAA,uCAAA;CAAA,GAAA;EAAA,EAAA,YAAA;GAAA,SAAA;GAAA,OAAA,EAAA,OAAA,4CAAA;EAAA,GAAA,CAAA,EAAA,YAAA;GAAA,SAAA;GAAA,OAAA,EAAA,OAAA,4BAAA;GAAA,aAAA,eAAA,UAAA,CAAA;EAAA,CAAA,GAAA,KAAA,eAAA,aAAA,CAAA,SAAA,EAAA,YAAA;GAAA,SAAA;GAAA,OAAA,EAAA,OAAA,+BAAA;GAAA,aAAA,eAAA,aAAA,CAAA;EAAA,CAAA,CAAA,CAAA,CAAA;EAAA,EAAA,YAAA;GAAA,UAAA;GAAA;EAAA,GAAA,EAAA,YAAA;GAAA,SAAA;GAAA,OAAA,EAAA,OAAA,yDAAA;EAAA,GAAA,KAAA,eAAA,UAAA,CAAA,IAAA,OAAA,UAAA,EAAA,YAAA;GAAA,SAAA;GAAA,OAAA;IAAA,OAAA,CAAA,oBAAA,gBAAA,EAAA,UAAA,gBAAA,KAAA,EAAA,EAAA,CAAA;IAAA,iBAAA,eAAA,cAAA,MAAA,QAAA,SAAA,OAAA;IAAA,UAAA;IAAA,OAAA,YAAA,KAAA;GAAA;GAAA,aAAA,MAAA;EAAA,CAAA,CAAA,CAAA,CAAA;EAAA,KAAA,eAAA,YAAA,CAAA,SAAA,EAAA,YAAA;GAAA,SAAA;GAAA,OAAA,EAAA,OAAA,8BAAA;GAAA,aAAA,eAAA,YAAA,CAAA;EAAA,CAAA,CAAA;CAAA,CAAA,CACK;AACR;AAEA,IAAM,iBAAa"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as EventLayerComponent } from './scenes/event-layer.ce';
|
|
2
|
+
import { default as SceneMap } from './scenes/draw-map.ce';
|
|
2
3
|
import { default as CharacterComponent } from './character.ce';
|
|
3
4
|
export { HpBar } from './prebuilt';
|
|
4
|
-
export { EventLayerComponent, CharacterComponent };
|
|
5
|
+
export { EventLayerComponent, SceneMap, CharacterComponent };
|
package/dist/components/index.js
CHANGED
|
@@ -7,16 +7,17 @@ import { Container, computed, h, loop, useDefineProps, useProps } from "canvasen
|
|
|
7
7
|
function component($$props) {
|
|
8
8
|
useProps($$props);
|
|
9
9
|
const { object, position, graphicBounds } = useDefineProps($$props)({ position: { default: "top" } });
|
|
10
|
+
const sprite = object();
|
|
10
11
|
const client = inject(RpgClientEngine);
|
|
11
12
|
const warnedComponents = /* @__PURE__ */ new Set();
|
|
12
13
|
const readPosition = computed(() => position?.() ?? "top");
|
|
13
14
|
const componentSource = computed(() => {
|
|
14
15
|
switch (readPosition()) {
|
|
15
|
-
case "bottom": return
|
|
16
|
-
case "center": return
|
|
17
|
-
case "left": return
|
|
18
|
-
case "right": return
|
|
19
|
-
default: return
|
|
16
|
+
case "bottom": return sprite.componentsBottom?.();
|
|
17
|
+
case "center": return sprite.componentsCenter?.();
|
|
18
|
+
case "left": return sprite.componentsLeft?.();
|
|
19
|
+
case "right": return sprite.componentsRight?.();
|
|
20
|
+
default: return sprite.componentsTop?.();
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
23
|
const componentData = computed(() => {
|
|
@@ -38,14 +39,14 @@ function component($$props) {
|
|
|
38
39
|
});
|
|
39
40
|
const layout = computed(() => componentData()?.layout ?? {});
|
|
40
41
|
const rows = computed(() => componentData()?.components ?? []);
|
|
41
|
-
const hitbox =
|
|
42
|
+
const hitbox = sprite.hitbox;
|
|
42
43
|
const toNumber = (value, fallback = 0) => {
|
|
43
|
-
const resolved = resolveDynamicValue(value,
|
|
44
|
+
const resolved = resolveDynamicValue(value, sprite);
|
|
44
45
|
const num = typeof resolved === "number" ? resolved : parseFloat(resolved);
|
|
45
46
|
return Number.isFinite(num) ? num : fallback;
|
|
46
47
|
};
|
|
47
48
|
const estimateTextWidth = (value, style = {}) => {
|
|
48
|
-
const text = String(resolveDynamicValue(value ?? "",
|
|
49
|
+
const text = String(resolveDynamicValue(value ?? "", sprite) ?? "");
|
|
49
50
|
const fontSize = toNumber(style.fontSize, 12);
|
|
50
51
|
return Math.max(1, Math.ceil(text.length * fontSize * .6));
|
|
51
52
|
};
|
|
@@ -139,7 +140,7 @@ function component($$props) {
|
|
|
139
140
|
}
|
|
140
141
|
entries.push({
|
|
141
142
|
component,
|
|
142
|
-
props: resolveDynamicProps(getComponentProps(definition),
|
|
143
|
+
props: resolveDynamicProps(getComponentProps(definition), sprite),
|
|
143
144
|
width: cell.width,
|
|
144
145
|
height: cell.height
|
|
145
146
|
});
|
|
@@ -177,7 +178,7 @@ function component($$props) {
|
|
|
177
178
|
justifyContent: "center",
|
|
178
179
|
alignItems: "center"
|
|
179
180
|
}, h(entry.component, {
|
|
180
|
-
object,
|
|
181
|
+
object: sprite,
|
|
181
182
|
...entry.props
|
|
182
183
|
}))))));
|
|
183
184
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player-components.ce.js","names":[],"sources":["../../src/components/player-components.ce"],"sourcesContent":["<Container\n x={blockPosition().x}\n y={blockPosition().y}\n width={blockSize().width}\n height={blockSize().height}\n minWidth={blockSize().width}\n minHeight={blockSize().height}\n display=\"flex\"\n flexDirection=\"column\"\n justifyContent=\"center\"\n alignItems=\"center\"\n rowGap={gap().row}\n>\n @for (row of renderedRows) {\n <Container\n width=\"100%\"\n height={row.height}\n display=\"flex\"\n flexDirection=\"row\"\n justifyContent=\"center\"\n alignItems=\"center\"\n columnGap={gap().column}\n >\n @for (entry of row.entries) {\n <Container\n width={entry.width}\n height={entry.height}\n display=\"flex\"\n justifyContent=\"center\"\n alignItems=\"center\"\n >\n <entry.component object ...entry.props />\n </Container>\n }\n </Container>\n }\n</Container>\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { inject } from \"../core/inject\";\nimport { resolveDynamicProps, resolveDynamicValue } from \"./dynamics/parse-value\";\nimport {\n computeBlockPosition,\n computeBlockSize,\n estimateComponentSize,\n getComponentId,\n getComponentProps\n} from \"./player-components-utils\";\n\nconst { object, position, graphicBounds } = defineProps({\n position: {\n default: 'top'\n }\n});\n\nconst client = inject(RpgClientEngine);\nconst warnedComponents = new Set();\n\nconst readPosition = computed(() => position?.() ?? 'top');\n\nconst componentSource = computed(() => {\n switch (readPosition()) {\n case 'bottom':\n return
|
|
1
|
+
{"version":3,"file":"player-components.ce.js","names":[],"sources":["../../src/components/player-components.ce"],"sourcesContent":["<Container\n x={blockPosition().x}\n y={blockPosition().y}\n width={blockSize().width}\n height={blockSize().height}\n minWidth={blockSize().width}\n minHeight={blockSize().height}\n display=\"flex\"\n flexDirection=\"column\"\n justifyContent=\"center\"\n alignItems=\"center\"\n rowGap={gap().row}\n>\n @for (row of renderedRows) {\n <Container\n width=\"100%\"\n height={row.height}\n display=\"flex\"\n flexDirection=\"row\"\n justifyContent=\"center\"\n alignItems=\"center\"\n columnGap={gap().column}\n >\n @for (entry of row.entries) {\n <Container\n width={entry.width}\n height={entry.height}\n display=\"flex\"\n justifyContent=\"center\"\n alignItems=\"center\"\n >\n <entry.component object={sprite} ...entry.props />\n </Container>\n }\n </Container>\n }\n</Container>\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { inject } from \"../core/inject\";\nimport { resolveDynamicProps, resolveDynamicValue } from \"./dynamics/parse-value\";\nimport {\n computeBlockPosition,\n computeBlockSize,\n estimateComponentSize,\n getComponentId,\n getComponentProps\n} from \"./player-components-utils\";\n\nconst { object, position, graphicBounds } = defineProps({\n position: {\n default: 'top'\n }\n});\nconst sprite = object();\n\nconst client = inject(RpgClientEngine);\nconst warnedComponents = new Set();\n\nconst readPosition = computed(() => position?.() ?? 'top');\n\nconst componentSource = computed(() => {\n switch (readPosition()) {\n case 'bottom':\n return sprite.componentsBottom?.();\n case 'center':\n return sprite.componentsCenter?.();\n case 'left':\n return sprite.componentsLeft?.();\n case 'right':\n return sprite.componentsRight?.();\n case 'top':\n default:\n return sprite.componentsTop?.();\n }\n});\n\nconst componentData = computed(() => {\n const value = componentSource();\n if (!value) {\n return { components: [], layout: {} };\n }\n\n if (typeof value !== 'string') {\n return value;\n }\n\n try {\n return JSON.parse(value);\n } catch (error) {\n if (typeof process === 'undefined' || process.env?.NODE_ENV !== 'production') {\n console.warn('[RPGJS] Invalid server sprite component payload', error);\n }\n return { components: [], layout: {} };\n }\n});\n\nconst layout = computed(() => componentData()?.layout ?? {});\nconst rows = computed(() => componentData()?.components ?? []);\nconst hitbox = sprite.hitbox;\n\nconst toNumber = (value, fallback = 0) => {\n const resolved = resolveDynamicValue(value, sprite);\n const num = typeof resolved === 'number' ? resolved : parseFloat(resolved);\n return Number.isFinite(num) ? num : fallback;\n};\n\nconst estimateTextWidth = (value, style = {}) => {\n const text = String(resolveDynamicValue(value ?? '', sprite) ?? '');\n const fontSize = toNumber(style.fontSize, 12);\n return Math.max(1, Math.ceil(text.length * fontSize * 0.6));\n};\n\nconst rowMetrics = computed(() => {\n return rows().map((row) => {\n const cells = row.map((definition) => {\n const intrinsic = estimateComponentSize(definition, { toNumber, estimateTextWidth });\n return {\n definition,\n width: intrinsic.width,\n height: intrinsic.height\n };\n });\n\n return {\n cells,\n width: cells.reduce((sum, cell) => sum + cell.width, 0),\n height: cells.reduce((max, cell) => Math.max(max, cell.height), 0)\n };\n });\n});\n\nconst gap = computed(() => ({\n row: toNumber(layout().rowGap ?? layout().gap, 0),\n column: toNumber(layout().columnGap ?? layout().gap, 0)\n}));\n\nconst fallbackBounds = computed(() => {\n const box = hitbox();\n const width = box?.w ?? 0;\n const height = box?.h ?? 0;\n\n return {\n left: 0,\n top: 0,\n right: width,\n bottom: height,\n width,\n height,\n centerX: width / 2,\n centerY: height / 2\n };\n});\n\nconst bounds = computed(() => {\n const resolvedBounds = typeof graphicBounds === 'function' ? graphicBounds() : undefined;\n return resolvedBounds ?? fallbackBounds();\n});\n\nconst blockSize = computed(() => {\n const box = hitbox() ?? { w: 0, h: 0 };\n const graphic = bounds();\n return computeBlockSize({\n position: readPosition(),\n layout: layout(),\n rowMetrics: rowMetrics(),\n gap: gap(),\n graphic,\n hitbox: box\n });\n});\n\nconst blockPosition = computed(() => {\n const box = hitbox() ?? { w: 0, h: 0 };\n const graphic = bounds();\n return computeBlockPosition({\n position: readPosition(),\n size: blockSize(),\n layout: layout(),\n graphic,\n hitbox: box\n });\n});\n\nconst warnMissingComponent = (id) => {\n if (!id || warnedComponents.has(id)) return;\n if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'production') return;\n warnedComponents.add(id);\n console.warn(`[RPGJS] Server sprite component \"${id}\" is not registered on the client.`);\n};\n\nconst renderedRows = computed(() => {\n return rowMetrics().map((row) => {\n const entries = [];\n\n row.cells.forEach((cell) => {\n const definition = cell.definition;\n const id = getComponentId(definition);\n const component = client.getSpriteComponent(id);\n\n if (!component) {\n warnMissingComponent(id);\n return;\n }\n\n entries.push({\n component,\n props: resolveDynamicProps(getComponentProps(definition), sprite),\n width: cell.width,\n height: cell.height\n });\n });\n\n return {\n height: row.height,\n entries\n };\n });\n});\n</script>\n"],"mappings":";;;;;;AAUE,SAAY,UAAM,SAAA;CACD,SAAA,OAAA;CAEX,MAAM,EAAC,QAAA,UAAc,kBAD7B,eAAA,OAC6B,EAAA,EACzB,UAAC,EACC,SAAW,MACb,EACJ,CAAC;CACD,MAAM,SAAA,OAAe;CACrB,MAAM,SAAA,OAAgB,eAAM;CAC5B,MAAM,mCAAkB,IAAA,IAAA;CACxB,MAAM,eAAe,eAAQ,WAAA,KAAA,KAAA;CAC7B,MAAI,kBAAA,eAAA;EACA,QAAQ,aAAa,GAArB;GACI,KAAC,UACC,OAAO,OAAM,mBAAK;GACpB,KAAE,UACA,OAAS,OAAI,mBAAA;GACf,KAAE,QACA,OAAA,OAAY,iBAAM;GACpB,KAAA,SACG,OAAM,OAAS,kBAAkB;GAEtC,SACA,OAAS,OAAA,gBAAA;EACb;CACF,CAAC;;EAEA,MAAM,QAAA,gBAAA;EACP,IAAQ,CAAC,OACD,OAAC;GAAA,YAAkB,CAAA;GAAM,Q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ACnB,OAAA,KAAA;KACD,QAAA,KAAA;;GAEI,CAAA;GACE,OAAA;IACC,QAAA,IAAe;IACtB;;EAEF,CAAK;CACL,CAAC;CAEO,OADU,EAAA,WAAQ;EAAA,GAAA,eAAA,cAAA,EAAA,CAAA;EAAA,GAAA,eAAA,cAAA,EAAA,CAAA;EAAA,OAAA,eAAA,UAAA,EAAA,KAAA;EAAA,QAAA,eAAA,UAAA,EAAA,MAAA;EAAA,UAAA,eAAA,UAAA,EAAA,KAAA;EAAA,WAAA,eAAA,UAAA,EAAA,MAAA;EAAA,SAAA;EAAA,eAAA;EAAA,gBAAA;EAAA,YAAA;EAAA,QAAA,eAAA,IAAA,EAAA,GAAA;CAAA,GAAA,KAAA,eAAA,QAAA,EAAA,WAAA;EAAA,OAAA;EAAA,QAAA,IAAA;EAAA,SAAA;EAAA,eAAA;EAAA,gBAAA;EAAA,YAAA;EAAA,WAAA,eAAA,IAAA,EAAA,MAAA;CAAA,GAAA,KAAA,IAAA,UAAA,UAAA,EAAA,WAAA;EAAA,OAAA,MAAA;EAAA,QAAA,MAAA;EAAA,SAAA;EAAA,gBAAA;EAAA,YAAA;CAAA,GAAA,EAAA,MAAA,WAAA;EAAA,QAAA;EAAA,GAAA,MAAA;CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACjB;AACL;AAEA,IAAA,iBAAwB"}
|
|
@@ -3,6 +3,7 @@ import { Container, Graphics, animatedSignal, computed, effect, h, useDefineProp
|
|
|
3
3
|
function component($$props) {
|
|
4
4
|
useProps($$props);
|
|
5
5
|
const { object } = useDefineProps($$props)();
|
|
6
|
+
const sprite = object();
|
|
6
7
|
const barWidth = 50;
|
|
7
8
|
const barHeight = 8;
|
|
8
9
|
const borderRadius = 4;
|
|
@@ -14,12 +15,12 @@ function component($$props) {
|
|
|
14
15
|
const maxFillWidth = barWidth - padding * 2;
|
|
15
16
|
const fillHeight = barHeight - padding * 2;
|
|
16
17
|
const highlightHeight = Math.floor(fillHeight / 2);
|
|
17
|
-
const hitbox =
|
|
18
|
+
const hitbox = sprite.hitbox;
|
|
18
19
|
const currentHp = computed(() => {
|
|
19
|
-
return
|
|
20
|
+
return sprite.hpSignal?.() ?? 0;
|
|
20
21
|
});
|
|
21
22
|
const maxHp = computed(() => {
|
|
22
|
-
return (
|
|
23
|
+
return (sprite._param?.() ?? {}).maxHp ?? 100;
|
|
23
24
|
});
|
|
24
25
|
const hpPercent = computed(() => {
|
|
25
26
|
const max = maxHp();
|
|
@@ -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 =
|
|
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();\nconst sprite = object();\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 = sprite.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 sprite.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 = sprite._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,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EAEI,EAAA,UAAY,GAAE,GAAA,UAAA,WAAA,YAAA;EAClB,EAAM,KAAA;GAAA,OAAc;GAAQ,OAAA;EAAA,CAAA;;CAE5B,MAAM,kBAAgB,MAAA;EACnB,EAAA,UAAW,GAAA,GAAA,UAAA,WAAA,YAAA;EACV,EAAE,KAAK;GAAE,OAAO;GAAE,OAAA;EAAA,CAAA;;CAEtB,MAAI,YAAa,MAAO;EACxB,MAAM,QAAY,UAAG;;GAEb,EAAC,UAAQ,SAAA,SAAA,OAAA,YAAA,WAAA;GACX,EAAA,KAAA,EAAW,OAAE,WAAa,EAAA,CAAA;;CAEhC;CACA,MAAM,iBAAiB,MAAM;;EAEzB,IAAI,QAAQ,GAAG;GAChB,EAAA,UAAY,SAAA,SAAA,OAAA,iBAAA,WAAA;GACP,EAAE,KAAK;IAAE,OAAK;IAAA,OAAA;GAAA,CAAA;;CAEtB;CACA,MAAM,cAAS,MAAO;;EAEpB,EAAA,OAAA;GACM,OAAI;GACJ,OAAA;GACN,OAAA;EACF,CAAK;CACL;WACE,EAAA,WAAA;EAAA,GAAA,SAAA;EAAA,GAAA,SAAA;CAAA,GAAA;EAAA,EAAA,UAAA;GAAA,MAAA;GAAA,GAAA;GAAA,GAAA;EAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,eAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,SAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,cAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,WAAA,CAAA;CAAA,CAAA,CAAA;AAEA;AAEC,IAAM,iBAAkB"}
|
|
@@ -4,6 +4,7 @@ import { BlurFilter } from "pixi.js";
|
|
|
4
4
|
function component($$props) {
|
|
5
5
|
useProps($$props);
|
|
6
6
|
const { object, baseRadius, radiusVariation, baseOpacity, opacityVariation, sizeSpeed, opacitySpeed, lightColor } = useDefineProps($$props)();
|
|
7
|
+
const sprite = object();
|
|
7
8
|
const getBaseRadius = computed(() => baseRadius?.() ?? 30);
|
|
8
9
|
const getRadiusVariation = computed(() => radiusVariation?.() ?? 10);
|
|
9
10
|
const getBaseOpacity = computed(() => baseOpacity?.() ?? .6);
|
|
@@ -28,7 +29,7 @@ function component($$props) {
|
|
|
28
29
|
const flicker = (Math.random() - .5) * .1;
|
|
29
30
|
return Math.max(0, Math.min(1, base + fade * variation + flicker));
|
|
30
31
|
});
|
|
31
|
-
const hitbox =
|
|
32
|
+
const hitbox = sprite.hitbox;
|
|
32
33
|
const position = computed(() => ({
|
|
33
34
|
x: hitbox().w / 2,
|
|
34
35
|
y: hitbox().h / 2
|
|
@@ -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 =
|
|
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();\nconst sprite = object();\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 = sprite.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"],"mappings":";;;AAQE,SAAA,UAAA,SAAA;CACqB,SAAA,OAAA;CAEhB,MAAM,EAAG,QAAQ,YAAO,iBAAsB,aAAa,kBAAI,WAAA,cAAA,eADpE,eAAA,OACoE,EAAA;CACtE,MAAG,SAAU,OAAS;CACtB,MAAE,gBAAA,eAAA,aAAA,KAAA,EAAA;CACF,MAAI,qBAAkB,eAAoB,kBAAgB,KAAA,EAAA;CAC1D,MAAI,iBAAiB,eAAiB,cAAc,KAAK,EAAA;CACzD,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GAAG,SAAA;EAAA,GAAA,SAAA;CAAA,GAAA,EAAA,UAAA,EAAA,MAAA,SAAA,CAAA,CACpB;AAChB;AAEA,IAAM,iBAAQ"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { inject } from "../../core/inject.js";
|
|
2
|
-
import __ce_component$1 from "./draw-map.ce.js";
|
|
3
2
|
import { RpgGui } from "../../Gui/Gui.js";
|
|
4
3
|
import { RpgClientEngine } from "../../RpgClientEngine.js";
|
|
5
4
|
import { Canvas, Container, Viewport, computed, cond, effect, h, loop, useDefineProps, useProps } from "canvasengine";
|
|
6
|
-
import { NightAmbiant, SpriteShadows } from "@canvasengine/presets";
|
|
7
5
|
import { delay } from "@rpgjs/common";
|
|
6
|
+
import { NightAmbiant, SpriteShadows } from "@canvasengine/presets";
|
|
8
7
|
//#region src/components/scenes/canvas.ce
|
|
9
8
|
function component($$props) {
|
|
10
9
|
useProps($$props);
|
|
11
10
|
useDefineProps($$props);
|
|
12
11
|
const engine = inject(RpgClientEngine);
|
|
12
|
+
const SceneMap = engine.sceneMapComponent;
|
|
13
13
|
const guiService = inject(RpgGui);
|
|
14
14
|
const sceneData = engine.sceneMap.data;
|
|
15
15
|
const lighting = engine.sceneMap.lighting;
|
|
@@ -177,8 +177,16 @@ function component($$props) {
|
|
|
177
177
|
cullToViewport: shadowCullToViewport,
|
|
178
178
|
shadowColor
|
|
179
179
|
})),
|
|
180
|
-
h(
|
|
181
|
-
]), loop(guiList, (gui) => h(Container, {
|
|
180
|
+
h(SceneMap)
|
|
181
|
+
]), loop(guiList, (gui) => h(Container, {
|
|
182
|
+
positionType: "absolute",
|
|
183
|
+
top: 0,
|
|
184
|
+
left: 0,
|
|
185
|
+
right: 0,
|
|
186
|
+
bottom: 0,
|
|
187
|
+
width: engine.width,
|
|
188
|
+
height: engine.height
|
|
189
|
+
}, cond(gui.display, () => h(gui.component, {
|
|
182
190
|
data: gui.data,
|
|
183
191
|
dependencies: gui.dependencies,
|
|
184
192
|
onFinish: (data) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.ce.js","names":[],"sources":["../../../src/components/scenes/canvas.ce"],"sourcesContent":["<Canvas width={engine.width} height={engine.height}>\n <Viewport worldWidth worldHeight clamp sortableChildren={true}>\n @if (lightingAmbientEnabled()) {\n <NightAmbiant\n spots={nightLights}\n darkness={lightingDarknessProps}\n haze={lightingHaze}\n />\n }\n @if (shadowEnabled()) {\n <SpriteShadows\n lights={shadowLights}\n ambientLight={shadowAmbientLight}\n minInfluence={shadowMinInfluence}\n falloffPower={shadowFalloffPower}\n mode={shadowMode}\n updateHz={shadowUpdateHz}\n scanHz={shadowScanHz}\n cullToViewport={shadowCullToViewport}\n shadowColor={shadowColor}\n />\n }\n <SceneMap />\n </Viewport>\n @for (gui of guiList) {\n <Container 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,QAAA,QAAA,CAAA,IAAA,cAAA;CACZ,CAAC;CACD,MAAM,aAAW,eAAc;EAC3B,MAAK,OAAQ,YAAS;EACtB,MAAM,QAAK,OAAU,MAAM,QAAQ,SAAE,CAAA,KAAa;EAClD,OAAO,OAAC,MAAY,SAAS,MAAA,QAAA,SAAA,IAAA,IAAA;CACjC,CAAC;CACD,MAAM,cAAM,eAAsB;EAC9B,MAAM,OAAK,YAAA;EACX,MAAI,QAAA,OAAA,MAAA,QAAA,SAAA,CAAA,KAAA;EACJ,OAAI,OAAS,MAAA,UAAA,MAAA,QAAA,UAAA,IAAA,IAAA;CACjB,CAAC;CACD,aAAQ;6CAED,MAAA,IAAA,MAAA,mHAAA;CAEP,CAAC;CACD,MAAE,eAAS,KAAe,SAAS;EACjC,YAAO;GACD,WAAW,SAAS,IAAI,MAAI,IAAI;EACtC,CAAA;CACF;;EAEE,WAAa,eAA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,gBAAc,eAAiB;EACjC,MAAE,UAAa,YAAA;EACf,OAAA,SAAA,SAAA,WAAA,cAAA,OAAA,aAAA,EAAA,SAAA,KAAA,mBAAA,EAAA;CACJ,CAAC;;CAED,MAAE,iBAAoB,eAAe,YAAA,GAAA,YAAA,EAAA;CACrC,MAAI,eAAc,eAAW,YAAA,GAAA,UAAA,CAAA;CAC7B,MAAI,uBAAyB,eAAA,YAAA,GAAA,kBAAA,IAAA;CAC7B,MAAG,qBAAA,eAAA,YAAA,GAAA,gBAAA,GAAA;;CAEH,MAAE,cAAkB,eAAe,YAAG,GAAA,eAAA,SAAA;CAMhC,OALY,EAAA,QAAW;EAAA,OAAA,OAAA;EAAA,QAAA,OAAA;CAAA,GAAA,CAAA,EAAA,UAAA;EAAA;EAAA;EAAA;EAAA,kBAAA;CAAA,GAAA;EAAA,KAAA,eAAA,uBAAA,CAAA,SAAA,EAAA,cAAA;GAAA,OAAA;GAAA,UAAA;GAAA,MAAA;EAAA,CAAA,CAAA;EAAA,KAAA,eAAA,cAAA,CAAA,SAAA,EAAA,eAAA;GAAA,QAAA;GAAA,cAAA;GAAA,cAAA;GAAA,cAAA;GAAA,MAAA;GAAA,UAAA;GAAA,QAAA;GAAA,gBAAA;GAAA;EAAA,CAAA,CAAA;EAAA,EAAA,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"}
|
|
1
|
+
{"version":3,"file":"canvas.ce.js","names":[],"sources":["../../../src/components/scenes/canvas.ce"],"sourcesContent":["<Canvas width={engine.width} height={engine.height}>\n <Viewport worldWidth worldHeight clamp sortableChildren={true}>\n @if (lightingAmbientEnabled()) {\n <NightAmbiant\n spots={nightLights}\n darkness={lightingDarknessProps}\n haze={lightingHaze}\n />\n }\n @if (shadowEnabled()) {\n <SpriteShadows\n lights={shadowLights}\n ambientLight={shadowAmbientLight}\n minInfluence={shadowMinInfluence}\n falloffPower={shadowFalloffPower}\n mode={shadowMode}\n updateHz={shadowUpdateHz}\n scanHz={shadowScanHz}\n cullToViewport={shadowCullToViewport}\n shadowColor={shadowColor}\n />\n }\n <SceneMap />\n </Viewport>\n @for (gui of guiList) {\n <Container\n positionType=\"absolute\"\n top={0}\n left={0}\n right={0}\n bottom={0}\n width={engine.width}\n height={engine.height}\n >\n @if (gui.display) {\n <gui.component data={gui.data} dependencies={gui.dependencies} 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 { 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 SceneMap = engine.sceneMapComponent;\n const guiService = inject(RpgGui);\n const sceneData = engine.sceneMap.data\n const lighting = engine.sceneMap.lighting\n const guiList = computed(() => {\n return Object.values(guiService.gui()).filter((gui) => !gui.attachToSprite)\n })\n const worldWidth = computed(() => {\n const data = sceneData?.()\n const scale = Number(data?.params?.scale ?? 1) || 1\n return Number(data?.width ?? data?.params?.width ?? 2048) * scale\n })\n const worldHeight = computed(() => {\n const data = sceneData?.()\n const scale = Number(data?.params?.scale ?? 1) || 1\n return Number(data?.height ?? data?.params?.height ?? 2048) * scale\n })\n\n effect(() => {\n if (sceneData() && !sceneData().component) {\n throw new Error(\"Warning ! You need to define a component for the scene. Use provideLoadMap() to define a component for the scene.\")\n }\n })\n\n const 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":";;;;;;;AAcM,SAAE,UAAc,SAAA;CACR,SAAU,OAAA;CACN,eAAc,OAAA;CACxB,MAAM,SAAE,OAAY,eAAA;CAC5B,MAAM,WAAE,OAAgB;CACxB,MAAM,aAAa,OAAE,MAAW;CAChC,MAAM,YAAC,OAAA,SAAA;CACP,MAAI,WAAA,OAAA,SAAA;CACJ,MAAK,UAAU,eAAA;EACX,OAAA,OAAQ,OAAA,WAAA,IAAA,CAAA,EAAA,QAAA,QAAA,CAAA,IAAA,cAAA;CACZ,CAAC;CACD,MAAM,aAAC,eAAA;EACH,MAAI,OAAA,YAAc;EAClB,MAAI,QAAM,OAAA,MAAA,QAAA,SAAA,CAAA,KAAA;EACV,OAAI,OAAO,MAAA,SAAA,MAAA,QAAA,SAAA,IAAA,IAAA;CACf,CAAC;CACD,MAAM,cAAW,eAAA;EACb,MAAI,OAAO,YAAY;EACvB,MAAI,QAAQ,OAAO,MAAM,QAAA,SAAA,CAAA,KAAA;EACzB,OAAE,OAAA,MAAA,UAAA,MAAA,QAAA,UAAA,IAAA,IAAA;CACN,CAAC;CACD,aAAW;EACP,IAAI,UAAI,KAAW,CAAC,UAAS,EAAA,WACzB,MAAK,IAAA,MAAA,mHAA+B;CAE5C,CAAC;CACD,MAAM,eAAE,KAAA,SAAA;EACJ,YAAI;GACN,WAAA,SAAA,IAAA,MAAA,IAAA;EACA,CAAA;;CAEF,MAAC,oBAAM,KAAA,MAAA,SAAA;EAC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|
|
@@ -5,9 +5,10 @@ import { Weather } from "@canvasengine/presets";
|
|
|
5
5
|
//#region src/components/scenes/draw-map.ce
|
|
6
6
|
function component($$props) {
|
|
7
7
|
useProps($$props);
|
|
8
|
-
useDefineProps($$props);
|
|
8
|
+
const { children } = useDefineProps($$props)();
|
|
9
9
|
const engine = inject(RpgClientEngine);
|
|
10
10
|
const componentAnimations = engine.componentAnimations;
|
|
11
|
+
const projectiles = engine.projectiles.current;
|
|
11
12
|
const map = engine.sceneMap?.data;
|
|
12
13
|
const sceneComponent = computed(() => map()?.component);
|
|
13
14
|
const mapParams = map()?.params;
|
|
@@ -64,11 +65,13 @@ function component($$props) {
|
|
|
64
65
|
freeze: engine.gamePause
|
|
65
66
|
}, [
|
|
66
67
|
h(Container, { sound: backgroundAmbientSound }),
|
|
67
|
-
cond(computed(() => map() && sceneComponent()), () => h(sceneComponent(), {
|
|
68
|
+
h(Container, null, cond(computed(() => map() && sceneComponent()), () => h(sceneComponent(), {
|
|
68
69
|
data: computed(() => map().data),
|
|
69
70
|
params: computed(() => map().params)
|
|
70
|
-
})),
|
|
71
|
+
}))),
|
|
72
|
+
loop(children, (child) => h(child)),
|
|
71
73
|
loop(componentAnimations, (componentAnimation) => h(Container, null, loop(componentAnimation.current, (animation) => h(componentAnimation.component, animation)))),
|
|
74
|
+
h(Container, { sortableChildren: true }, loop(computed(() => projectiles()), (projectile) => h(projectile.component, projectile.props), { track: (projectile) => projectile.props.id })),
|
|
72
75
|
cond(computed(() => weatherProps()), () => h(Weather, weatherProps()))
|
|
73
76
|
]);
|
|
74
77
|
}
|
|
@@ -1 +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
|
|
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 <Container>\n @if (map() && sceneComponent()) {\n <sceneComponent() data={map().data} params={map().params} />\n }\n </Container>\n\n @for (child of children) {\n <child />\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 <Container sortableChildren={true}>\n @for (projectile of projectiles() ; track projectile.props.id) {\n <projectile.component ...projectile.props />\n }\n </Container>\n\n @if (weatherProps()) {\n <Weather ...weatherProps() />\n }\n</Container>\n\n<script>\n import { computed, effect } from 'canvasengine'\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { Weather } from '@canvasengine/presets'\n\n const { children } = defineProps()\n const engine = inject(RpgClientEngine);\n const componentAnimations = engine.componentAnimations\n const projectiles = engine.projectiles.current\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.rayTwinkleSpe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,EAAA,IAAA;GAAA,QAAA,eAAA,IAAA,EAAA,MAAA;EAAA,CAAA,CAAA,CAAA;EAAA,KAAA,WAAA,UAAA,EAAA,KAAA,CAAA;EAAA,KAAA,sBAAA,uBAAA,EAAA,WAAA,MAAA,KAAA,mBAAA,UAAA,cAAA,EAAA,mBAAA,WAAA,SAAA,CAAA,CAAA,CAAA;EAAA,EAAA,WAAA,EAAA,kBAAA,KAAA,GAAA,KAAA,eAAA,YAAA,CAAA,IAAA,eAAA,EAAA,WAAA,WAAA,WAAA,KAAA,GAAA,EAAA,QAAA,eAAA,WAAA,MAAA,GAAA,CAAA,CAAA;EAAA,KAAA,eAAA,aAAA,CAAA,SAAA,EAAA,SAAA,aAAA,CAAA,CAAA;CAAA,CACZ;AACZ;AAEA,IAAM,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-layer.ce.js","names":[],"sources":["../../../src/components/scenes/event-layer.ce"],"sourcesContent":["<Container sortableChildren={true}>\n @for ((event,id) of events) {\n <Character id={id} object={event} />\n }\n\n @for ((player,id) of players) {\n <Character id={id} object={player} />\n }\n\n @for (child of children) {\n <child />\n }\n</Container>\n\n<script>\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import Character from \"../character.ce\";\n import LightHalo from \"../prebuilt/light-halo.ce\";\n \n const engine = inject(RpgClientEngine);\n const { children } = defineProps()\n \n const players = engine.sceneMap.players\n const events = engine.sceneMap.events\n</script>\n"],"mappings":";;;;;;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,
|
|
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,iBAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export * from './services/save';
|
|
|
6
6
|
export * from './core/setup';
|
|
7
7
|
export * from './core/inject';
|
|
8
8
|
export * from './services/loadMap';
|
|
9
|
+
export * from './services/actionInput';
|
|
10
|
+
export * from './services/pointerContext';
|
|
9
11
|
export * from './module';
|
|
10
12
|
export * from './Gui/Gui';
|
|
11
13
|
export * from './components/gui';
|
|
@@ -24,5 +26,7 @@ export { Control } from './services/keyboardControls';
|
|
|
24
26
|
export { RpgClientObject } from './Game/Object';
|
|
25
27
|
export { RpgClientPlayer } from './Game/Player';
|
|
26
28
|
export { RpgClientEvent } from './Game/Event';
|
|
29
|
+
export * from './Game/ProjectileManager';
|
|
30
|
+
export * from './Game/ClientVisuals';
|
|
27
31
|
export { withMobile } from './components/gui/mobile';
|
|
28
32
|
export * from './services/AbstractSocket';
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { Context } from "./node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js";
|
|
2
2
|
import { clearInject, context, inject, setInject } from "./core/inject.js";
|
|
3
3
|
import { AbstractWebsocket, WebSocketToken } from "./services/AbstractSocket.js";
|
|
4
|
+
import { getKeyboardControlBind, isKeyboardActionConfig, keyboardEventMatchesBind, normalizeActionInput, resolveKeyboardActionInput, resolveKeyboardDirectionInput } from "./services/actionInput.js";
|
|
4
5
|
import __ce_component$2 from "./components/gui/dialogbox/index.ce.js";
|
|
5
6
|
import __ce_component from "./components/gui/box.ce.js";
|
|
6
|
-
import __ce_component$
|
|
7
|
+
import __ce_component$16 from "./components/gui/shop/shop.ce.js";
|
|
7
8
|
import { getEntityProp } from "./utils/getEntityProp.js";
|
|
8
9
|
import __ce_component$8 from "./components/gui/hud/hud.ce.js";
|
|
9
10
|
import { SaveClientService, SaveClientToken, provideSaveClient } from "./services/save.js";
|
|
10
11
|
import __ce_component$14 from "./components/gui/save-load.ce.js";
|
|
11
12
|
import __ce_component$9 from "./components/gui/menu/items-menu.ce.js";
|
|
12
|
-
import __ce_component$
|
|
13
|
+
import __ce_component$17 from "./components/gui/menu/skills-menu.ce.js";
|
|
13
14
|
import __ce_component$3 from "./components/gui/menu/equip-menu.ce.js";
|
|
14
15
|
import __ce_component$13 from "./components/gui/menu/options-menu.ce.js";
|
|
15
16
|
import __ce_component$5 from "./components/gui/menu/exit-menu.ce.js";
|
|
16
17
|
import __ce_component$11 from "./components/gui/menu/main-menu.ce.js";
|
|
17
18
|
import __ce_component$12 from "./components/gui/notification/notification.ce.js";
|
|
18
|
-
import __ce_component$
|
|
19
|
+
import __ce_component$18 from "./components/gui/title-screen.ce.js";
|
|
19
20
|
import __ce_component$6 from "./components/gui/gameover.ce.js";
|
|
20
21
|
import "./components/gui/index.js";
|
|
21
22
|
import { RpgGui } from "./Gui/Gui.js";
|
|
23
|
+
import __ce_component$15 from "./components/scenes/draw-map.ce.js";
|
|
22
24
|
import { LoadMapService, LoadMapToken, provideLoadMap } from "./services/loadMap.js";
|
|
23
25
|
import { RpgSound, Sound, getSoundMetadata } from "./Sound.js";
|
|
24
26
|
import { RpgResource } from "./Resource.js";
|
|
@@ -27,10 +29,13 @@ import { RpgClientPlayer } from "./Game/Player.js";
|
|
|
27
29
|
import { RpgClientEvent } from "./Game/Event.js";
|
|
28
30
|
import { GlobalConfigToken, provideClientGlobalConfig, provideClientModules, provideGlobalConfig } from "./module.js";
|
|
29
31
|
import { PrebuiltComponentAnimations } from "./components/animations/index.js";
|
|
32
|
+
import { ProjectileManager } from "./Game/ProjectileManager.js";
|
|
33
|
+
import { ClientVisualRegistry } from "./Game/ClientVisuals.js";
|
|
34
|
+
import { createClientPointerContext } from "./services/pointerContext.js";
|
|
30
35
|
import { RpgClientEngine } from "./RpgClientEngine.js";
|
|
31
36
|
import { Control } from "./services/keyboardControls.js";
|
|
32
37
|
import { provideRpg } from "./services/standalone.js";
|
|
33
|
-
import { provideMmorpg } from "./services/mmorpg.js";
|
|
38
|
+
import { BridgeWebsocket, provideMmorpg } from "./services/mmorpg.js";
|
|
34
39
|
import { startGame } from "./core/setup.js";
|
|
35
40
|
import __ce_component$7 from "./components/prebuilt/hp-bar.ce.js";
|
|
36
41
|
import __ce_component$10 from "./components/prebuilt/light-halo.ce.js";
|
|
@@ -42,4 +47,4 @@ import "./components/index.js";
|
|
|
42
47
|
import { Spritesheet } from "./decorators/spritesheet.js";
|
|
43
48
|
import { withMobile } from "./components/gui/mobile/index.js";
|
|
44
49
|
import { Input, KeyboardControls } from "canvasengine";
|
|
45
|
-
export { AbstractWebsocket, __ce_component as BoxComponent, __ce_component$1 as CharacterComponent, Context, Control, __ce_component$2 as DialogboxComponent, __ce_component$3 as EquipMenuComponent, __ce_component$4 as EventLayerComponent, __ce_component$5 as ExitMenuComponent, __ce_component$6 as GameoverComponent, GlobalConfigToken, __ce_component$7 as HpBar, __ce_component$8 as HudComponent, Input, __ce_component$9 as ItemsMenuComponent, KeyboardControls, __ce_component$10 as LightHalo, LoadMapService, LoadMapToken, __ce_component$11 as MainMenuComponent, __ce_component$12 as NotificationComponent, __ce_component$13 as OptionsMenuComponent, PrebuiltComponentAnimations, Presets, RpgClientEngine, RpgClientEvent, RpgClientObject, RpgClientPlayer, RpgGui, RpgResource, RpgSound, SaveClientService, SaveClientToken, __ce_component$14 as SaveLoadComponent, __ce_component$15 as
|
|
50
|
+
export { AbstractWebsocket, __ce_component as BoxComponent, BridgeWebsocket, __ce_component$1 as CharacterComponent, ClientVisualRegistry, Context, Control, __ce_component$2 as DialogboxComponent, __ce_component$3 as EquipMenuComponent, __ce_component$4 as EventLayerComponent, __ce_component$5 as ExitMenuComponent, __ce_component$6 as GameoverComponent, GlobalConfigToken, __ce_component$7 as HpBar, __ce_component$8 as HudComponent, Input, __ce_component$9 as ItemsMenuComponent, KeyboardControls, __ce_component$10 as LightHalo, LoadMapService, LoadMapToken, __ce_component$11 as MainMenuComponent, __ce_component$12 as NotificationComponent, __ce_component$13 as OptionsMenuComponent, PrebuiltComponentAnimations, Presets, ProjectileManager, RpgClientEngine, RpgClientEvent, RpgClientObject, RpgClientPlayer, RpgGui, RpgResource, RpgSound, SaveClientService, SaveClientToken, __ce_component$14 as SaveLoadComponent, __ce_component$15 as SceneMap, __ce_component$16 as ShopComponent, __ce_component$17 as SkillsMenuComponent, Sound, Spritesheet, __ce_component$18 as TitleScreenComponent, WebSocketToken, clearInject, context, createClientPointerContext, getEntityProp, getKeyboardControlBind, getSoundMetadata, inject, isKeyboardActionConfig, keyboardEventMatchesBind, normalizeActionInput, provideClientGlobalConfig, provideClientModules, provideGlobalConfig, provideLoadMap, provideMmorpg, provideRpg, provideSaveClient, resolveKeyboardActionInput, resolveKeyboardDirectionInput, setInject, startGame, withMobile };
|
package/dist/module.js
CHANGED
|
@@ -112,6 +112,23 @@ function provideClientModules(modules) {
|
|
|
112
112
|
});
|
|
113
113
|
} };
|
|
114
114
|
}
|
|
115
|
+
if (module.clientVisuals) {
|
|
116
|
+
const clientVisuals = { ...module.clientVisuals };
|
|
117
|
+
module.clientVisuals = { load: (engine) => {
|
|
118
|
+
engine.registerClientVisuals(clientVisuals);
|
|
119
|
+
} };
|
|
120
|
+
}
|
|
121
|
+
if (module.projectiles) {
|
|
122
|
+
const projectiles = { ...module.projectiles };
|
|
123
|
+
module.projectiles = {
|
|
124
|
+
...projectiles,
|
|
125
|
+
load: (engine) => {
|
|
126
|
+
if (projectiles.components) Object.entries(projectiles.components).forEach(([type, component]) => {
|
|
127
|
+
engine.registerProjectileComponent(type, component);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
115
132
|
if (module.transitions) {
|
|
116
133
|
const transitions = [...module.transitions];
|
|
117
134
|
module.transitions = { load: (engine) => {
|
|
@@ -147,6 +164,7 @@ function provideClientModules(modules) {
|
|
|
147
164
|
if (sprite.components) Object.entries(sprite.components).forEach(([id, component]) => {
|
|
148
165
|
engine.registerSpriteComponent(id, component);
|
|
149
166
|
});
|
|
167
|
+
if (sprite.eventComponent) engine.addEventComponentResolver(sprite.eventComponent);
|
|
150
168
|
}
|
|
151
169
|
};
|
|
152
170
|
}
|