@rpgjs/client 5.0.0-alpha.4 → 5.0.0-alpha.6
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/dist/components/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.js +2 -2
- package/dist/index12.js +1 -1
- package/dist/index13.js +1 -1
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +80 -39
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +45 -186
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +187 -5
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +5 -383
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +384 -28
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +24 -17
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +6 -6
- package/dist/index20.js +16 -2413
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +2395 -88
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +108 -103
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +95 -57
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +62 -12
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +17 -37
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +39 -3
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +1 -318
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +319 -22
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +22 -8
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +2 -2
- package/dist/index30.js +3 -3
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +8 -9
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +9 -4400
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +4394 -307
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +307 -165
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +162 -489
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +496 -86
- package/dist/index36.js.map +1 -1
- package/dist/index37.js.map +1 -1
- package/dist/index38.js.map +1 -1
- package/dist/index4.js +2 -2
- package/dist/index5.js +1 -1
- package/dist/index6.js +1 -1
- package/dist/index7.js +1 -1
- package/dist/index8.js +1 -1
- package/dist/index9.js +2 -2
- package/package.json +8 -6
- package/src/components/index.ts +2 -1
- package/src/components/scenes/draw-map.ce +0 -18
- package/src/components/scenes/event-layer.ce +1 -1
- package/vite.config.ts +1 -1
- package/src/components/scenes/element-map.ce +0 -23
package/dist/index22.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index22.js","sources":["
|
|
1
|
+
{"version":3,"file":"index22.js","sources":["../../../node_modules/.pnpm/@signe+sync@2.3.3/node_modules/@signe/sync/dist/client/index.js"],"sourcesContent":["import {\n __name\n} from \"../chunk-7QVYU63E.js\";\n\n// src/client/index.ts\nimport { load } from \"@signe/sync\";\nimport PartySocket from \"partysocket\";\nfunction createConnection(options, roomInstance) {\n const conn = new PartySocket(options);\n conn.addEventListener(\"message\", (event) => {\n const object = JSON.parse(event.data);\n switch (object.type) {\n case \"sync\":\n load(roomInstance, object.value, true);\n break;\n }\n });\n return {\n emit: /* @__PURE__ */ __name((key, value) => {\n conn.send(JSON.stringify({\n action: key,\n value\n }));\n }, \"emit\"),\n on: /* @__PURE__ */ __name((key, cb) => {\n conn.addEventListener(\"message\", (event) => {\n const object = JSON.parse(event.data);\n if (object.type === key) {\n cb(object.value);\n }\n });\n }, \"on\"),\n off: /* @__PURE__ */ __name((key, cb) => {\n conn.removeEventListener(\"message\", (event) => {\n const object = JSON.parse(event.data);\n if (object.type === key) {\n cb(object.value);\n }\n });\n }, \"off\"),\n close: /* @__PURE__ */ __name(() => conn.close(), \"close\"),\n conn\n };\n}\n__name(createConnection, \"createConnection\");\nasync function connectionRoom(options, roomInstance) {\n return createConnection(options, roomInstance);\n}\n__name(connectionRoom, \"connectionRoom\");\nasync function connectionWorld(options, roomInstance) {\n const shardInfo = await getOptimalShard(options);\n const result = createConnection({\n ...options,\n party: \"shard\",\n room: shardInfo.url\n }, roomInstance);\n return {\n ...result,\n shardInfo\n };\n}\n__name(connectionWorld, \"connectionWorld\");\nasync function getOptimalShard(worldOptions) {\n const {\n host,\n room,\n worldId = \"world-default\",\n retryCount = 3,\n retryDelay = 1e3,\n autoCreate = true\n // Default to true for auto-creation\n } = worldOptions;\n let attempts = 0;\n const url = new URL(`${host}/parties/world/${encodeURIComponent(worldId)}/connect`);\n const requestUrl = url.toString();\n while (attempts < retryCount) {\n try {\n const response = await fetch(requestUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n roomId: room,\n autoCreate\n })\n });\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({\n error: \"Unknown error\"\n }));\n throw new Error(`World service returned ${response.status}: ${errorData.error || \"Unknown error\"}`);\n }\n const data = await response.json();\n if (!data.url || !data.shardId) {\n throw new Error(\"Invalid response from World service: missing url or shardId\");\n }\n return {\n shardId: data.shardId,\n url: data.url\n };\n } catch (error) {\n attempts++;\n if (attempts >= retryCount) {\n throw error;\n }\n console.warn(`Failed to get shard (attempt ${attempts}/${retryCount}). Retrying in ${retryDelay}ms...`);\n await new Promise((resolve) => setTimeout(resolve, retryDelay));\n }\n }\n throw new Error(\"Failed to get shard after all retry attempts\");\n}\n__name(getOptimalShard, \"getOptimalShard\");\nexport {\n PartySocket,\n connectionRoom,\n connectionWorld\n};\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;AAOA,SAAS,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE;AACjD,EAAE,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC;AACvC,EAAE,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,KAAK;AAC9C,IAAI,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;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AAI,KAAK,CAAC,8CAA8C,CAAC;AACjE;AACA,MAAM,CAAC,eAAe,EAAE,iBAAiB,CAAC;;;;","x_google_ignoreList":[0]}
|
package/dist/index23.js
CHANGED
|
@@ -1,69 +1,107 @@
|
|
|
1
|
-
import { useProps, useDefineProps, animatedSignal,
|
|
2
|
-
import
|
|
1
|
+
import { useProps, useDefineProps, signal, animatedSignal, computed, trigger, mount, effect, h, Container, Rect, cond, Text } from 'canvasengine';
|
|
2
|
+
import component$1 from './index37.js';
|
|
3
|
+
import { inject } from './index6.js';
|
|
4
|
+
import { RpgClientEngine } from './index2.js';
|
|
3
5
|
|
|
4
6
|
function component($$props) {
|
|
5
7
|
useProps($$props);
|
|
6
8
|
const defineProps = useDefineProps($$props);
|
|
7
|
-
var _a = defineProps(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
9
|
+
var _a = defineProps(), message = _a.message, _choices = _a.choices, onFinish = _a.onFinish; _a.onInteraction;
|
|
10
|
+
var client = inject(RpgClientEngine);
|
|
11
|
+
var keyboardControls = client.globalConfig.keyboardControls;
|
|
12
|
+
client.stopProcessingInput = true;
|
|
13
|
+
var isDestroyed = false;
|
|
14
|
+
var texts = [message()];
|
|
15
|
+
var height = signal(250);
|
|
16
|
+
var isTextCompleted = signal(false);
|
|
17
|
+
var border = signal({ width: 5, color: "#595971" });
|
|
18
|
+
var shadow = signal({ color: "#000", blur: 10, offsetX: 10, offsetY: 10 });
|
|
19
|
+
var contentOpacity = animatedSignal(0, {
|
|
20
|
+
duration: 1000,
|
|
21
|
+
});
|
|
22
|
+
var scaleX = animatedSignal(0, {
|
|
23
|
+
duration: 500,
|
|
24
|
+
});
|
|
25
|
+
scaleX.set(1);
|
|
26
|
+
contentOpacity.set(1);
|
|
27
|
+
var currentTextIndex = signal(0);
|
|
28
|
+
var currentText = computed(function () { var _a; return (_a = texts === null || texts === void 0 ? void 0 : texts[currentTextIndex()]) !== null && _a !== void 0 ? _a : ''; });
|
|
29
|
+
var isChoiceDisplayed = signal(false);
|
|
30
|
+
var text = computed(function () {
|
|
31
|
+
var current = currentText();
|
|
32
|
+
return typeof current === "string" ? current : current.text;
|
|
17
33
|
});
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var velocityX = 0;
|
|
23
|
-
var velocityY = 0;
|
|
24
|
-
var speed = 200;
|
|
25
|
-
switch (direction()) {
|
|
26
|
-
case Direction.Left:
|
|
27
|
-
velocityX = speed;
|
|
28
|
-
break;
|
|
29
|
-
case Direction.Right:
|
|
30
|
-
velocityX = -200;
|
|
31
|
-
break;
|
|
32
|
-
case Direction.Up:
|
|
33
|
-
velocityY = speed;
|
|
34
|
-
break;
|
|
35
|
-
case Direction.Down:
|
|
36
|
-
velocityY = -200;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
velocityX += (Math.random() - 0.5) * 100;
|
|
40
|
-
velocityY += (Math.random() - 0.5) * 100;
|
|
41
|
-
var gravity = 500;
|
|
42
|
-
var deceleration = 0.98;
|
|
43
|
-
mount(function () {
|
|
44
|
-
scale.set(0.1);
|
|
34
|
+
var choices = computed(function () {
|
|
35
|
+
//const current = currentText();
|
|
36
|
+
//return typeof current === "string" ? null : current.choices;
|
|
37
|
+
return _choices;
|
|
45
38
|
});
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
y.update(function (y) { return y + (velocityY * deltaTime) / 1000; });
|
|
54
|
-
// Apply gravity
|
|
55
|
-
velocityY += (gravity * deltaTime) / 1000;
|
|
56
|
-
// Apply deceleration
|
|
57
|
-
velocityX *= deceleration;
|
|
58
|
-
velocityY *= deceleration;
|
|
39
|
+
var visibleSelection = computed(function () { return isChoiceDisplayed() && choices().length != 0; });
|
|
40
|
+
var triggerSkip = trigger();
|
|
41
|
+
var typewriter = {
|
|
42
|
+
speed: 0.3,
|
|
43
|
+
skip: triggerSkip,
|
|
44
|
+
onComplete: function () {
|
|
45
|
+
isTextCompleted.set(true);
|
|
59
46
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
};
|
|
48
|
+
var textStyle = {
|
|
49
|
+
wordWrap: true,
|
|
50
|
+
wordWrapWidth: 700 - 256 - 80
|
|
51
|
+
};
|
|
52
|
+
signal({ x: 0, y: 0, width: 256, height: 256 });
|
|
53
|
+
mount(function (element) {
|
|
54
|
+
var dialogbox = element.props.children[0];
|
|
55
|
+
return function () {
|
|
56
|
+
dialogbox.directives.controls.onDestroy();
|
|
57
|
+
isDestroyed = true;
|
|
58
|
+
// Wait destroy is finished before start processing input
|
|
59
|
+
setTimeout(function () {
|
|
60
|
+
client.stopProcessingInput = false;
|
|
61
|
+
}, 500);
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
var controls = signal({
|
|
65
|
+
next: {
|
|
66
|
+
bind: keyboardControls.action,
|
|
67
|
+
keyDown: function (e) {
|
|
68
|
+
if (isDestroyed)
|
|
69
|
+
return;
|
|
70
|
+
if (isChoiceDisplayed()) {
|
|
71
|
+
// If choices are displayed, do nothing (wait for selection)
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// If text is still typing, just skip (fast forward) the animation
|
|
75
|
+
if (!isTextCompleted()) {
|
|
76
|
+
triggerSkip.start();
|
|
77
|
+
isTextCompleted.set(true);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
var isFinished = currentTextIndex() === texts.length - 1;
|
|
81
|
+
currentTextIndex.update(function (index) {
|
|
82
|
+
if (index < texts.length - 1) {
|
|
83
|
+
return index + 1;
|
|
84
|
+
}
|
|
85
|
+
return index;
|
|
86
|
+
});
|
|
87
|
+
isChoiceDisplayed.set(false);
|
|
88
|
+
isTextCompleted.set(false);
|
|
89
|
+
if (isFinished && onFinish) {
|
|
90
|
+
onFinish();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
var onSelect = function (index) {
|
|
97
|
+
onFinish(index);
|
|
98
|
+
};
|
|
99
|
+
effect(function () {
|
|
100
|
+
if (choices().length != 0) {
|
|
101
|
+
isChoiceDisplayed.set(true);
|
|
64
102
|
}
|
|
65
103
|
});
|
|
66
|
-
let $this = h(
|
|
104
|
+
let $this = h(Container, { justifyContent: 'center', alignItems: 'center', width: '100%', height: '100%' }, h(Container, { ref: 'dialogbox', scale: { x: scaleX }, anchor: [0.5, 0.5], width: 700, height, controls, positionType: 'absolute', bottom: 10 }, [h(Rect, { width: 700, height: 250, color: '#1a1a2e' }), h(Rect, { x: 0, y: 0, width: 700, height, color: '#1a1a2e', alpha: 0.9, borderRadius: 10, border, shadow }), h(Container, { flexDirection: 'row', width: 700, height, alpha: contentOpacity }, h(Container, { flexDirection: 'column' }, [h(Text, { text, color: '#fff', fontSize: 18, margin: 40, typewriter, style: textStyle }), cond(visibleSelection, () => h(component$1, { selectedIndex: 0, items: choices, onSelect }))]))]));
|
|
67
105
|
return $this
|
|
68
106
|
}
|
|
69
107
|
|
package/dist/index23.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index23.js","sources":["../src/components/
|
|
1
|
+
{"version":3,"file":"index23.js","sources":["../src/components/gui/dialogbox/index.ce"],"sourcesContent":["\n import { Rect } from 'canvasengine';\nimport { Container } from 'canvasengine';\nimport { Text } from 'canvasengine';\nimport { h, cond, loop } from 'canvasengine';\nimport Selection from './selection.ce';\nimport { animatedSignal, computed, effect, signal, trigger, mount } from \"canvasengine\";\nimport { inject } from \"../../../core/inject\";\nimport { RpgClientEngine } from \"../../../RpgClientEngine\";\n import { useProps, useDefineProps } from 'canvasengine'\n\n export default function component($$props) {\n const $props = useProps($$props)\n const defineProps = useDefineProps($$props)\n var _a = defineProps(), message = _a.message, _choices = _a.choices, onFinish = _a.onFinish, onInteraction = _a.onInteraction;\nvar client = inject(RpgClientEngine);\nvar keyboardControls = client.globalConfig.keyboardControls;\nclient.stopProcessingInput = true;\nvar isDestroyed = false;\nvar texts = [message()];\nvar height = signal(250);\nvar isTextCompleted = signal(false);\nvar drawSpeaker = function (g) {\n g.beginFill(0xffa500); // Orange color\n g.lineStyle(2, 0x000000); // Black border\n g.moveTo(0, 0);\n g.lineTo(70, 0);\n g.lineTo(80, 15);\n g.lineTo(70, 30);\n g.lineTo(0, 30);\n g.lineTo(0, 0);\n g.endFill();\n};\nvar border = signal({ width: 5, color: \"#595971\" });\nvar shadow = signal({ color: \"#000\", blur: 10, offsetX: 10, offsetY: 10 });\nvar contentOpacity = animatedSignal(0, {\n duration: 1000,\n});\nvar scaleX = animatedSignal(0, {\n duration: 500,\n});\nscaleX.set(1);\ncontentOpacity.set(1);\nvar currentTextIndex = signal(0);\nvar currentText = computed(function () { var _a; return (_a = texts === null || texts === void 0 ? void 0 : texts[currentTextIndex()]) !== null && _a !== void 0 ? _a : ''; });\nvar isChoiceDisplayed = signal(false);\nvar text = computed(function () {\n var current = currentText();\n return typeof current === \"string\" ? current : current.text;\n});\nvar choices = computed(function () {\n //const current = currentText();\n //return typeof current === \"string\" ? null : current.choices;\n return _choices;\n});\nvar visibleSelection = computed(function () { return isChoiceDisplayed() && choices().length != 0; });\nvar triggerSkip = trigger();\nvar typewriter = {\n speed: 0.3,\n skip: triggerSkip,\n onComplete: function () {\n isTextCompleted.set(true);\n }\n};\nvar textStyle = {\n wordWrap: true,\n wordWrapWidth: 700 - 256 - 80\n};\nvar face = signal({ x: 0, y: 0, width: 256, height: 256 });\nmount(function (element) {\n var dialogbox = element.props.children[0];\n return function () {\n dialogbox.directives.controls.onDestroy();\n isDestroyed = true;\n // Wait destroy is finished before start processing input\n setTimeout(function () {\n client.stopProcessingInput = false;\n }, 500);\n };\n});\nvar controls = signal({\n next: {\n bind: keyboardControls.action,\n keyDown: function (e) {\n if (isDestroyed)\n return;\n if (isChoiceDisplayed()) {\n // If choices are displayed, do nothing (wait for selection)\n return;\n }\n // If text is still typing, just skip (fast forward) the animation\n if (!isTextCompleted()) {\n triggerSkip.start();\n isTextCompleted.set(true);\n }\n else {\n var isFinished = currentTextIndex() === texts.length - 1;\n currentTextIndex.update(function (index) {\n if (index < texts.length - 1) {\n return index + 1;\n }\n return index;\n });\n isChoiceDisplayed.set(false);\n isTextCompleted.set(false);\n if (isFinished && onFinish) {\n onFinish();\n }\n }\n },\n },\n});\nvar onSelect = function (index) {\n onFinish(index);\n};\neffect(function () {\n if (choices().length != 0) {\n isChoiceDisplayed.set(true);\n }\n});\n let $this = h(Container, { justifyContent: 'center', alignItems: 'center', width: '100%', height: '100%' }, h(Container, { ref: 'dialogbox', scale: { x: scaleX }, anchor: [0.5, 0.5], width: 700, height, controls, positionType: 'absolute', bottom: 10 }, [h(Rect, { width: 700, height: 250, color: '#1a1a2e' }), h(Rect, { x: 0, y: 0, width: 700, height, color: '#1a1a2e', alpha: 0.9, borderRadius: 10, border, shadow }), h(Container, { flexDirection: 'row', width: 700, height, alpha: contentOpacity }, h(Container, { flexDirection: 'column' }, [h(Text, { text, color: '#fff', fontSize: 18, margin: 40, typewriter, style: textStyle }), cond(visibleSelection, () => h(Selection, { selectedIndex: 0, items: choices, onSelect }))]))]))\n return $this\n }\n "],"names":["Selection"],"mappings":";;;;;AAWqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAW,IAAC,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAiB,EAAE,CAAC;AACxH,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;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@@ -1,19 +1,69 @@
|
|
|
1
|
-
import { useProps, useDefineProps, h,
|
|
2
|
-
import {
|
|
3
|
-
import { inject } from './index6.js';
|
|
1
|
+
import { useProps, useDefineProps, animatedSignal, signal, mount, tick, h, Text } from 'canvasengine';
|
|
2
|
+
import { Direction } from '@rpgjs/common';
|
|
4
3
|
|
|
5
4
|
function component($$props) {
|
|
6
5
|
useProps($$props);
|
|
7
6
|
const defineProps = useDefineProps($$props);
|
|
8
|
-
var _a = defineProps(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
|
|
7
|
+
var _a = defineProps({
|
|
8
|
+
duration: {
|
|
9
|
+
default: 1000
|
|
10
|
+
},
|
|
11
|
+
color: {
|
|
12
|
+
default: 'black'
|
|
13
|
+
}
|
|
14
|
+
}), text = _a.text, direction = _a.direction, onFinish = _a.onFinish, duration = _a.duration, color = _a.color, positionX = _a.x, positionY = _a.y;
|
|
15
|
+
var scale = animatedSignal(1, {
|
|
16
|
+
duration: duration(),
|
|
17
|
+
});
|
|
18
|
+
var randomPosition = function () { return Math.floor(Math.random() * 60); };
|
|
19
|
+
var initialY = randomPosition();
|
|
20
|
+
var x = signal(positionX());
|
|
21
|
+
var y = signal(positionY() - initialY);
|
|
22
|
+
var velocityX = 0;
|
|
23
|
+
var velocityY = 0;
|
|
24
|
+
var speed = 200;
|
|
25
|
+
switch (direction()) {
|
|
26
|
+
case Direction.Left:
|
|
27
|
+
velocityX = speed;
|
|
28
|
+
break;
|
|
29
|
+
case Direction.Right:
|
|
30
|
+
velocityX = -200;
|
|
31
|
+
break;
|
|
32
|
+
case Direction.Up:
|
|
33
|
+
velocityY = speed;
|
|
34
|
+
break;
|
|
35
|
+
case Direction.Down:
|
|
36
|
+
velocityY = -200;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
velocityX += (Math.random() - 0.5) * 100;
|
|
40
|
+
velocityY += (Math.random() - 0.5) * 100;
|
|
41
|
+
var gravity = 500;
|
|
42
|
+
var deceleration = 0.98;
|
|
43
|
+
mount(function () {
|
|
44
|
+
scale.set(0.1);
|
|
45
|
+
});
|
|
46
|
+
var elapsedTime = 0;
|
|
47
|
+
tick(function (_a) {
|
|
48
|
+
var deltaTime = _a.deltaTime;
|
|
49
|
+
elapsedTime += deltaTime;
|
|
50
|
+
if (elapsedTime < duration()) {
|
|
51
|
+
// Update position
|
|
52
|
+
x.update(function (x) { return x + (velocityX * deltaTime) / 1000; });
|
|
53
|
+
y.update(function (y) { return y + (velocityY * deltaTime) / 1000; });
|
|
54
|
+
// Apply gravity
|
|
55
|
+
velocityY += (gravity * deltaTime) / 1000;
|
|
56
|
+
// Apply deceleration
|
|
57
|
+
velocityX *= deceleration;
|
|
58
|
+
velocityY *= deceleration;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (onFinish) {
|
|
62
|
+
onFinish();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
let $this = h(Text, { x, y, zIndex: 10000, color, scale, size: 30, text });
|
|
17
67
|
return $this
|
|
18
68
|
}
|
|
19
69
|
|
package/dist/index24.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index24.js","sources":["../src/components/effects/
|
|
1
|
+
{"version":3,"file":"index24.js","sources":["../src/components/effects/hit.ce"],"sourcesContent":["\n import { Text } from 'canvasengine';\nimport { h, computed, cond, loop } from 'canvasengine';\nimport { animatedSignal, mount, signal, tick } from \"canvasengine\";\nimport { Direction } from \"@rpgjs/common\";\n import { useProps, useDefineProps } from 'canvasengine'\n\n export default function component($$props) {\n const $props = useProps($$props)\n const defineProps = useDefineProps($$props)\n var _a = defineProps({\n duration: {\n default: 1000\n },\n color: {\n default: 'black'\n }\n}), text = _a.text, direction = _a.direction, onFinish = _a.onFinish, duration = _a.duration, color = _a.color, positionX = _a.x, positionY = _a.y;\nvar scale = animatedSignal(1, {\n duration: duration(),\n});\nvar randomPosition = function () { return Math.floor(Math.random() * 60); };\nvar initialY = randomPosition();\nvar x = signal(positionX());\nvar y = signal(positionY() - initialY);\nvar velocityX = 0;\nvar velocityY = 0;\nvar speed = 200;\nswitch (direction()) {\n case Direction.Left:\n velocityX = speed;\n break;\n case Direction.Right:\n velocityX = -speed;\n break;\n case Direction.Up:\n velocityY = speed;\n break;\n case Direction.Down:\n velocityY = -speed;\n break;\n}\nvelocityX += (Math.random() - 0.5) * 100;\nvelocityY += (Math.random() - 0.5) * 100;\nvar gravity = 500;\nvar deceleration = 0.98;\nmount(function () {\n scale.set(0.1);\n});\nvar elapsedTime = 0;\ntick(function (_a) {\n var deltaTime = _a.deltaTime;\n elapsedTime += deltaTime;\n if (elapsedTime < duration()) {\n // Update position\n x.update(function (x) { return x + (velocityX * deltaTime) / 1000; });\n y.update(function (y) { return y + (velocityY * deltaTime) / 1000; });\n // Apply gravity\n velocityY += (gravity * deltaTime) / 1000;\n // Apply deceleration\n velocityX *= deceleration;\n velocityY *= deceleration;\n }\n else {\n if (onFinish) {\n onFinish();\n }\n }\n});\n let $this = h(Text, { x, y, zIndex: 10000, color, scale, size: 30, text })\n return $this\n }\n "],"names":[],"mappings":";;;AAOqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,EAAE,GAAG,WAAW,CAAC;AAC7B,IAAI,QAAQ,EAAE;AACd,QAAQ,OAAO,EAAE;AACjB,KAAK;AACL,IAAI,KAAK,EAAE;AACX,QAAQ,OAAO,EAAE;AACjB;AACA,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAC,SAAS,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,GAAG,EAA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CAAC;AACnB,IAAI,CAAC,UAAU,EAAE,EAAE;AACnB,IAAI,IAAI,SAAS,GAAG,EAAE,CAAC,SAAS;AAChC,IAAI,WAAW,IAAI,SAAS;AAC5B,IAAI,IAAI,WAAW,GAAG,QAAQ,EAAE,EAAE;AAClC;AACA,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,CAAC,EAAE,CAAC;AAC7E,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,CAAC,EAAE,CAAC;AAC7E;AACA,QAAQ,SAAS,IAAI,CAAC,OAAO,GAAG,SAAS,IAAI,IAAI;AACjD;AACA,QAAQ,SAAS,IAAI,YAAY;AACjC,QAAQ,SAAS,IAAI,YAAY;AACjC;AACA,SAAS;AACT,QAAQ,IAAI,QAAQ,EAAE;AACtB,YAAY,QAAQ,EAAE;AACtB;AACA;AACA,CAAC,CAAC;AACF,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE;AACjF,QAAQ,OAAO;AACf;;;;"}
|
package/dist/index25.js
CHANGED
|
@@ -1,41 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useProps, useDefineProps, h, Sprite } from 'canvasengine';
|
|
2
|
+
import { RpgClientEngine } from './index2.js';
|
|
3
|
+
import { inject } from './index6.js';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
[Direction.Up]: Math.max(0, 3 - gap)
|
|
14
|
-
}[direction];
|
|
15
|
-
};
|
|
16
|
-
const stand = (direction) => [{ time: 0, frameX: frameStand, frameY: frameY(direction) }];
|
|
17
|
-
const walk = (direction) => {
|
|
18
|
-
const array = [];
|
|
19
|
-
const durationFrame = 10;
|
|
20
|
-
for (let i = 0; i < framesWidth; i++) {
|
|
21
|
-
array.push({ time: i * durationFrame, frameX: i, frameY: frameY(direction) });
|
|
22
|
-
}
|
|
23
|
-
array.push({ time: array[array.length - 1].time + durationFrame });
|
|
24
|
-
return array;
|
|
25
|
-
};
|
|
26
|
-
return {
|
|
27
|
-
textures: {
|
|
28
|
-
[Animation.Stand]: {
|
|
29
|
-
animations: ({ direction }) => [stand(direction)]
|
|
30
|
-
},
|
|
31
|
-
[Animation.Walk]: {
|
|
32
|
-
animations: ({ direction }) => [walk(direction)]
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
framesHeight,
|
|
36
|
-
framesWidth
|
|
37
|
-
};
|
|
5
|
+
function component($$props) {
|
|
6
|
+
useProps($$props);
|
|
7
|
+
const defineProps = useDefineProps($$props);
|
|
8
|
+
var _a = defineProps(), x = _a.x, y = _a.y, name = _a.name, onFinish = _a.onFinish;
|
|
9
|
+
var client = inject(RpgClientEngine);
|
|
10
|
+
var spritesheets = client.spritesheets;
|
|
11
|
+
var sheet = {
|
|
12
|
+
definition: spritesheets.get(name()),
|
|
13
|
+
playing: 'default',
|
|
14
|
+
onFinish: onFinish
|
|
38
15
|
};
|
|
16
|
+
let $this = h(Sprite, { sheet, x, y, anchor: 0.5 });
|
|
17
|
+
return $this
|
|
18
|
+
}
|
|
39
19
|
|
|
40
|
-
export {
|
|
20
|
+
export { component as default };
|
|
41
21
|
//# sourceMappingURL=index25.js.map
|
package/dist/index25.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index25.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index25.js","sources":["../src/components/effects/animation.ce"],"sourcesContent":["\n import { Sprite } from 'canvasengine';\nimport { h, computed, cond, loop } from 'canvasengine';\nimport { RpgClientEngine } from \"../../RpgClientEngine\";\nimport { inject } from \"../../core/inject\";\n import { useProps, useDefineProps } from 'canvasengine'\n\n export default function component($$props) {\n const $props = useProps($$props)\n const defineProps = useDefineProps($$props)\n var _a = defineProps(), x = _a.x, y = _a.y, name = _a.name, onFinish = _a.onFinish;\nvar client = inject(RpgClientEngine);\nvar spritesheets = client.spritesheets;\nvar sheet = {\n definition: spritesheets.get(name()),\n playing: 'default',\n onFinish: onFinish\n};\n let $this = h(Sprite, { sheet, x, y, anchor: 0.5 })\n return $this\n }\n "],"names":[],"mappings":";;;;AAOqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,EAAE,GAAG,WAAW,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ;AAC1F,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AACpC,IAAI,YAAY,GAAG,MAAM,CAAC,YAAY;AACtC,IAAI,KAAK,GAAG;AACZ,IAAI,UAAU,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AACxC,IAAI,OAAO,EAAE,SAAS;AACtB,IAAI,QAAQ,EAAE;AACd,CAAC;AACD,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE;AAC1D,QAAQ,OAAO;AACf;;;;"}
|
package/dist/index26.js
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
|
+
import { Animation, Direction } from '@rpgjs/common';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
const RMSpritesheet = (framesWidth, framesHeight, frameStand = 1) => {
|
|
4
|
+
if (framesWidth <= frameStand) {
|
|
5
|
+
frameStand = framesWidth - 1;
|
|
6
|
+
}
|
|
7
|
+
const frameY = (direction) => {
|
|
8
|
+
const gap = Math.max(4 - framesHeight, 0);
|
|
9
|
+
return {
|
|
10
|
+
[Direction.Down]: 0,
|
|
11
|
+
[Direction.Left]: Math.max(0, 1 - gap),
|
|
12
|
+
[Direction.Right]: Math.max(0, 2 - gap),
|
|
13
|
+
[Direction.Up]: Math.max(0, 3 - gap)
|
|
14
|
+
}[direction];
|
|
15
|
+
};
|
|
16
|
+
const stand = (direction) => [{ time: 0, frameX: frameStand, frameY: frameY(direction) }];
|
|
17
|
+
const walk = (direction) => {
|
|
18
|
+
const array = [];
|
|
19
|
+
const durationFrame = 10;
|
|
20
|
+
for (let i = 0; i < framesWidth; i++) {
|
|
21
|
+
array.push({ time: i * durationFrame, frameX: i, frameY: frameY(direction) });
|
|
22
|
+
}
|
|
23
|
+
array.push({ time: array[array.length - 1].time + durationFrame });
|
|
24
|
+
return array;
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
textures: {
|
|
28
|
+
[Animation.Stand]: {
|
|
29
|
+
animations: ({ direction }) => [stand(direction)]
|
|
30
|
+
},
|
|
31
|
+
[Animation.Walk]: {
|
|
32
|
+
animations: ({ direction }) => [walk(direction)]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
framesHeight,
|
|
36
|
+
framesWidth
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { RMSpritesheet };
|
|
5
41
|
//# sourceMappingURL=index26.js.map
|
package/dist/index26.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index26.js","sources":["
|
|
1
|
+
{"version":3,"file":"index26.js","sources":["../src/presets/rmspritesheet.ts"],"sourcesContent":["import { Direction, Animation } from '@rpgjs/common'\n\nexport const RMSpritesheet = (framesWidth: number, framesHeight: number, frameStand: number = 1) => {\n\n if (framesWidth <= frameStand) {\n frameStand = framesWidth - 1\n }\n\n const frameY = direction => {\n const gap = Math.max(4 - framesHeight, 0)\n return {\n [Direction.Down]: 0,\n [Direction.Left]: Math.max(0, 1 - gap),\n [Direction.Right]: Math.max(0, 2 - gap),\n [Direction.Up]: Math.max(0, 3 - gap)\n }[direction]\n }\n\n const stand = (direction: number) => [{ time: 0, frameX: frameStand, frameY: frameY(direction) }]\n const walk = direction => {\n const array: any = []\n const durationFrame = 10\n for (let i = 0; i < framesWidth; i++) {\n array.push({ time: i * durationFrame, frameX: i, frameY: frameY(direction) })\n }\n array.push({ time: array[array.length - 1].time + durationFrame })\n return array\n }\n\n return {\n textures: {\n [Animation.Stand]: {\n animations: ({direction}) => [stand(direction)]\n },\n [Animation.Walk]: {\n animations: ({direction}) => [walk(direction)]\n }\n },\n framesHeight,\n framesWidth\n }\n}"],"names":[],"mappings":";;AAEO,MAAM,aAAgB,GAAA,CAAC,WAAqB,EAAA,YAAA,EAAsB,aAAqB,CAAM,KAAA;AAEhG,EAAA,IAAI,eAAe,UAAY,EAAA;AAC3B,IAAA,UAAA,GAAa,WAAc,GAAA,CAAA;AAAA;AAG/B,EAAA,MAAM,SAAS,CAAa,SAAA,KAAA;AACxB,IAAA,MAAM,GAAM,GAAA,IAAA,CAAK,GAAI,CAAA,CAAA,GAAI,cAAc,CAAC,CAAA;AACxC,IAAO,OAAA;AAAA,MACH,CAAC,SAAU,CAAA,IAAI,GAAG,CAAA;AAAA,MAClB,CAAC,UAAU,IAAI,GAAG,KAAK,GAAI,CAAA,CAAA,EAAG,IAAI,GAAG,CAAA;AAAA,MACrC,CAAC,UAAU,KAAK,GAAG,KAAK,GAAI,CAAA,CAAA,EAAG,IAAI,GAAG,CAAA;AAAA,MACtC,CAAC,UAAU,EAAE,GAAG,KAAK,GAAI,CAAA,CAAA,EA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