@rpgjs/client 5.0.0-alpha.22 → 5.0.0-alpha.24
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/Game/Object.d.ts +2 -0
- package/dist/RpgClientEngine.d.ts +115 -9
- package/dist/components/gui/mobile/index.d.ts +8 -0
- package/dist/components/prebuilt/index.d.ts +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +13 -8
- package/dist/index.js.map +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.js +6 -5
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +2 -2
- package/dist/index13.js +102 -10
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +67 -9
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +10 -263
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +9 -97
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +300 -89
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +63 -80
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +96 -348
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +176 -24
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +360 -17
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +19 -50
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +212 -5
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +6 -395
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +4 -39
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +19 -20
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +43 -2624
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +5 -110
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +394 -65
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +40 -15
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +3 -3
- package/dist/index30.js +21 -23
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +2624 -86
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +107 -34
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +69 -22
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +19 -3
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +21 -329
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +91 -30
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +37 -7
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +22 -9
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +139 -10
- package/dist/index39.js.map +1 -1
- package/dist/index4.js +3 -3
- package/dist/index40.js +16 -6
- package/dist/index40.js.map +1 -1
- package/dist/index41.js +1 -325
- package/dist/index41.js.map +1 -1
- package/dist/index42.js +530 -3680
- package/dist/index42.js.map +1 -1
- package/dist/index43.js +24 -67
- package/dist/index43.js.map +1 -1
- package/dist/index44.js +9 -184
- package/dist/index44.js.map +1 -1
- package/dist/index45.js +6 -503
- package/dist/index45.js.map +1 -1
- package/dist/index46.js +325 -2
- package/dist/index46.js.map +1 -1
- package/dist/index47.js +3687 -17
- package/dist/index47.js.map +1 -1
- package/dist/index48.js +69 -202
- package/dist/index48.js.map +1 -1
- package/dist/index49.js +182 -7
- package/dist/index49.js.map +1 -1
- package/dist/index5.js +1 -1
- package/dist/index50.js +497 -106
- package/dist/index50.js.map +1 -1
- package/dist/index51.js +48 -130
- package/dist/index51.js.map +1 -1
- package/dist/index52.js +17 -134
- package/dist/index52.js.map +1 -1
- package/dist/index53.js +3 -109
- package/dist/index53.js.map +1 -1
- package/dist/index54.js +9 -138
- package/dist/index54.js.map +1 -1
- package/dist/index55.js +111 -7
- package/dist/index55.js.map +1 -1
- package/dist/index56.js +130 -48
- package/dist/index56.js.map +1 -1
- package/dist/index57.js +137 -0
- package/dist/index57.js.map +1 -0
- package/dist/index58.js +112 -0
- package/dist/index58.js.map +1 -0
- package/dist/index59.js +9 -0
- package/dist/index59.js.map +1 -0
- package/dist/index6.js +1 -1
- package/dist/index7.js +1 -1
- package/dist/index8.js +17 -2
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +10 -27
- package/dist/index9.js.map +1 -1
- package/dist/services/keyboardControls.d.ts +1 -2
- package/dist/services/mmorpg.d.ts +1 -1
- package/dist/services/standalone.d.ts +1 -1
- package/package.json +9 -9
- package/src/Game/Object.ts +8 -0
- package/src/Gui/Gui.ts +4 -31
- package/src/RpgClientEngine.ts +193 -20
- package/src/components/character.ce +146 -9
- package/src/components/gui/mobile/index.ts +24 -0
- package/src/components/gui/mobile/mobile.ce +80 -0
- package/src/components/prebuilt/index.ts +1 -0
- package/src/components/prebuilt/light-halo.ce +148 -0
- package/src/components/scenes/canvas.ce +2 -2
- package/src/components/scenes/event-layer.ce +1 -0
- package/src/components/scenes/transition.ce +60 -0
- package/src/index.ts +6 -1
- package/src/module.ts +15 -0
- package/src/services/keyboardControls.ts +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<Container justifyContent="space-between" alignItems="flex-end" width="100%" height="100%">
|
|
2
|
+
<!-- Gamepad buttons A and B (left side) -->
|
|
3
|
+
<Container justifyContent="flex-start" alignItems="flex-end" gap={20}>
|
|
4
|
+
<Container display="flex" direction="column" gap={20} margin={50}>
|
|
5
|
+
<!-- Button B (top) -->
|
|
6
|
+
|
|
7
|
+
<!-- Button A (bottom) -->
|
|
8
|
+
<Button
|
|
9
|
+
text="A"
|
|
10
|
+
shape="circle"
|
|
11
|
+
width={70}
|
|
12
|
+
height={70}
|
|
13
|
+
controls={controlsInstance}
|
|
14
|
+
controlName="action"
|
|
15
|
+
style={{
|
|
16
|
+
backgroundColor: {
|
|
17
|
+
normal: "#2ecc71",
|
|
18
|
+
hover: "#27ae60",
|
|
19
|
+
pressed: "#229954",
|
|
20
|
+
disabled: "#7f8c8d"
|
|
21
|
+
},
|
|
22
|
+
text: {
|
|
23
|
+
fontSize: 24,
|
|
24
|
+
fontFamily: "Arial Bold",
|
|
25
|
+
color: "#ffffff"
|
|
26
|
+
}
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<Button
|
|
31
|
+
text="B"
|
|
32
|
+
shape="circle"
|
|
33
|
+
width={70}
|
|
34
|
+
height={70}
|
|
35
|
+
controls={controlsInstance}
|
|
36
|
+
controlName="back"
|
|
37
|
+
style={{
|
|
38
|
+
backgroundColor: {
|
|
39
|
+
normal: "#e74c3c",
|
|
40
|
+
hover: "#c0392b",
|
|
41
|
+
pressed: "#a93226",
|
|
42
|
+
disabled: "#7f8c8d"
|
|
43
|
+
},
|
|
44
|
+
text: {
|
|
45
|
+
fontSize: 24,
|
|
46
|
+
fontFamily: "Arial Bold",
|
|
47
|
+
color: "#ffffff"
|
|
48
|
+
}
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
</Container>
|
|
53
|
+
</Container>
|
|
54
|
+
|
|
55
|
+
<Container margin={100} alignItems="flex-end">
|
|
56
|
+
<Container>
|
|
57
|
+
<Joystick
|
|
58
|
+
controls={controlsInstance}
|
|
59
|
+
outerColor="#34495e"
|
|
60
|
+
innerColor="#3498db"
|
|
61
|
+
/>
|
|
62
|
+
</Container>
|
|
63
|
+
</Container>
|
|
64
|
+
</Container>
|
|
65
|
+
|
|
66
|
+
<script>
|
|
67
|
+
import { signal, mount } from 'canvasengine'
|
|
68
|
+
import { Button } from 'canvasengine'
|
|
69
|
+
import { inject } from '../../../core/inject'
|
|
70
|
+
import { RpgClientEngine } from '../../../RpgClientEngine'
|
|
71
|
+
import { Direction } from '@rpgjs/common'
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
const controlsInstance = signal(null)
|
|
75
|
+
|
|
76
|
+
mount((element) => {
|
|
77
|
+
const control = inject('KeyboardControls')
|
|
78
|
+
controlsInstance.set(control)
|
|
79
|
+
})
|
|
80
|
+
</script>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<Container x={position.@x} y={position.@y}>
|
|
2
|
+
<Graphics draw={drawHalo} />
|
|
3
|
+
</Container>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import { computed, signal, tick, mount } from "canvasengine";
|
|
7
|
+
import { BlurFilter } from "pixi.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Component props for LightHalo
|
|
11
|
+
*
|
|
12
|
+
* All props are signals (even static ones) and must be read with `()`.
|
|
13
|
+
* Props are optional and will use default values if not provided.
|
|
14
|
+
*
|
|
15
|
+
* @property {Object} object - The sprite object (required)
|
|
16
|
+
* @property {number|Signal<number>} [baseRadius] - Base radius of the light halo in pixels (default: 30)
|
|
17
|
+
* @property {number|Signal<number>} [radiusVariation] - Radius variation range (halo will pulse between baseRadius ± radiusVariation) (default: 10)
|
|
18
|
+
* @property {number|Signal<number>} [baseOpacity] - Base opacity of the light halo (0 to 1) (default: 0.6)
|
|
19
|
+
* @property {number|Signal<number>} [opacityVariation] - Opacity variation range (halo will fade between baseOpacity ± opacityVariation) (default: 0.3)
|
|
20
|
+
* @property {number|Signal<number>} [sizeSpeed] - Animation speed for size pulsing (higher = faster) (default: 0.002)
|
|
21
|
+
* @property {number|Signal<number>} [opacitySpeed] - Animation speed for opacity fading (higher = faster) (default: 0.003)
|
|
22
|
+
* @property {number|Signal<number>} [lightColor] - Color of the light halo (hex value, warm yellow-white by default: 0xffffaa)
|
|
23
|
+
*/
|
|
24
|
+
const {
|
|
25
|
+
object,
|
|
26
|
+
baseRadius,
|
|
27
|
+
radiusVariation,
|
|
28
|
+
baseOpacity,
|
|
29
|
+
opacityVariation,
|
|
30
|
+
sizeSpeed,
|
|
31
|
+
opacitySpeed,
|
|
32
|
+
lightColor
|
|
33
|
+
} = defineProps();
|
|
34
|
+
|
|
35
|
+
// ====================
|
|
36
|
+
// Props with default values
|
|
37
|
+
// ====================
|
|
38
|
+
|
|
39
|
+
const getBaseRadius = computed(() => baseRadius?.() ?? 30);
|
|
40
|
+
const getRadiusVariation = computed(() => radiusVariation?.() ?? 10);
|
|
41
|
+
const getBaseOpacity = computed(() => baseOpacity?.() ?? 0.6);
|
|
42
|
+
const getOpacityVariation = computed(() => opacityVariation?.() ?? 0.3);
|
|
43
|
+
const getSizeSpeed = computed(() => sizeSpeed?.() ?? 0.002);
|
|
44
|
+
const getOpacitySpeed = computed(() => opacitySpeed?.() ?? 0.003);
|
|
45
|
+
const getLightColor = computed(() => lightColor?.() ?? 0xffffaa);
|
|
46
|
+
|
|
47
|
+
// ====================
|
|
48
|
+
// Animation state
|
|
49
|
+
// ====================
|
|
50
|
+
|
|
51
|
+
/** Time counter for animations */
|
|
52
|
+
const time = signal(0);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Current radius of the halo with pulsing animation
|
|
56
|
+
* Uses multiple sine waves for more organic movement
|
|
57
|
+
*/
|
|
58
|
+
const currentRadius = computed(() => {
|
|
59
|
+
const t = time();
|
|
60
|
+
const base = getBaseRadius();
|
|
61
|
+
const variation = getRadiusVariation();
|
|
62
|
+
const speed = getSizeSpeed();
|
|
63
|
+
|
|
64
|
+
// Combine two sine waves for less predictable pulsing
|
|
65
|
+
const pulse1 = Math.sin(t * speed);
|
|
66
|
+
const pulse2 = Math.sin(t * speed * 1.5) * 0.5;
|
|
67
|
+
const combinedPulse = (pulse1 + pulse2) / 1.5;
|
|
68
|
+
|
|
69
|
+
return base + (combinedPulse * variation);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Current opacity of the halo with fading animation
|
|
74
|
+
* Includes a subtle flicker effect
|
|
75
|
+
*/
|
|
76
|
+
const currentOpacity = computed(() => {
|
|
77
|
+
const t = time();
|
|
78
|
+
const base = getBaseOpacity();
|
|
79
|
+
const variation = getOpacityVariation();
|
|
80
|
+
const speed = getOpacitySpeed();
|
|
81
|
+
|
|
82
|
+
// Main breathing cycle
|
|
83
|
+
const fade = Math.sin(t * speed);
|
|
84
|
+
|
|
85
|
+
// Subtle high-frequency flicker (candle-like)
|
|
86
|
+
const flicker = (Math.random() - 0.5) * 0.1;
|
|
87
|
+
|
|
88
|
+
return Math.max(0, Math.min(1, base + (fade * variation) + flicker));
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// ====================
|
|
92
|
+
// Position calculations
|
|
93
|
+
// ====================
|
|
94
|
+
|
|
95
|
+
const hitbox = object.hitbox;
|
|
96
|
+
|
|
97
|
+
const position = computed(() => ({
|
|
98
|
+
x: hitbox().w / 2,
|
|
99
|
+
y: hitbox().h / 2
|
|
100
|
+
}));
|
|
101
|
+
|
|
102
|
+
// ====================
|
|
103
|
+
// Drawing function
|
|
104
|
+
// ====================
|
|
105
|
+
|
|
106
|
+
// Create filters once to avoid recreation on every frame
|
|
107
|
+
const blurFilter = new BlurFilter({ strength: 20, quality: 3 });
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Draws the light halo effect with realistic diffusion
|
|
111
|
+
*/
|
|
112
|
+
const drawHalo = (g) => {
|
|
113
|
+
const radius = currentRadius();
|
|
114
|
+
const opacity = currentOpacity();
|
|
115
|
+
const color = getLightColor();
|
|
116
|
+
|
|
117
|
+
if (opacity <= 0 || radius <= 0) return;
|
|
118
|
+
|
|
119
|
+
// Set blend mode to ADD for glowing light effect
|
|
120
|
+
g.blendMode = 'add';
|
|
121
|
+
|
|
122
|
+
// Apply blur filter for soft light diffusion
|
|
123
|
+
g.filters = [blurFilter];
|
|
124
|
+
|
|
125
|
+
// Draw main light source
|
|
126
|
+
// The blur filter will spread this out into a nice gradient
|
|
127
|
+
g.circle(0, 0, radius);
|
|
128
|
+
g.fill({
|
|
129
|
+
color: color,
|
|
130
|
+
alpha: opacity
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Draw a smaller, brighter core
|
|
134
|
+
g.circle(0, 0, radius * 0.4);
|
|
135
|
+
g.fill({
|
|
136
|
+
color: 0xffffff,
|
|
137
|
+
alpha: opacity * 0.5
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// ====================
|
|
142
|
+
// Animation loop
|
|
143
|
+
// ====================
|
|
144
|
+
tick(() => {
|
|
145
|
+
time.update(t => t + 1);
|
|
146
|
+
});
|
|
147
|
+
</script>
|
|
148
|
+
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
@for (gui of gui) {
|
|
8
8
|
<Container display="flex">
|
|
9
9
|
@if (gui.display) {
|
|
10
|
-
<gui.component ...gui.data() onFinish={(data) => {
|
|
10
|
+
<gui.component ...gui.data() dependencies={@gui.@dependencies} onFinish={(data) => {
|
|
11
11
|
onGuiFinish(gui, data)
|
|
12
12
|
}} onInteraction={(name, data) => {
|
|
13
13
|
onGuiInteraction(gui, name, data)
|
|
14
14
|
}} />
|
|
15
15
|
}
|
|
16
16
|
</Container>
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
18
|
</Canvas>
|
|
19
19
|
|
|
20
20
|
<script>
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import { inject } from "../../core/inject";
|
|
18
18
|
import { RpgClientEngine } from "../../RpgClientEngine";
|
|
19
19
|
import Character from "../character.ce";
|
|
20
|
+
import LightHalo from "../prebuilt/light-halo.ce";
|
|
20
21
|
|
|
21
22
|
const engine = inject(RpgClientEngine);
|
|
22
23
|
const { children } = defineProps()
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<Rect
|
|
2
|
+
x={0}
|
|
3
|
+
y={0}
|
|
4
|
+
width={@engine.width}
|
|
5
|
+
height={@engine.height}
|
|
6
|
+
fill={color}
|
|
7
|
+
alpha={opacity}
|
|
8
|
+
zIndex={100000}
|
|
9
|
+
/>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
import { animatedSignal, mount, computed, signal } from "canvasengine";
|
|
13
|
+
import { inject } from "../../core/inject";
|
|
14
|
+
import { RpgClientEngine } from "../../RpgClientEngine";
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
onFinish,
|
|
18
|
+
duration,
|
|
19
|
+
color,
|
|
20
|
+
fadeIn
|
|
21
|
+
} = defineProps({
|
|
22
|
+
duration: {
|
|
23
|
+
default: 1000
|
|
24
|
+
},
|
|
25
|
+
color: {
|
|
26
|
+
default: 'black'
|
|
27
|
+
},
|
|
28
|
+
fadeIn: {
|
|
29
|
+
default: true
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const engine = inject(RpgClientEngine);
|
|
34
|
+
|
|
35
|
+
// Calculate width and height from engine
|
|
36
|
+
const width = computed(() => {
|
|
37
|
+
const w = engine.width();
|
|
38
|
+
return typeof w === 'string' ? parseInt(w) || 1920 : w;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const height = computed(() => {
|
|
42
|
+
const h = engine.height();
|
|
43
|
+
return typeof h === 'string' ? parseInt(h) || 1080 : h;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Animation: fade in from transparent to opaque, or fade out from opaque to transparent
|
|
47
|
+
const opacity = animatedSignal(fadeIn() ? 0 : 1, {
|
|
48
|
+
duration: duration(),
|
|
49
|
+
onComplete: () => {
|
|
50
|
+
if (onFinish) {
|
|
51
|
+
onFinish();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
mount(() => {
|
|
57
|
+
// Start the fade animation
|
|
58
|
+
opacity.set(fadeIn() ? 1 : 0);
|
|
59
|
+
});
|
|
60
|
+
</script>
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./module";
|
|
|
9
9
|
export * from "./Gui/Gui";
|
|
10
10
|
export * from "./components/gui";
|
|
11
11
|
export * from "./components/animations";
|
|
12
|
+
export * from "./components/prebuilt";
|
|
12
13
|
export * from "./presets";
|
|
13
14
|
export * from "./components";
|
|
14
15
|
export * from "./components/gui";
|
|
@@ -16,4 +17,8 @@ export * from "./Sound";
|
|
|
16
17
|
export * from "./Resource";
|
|
17
18
|
export { Context } from "@signe/di";
|
|
18
19
|
export { KeyboardControls, Input } from "canvasengine";
|
|
19
|
-
export { Control } from "./services/keyboardControls";
|
|
20
|
+
export { Control } from "./services/keyboardControls";
|
|
21
|
+
export { RpgClientObject } from "./Game/Object";
|
|
22
|
+
export { RpgClientPlayer } from "./Game/Player";
|
|
23
|
+
export { RpgClientEvent } from "./Game/Event";
|
|
24
|
+
export { withMobile } from "./components/gui/mobile";
|
package/src/module.ts
CHANGED
|
@@ -155,6 +155,21 @@ export function provideClientModules(modules: RpgClientModule[]): FactoryProvide
|
|
|
155
155
|
},
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
+
if (module.transitions) {
|
|
159
|
+
const transitions = [...module.transitions];
|
|
160
|
+
module.transitions = {
|
|
161
|
+
load: (engine: RpgClientEngine) => {
|
|
162
|
+
const guiService = inject(engine.context, RpgGui) as RpgGui;
|
|
163
|
+
transitions.forEach((transition) => {
|
|
164
|
+
guiService.add({
|
|
165
|
+
name: transition.id,
|
|
166
|
+
component: transition.component,
|
|
167
|
+
data: transition.props || {}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
158
173
|
if (module.particles) {
|
|
159
174
|
const particles = [...module.particles];
|
|
160
175
|
module.particles = {
|