@rpgjs/client 5.0.0-alpha.21 → 5.0.0-alpha.22
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 +109 -0
- package/dist/RpgClientEngine.d.ts +111 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index10.js +1 -1
- package/dist/index15.js +42 -3
- package/dist/index15.js.map +1 -1
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +142 -2
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +15 -2
- package/dist/index20.js.map +1 -1
- package/dist/index23.js.map +1 -1
- package/dist/index26.js +2 -2
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +2 -2
- package/dist/index27.js.map +1 -1
- package/dist/index34.js.map +1 -1
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +8 -1
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +1 -1
- package/dist/index38.js +1 -1
- package/dist/index40.js +6 -6
- package/dist/index41.js +320 -3681
- package/dist/index41.js.map +1 -1
- package/dist/index42.js +3686 -183
- package/dist/index42.js.map +1 -1
- package/dist/index43.js +71 -498
- package/dist/index43.js.map +1 -1
- package/dist/index44.js +182 -72
- package/dist/index44.js.map +1 -1
- package/dist/index45.js +500 -2
- package/dist/index45.js.map +1 -1
- package/dist/index46.js +3 -17
- package/dist/index46.js.map +1 -1
- package/dist/index47.js +16 -142
- package/dist/index47.js.map +1 -1
- package/dist/index48.js +206 -8
- package/dist/index48.js.map +1 -1
- package/dist/index49.js +7 -108
- package/dist/index49.js.map +1 -1
- package/dist/index50.js +104 -127
- package/dist/index50.js.map +1 -1
- package/dist/index51.js +122 -123
- package/dist/index51.js.map +1 -1
- package/dist/index52.js +123 -98
- package/dist/index52.js.map +1 -1
- package/dist/index53.js +107 -136
- package/dist/index53.js.map +1 -1
- package/dist/index54.js +139 -7
- package/dist/index54.js.map +1 -1
- package/dist/index55.js +7 -52
- package/dist/index55.js.map +1 -1
- package/dist/index56.js +54 -0
- package/dist/index56.js.map +1 -0
- package/dist/index8.js +8 -0
- package/dist/index8.js.map +1 -1
- package/dist/module.d.ts +43 -4
- package/dist/services/keyboardControls.d.ts +13 -2
- package/dist/services/mmorpg.d.ts +1 -1
- package/dist/services/standalone.d.ts +1 -1
- package/package.json +11 -10
- package/src/Game/Object.ts +82 -8
- package/src/RpgClientEngine.ts +173 -2
- package/src/components/character.ce +67 -4
- package/src/components/prebuilt/index.ts +1 -0
- package/src/components/scenes/draw-map.ce +12 -3
- package/src/index.ts +2 -1
- package/src/module.ts +56 -2
- package/src/services/keyboardControls.ts +13 -1
package/dist/index47.js
CHANGED
|
@@ -1,146 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { trigger, signal } from 'canvasengine';
|
|
3
|
-
import { map, filter, switchMap, from } from 'rxjs';
|
|
4
|
-
import { inject } from './index6.js';
|
|
5
|
-
import { RpgClientEngine } from './index2.js';
|
|
6
|
-
import component from './index53.js';
|
|
1
|
+
import { useProps, useDefineProps, animatedSignal, h, Container, Rect, Text } from 'canvasengine';
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this._component = {};
|
|
23
|
-
this.hooks.callHooks("client-sprite-onInit", this).subscribe();
|
|
24
|
-
this._frames.observable.subscribe(({ items }) => {
|
|
25
|
-
if (!this.id) return;
|
|
26
|
-
this.frames = [...this.frames, ...items];
|
|
27
|
-
});
|
|
28
|
-
this.graphics.observable.pipe(
|
|
29
|
-
map(({ items }) => items),
|
|
30
|
-
filter((graphics) => graphics.length > 0),
|
|
31
|
-
switchMap((graphics) => from(Promise.all(graphics.map((graphic) => this.engine.getSpriteSheet(graphic)))))
|
|
32
|
-
).subscribe((sheets) => {
|
|
33
|
-
this.graphicsSignals.set(sheets);
|
|
34
|
-
});
|
|
35
|
-
this.componentsTop.observable.pipe(
|
|
36
|
-
filter((value) => value !== null && value !== void 0),
|
|
37
|
-
map((value) => typeof value === "string" ? JSON.parse(value) : value)
|
|
38
|
-
).subscribe(({ components }) => {
|
|
39
|
-
for (const component of components) {
|
|
40
|
-
for (const [key, value] of Object.entries(component)) {
|
|
41
|
-
this._component = value;
|
|
42
|
-
console.log(value);
|
|
43
|
-
const type = value.type;
|
|
44
|
-
if (DYNAMIC_COMPONENTS[type]) {
|
|
45
|
-
this.engine.addSpriteComponentInFront(DYNAMIC_COMPONENTS[type]);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
3
|
+
function component($$props) {
|
|
4
|
+
useProps($$props);
|
|
5
|
+
const defineProps = useDefineProps($$props);
|
|
6
|
+
var _a = defineProps(), text = _a.text, isSelected = _a.isSelected;
|
|
7
|
+
var alpha = animatedSignal(1, {
|
|
8
|
+
repeatType: "reverse",
|
|
9
|
+
duration: 500,
|
|
10
|
+
repeat: Infinity,
|
|
11
|
+
});
|
|
12
|
+
alpha.set(0.5);
|
|
13
|
+
var height = 40;
|
|
14
|
+
var width = 256;
|
|
15
|
+
let $this = h(Container, null, [h(Rect, { width, height, color: '#595971', alpha, visible: isSelected }), h(Container, { flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }, h(Text, { text, color: '#fff', fontSize: 18, margin: 10 }))]);
|
|
16
|
+
return $this
|
|
48
17
|
}
|
|
49
|
-
});
|
|
50
|
-
this.engine.tick.pipe().subscribe(() => {
|
|
51
|
-
const frame = this.frames.shift();
|
|
52
|
-
if (frame) {
|
|
53
|
-
if (!frame.x || !frame.y) return;
|
|
54
|
-
this.engine.scene.setBodyPosition(
|
|
55
|
-
this.id,
|
|
56
|
-
frame.x,
|
|
57
|
-
frame.y,
|
|
58
|
-
"top-left"
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
get hooks() {
|
|
64
|
-
return inject(ModulesToken);
|
|
65
|
-
}
|
|
66
|
-
get engine() {
|
|
67
|
-
return inject(RpgClientEngine);
|
|
68
|
-
}
|
|
69
|
-
flash(color, duration = 100) {
|
|
70
|
-
return new Promise((resolve) => {
|
|
71
|
-
const lastTint = this.tint();
|
|
72
|
-
this.tint.set(color);
|
|
73
|
-
setTimeout(() => {
|
|
74
|
-
this.tint.set(lastTint);
|
|
75
|
-
resolve(true);
|
|
76
|
-
}, duration);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Reset animation state when animation changes externally
|
|
81
|
-
*
|
|
82
|
-
* This method should be called when the animation changes due to movement
|
|
83
|
-
* or other external factors to ensure the animation system doesn't get stuck
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```ts
|
|
87
|
-
* // Reset when player starts moving
|
|
88
|
-
* player.resetAnimationState();
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
resetAnimationState() {
|
|
92
|
-
this.animationIsPlaying.set(false);
|
|
93
|
-
this.animationCurrentIndex.set(0);
|
|
94
|
-
if (this.animationSubscription) {
|
|
95
|
-
this.animationSubscription.unsubscribe();
|
|
96
|
-
this.animationSubscription = void 0;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Set a custom animation for a specific number of times
|
|
101
|
-
*
|
|
102
|
-
* Plays a custom animation for the specified number of repetitions.
|
|
103
|
-
* The animation system prevents overlapping animations and automatically
|
|
104
|
-
* returns to the previous animation when complete.
|
|
105
|
-
*
|
|
106
|
-
* @param animationName - Name of the animation to play
|
|
107
|
-
* @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```ts
|
|
111
|
-
* // Play attack animation 3 times
|
|
112
|
-
* player.setAnimation('attack', 3);
|
|
113
|
-
*
|
|
114
|
-
* // Play continuous spell animation
|
|
115
|
-
* player.setAnimation('spell');
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
setAnimation(animationName, nbTimes = Infinity) {
|
|
119
|
-
if (this.animationIsPlaying()) return;
|
|
120
|
-
this.animationIsPlaying.set(true);
|
|
121
|
-
const previousAnimationName = this.animationName();
|
|
122
|
-
this.animationCurrentIndex.set(0);
|
|
123
|
-
if (this.animationSubscription) {
|
|
124
|
-
this.animationSubscription.unsubscribe();
|
|
125
|
-
}
|
|
126
|
-
this.animationSubscription = this.animationCurrentIndex.observable.subscribe((index) => {
|
|
127
|
-
if (index >= nbTimes) {
|
|
128
|
-
this.animationCurrentIndex.set(0);
|
|
129
|
-
this.animationName.set(previousAnimationName);
|
|
130
|
-
this.animationIsPlaying.set(false);
|
|
131
|
-
if (this.animationSubscription) {
|
|
132
|
-
this.animationSubscription.unsubscribe();
|
|
133
|
-
this.animationSubscription = void 0;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
this.animationName.set(animationName);
|
|
138
|
-
}
|
|
139
|
-
showComponentAnimation(id, params) {
|
|
140
|
-
const engine = inject(RpgClientEngine);
|
|
141
|
-
engine.getComponentAnimation(id).displayEffect(params, this);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
18
|
|
|
145
|
-
export {
|
|
19
|
+
export { component as default };
|
|
146
20
|
//# sourceMappingURL=index47.js.map
|
package/dist/index47.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index47.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index47.js","sources":["../src/components/gui/dialogbox/itemMenu.ce"],"sourcesContent":["<Container>\n <Rect width height color=\"#595971\" alpha visible={isSelected} />\n <Container flexDirection=\"row\" alignItems=\"center\" justifyContent=\"center\">\n <Text text color=\"#fff\" fontSize={18} margin={10} />\n </Container>\n</Container>\n\n<script>\nimport { animatedSignal } from \"canvasengine\";\n\nconst { text, isSelected } = defineProps();\n\nconst alpha = animatedSignal(1, {\n repeatType: \"reverse\",\n duration: 500,\n repeat: Infinity,\n});\n\nalpha.set(0.5);\n\nconst height = 40;\nconst width = 256;\n</script>"],"names":[],"mappings":";;AAQqB,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,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,EAAE,CAAC,UAAU;AAC1E,IAAI,KAAK,GAAG,cAAc,CAAC,CAAC,EAAE;AAC9B,IAAI,UAAU,EAAE,SAAS;AACzB,IAAI,QAAQ,EAAE,GAAG;AACjB,IAAI,MAAM,EAAE,QAAQ;AACpB,CAAC,CAAC;AACF,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;AACd,IAAI,MAAM,GAAG,EAAE;AACf,IAAI,KAAK,GAAG,GAAG;AACf,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACrQ,QAAQ,OAAO;AACf,MAAM;;;;"}
|
package/dist/index48.js
CHANGED
|
@@ -1,12 +1,210 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RpgCommonPlayer, ModulesToken } from '@rpgjs/common';
|
|
2
|
+
import { trigger, signal } from 'canvasengine';
|
|
3
|
+
import { map, filter, switchMap, from } from 'rxjs';
|
|
4
|
+
import { inject } from './index6.js';
|
|
5
|
+
import { RpgClientEngine } from './index2.js';
|
|
6
|
+
import component from './index54.js';
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const DYNAMIC_COMPONENTS = {
|
|
9
|
+
text: component
|
|
10
|
+
};
|
|
11
|
+
class RpgClientObject extends RpgCommonPlayer {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.emitParticleTrigger = trigger();
|
|
15
|
+
this.particleName = signal("");
|
|
16
|
+
this.animationCurrentIndex = signal(0);
|
|
17
|
+
this.animationIsPlaying = signal(false);
|
|
18
|
+
this._param = signal({});
|
|
19
|
+
this.frames = [];
|
|
20
|
+
this.graphicsSignals = signal([]);
|
|
21
|
+
this._component = {};
|
|
22
|
+
// temporary component memory
|
|
23
|
+
this.flashTrigger = trigger();
|
|
24
|
+
this.hooks.callHooks("client-sprite-onInit", this).subscribe();
|
|
25
|
+
this._frames.observable.subscribe(({ items }) => {
|
|
26
|
+
if (!this.id) return;
|
|
27
|
+
this.frames = [...this.frames, ...items];
|
|
28
|
+
});
|
|
29
|
+
this.graphics.observable.pipe(
|
|
30
|
+
map(({ items }) => items),
|
|
31
|
+
filter((graphics) => graphics.length > 0),
|
|
32
|
+
switchMap((graphics) => from(Promise.all(graphics.map((graphic) => this.engine.getSpriteSheet(graphic)))))
|
|
33
|
+
).subscribe((sheets) => {
|
|
34
|
+
this.graphicsSignals.set(sheets);
|
|
35
|
+
});
|
|
36
|
+
this.componentsTop.observable.pipe(
|
|
37
|
+
filter((value) => value !== null && value !== void 0),
|
|
38
|
+
map((value) => typeof value === "string" ? JSON.parse(value) : value)
|
|
39
|
+
).subscribe(({ components }) => {
|
|
40
|
+
for (const component of components) {
|
|
41
|
+
for (const [key, value] of Object.entries(component)) {
|
|
42
|
+
this._component = value;
|
|
43
|
+
console.log(value);
|
|
44
|
+
const type = value.type;
|
|
45
|
+
if (DYNAMIC_COMPONENTS[type]) {
|
|
46
|
+
this.engine.addSpriteComponentInFront(DYNAMIC_COMPONENTS[type]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
this.engine.tick.pipe().subscribe(() => {
|
|
52
|
+
const frame = this.frames.shift();
|
|
53
|
+
if (frame) {
|
|
54
|
+
if (!frame.x || !frame.y) return;
|
|
55
|
+
this.engine.scene.setBodyPosition(
|
|
56
|
+
this.id,
|
|
57
|
+
frame.x,
|
|
58
|
+
frame.y,
|
|
59
|
+
"top-left"
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
get hooks() {
|
|
65
|
+
return inject(ModulesToken);
|
|
66
|
+
}
|
|
67
|
+
get engine() {
|
|
68
|
+
return inject(RpgClientEngine);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Trigger a flash animation on this sprite
|
|
72
|
+
*
|
|
73
|
+
* This method triggers a flash effect using CanvasEngine's flash directive.
|
|
74
|
+
* The flash can be configured with various options including type (alpha, tint, or both),
|
|
75
|
+
* duration, cycles, and color.
|
|
76
|
+
*
|
|
77
|
+
* ## Design
|
|
78
|
+
*
|
|
79
|
+
* The flash uses a trigger system that is connected to the flash directive in the
|
|
80
|
+
* character component. This allows for flexible configuration and can be triggered
|
|
81
|
+
* from both server events and client-side code.
|
|
82
|
+
*
|
|
83
|
+
* @param options - Flash configuration options
|
|
84
|
+
* @param options.type - Type of flash effect: 'alpha' (opacity), 'tint' (color), or 'both' (default: 'alpha')
|
|
85
|
+
* @param options.duration - Duration of the flash animation in milliseconds (default: 300)
|
|
86
|
+
* @param options.cycles - Number of flash cycles (flash on/off) (default: 1)
|
|
87
|
+
* @param options.alpha - Alpha value when flashing, from 0 to 1 (default: 0.3)
|
|
88
|
+
* @param options.tint - Tint color when flashing as hex value or color name (default: 0xffffff - white)
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* // Simple flash with default settings (alpha flash)
|
|
93
|
+
* player.flash();
|
|
94
|
+
*
|
|
95
|
+
* // Flash with red tint
|
|
96
|
+
* player.flash({ type: 'tint', tint: 0xff0000 });
|
|
97
|
+
*
|
|
98
|
+
* // Flash with both alpha and tint
|
|
99
|
+
* player.flash({
|
|
100
|
+
* type: 'both',
|
|
101
|
+
* alpha: 0.5,
|
|
102
|
+
* tint: 0xff0000,
|
|
103
|
+
* duration: 200,
|
|
104
|
+
* cycles: 2
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* // Quick damage flash
|
|
108
|
+
* player.flash({
|
|
109
|
+
* type: 'tint',
|
|
110
|
+
* tint: 0xff0000,
|
|
111
|
+
* duration: 150,
|
|
112
|
+
* cycles: 1
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
flash(options) {
|
|
117
|
+
const flashOptions = {
|
|
118
|
+
type: options?.type || "alpha",
|
|
119
|
+
duration: options?.duration ?? 300,
|
|
120
|
+
cycles: options?.cycles ?? 1,
|
|
121
|
+
alpha: options?.alpha ?? 0.3,
|
|
122
|
+
tint: options?.tint ?? 16777215
|
|
123
|
+
};
|
|
124
|
+
let tintValue = flashOptions.tint;
|
|
125
|
+
if (typeof tintValue === "string") {
|
|
126
|
+
const colorMap = {
|
|
127
|
+
"white": 16777215,
|
|
128
|
+
"red": 16711680,
|
|
129
|
+
"green": 65280,
|
|
130
|
+
"blue": 255,
|
|
131
|
+
"yellow": 16776960,
|
|
132
|
+
"cyan": 65535,
|
|
133
|
+
"magenta": 16711935,
|
|
134
|
+
"black": 0
|
|
135
|
+
};
|
|
136
|
+
tintValue = colorMap[tintValue.toLowerCase()] ?? 16777215;
|
|
137
|
+
}
|
|
138
|
+
this.flashTrigger.start({
|
|
139
|
+
...flashOptions,
|
|
140
|
+
tint: tintValue
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Reset animation state when animation changes externally
|
|
145
|
+
*
|
|
146
|
+
* This method should be called when the animation changes due to movement
|
|
147
|
+
* or other external factors to ensure the animation system doesn't get stuck
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* // Reset when player starts moving
|
|
152
|
+
* player.resetAnimationState();
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
resetAnimationState() {
|
|
156
|
+
this.animationIsPlaying.set(false);
|
|
157
|
+
this.animationCurrentIndex.set(0);
|
|
158
|
+
if (this.animationSubscription) {
|
|
159
|
+
this.animationSubscription.unsubscribe();
|
|
160
|
+
this.animationSubscription = void 0;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Set a custom animation for a specific number of times
|
|
165
|
+
*
|
|
166
|
+
* Plays a custom animation for the specified number of repetitions.
|
|
167
|
+
* The animation system prevents overlapping animations and automatically
|
|
168
|
+
* returns to the previous animation when complete.
|
|
169
|
+
*
|
|
170
|
+
* @param animationName - Name of the animation to play
|
|
171
|
+
* @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* // Play attack animation 3 times
|
|
176
|
+
* player.setAnimation('attack', 3);
|
|
177
|
+
*
|
|
178
|
+
* // Play continuous spell animation
|
|
179
|
+
* player.setAnimation('spell');
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
setAnimation(animationName, nbTimes = Infinity) {
|
|
183
|
+
if (this.animationIsPlaying()) return;
|
|
184
|
+
this.animationIsPlaying.set(true);
|
|
185
|
+
const previousAnimationName = this.animationName();
|
|
186
|
+
this.animationCurrentIndex.set(0);
|
|
187
|
+
if (this.animationSubscription) {
|
|
188
|
+
this.animationSubscription.unsubscribe();
|
|
189
|
+
}
|
|
190
|
+
this.animationSubscription = this.animationCurrentIndex.observable.subscribe((index) => {
|
|
191
|
+
if (index >= nbTimes) {
|
|
192
|
+
this.animationCurrentIndex.set(0);
|
|
193
|
+
this.animationName.set(previousAnimationName);
|
|
194
|
+
this.animationIsPlaying.set(false);
|
|
195
|
+
if (this.animationSubscription) {
|
|
196
|
+
this.animationSubscription.unsubscribe();
|
|
197
|
+
this.animationSubscription = void 0;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
this.animationName.set(animationName);
|
|
202
|
+
}
|
|
203
|
+
showComponentAnimation(id, params) {
|
|
204
|
+
const engine = inject(RpgClientEngine);
|
|
205
|
+
engine.getComponentAnimation(id).displayEffect(params, this);
|
|
206
|
+
}
|
|
9
207
|
}
|
|
10
208
|
|
|
11
|
-
export {
|
|
209
|
+
export { RpgClientObject };
|
|
12
210
|
//# sourceMappingURL=index48.js.map
|
package/dist/index48.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index48.js","sources":["../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js"],"sourcesContent":["import defaultErrorMap from \"./locales/en.js\";\nlet overrideErrorMap = defaultErrorMap;\nexport { defaultErrorMap };\nexport function setErrorMap(map) {\n overrideErrorMap = map;\n}\nexport function getErrorMap() {\n return overrideErrorMap;\n}\n"],"names":["defaultErrorMap"],"mappings":";;AACA,IAAI,gBAAgB,GAAGA,QAAe;AAE/B,SAAS,WAAW,CAAC,GAAG,EAAE;AACjC,IAAI,gBAAgB,GAAG,GAAG;AAC1B;AACO,SAAS,WAAW,GAAG;AAC9B,IAAI,OAAO,gBAAgB;AAC3B;;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index48.js","sources":["../src/Game/Object.ts"],"sourcesContent":["import { Hooks, ModulesToken, RpgCommonPlayer } from \"@rpgjs/common\";\nimport { trigger, signal } from \"canvasengine\";\nimport { filter, from, map, Subscription, switchMap } from \"rxjs\";\nimport { inject } from \"../core/inject\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport TextComponent from \"../components/dynamics/text.ce\";\n\nconst DYNAMIC_COMPONENTS = {\n text: TextComponent,\n}\n\nexport abstract class RpgClientObject extends RpgCommonPlayer {\n abstract type: string;\n emitParticleTrigger = trigger();\n particleName = signal(\"\");\n animationCurrentIndex = signal(0);\n animationIsPlaying = signal(false);\n _param = signal({});\n frames: { x: number; y: number; ts: number }[] = [];\n graphicsSignals = signal<any[]>([]);\n _component = {} // temporary component memory\n flashTrigger = trigger();\n\n constructor() {\n super();\n this.hooks.callHooks(\"client-sprite-onInit\", this).subscribe();\n\n this._frames.observable.subscribe(({ items }) => {\n if (!this.id) return;\n //if (this.id == this.engine.playerIdSignal()!) return;\n this.frames = [...this.frames, ...items];\n });\n\n this.graphics.observable\n .pipe(\n map(({ items }) => items),\n filter(graphics => graphics.length > 0),\n switchMap(graphics => from(Promise.all(graphics.map(graphic => this.engine.getSpriteSheet(graphic)))))\n )\n .subscribe((sheets) => { \n this.graphicsSignals.set(sheets);\n });\n\n this.componentsTop.observable\n .pipe(\n filter(value => value !== null && value !== undefined),\n map((value) => typeof value === 'string' ? JSON.parse(value) : value),\n )\n .subscribe(({components}) => {\n for (const component of components) {\n for (const [key, value] of Object.entries(component)) {\n this._component = value as any; // temporary component memory\n console.log(value)\n const type = (value as any).type as keyof typeof DYNAMIC_COMPONENTS;\n if (DYNAMIC_COMPONENTS[type]) {\n this.engine.addSpriteComponentInFront(DYNAMIC_COMPONENTS[type]);\n }\n }\n }\n });\n\n this.engine.tick\n .pipe\n //throttleTime(10)\n ()\n .subscribe(() => {\n const frame = this.frames.shift();\n if (frame) {\n if (!frame.x || !frame.y) return;\n this.engine.scene.setBodyPosition(\n this.id,\n frame.x,\n frame.y,\n \"top-left\"\n );\n }\n });\n }\n\n get hooks() {\n return inject<Hooks>(ModulesToken);\n }\n\n get engine() {\n return inject(RpgClientEngine);\n }\n\n private animationSubscription?: Subscription;\n\n /**\n * Trigger a flash animation on this sprite\n * \n * This method triggers a flash effect using CanvasEngine's flash directive.\n * The flash can be configured with various options including type (alpha, tint, or both),\n * duration, cycles, and color.\n * \n * ## Design\n * \n * The flash uses a trigger system that is connected to the flash directive in the\n * character component. This allows for flexible configuration and can be triggered\n * from both server events and client-side code.\n * \n * @param options - Flash configuration options\n * @param options.type - Type of flash effect: 'alpha' (opacity), 'tint' (color), or 'both' (default: 'alpha')\n * @param options.duration - Duration of the flash animation in milliseconds (default: 300)\n * @param options.cycles - Number of flash cycles (flash on/off) (default: 1)\n * @param options.alpha - Alpha value when flashing, from 0 to 1 (default: 0.3)\n * @param options.tint - Tint color when flashing as hex value or color name (default: 0xffffff - white)\n * \n * @example\n * ```ts\n * // Simple flash with default settings (alpha flash)\n * player.flash();\n * \n * // Flash with red tint\n * player.flash({ type: 'tint', tint: 0xff0000 });\n * \n * // Flash with both alpha and tint\n * player.flash({ \n * type: 'both', \n * alpha: 0.5, \n * tint: 0xff0000,\n * duration: 200,\n * cycles: 2\n * });\n * \n * // Quick damage flash\n * player.flash({ \n * type: 'tint', \n * tint: 0xff0000, \n * duration: 150,\n * cycles: 1\n * });\n * ```\n */\n flash(options?: {\n type?: 'alpha' | 'tint' | 'both';\n duration?: number;\n cycles?: number;\n alpha?: number;\n tint?: number | string;\n }): void {\n const flashOptions = {\n type: options?.type || 'alpha',\n duration: options?.duration ?? 300,\n cycles: options?.cycles ?? 1,\n alpha: options?.alpha ?? 0.3,\n tint: options?.tint ?? 0xffffff,\n };\n \n // Convert color name to hex if needed\n let tintValue = flashOptions.tint;\n if (typeof tintValue === 'string') {\n // Common color name to hex mapping\n const colorMap: Record<string, number> = {\n 'white': 0xffffff,\n 'red': 0xff0000,\n 'green': 0x00ff00,\n 'blue': 0x0000ff,\n 'yellow': 0xffff00,\n 'cyan': 0x00ffff,\n 'magenta': 0xff00ff,\n 'black': 0x000000,\n };\n tintValue = colorMap[tintValue.toLowerCase()] ?? 0xffffff;\n }\n \n this.flashTrigger.start({\n ...flashOptions,\n tint: tintValue,\n });\n }\n\n /**\n * Reset animation state when animation changes externally\n *\n * This method should be called when the animation changes due to movement\n * or other external factors to ensure the animation system doesn't get stuck\n *\n * @example\n * ```ts\n * // Reset when player starts moving\n * player.resetAnimationState();\n * ```\n */\n resetAnimationState() {\n this.animationIsPlaying.set(false);\n this.animationCurrentIndex.set(0);\n if (this.animationSubscription) {\n this.animationSubscription.unsubscribe();\n this.animationSubscription = undefined;\n }\n }\n\n /**\n * Set a custom animation for a specific number of times\n *\n * Plays a custom animation for the specified number of repetitions.\n * The animation system prevents overlapping animations and automatically\n * returns to the previous animation when complete.\n *\n * @param animationName - Name of the animation to play\n * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)\n *\n * @example\n * ```ts\n * // Play attack animation 3 times\n * player.setAnimation('attack', 3);\n *\n * // Play continuous spell animation\n * player.setAnimation('spell');\n * ```\n */\n setAnimation(animationName: string, nbTimes: number = Infinity) {\n if (this.animationIsPlaying()) return;\n this.animationIsPlaying.set(true);\n const previousAnimationName = this.animationName();\n this.animationCurrentIndex.set(0);\n\n // Clean up any existing subscription\n if (this.animationSubscription) {\n this.animationSubscription.unsubscribe();\n }\n\n this.animationSubscription =\n this.animationCurrentIndex.observable.subscribe((index) => {\n if (index >= nbTimes) {\n this.animationCurrentIndex.set(0);\n this.animationName.set(previousAnimationName);\n this.animationIsPlaying.set(false);\n if (this.animationSubscription) {\n this.animationSubscription.unsubscribe();\n this.animationSubscription = undefined;\n }\n }\n });\n this.animationName.set(animationName);\n }\n\n showComponentAnimation(id: string, params: any) {\n const engine = inject(RpgClientEngine);\n engine.getComponentAnimation(id).displayEffect(params, this);\n }\n}\n"],"names":["TextComponent"],"mappings":";;;;;;;AAOA,MAAM,kBAAA,GAAqB;AAAA,EACzB,IAAA,EAAMA;AACR,CAAA;AAEO,MAAe,wBAAwB,eAAA,CAAgB;AAAA,EAY5D,WAAA,GAAc;AACZ,IAAA,KAAA,EA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,kBAAA,CAAmB,IAAI,KAAK,CAAA;AACjC,QAAA,IAAI,KAAK,qBAAA,EAAuB;AAC9B,UAAA,IAAA,CAAK,sBAAsB,WAAA,EAAY;AACvC,UAAA,IAAA,CAAK,qBAAA,GAAwB,MAAA;AAAA,QAC/B;AAAA,MACF;AAAA,IACF,CAAC,CAAA;AACH,IAAA,IAAA,CAAK,aAAA,CAAc,IAAI,aAAa,CAAA;AAAA,EACtC;AAAA,EAEA,sBAAA,CAAuB,IAAY,MAAA,EAAa;AAC9C,IAAA,MAAM,MAAA,GAAS,OAAO,eAAe,CAAA;AACrC,IAAA,MAAA,CAAO,qBAAA,CAAsB,EAAE,CAAA,CAAE,aAAA,CAAc,QAAQ,IAAI,CAAA;AAAA,EAC7D;AACF;;;;"}
|
package/dist/index49.js
CHANGED
|
@@ -1,113 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import errorMap from './index52.js';
|
|
1
|
+
import errorMap from './index53.js';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const fullIssue = {
|
|
8
|
-
...issueData,
|
|
9
|
-
path: fullPath,
|
|
10
|
-
};
|
|
11
|
-
if (issueData.message !== undefined) {
|
|
12
|
-
return {
|
|
13
|
-
...issueData,
|
|
14
|
-
path: fullPath,
|
|
15
|
-
message: issueData.message,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
let errorMessage = "";
|
|
19
|
-
const maps = errorMaps
|
|
20
|
-
.filter((m) => !!m)
|
|
21
|
-
.slice()
|
|
22
|
-
.reverse();
|
|
23
|
-
for (const map of maps) {
|
|
24
|
-
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
...issueData,
|
|
28
|
-
path: fullPath,
|
|
29
|
-
message: errorMessage,
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
const EMPTY_PATH = [];
|
|
33
|
-
function addIssueToContext(ctx, issueData) {
|
|
34
|
-
const overrideMap = getErrorMap();
|
|
35
|
-
const issue = makeIssue({
|
|
36
|
-
issueData: issueData,
|
|
37
|
-
data: ctx.data,
|
|
38
|
-
path: ctx.path,
|
|
39
|
-
errorMaps: [
|
|
40
|
-
ctx.common.contextualErrorMap, // contextual error map is first priority
|
|
41
|
-
ctx.schemaErrorMap, // then schema-bound map if available
|
|
42
|
-
overrideMap, // then global override map
|
|
43
|
-
overrideMap === errorMap ? undefined : errorMap, // then global default map
|
|
44
|
-
].filter((x) => !!x),
|
|
45
|
-
});
|
|
46
|
-
ctx.common.issues.push(issue);
|
|
3
|
+
let overrideErrorMap = errorMap;
|
|
4
|
+
function setErrorMap(map) {
|
|
5
|
+
overrideErrorMap = map;
|
|
47
6
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.value = "valid";
|
|
51
|
-
}
|
|
52
|
-
dirty() {
|
|
53
|
-
if (this.value === "valid")
|
|
54
|
-
this.value = "dirty";
|
|
55
|
-
}
|
|
56
|
-
abort() {
|
|
57
|
-
if (this.value !== "aborted")
|
|
58
|
-
this.value = "aborted";
|
|
59
|
-
}
|
|
60
|
-
static mergeArray(status, results) {
|
|
61
|
-
const arrayValue = [];
|
|
62
|
-
for (const s of results) {
|
|
63
|
-
if (s.status === "aborted")
|
|
64
|
-
return INVALID;
|
|
65
|
-
if (s.status === "dirty")
|
|
66
|
-
status.dirty();
|
|
67
|
-
arrayValue.push(s.value);
|
|
68
|
-
}
|
|
69
|
-
return { status: status.value, value: arrayValue };
|
|
70
|
-
}
|
|
71
|
-
static async mergeObjectAsync(status, pairs) {
|
|
72
|
-
const syncPairs = [];
|
|
73
|
-
for (const pair of pairs) {
|
|
74
|
-
const key = await pair.key;
|
|
75
|
-
const value = await pair.value;
|
|
76
|
-
syncPairs.push({
|
|
77
|
-
key,
|
|
78
|
-
value,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
82
|
-
}
|
|
83
|
-
static mergeObjectSync(status, pairs) {
|
|
84
|
-
const finalObject = {};
|
|
85
|
-
for (const pair of pairs) {
|
|
86
|
-
const { key, value } = pair;
|
|
87
|
-
if (key.status === "aborted")
|
|
88
|
-
return INVALID;
|
|
89
|
-
if (value.status === "aborted")
|
|
90
|
-
return INVALID;
|
|
91
|
-
if (key.status === "dirty")
|
|
92
|
-
status.dirty();
|
|
93
|
-
if (value.status === "dirty")
|
|
94
|
-
status.dirty();
|
|
95
|
-
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
96
|
-
finalObject[key.value] = value.value;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return { status: status.value, value: finalObject };
|
|
100
|
-
}
|
|
7
|
+
function getErrorMap() {
|
|
8
|
+
return overrideErrorMap;
|
|
101
9
|
}
|
|
102
|
-
const INVALID = Object.freeze({
|
|
103
|
-
status: "aborted",
|
|
104
|
-
});
|
|
105
|
-
const DIRTY = (value) => ({ status: "dirty", value });
|
|
106
|
-
const OK = (value) => ({ status: "valid", value });
|
|
107
|
-
const isAborted = (x) => x.status === "aborted";
|
|
108
|
-
const isDirty = (x) => x.status === "dirty";
|
|
109
|
-
const isValid = (x) => x.status === "valid";
|
|
110
|
-
const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
111
10
|
|
|
112
|
-
export {
|
|
11
|
+
export { errorMap as defaultErrorMap, getErrorMap, setErrorMap };
|
|
113
12
|
//# sourceMappingURL=index49.js.map
|
package/dist/index49.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index49.js","sources":["../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/
|
|
1
|
+
{"version":3,"file":"index49.js","sources":["../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js"],"sourcesContent":["import defaultErrorMap from \"./locales/en.js\";\nlet overrideErrorMap = defaultErrorMap;\nexport { defaultErrorMap };\nexport function setErrorMap(map) {\n overrideErrorMap = map;\n}\nexport function getErrorMap() {\n return overrideErrorMap;\n}\n"],"names":["defaultErrorMap"],"mappings":";;AACA,IAAI,gBAAgB,GAAGA,QAAe;AAE/B,SAAS,WAAW,CAAC,GAAG,EAAE;AACjC,IAAI,gBAAgB,GAAG,GAAG;AAC1B;AACO,SAAS,WAAW,GAAG;AAC9B,IAAI,OAAO,gBAAgB;AAC3B;;;;","x_google_ignoreList":[0]}
|