@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.
Files changed (72) hide show
  1. package/dist/Game/Object.d.ts +109 -0
  2. package/dist/RpgClientEngine.d.ts +111 -0
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.js +2 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/index10.js +1 -1
  7. package/dist/index15.js +42 -3
  8. package/dist/index15.js.map +1 -1
  9. package/dist/index19.js.map +1 -1
  10. package/dist/index2.js +142 -2
  11. package/dist/index2.js.map +1 -1
  12. package/dist/index20.js +15 -2
  13. package/dist/index20.js.map +1 -1
  14. package/dist/index23.js.map +1 -1
  15. package/dist/index26.js +2 -2
  16. package/dist/index26.js.map +1 -1
  17. package/dist/index27.js +2 -2
  18. package/dist/index27.js.map +1 -1
  19. package/dist/index34.js.map +1 -1
  20. package/dist/index35.js.map +1 -1
  21. package/dist/index36.js +8 -1
  22. package/dist/index36.js.map +1 -1
  23. package/dist/index37.js +1 -1
  24. package/dist/index38.js +1 -1
  25. package/dist/index40.js +6 -6
  26. package/dist/index41.js +320 -3681
  27. package/dist/index41.js.map +1 -1
  28. package/dist/index42.js +3686 -183
  29. package/dist/index42.js.map +1 -1
  30. package/dist/index43.js +71 -498
  31. package/dist/index43.js.map +1 -1
  32. package/dist/index44.js +182 -72
  33. package/dist/index44.js.map +1 -1
  34. package/dist/index45.js +500 -2
  35. package/dist/index45.js.map +1 -1
  36. package/dist/index46.js +3 -17
  37. package/dist/index46.js.map +1 -1
  38. package/dist/index47.js +16 -142
  39. package/dist/index47.js.map +1 -1
  40. package/dist/index48.js +206 -8
  41. package/dist/index48.js.map +1 -1
  42. package/dist/index49.js +7 -108
  43. package/dist/index49.js.map +1 -1
  44. package/dist/index50.js +104 -127
  45. package/dist/index50.js.map +1 -1
  46. package/dist/index51.js +122 -123
  47. package/dist/index51.js.map +1 -1
  48. package/dist/index52.js +123 -98
  49. package/dist/index52.js.map +1 -1
  50. package/dist/index53.js +107 -136
  51. package/dist/index53.js.map +1 -1
  52. package/dist/index54.js +139 -7
  53. package/dist/index54.js.map +1 -1
  54. package/dist/index55.js +7 -52
  55. package/dist/index55.js.map +1 -1
  56. package/dist/index56.js +54 -0
  57. package/dist/index56.js.map +1 -0
  58. package/dist/index8.js +8 -0
  59. package/dist/index8.js.map +1 -1
  60. package/dist/module.d.ts +43 -4
  61. package/dist/services/keyboardControls.d.ts +13 -2
  62. package/dist/services/mmorpg.d.ts +1 -1
  63. package/dist/services/standalone.d.ts +1 -1
  64. package/package.json +11 -10
  65. package/src/Game/Object.ts +82 -8
  66. package/src/RpgClientEngine.ts +173 -2
  67. package/src/components/character.ce +67 -4
  68. package/src/components/prebuilt/index.ts +1 -0
  69. package/src/components/scenes/draw-map.ce +12 -3
  70. package/src/index.ts +2 -1
  71. package/src/module.ts +56 -2
  72. package/src/services/keyboardControls.ts +13 -1
package/dist/index47.js CHANGED
@@ -1,146 +1,20 @@
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 './index53.js';
1
+ import { useProps, useDefineProps, animatedSignal, h, Container, Rect, Text } from 'canvasengine';
7
2
 
8
- const DYNAMIC_COMPONENTS = {
9
- text: component
10
- };
11
- class RpgClientObject extends RpgCommonPlayer {
12
- // temporary component memory
13
- constructor() {
14
- super();
15
- this.emitParticleTrigger = trigger();
16
- this.particleName = signal("");
17
- this.animationCurrentIndex = signal(0);
18
- this.animationIsPlaying = signal(false);
19
- this._param = signal({});
20
- this.frames = [];
21
- this.graphicsSignals = signal([]);
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 { RpgClientObject };
19
+ export { component as default };
146
20
  //# sourceMappingURL=index47.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index47.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\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 flash(color: string, duration: number = 100) {\n return new Promise((resolve) => {\n const lastTint = this.tint();\n this.tint.set(color);\n setTimeout(() => {\n this.tint.set(lastTint);\n resolve(true);\n }, duration);\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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AqBA,YAAA,CAAa,aAAA,EAAuB,OAAA,GAAkB,QAAA,EAAU;AAC9D,IAAA,IAAI,IAAA,CAAK,oBAAmB,EAAG;AAC/B,IAAA,IAAA,CAAK,kBAAA,CAAmB,IAAI,IAAI,CAAA;AAChC,IAAA,MAAM,qBAAA,GAAwB,KAAK,aAAA,EAAc;AACjD,IAAA,IAAA,CAAK,qBAAA,CAAsB,IAAI,CAAC,CAAA;AAGhC,IAAA,IAAI,KAAK,qBAAA,EAAuB;AAC9B,MAAA,IAAA,CAAK,sBAAsB,WAAA,EAAY;AAAA,IACzC;AAEA,IAAA,IAAA,CAAK,wBACH,IAAA,CAAK,qBAAA,CAAsB,UAAA,CAAW,SAAA,CAAU,CAAC,KAAA,KAAU;AACzD,MAAA,IAAI,SAAS,OAAA,EAAS;AACpB,QAAA,IAAA,CAAK,qBAAA,CAAsB,IAAI,CAAC,CAAA;AAChC,QAAA,IAAA,CAAK,aAAA,CAAc,IAAI,qBAAqB,CAAA;AAC5C,QAAA,IAAA,CAAK,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;;;;"}
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 errorMap from './index52.js';
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
- let overrideErrorMap = errorMap;
4
- function setErrorMap(map) {
5
- overrideErrorMap = map;
6
- }
7
- function getErrorMap() {
8
- return overrideErrorMap;
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 { errorMap as defaultErrorMap, getErrorMap, setErrorMap };
209
+ export { RpgClientObject };
12
210
  //# sourceMappingURL=index48.js.map
@@ -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,EAAM;AAXR,IAAA,IAAA,CAAA,mBAAA,GAAsB,OAAA,EAAQ;AAC9B,IAAA,IAAA,CAAA,YAAA,GAAe,OAAO,EAAE,CAAA;AACxB,IAAA,IAAA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A,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 { getErrorMap } from './index48.js';
2
- import errorMap from './index52.js';
1
+ import errorMap from './index53.js';
3
2
 
4
- const makeIssue = (params) => {
5
- const { data, path, errorMaps, issueData } = params;
6
- const fullPath = [...path, ...(issueData.path || [])];
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
- class ParseStatus {
49
- constructor() {
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 { DIRTY, EMPTY_PATH, INVALID, OK, ParseStatus, addIssueToContext, isAborted, isAsync, isDirty, isValid, makeIssue };
11
+ export { errorMap as defaultErrorMap, getErrorMap, setErrorMap };
113
12
  //# sourceMappingURL=index49.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index49.js","sources":["../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js"],"sourcesContent":["import { getErrorMap } from \"../errors.js\";\nimport defaultErrorMap from \"../locales/en.js\";\nexport const makeIssue = (params) => {\n const { data, path, errorMaps, issueData } = params;\n const fullPath = [...path, ...(issueData.path || [])];\n const fullIssue = {\n ...issueData,\n path: fullPath,\n };\n if (issueData.message !== undefined) {\n return {\n ...issueData,\n path: fullPath,\n message: issueData.message,\n };\n }\n let errorMessage = \"\";\n const maps = errorMaps\n .filter((m) => !!m)\n .slice()\n .reverse();\n for (const map of maps) {\n errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;\n }\n return {\n ...issueData,\n path: fullPath,\n message: errorMessage,\n };\n};\nexport const EMPTY_PATH = [];\nexport function addIssueToContext(ctx, issueData) {\n const overrideMap = getErrorMap();\n const issue = makeIssue({\n issueData: issueData,\n data: ctx.data,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap, // contextual error map is first priority\n ctx.schemaErrorMap, // then schema-bound map if available\n overrideMap, // then global override map\n overrideMap === defaultErrorMap ? undefined : defaultErrorMap, // then global default map\n ].filter((x) => !!x),\n });\n ctx.common.issues.push(issue);\n}\nexport class ParseStatus {\n constructor() {\n this.value = \"valid\";\n }\n dirty() {\n if (this.value === \"valid\")\n this.value = \"dirty\";\n }\n abort() {\n if (this.value !== \"aborted\")\n this.value = \"aborted\";\n }\n static mergeArray(status, results) {\n const arrayValue = [];\n for (const s of results) {\n if (s.status === \"aborted\")\n return INVALID;\n if (s.status === \"dirty\")\n status.dirty();\n arrayValue.push(s.value);\n }\n return { status: status.value, value: arrayValue };\n }\n static async mergeObjectAsync(status, pairs) {\n const syncPairs = [];\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n syncPairs.push({\n key,\n value,\n });\n }\n return ParseStatus.mergeObjectSync(status, syncPairs);\n }\n static mergeObjectSync(status, pairs) {\n const finalObject = {};\n for (const pair of pairs) {\n const { key, value } = pair;\n if (key.status === \"aborted\")\n return INVALID;\n if (value.status === \"aborted\")\n return INVALID;\n if (key.status === \"dirty\")\n status.dirty();\n if (value.status === \"dirty\")\n status.dirty();\n if (key.value !== \"__proto__\" && (typeof value.value !== \"undefined\" || pair.alwaysSet)) {\n finalObject[key.value] = value.value;\n }\n }\n return { status: status.value, value: finalObject };\n }\n}\nexport const INVALID = Object.freeze({\n status: \"aborted\",\n});\nexport const DIRTY = (value) => ({ status: \"dirty\", value });\nexport const OK = (value) => ({ status: \"valid\", value });\nexport const isAborted = (x) => x.status === \"aborted\";\nexport const isDirty = (x) => x.status === \"dirty\";\nexport const isValid = (x) => x.status === \"valid\";\nexport const isAsync = (x) => typeof Promise !== \"undefined\" && x instanceof Promise;\n"],"names":["defaultErrorMap"],"mappings":";;;AAEY,MAAC,SAAS,GAAG,CAAC,MAAM,KAAK;AACrC,IAAI,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,MAAM;AACvD,IAAI,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AACzD,IAAI,MAAM,SAAS,GAAG;AACtB,QAAQ,GAAG,SAAS;AACpB,QAAQ,IAAI,EAAE,QAAQ;AACtB,KAAK;AACL,IAAI,IAAI,SAAS,CAAC,OAAO,KAAK,SAAS,EAAE;AACzC,QAAQ,OAAO;AACf,YAAY,GAAG,SAAS;AACxB,YAAY,IAAI,EAAE,QAAQ;AAC1B,YAAY,OAAO,EAAE,SAAS,CAAC,OAAO;AACtC,SAAS;AACT,IAAI;AACJ,IAAI,IAAI,YAAY,GAAG,EAAE;AACzB,IAAI,MAAM,IAAI,GAAG;AACjB,SAAS,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1B,SAAS,KAAK;AACd,SAAS,OAAO,EAAE;AAClB,IAA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":["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]}