@rpgjs/client 5.0.0-alpha.0 → 5.0.0-alpha.10

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 (114) hide show
  1. package/dist/Game/AnimationManager.d.ts +8 -0
  2. package/dist/RpgClient.d.ts +99 -68
  3. package/dist/RpgClientEngine.d.ts +86 -4
  4. package/dist/components/animations/index.d.ts +4 -0
  5. package/dist/components/index.d.ts +2 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +2 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/index10.js +1 -1
  10. package/dist/index11.js +4 -4
  11. package/dist/index11.js.map +1 -1
  12. package/dist/index12.js +6 -2
  13. package/dist/index12.js.map +1 -1
  14. package/dist/index13.js +2 -2
  15. package/dist/index13.js.map +1 -1
  16. package/dist/index14.js +95 -35
  17. package/dist/index14.js.map +1 -1
  18. package/dist/index15.js +45 -186
  19. package/dist/index15.js.map +1 -1
  20. package/dist/index16.js +187 -5
  21. package/dist/index16.js.map +1 -1
  22. package/dist/index17.js +5 -383
  23. package/dist/index17.js.map +1 -1
  24. package/dist/index18.js +384 -28
  25. package/dist/index18.js.map +1 -1
  26. package/dist/index19.js +24 -17
  27. package/dist/index19.js.map +1 -1
  28. package/dist/index2.js +147 -25
  29. package/dist/index2.js.map +1 -1
  30. package/dist/index20.js +16 -2413
  31. package/dist/index20.js.map +1 -1
  32. package/dist/index21.js +2395 -88
  33. package/dist/index21.js.map +1 -1
  34. package/dist/index22.js +108 -103
  35. package/dist/index22.js.map +1 -1
  36. package/dist/index23.js +95 -57
  37. package/dist/index23.js.map +1 -1
  38. package/dist/index24.js +62 -12
  39. package/dist/index24.js.map +1 -1
  40. package/dist/index25.js +18 -37
  41. package/dist/index25.js.map +1 -1
  42. package/dist/index26.js +25 -3
  43. package/dist/index26.js.map +1 -1
  44. package/dist/index27.js +87 -314
  45. package/dist/index27.js.map +1 -1
  46. package/dist/index28.js +37 -21
  47. package/dist/index28.js.map +1 -1
  48. package/dist/index29.js +3 -9
  49. package/dist/index29.js.map +1 -1
  50. package/dist/index3.js +2 -2
  51. package/dist/index30.js +317 -6
  52. package/dist/index30.js.map +1 -1
  53. package/dist/index31.js +24 -171
  54. package/dist/index31.js.map +1 -1
  55. package/dist/index32.js +7 -497
  56. package/dist/index32.js.map +1 -1
  57. package/dist/index33.js +8 -9
  58. package/dist/index33.js.map +1 -1
  59. package/dist/index34.js +9 -4400
  60. package/dist/index34.js.map +1 -1
  61. package/dist/index35.js +4397 -85
  62. package/dist/index35.js.map +1 -1
  63. package/dist/index36.js +310 -55
  64. package/dist/index36.js.map +1 -1
  65. package/dist/index37.js +169 -15
  66. package/dist/index37.js.map +1 -1
  67. package/dist/index38.js +496 -15
  68. package/dist/index38.js.map +1 -1
  69. package/dist/index39.js +61 -0
  70. package/dist/index39.js.map +1 -0
  71. package/dist/index4.js +18 -5
  72. package/dist/index4.js.map +1 -1
  73. package/dist/index40.js +20 -0
  74. package/dist/index40.js.map +1 -0
  75. package/dist/index41.js +82 -0
  76. package/dist/index41.js.map +1 -0
  77. package/dist/index5.js +2 -1
  78. package/dist/index5.js.map +1 -1
  79. package/dist/index6.js +1 -1
  80. package/dist/index7.js +10 -2
  81. package/dist/index7.js.map +1 -1
  82. package/dist/index8.js +24 -6
  83. package/dist/index8.js.map +1 -1
  84. package/dist/index9.js +2 -2
  85. package/dist/presets/animation.d.ts +31 -0
  86. package/dist/presets/index.d.ts +102 -0
  87. package/dist/presets/lpc.d.ts +89 -0
  88. package/dist/services/loadMap.d.ts +123 -2
  89. package/dist/services/mmorpg.d.ts +7 -3
  90. package/package.json +14 -12
  91. package/src/Game/{EffectManager.ts → AnimationManager.ts} +2 -2
  92. package/src/Game/Object.ts +69 -0
  93. package/src/RpgClient.ts +101 -67
  94. package/src/RpgClientEngine.ts +159 -24
  95. package/src/components/{effects → animations}/animation.ce +3 -5
  96. package/src/components/{effects → animations}/index.ts +1 -1
  97. package/src/components/character.ce +74 -33
  98. package/src/components/index.ts +2 -1
  99. package/src/components/scenes/draw-map.ce +6 -23
  100. package/src/components/scenes/event-layer.ce +3 -3
  101. package/src/core/setup.ts +2 -0
  102. package/src/index.ts +1 -1
  103. package/src/module.ts +23 -5
  104. package/src/presets/animation.ts +46 -0
  105. package/src/presets/index.ts +5 -1
  106. package/src/presets/lpc.ts +108 -0
  107. package/src/services/loadMap.ts +131 -2
  108. package/src/services/mmorpg.ts +20 -4
  109. package/tsconfig.json +1 -1
  110. package/vite.config.ts +1 -1
  111. package/dist/Game/EffectManager.d.ts +0 -5
  112. package/dist/components/effects/index.d.ts +0 -4
  113. package/src/components/scenes/element-map.ce +0 -23
  114. /package/src/components/{effects → animations}/hit.ce +0 -0
package/dist/index4.js CHANGED
@@ -1,20 +1,24 @@
1
- import { connectionRoom } from './index21.js';
1
+ import { connectionRoom } from './index22.js';
2
2
  import { RpgGui } from './index9.js';
3
3
  import { RpgClientEngine } from './index2.js';
4
- import { WebSocketToken, AbstractWebsocket } from './index16.js';
4
+ import { WebSocketToken, AbstractWebsocket } from './index17.js';
5
5
  import { UpdateMapToken, UpdateMapService } from '@rpgjs/common';
6
6
 
7
7
  class BridgeWebsocket extends AbstractWebsocket {
8
- constructor(context, options) {
8
+ constructor(context, options = {}) {
9
9
  super(context);
10
10
  this.context = context;
11
11
  this.options = options;
12
12
  }
13
- async connection() {
13
+ async connection(listeners) {
14
14
  class Room {
15
15
  }
16
16
  const instance = new Room();
17
- this.socket = await connectionRoom(this.options, instance);
17
+ this.socket = await connectionRoom({
18
+ host: this.options.host || window.location.host,
19
+ room: "lobby-1"
20
+ }, instance);
21
+ listeners?.(this.socket);
18
22
  }
19
23
  on(key, callback) {
20
24
  this.socket.on(key, callback);
@@ -25,6 +29,15 @@ class BridgeWebsocket extends AbstractWebsocket {
25
29
  emit(event, data) {
26
30
  this.socket.emit(event, data);
27
31
  }
32
+ updateProperties({ room }) {
33
+ this.socket.conn.updateProperties({
34
+ room,
35
+ host: this.options.host
36
+ });
37
+ }
38
+ async reconnect(listeners) {
39
+ this.socket.conn.reconnect();
40
+ }
28
41
  }
29
42
  class UpdateMapStandaloneService extends UpdateMapService {
30
43
  constructor(context, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"index4.js","sources":["../src/services/mmorpg.ts"],"sourcesContent":["import { Context } from \"@signe/di\";\nimport { connectionRoom } from \"@signe/sync/client\";\nimport { RpgGui } from \"../Gui/Gui\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { AbstractWebsocket, WebSocketToken } from \"./AbstractSocket\";\nimport { UpdateMapService, UpdateMapToken } from \"@rpgjs/common\";\n\ninterface MmorpgOptions {\n host: string;\n}\n\nclass BridgeWebsocket extends AbstractWebsocket {\n private socket: any;\n\n constructor(protected context: Context, private options: MmorpgOptions) {\n super(context);\n }\n\n async connection() {\n // tmp\n class Room {\n \n }\n const instance = new Room()\n this.socket = await connectionRoom(this.options, instance)\n }\n\n on(key: string, callback: (data: any) => void) {\n this.socket.on(key, callback);\n }\n\n off(event: string, callback: (data: any) => void) {\n this.socket.off(event, callback);\n }\n\n emit(event: string, data: any) {\n this.socket.emit(event, data);\n }\n}\n\nclass UpdateMapStandaloneService extends UpdateMapService {\n constructor(protected context: Context, private options: MmorpgOptions) {\n super(context);\n }\n\n async update(map: any) {\n // nothing\n }\n}\n\nexport function provideMmorpg(options: MmorpgOptions) {\n return [\n {\n provide: WebSocketToken,\n useFactory: (context: Context) => new BridgeWebsocket(context, options),\n },\n {\n provide: UpdateMapToken,\n useFactory: (context: Context) => new UpdateMapStandaloneService(context, options),\n },\n RpgGui,\n RpgClientEngine,\n ];\n}\n"],"names":[],"mappings":";;;;;;AAWA,MAAM,wBAAwB,iBAAkB,CAAA;AAAA,EAG9C,WAAA,CAAsB,SAA0B,OAAwB,EAAA;AACtE,IAAA,KAAA,CAAM,OAAO,CAAA;AADO,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAA0B,IAAA,IAAA,CAAA,OAAA,GA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/mmorpg.ts"],"sourcesContent":["import { Context } from \"@signe/di\";\nimport { connectionRoom } from \"@signe/sync/client\";\nimport { RpgGui } from \"../Gui/Gui\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { AbstractWebsocket, WebSocketToken } from \"./AbstractSocket\";\nimport { UpdateMapService, UpdateMapToken } from \"@rpgjs/common\";\n\ninterface MmorpgOptions {\n host?: string;\n}\n\nclass BridgeWebsocket extends AbstractWebsocket {\n private socket: any;\n\n constructor(protected context: Context, private options: MmorpgOptions = {}) {\n super(context);\n }\n\n async connection(listeners?: (data: any) => void) {\n // tmp\n class Room {\n \n }\n const instance = new Room()\n this.socket = await connectionRoom({\n host: this.options.host || window.location.host,\n room: \"lobby-1\",\n }, instance)\n\n listeners?.(this.socket)\n }\n\n on(key: string, callback: (data: any) => void) {\n this.socket.on(key, callback);\n }\n\n off(event: string, callback: (data: any) => void) {\n this.socket.off(event, callback);\n }\n\n emit(event: string, data: any) {\n this.socket.emit(event, data);\n }\n\n updateProperties({ room }: { room: any }) {\n this.socket.conn.updateProperties({\n room: room,\n host: this.options.host\n })\n }\n\n async reconnect(listeners?: (data: any) => void) {\n this.socket.conn.reconnect()\n }\n}\n\nclass UpdateMapStandaloneService extends UpdateMapService {\n constructor(protected context: Context, private options: MmorpgOptions) {\n super(context);\n }\n\n async update(map: any) {\n // nothing\n }\n}\n\nexport function provideMmorpg(options: MmorpgOptions) {\n return [\n {\n provide: WebSocketToken,\n useFactory: (context: Context) => new BridgeWebsocket(context, options),\n },\n {\n provide: UpdateMapToken,\n useFactory: (context: Context) => new UpdateMapStandaloneService(context, options),\n },\n RpgGui,\n RpgClientEngine,\n ];\n}\n"],"names":[],"mappings":";;;;;;AAWA,MAAM,wBAAwB,iBAAkB,CAAA;AAAA,EAG9C,WAAsB,CAAA,OAAA,EAA0B,OAAyB,GAAA,EAAI,EAAA;AAC3E,IAAA,KAAA,CAAM,OAAO,CAAA;AADO,IAAA,IAAA,CAAA,OAAA,GAAA,O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AAA,OAAA;AAA0B,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA;AAEhD,EAEA,MAAM,OAAO,GAAU,EAAA;AAAA;AAGzB;AAEO,SAAS,cAAc,OAAwB,EAAA;AACpD,EAAO,OAAA;AAAA,IACL;AAAA,MACE,OAAS,EAAA,cAAA;AAAA,MACT,YAAY,CAAC,OAAA,KAAqB,IAAI,eAAA,CAAgB,SAAS,OAAO;AAAA,KACxE;AAAA,IACA;AAAA,MACE,OAAS,EAAA,cAAA;AAAA,MACT,YAAY,CAAC,OAAA,KAAqB,IAAI,0BAAA,CAA2B,SAAS,OAAO;AAAA,KACnF;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,20 @@
1
+ import { useProps, useDefineProps, animatedSignal, h, Container, Rect, Text } from 'canvasengine';
2
+
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
17
+ }
18
+
19
+ export { component as default };
20
+ //# sourceMappingURL=index40.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index40.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;;;;"}
@@ -0,0 +1,82 @@
1
+ import { RpgCommonPlayer } from '@rpgjs/common';
2
+ import { trigger, signal } from 'canvasengine';
3
+
4
+ class RpgClientObject extends RpgCommonPlayer {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.emitParticleTrigger = trigger();
8
+ this.particleName = signal("");
9
+ this.animationCurrentIndex = signal(0);
10
+ this.animationIsPlaying = signal(false);
11
+ }
12
+ flash(color, duration = 100) {
13
+ const lastTint = this.tint();
14
+ this.tint.set(color);
15
+ setTimeout(() => {
16
+ this.tint.set(lastTint);
17
+ }, duration);
18
+ }
19
+ /**
20
+ * Reset animation state when animation changes externally
21
+ *
22
+ * This method should be called when the animation changes due to movement
23
+ * or other external factors to ensure the animation system doesn't get stuck
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * // Reset when player starts moving
28
+ * player.resetAnimationState();
29
+ * ```
30
+ */
31
+ resetAnimationState() {
32
+ this.animationIsPlaying.set(false);
33
+ this.animationCurrentIndex.set(0);
34
+ if (this.animationSubscription) {
35
+ this.animationSubscription.unsubscribe();
36
+ this.animationSubscription = void 0;
37
+ }
38
+ }
39
+ /**
40
+ * Set a custom animation for a specific number of times
41
+ *
42
+ * Plays a custom animation for the specified number of repetitions.
43
+ * The animation system prevents overlapping animations and automatically
44
+ * returns to the previous animation when complete.
45
+ *
46
+ * @param animationName - Name of the animation to play
47
+ * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * // Play attack animation 3 times
52
+ * player.setAnimation('attack', 3);
53
+ *
54
+ * // Play continuous spell animation
55
+ * player.setAnimation('spell');
56
+ * ```
57
+ */
58
+ setAnimation(animationName, nbTimes = Infinity) {
59
+ if (this.animationIsPlaying()) return;
60
+ this.animationIsPlaying.set(true);
61
+ const previousAnimationName = this.animationName();
62
+ this.animationCurrentIndex.set(0);
63
+ if (this.animationSubscription) {
64
+ this.animationSubscription.unsubscribe();
65
+ }
66
+ this.animationSubscription = this.animationCurrentIndex.observable.subscribe((index) => {
67
+ if (index >= nbTimes) {
68
+ this.animationCurrentIndex.set(0);
69
+ this.animationName.set(previousAnimationName);
70
+ this.animationIsPlaying.set(false);
71
+ if (this.animationSubscription) {
72
+ this.animationSubscription.unsubscribe();
73
+ this.animationSubscription = void 0;
74
+ }
75
+ }
76
+ });
77
+ this.animationName.set(animationName);
78
+ }
79
+ }
80
+
81
+ export { RpgClientObject };
82
+ //# sourceMappingURL=index41.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index41.js","sources":["../src/Game/Object.ts"],"sourcesContent":["import { RpgCommonPlayer } from \"@rpgjs/common\";\nimport { trigger, signal } from \"canvasengine\";\nimport { Subscription } from \"rxjs\";\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 private animationSubscription?: Subscription\n\n flash(color: string, duration: number = 100) {\n const lastTint = this.tint()\n this.tint.set(color);\n setTimeout(() => {\n this.tint.set(lastTint)\n }, duration)\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 = 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} "],"names":[],"mappings":";;;AAIO,MAAe,wBAAwB,eAAgB,CAAA;AAAA,EAAvD,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAEL,IAAA,IAAA,CAAA,mBAAA,GAAsB,OAAQ,EAAA;AAC9B,IAAA,IAAA,CAAA,YAAA,GAAe,OAAO,EAAE,CAAA;AACxB,IAAA,IAAA,CAAA,qBAAA,GAAwB,OAAO,CAAC,CAAA;AAChC,IAAA,IAAA,CAAA,kBAAA,GAAqB,OAAO,KAAK,CAAA;AAAA;AAAA,EAGjC,KAAA,CAAM,KAAe,EAAA,QAAA,GAAmB,GAAK,EAAA;AAC3C,IAAM,MAAA,QAAA,GAAW,KAAK,IAAK,EAAA;AAC3B,IAAK,IAAA,CAAA,IAAA,CAAK,IAAI,KAAK,CAAA;AACnB,IAAA,UAAA,CAAW,MAAM;AACf,MAAK,IAAA,CAAA,IAAA,CAAK,IAAI,QAAQ,CAAA;AAAA,OACrB,QAAQ,CAAA;AAAA;AACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,mBAAsB,GAAA;AACpB,IAAK,IAAA,CAAA,kBAAA,CAAmB,IAAI,KAAK,CAAA;AACjC,IAAK,IAAA,CAAA,qBAAA,CAAsB,IAAI,CAAC,CAAA;AAChC,IAAA,IAAI,KAAK,qBAAuB,EAAA;AAC9B,MAAA,IAAA,CAAK,sBAAsB,WAAY,EAAA;AACvC,MAAA,IAAA,CAAK,qBAAwB,GAAA,MAAA;AAAA;AAC/B;AACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBA,YAAA,CAAa,aAAuB,EAAA,OAAA,GAAkB,QAAU,EAAA;AAC9D,IAAI,IAAA,IAAA,CAAK,oBAAsB,EAAA;AAC/B,IAAK,IAAA,CAAA,kBAAA,CAAmB,IAAI,IAAI,CAAA;AAChC,IAAM,MAAA,qBAAA,GAAwB,KAAK,aAAc,EAAA;AACjD,IAAK,IAAA,CAAA,qBAAA,CAAsB,IAAI,CAAC,CAAA;AAGhC,IAAA,IAAI,KAAK,qBAAuB,EAAA;AAC9B,MAAA,IAAA,CAAK,sBAAsB,WAAY,EAAA;AAAA;AAGzC,IAAA,IAAA,CAAK,qBAAwB,GAAA,IAAA,CAAK,qBAAsB,CAAA,UAAA,CAAW,UAAU,CAAS,KAAA,KAAA;AACpF,MAAA,IAAI,SAAS,OAAS,EAAA;AACpB,QAAK,IAAA,CAAA,qBAAA,CAAsB,IAAI,CAAC,CAAA;AAChC,QAAK,IAAA,CAAA,aAAA,CAAc,IAAI,qBAAqB,CAAA;AAC5C,QAAK,IAAA,CAAA,kBAAA,CAAmB,IAAI,KAAK,CAAA;AACjC,QAAA,IAAI,KAAK,qBAAuB,EAAA;AAC9B,UAAA,IAAA,CAAK,sBAAsB,WAAY,EAAA;AACvC,UAAA,IAAA,CAAK,qBAAwB,GAAA,MAAA;AAAA;AAC/B;AACF,KACD,CAAA;AACD,IAAK,IAAA,CAAA,aAAA,CAAc,IAAI,aAAa,CAAA;AAAA;AAExC;;;;"}
package/dist/index5.js CHANGED
@@ -1,9 +1,10 @@
1
- import { injector, inject, Context } from './index15.js';
1
+ import { Context, injector, inject } from './index16.js';
2
2
  import { RpgClientEngine } from './index2.js';
3
3
  import { setInject } from './index6.js';
4
4
 
5
5
  async function startGame(options) {
6
6
  const context = new Context();
7
+ context["side"] = "client";
7
8
  setInject(context);
8
9
  await injector(context, options.providers);
9
10
  const engine = inject(context, RpgClientEngine);
@@ -1 +1 @@
1
- {"version":3,"file":"index5.js","sources":["../src/core/setup.ts"],"sourcesContent":["import { Context, FactoryProvider, findProvider, findProviders, inject, injector, Providers } from \"@signe/di\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { setInject } from \"./inject\";\n\ninterface SetupOptions {\n providers: Providers;\n}\n\nexport async function startGame(options: SetupOptions) {\n const context = new Context();\n setInject(context);\n\n await injector(context, options.providers);\n\n const engine = inject(context, RpgClientEngine);\n await engine.start();\n return context;\n}"],"names":[],"mappings":";;;;AAQA,eAAsB,UAAU,OAAuB,EAAA;AACrD,EAAM,MAAA,OAAA,GAAU,IAAI,OAAQ,EAAA;AAC5B,EAAA,SAAA,CAAU,OAAO,CAAA;AAEjB,EAAM,MAAA,QAAA,CAAS,OAAS,EAAA,OAAA,CAAQ,SAAS,CAAA;AAEzC,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,OAAA,EAAS,eAAe,CAAA;AAC9C,EAAA,MAAM,OAAO,KAAM,EAAA;AACnB,EAAO,OAAA,OAAA;AACT;;;;"}
1
+ {"version":3,"file":"index5.js","sources":["../src/core/setup.ts"],"sourcesContent":["import { Context, FactoryProvider, findProvider, findProviders, inject, injector, Providers } from \"@signe/di\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { setInject } from \"./inject\";\n\ninterface SetupOptions {\n providers: Providers;\n}\n\n\nexport async function startGame(options: SetupOptions) {\n const context = new Context();\n context['side'] = 'client'\n setInject(context);\n\n await injector(context, options.providers);\n\n const engine = inject(context, RpgClientEngine);\n await engine.start();\n return context;\n}"],"names":[],"mappings":";;;;AASA,eAAsB,UAAU,OAAuB,EAAA;AACrD,EAAM,MAAA,OAAA,GAAU,IAAI,OAAQ,EAAA;AAC5B,EAAA,OAAA,CAAQ,MAAM,CAAI,GAAA,QAAA;AAClB,EAAA,SAAA,CAAU,OAAO,CAAA;AAEjB,EAAM,MAAA,QAAA,CAAS,OAAS,EAAA,OAAA,CAAQ,SAAS,CAAA;AAEzC,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,OAAA,EAAS,eAAe,CAAA;AAC9C,EAAA,MAAM,OAAO,KAAM,EAAA;AACnB,EAAO,OAAA,OAAA;AACT;;;;"}
package/dist/index6.js CHANGED
@@ -1,4 +1,4 @@
1
- import { inject as inject$1 } from './index15.js';
1
+ import { inject as inject$1 } from './index16.js';
2
2
 
3
3
  let context = null;
4
4
  function inject(service, _context) {
package/dist/index7.js CHANGED
@@ -1,4 +1,4 @@
1
- import { inject } from './index15.js';
1
+ import { inject } from './index16.js';
2
2
  import { UpdateMapToken } from '@rpgjs/common';
3
3
 
4
4
  const LoadMapToken = "LoadMapToken";
@@ -6,6 +6,9 @@ class LoadMapService {
6
6
  constructor(context, options) {
7
7
  this.context = context;
8
8
  this.options = options;
9
+ if (context["side"] === "server") {
10
+ return;
11
+ }
9
12
  this.updateMapService = inject(context, UpdateMapToken);
10
13
  }
11
14
  async load(mapId) {
@@ -18,7 +21,12 @@ function provideLoadMap(options) {
18
21
  return [
19
22
  {
20
23
  provide: UpdateMapToken,
21
- useFactory: (context) => console.warn("UpdateMapToken is not overridden")
24
+ useFactory: (context) => {
25
+ if (context["side"] === "client") {
26
+ console.warn("UpdateMapToken is not overridden");
27
+ }
28
+ return;
29
+ }
22
30
  },
23
31
  {
24
32
  provide: LoadMapToken,
@@ -1 +1 @@
1
- {"version":3,"file":"index7.js","sources":["../src/services/loadMap.ts"],"sourcesContent":["import { Context, inject } from \"@signe/di\";\nimport { UpdateMapToken, UpdateMapService } from \"@rpgjs/common\";\n\nexport const LoadMapToken = 'LoadMapToken'\n\nexport type LoadMapOptions = (mapId: string) => Promise<void>\n\nexport class LoadMapService {\n private updateMapService: UpdateMapService;\n\n constructor(private context: Context, private options: LoadMapOptions) {\n this.updateMapService = inject(context, UpdateMapToken);\n }\n\n async load(mapId: string) {\n const map = await this.options(mapId.replace('map-', ''))\n await this.updateMapService.update(mapId, map);\n return map;\n }\n}\n\nexport function provideLoadMap(options: LoadMapOptions) {\n return [\n {\n provide: UpdateMapToken,\n useFactory: (context: Context) => console.warn('UpdateMapToken is not overridden'),\n },\n {\n provide: LoadMapToken,\n useFactory: (context: Context) => new LoadMapService(context, options),\n },\n ];\n}\n"],"names":[],"mappings":";;;AAGO,MAAM,YAAe,GAAA;AAIrB,MAAM,cAAe,CAAA;AAAA,EAG1B,WAAA,CAAoB,SAA0B,OAAyB,EAAA;AAAnD,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAA0B,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAC5C,IAAK,IAAA,CAAA,gBAAA,GAAmB,MAAO,CAAA,OAAA,EAAS,cAAc,CAAA;AAAA;AACxD,EAEA,MAAM,KAAK,KAAe,EAAA;AACxB,IAAM,MAAA,GAAA,GAAM,MAAM,IAAK,CAAA,OAAA,CAAQ,MAAM,OAAQ,CAAA,MAAA,EAAQ,EAAE,CAAC,CAAA;AACxD,IAAA,MAAM,IAAK,CAAA,gBAAA,CAAiB,MAAO,CAAA,KAAA,EAAO,GAAG,CAAA;AAC7C,IAAO,OAAA,GAAA;AAAA;AAEX;AAEO,SAAS,eAAe,OAAyB,EAAA;AACtD,EAAO,OAAA;AAAA,IACL;AAAA,MACE,OAAS,EAAA,cAAA;AAAA,MACT,UAAY,EAAA,CAAC,OAAqB,KAAA,OAAA,CAAQ,KAAK,kCAAkC;AAAA,KACnF;AAAA,IACA;AAAA,MACE,OAAS,EAAA,YAAA;AAAA,MACT,YAAY,CAAC,OAAA,KAAqB,IAAI,cAAA,CAAe,SAAS,OAAO;AAAA;AACvE,GACF;AACF;;;;"}
1
+ {"version":3,"file":"index7.js","sources":["../src/services/loadMap.ts"],"sourcesContent":["import { Context, inject } from \"@signe/di\";\nimport { UpdateMapToken, UpdateMapService } from \"@rpgjs/common\";\n\nexport const LoadMapToken = 'LoadMapToken'\n\n/**\n * Represents the structure of map data that should be returned by the load map callback.\n * This interface defines all the properties that can be provided when loading a custom map.\n * \n * @interface MapData\n */\ntype MapData = {\n /** Raw map data that will be passed to the map component */\n data: any;\n /** CanvasEngine component that will render the map */\n component: any;\n /** Optional map width in pixels, used for viewport calculations */\n width?: number;\n /** Optional map height in pixels, used for viewport calculations */\n height?: number;\n /** Optional map events data (NPCs, interactive objects, etc.) */\n events?: any;\n /** Optional map identifier, defaults to the mapId parameter if not provided */\n id?: string;\n}\n\n/**\n * Callback function type for loading map data.\n * This function receives a map ID and should return either a MapData object directly\n * or a Promise that resolves to a MapData object.\n * \n * @callback LoadMapOptions\n * @param {string} mapId - The identifier of the map to load\n * @returns {Promise<MapData> | MapData} The map data object or a promise resolving to it\n */\nexport type LoadMapOptions = (mapId: string) => Promise<MapData> | MapData \n\nexport class LoadMapService {\n private updateMapService: UpdateMapService;\n\n constructor(private context: Context, private options: LoadMapOptions) {\n if (context['side'] === 'server') {\n return\n }\n this.updateMapService = inject(context, UpdateMapToken);\n }\n\n async load(mapId: string) {\n const map = await this.options(mapId.replace('map-', ''))\n await this.updateMapService.update(mapId, map);\n return map;\n }\n}\n\n/**\n * Creates a dependency injection configuration for custom map loading on the client side.\n * \n * This function allows you to customize how maps are loaded and displayed by providing\n * a callback that defines custom map data and rendering components. It's designed to work\n * with the RPG-JS dependency injection system and enables integration of custom map formats\n * like Tiled TMX files or any other map data structure.\n * \n * The function sets up the necessary service providers for map loading, including:\n * - UpdateMapToken: Handles map updates in the client context\n * - LoadMapToken: Provides the LoadMapService with your custom loading logic\n * \n * **Design Concept:**\n * The function follows the provider pattern, creating a modular way to inject custom\n * map loading behavior into the RPG-JS client engine. It separates the concern of\n * map data fetching from map rendering, allowing developers to focus on their specific\n * map format while leveraging the engine's rendering capabilities.\n * \n * @param {LoadMapOptions} options - Callback function that handles map loading logic\n * @returns {Array<Object>} Array of dependency injection provider configurations\n * \n * @example\n * ```typescript\n * import { provideLoadMap } from '@rpgjs/client'\n * import { createModule } from '@rpgjs/common'\n * import MyTiledMapComponent from './MyTiledMapComponent.ce'\n * \n * // Basic usage with JSON map data\n * export function provideCustomMap() {\n * return createModule(\"CustomMap\", [\n * provideLoadMap(async (mapId) => {\n * const response = await fetch(`/maps/${mapId}.json`)\n * const mapData = await response.json()\n * \n * return {\n * data: mapData,\n * component: MyTiledMapComponent,\n * width: mapData.width,\n * height: mapData.height,\n * events: mapData.events\n * }\n * })\n * ])\n * }\n * \n * // Advanced usage with Tiled TMX files\n * export function provideTiledMap() {\n * return createModule(\"TiledMap\", [\n * provideLoadMap(async (mapId) => {\n * // Load TMX file\n * const tmxResponse = await fetch(`/tiled/${mapId}.tmx`)\n * const tmxData = await tmxResponse.text()\n * \n * // Parse TMX data (using a TMX parser)\n * const parsedMap = parseTMX(tmxData)\n * \n * return {\n * data: parsedMap,\n * component: TiledMapRenderer,\n * width: parsedMap.width * parsedMap.tilewidth,\n * height: parsedMap.height * parsedMap.tileheight,\n * events: parsedMap.objectGroups?.find(g => g.name === 'events')?.objects\n * }\n * })\n * ])\n * }\n * \n * // Synchronous usage for static maps\n * export function provideStaticMap() {\n * return createModule(\"StaticMap\", [\n * provideLoadMap((mapId) => {\n * const staticMaps = {\n * 'town': { tiles: [...], npcs: [...] },\n * 'dungeon': { tiles: [...], monsters: [...] }\n * }\n * \n * return {\n * data: staticMaps[mapId],\n * component: StaticMapComponent,\n * width: 800,\n * height: 600\n * }\n * })\n * ])\n * }\n * ```\n * \n * @since 4.0.0\n * @see {@link LoadMapOptions} for callback function signature\n * @see {@link MapData} for return data structure\n */\nexport function provideLoadMap(options: LoadMapOptions) {\n return [\n {\n provide: UpdateMapToken,\n useFactory: (context: Context) => {\n if (context['side'] === 'client') {\n console.warn('UpdateMapToken is not overridden')\n }\n return\n },\n },\n {\n provide: LoadMapToken,\n useFactory: (context: Context) => new LoadMapService(context, options),\n },\n ];\n}\n"],"names":[],"mappings":";;;AAGO,MAAM,YAAe,GAAA;AAkCrB,MAAM,cAAe,CAAA;AAAA,EAG1B,WAAA,CAAoB,SAA0B,OAAyB,EAAA;AAAnD,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAA0B,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAC5C,IAAI,IAAA,OAAA,CAAQ,MAAM,CAAA,KAAM,QAAU,EAAA;AAChC,MAAA;AAAA;AAEF,IAAK,IAAA,CAAA,gBAAA,GAAmB,MAAO,CAAA,OAAA,EAAS,cAAc,CAAA;AAAA;AACxD,EAEA,MAAM,KAAK,KAAe,EAAA;AACxB,IAAM,MAAA,GAAA,GAAM,MAAM,IAAK,CAAA,OAAA,CAAQ,MAAM,OAAQ,CAAA,MAAA,EAAQ,EAAE,CAAC,CAAA;AACxD,IAAA,MAAM,IAAK,CAAA,gBAAA,CAAiB,MAAO,CAAA,KAAA,EAAO,GAAG,CAAA;AAC7C,IAAO,OAAA,GAAA;AAAA;AAEX;AA6FO,SAAS,eAAe,OAAyB,EAAA;AACtD,EAAO,OAAA;AAAA,IACL;AAAA,MACE,OAAS,EAAA,cAAA;AAAA,MACT,UAAA,EAAY,CAAC,OAAqB,KAAA;AAChC,QAAI,IAAA,OAAA,CAAQ,MAAM,CAAA,KAAM,QAAU,EAAA;AAChC,UAAA,OAAA,CAAQ,KAAK,kCAAkC,CAAA;AAAA;AAEjD,QAAA;AAAA;AACF,KACF;AAAA,IACA;AAAA,MACE,OAAS,EAAA,YAAA;AAAA,MACT,YAAY,CAAC,OAAA,KAAqB,IAAI,cAAA,CAAe,SAAS,OAAO;AAAA;AACvE,GACF;AACF;;;;"}
package/dist/index8.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { provideModules, findModules } from '@rpgjs/common';
2
- import { inject } from './index15.js';
2
+ import { inject } from './index16.js';
3
3
  import { RpgGui } from './index9.js';
4
4
 
5
5
  function provideClientModules(modules) {
@@ -41,12 +41,12 @@ function provideClientModules(modules) {
41
41
  }
42
42
  };
43
43
  }
44
- if (module.effects) {
45
- const effects = [...module.effects];
46
- module.effects = {
44
+ if (module.componentAnimations) {
45
+ const componentAnimations = [...module.componentAnimations];
46
+ module.componentAnimations = {
47
47
  load: (engine) => {
48
- effects.forEach((effect) => {
49
- engine.addEffect(effect);
48
+ componentAnimations.forEach((componentAnimation) => {
49
+ engine.addComponentAnimation(componentAnimation);
50
50
  });
51
51
  }
52
52
  };
@@ -61,6 +61,24 @@ function provideClientModules(modules) {
61
61
  }
62
62
  };
63
63
  }
64
+ if (module.sprite) {
65
+ const sprite = { ...module.sprite };
66
+ module.sprite = {
67
+ ...sprite,
68
+ load: (engine) => {
69
+ if (sprite.componentsBehind) {
70
+ sprite.componentsBehind.forEach((component) => {
71
+ engine.addSpriteComponentBehind(component);
72
+ });
73
+ }
74
+ if (sprite.componentsInFront) {
75
+ sprite.componentsInFront.forEach((component) => {
76
+ engine.addSpriteComponentInFront(component);
77
+ });
78
+ }
79
+ }
80
+ };
81
+ }
64
82
  return module;
65
83
  });
66
84
  return modules2;
@@ -1 +1 @@
1
- {"version":3,"file":"index8.js","sources":["../src/module.ts"],"sourcesContent":["import { findModules, provideModules } from \"@rpgjs/common\";\nimport { RpgClientEngine } from \"./RpgClientEngine\";\nimport { RpgClient } from \"./RpgClient\";\nimport { inject } from \"@signe/di\";\nimport { RpgGui } from \"./Gui/Gui\";\n\nexport function provideClientModules(modules: RpgClient[]) {\n return provideModules(modules, \"client\", (modules, context) => {\n const mainModuleClient = findModules(context, 'Client')\n modules = [...mainModuleClient, ...modules]\n modules = modules.map((module) => {\n if ('client' in module) {\n module = module.client as any;\n }\n if (module.spritesheets) {\n const spritesheets = [...module.spritesheets];\n module.spritesheets = {\n load: (engine: RpgClientEngine) => {\n spritesheets.forEach((spritesheet) => {\n engine.addSpriteSheet(spritesheet);\n });\n },\n };\n }\n if (module.sounds) {\n const sounds = [...module.sounds];\n module.sounds = {\n load: (engine: RpgClientEngine) => {\n sounds.forEach((sound) => {\n engine.addSound(sound);\n });\n },\n };\n }\n if (module.gui) {\n const gui = [...module.gui];\n module.gui = {\n load: (engine: RpgClientEngine) => {\n const guiService = inject(engine.context, RpgGui);\n gui.forEach((gui) => {\n guiService.add(gui);\n });\n },\n };\n }\n if (module.effects) {\n const effects = [...module.effects];\n module.effects = {\n load: (engine: RpgClientEngine) => {\n effects.forEach((effect) => {\n engine.addEffect(effect);\n });\n },\n };\n }\n if (module.particles) {\n const particles = [...module.particles];\n module.particles = {\n load: (engine: RpgClientEngine) => {\n particles.forEach((particle) => {\n engine.addParticle(particle);\n });\n },\n };\n }\n return module;\n });\n return modules\n });\n}\n\nexport const GlobalConfigToken = \"GlobalConfigToken\";\n\nexport function provideGlobalConfig(config: any) {\n return {\n provide: GlobalConfigToken,\n useValue: config ?? {},\n };\n}\n\nexport function provideClientGlobalConfig(config: any = {}) {\n if (!config.keyboardControls) {\n config.keyboardControls = {\n up: 'up',\n down: 'down',\n left: 'left',\n right: 'right',\n action: 'space'\n }\n }\n return provideGlobalConfig(config)\n}\n\n"],"names":["modules","gui"],"mappings":";;;;AAMO,SAAS,qBAAqB,OAAsB,EAAA;AACzD,EAAA,OAAO,cAAe,CAAA,OAAA,EAAS,QAAU,EAAA,CAACA,UAAS,OAAY,KAAA;AAC7D,IAAM,MAAA,gBAAA,GAAmB,WAAY,CAAA,OAAA,EAAS,QAAQ,CAAA;AACtD,IAAAA,QAAU,GAAA,CAAC,GAAG,gBAAA,EAAkB,GAAGA,QAAO,CAAA;AAC1C,IAAAA,QAAUA,GAAAA,QAAAA,CAAQ,GAAI,CAAA,CAAC,MAAW,KAAA;AAChC,MAAA,IAAI,YAAY,MAAQ,EAAA;AACtB,QAAA,MAAA,GAAS,MAAO,CAAA,MAAA;AAAA;AAElB,MAAA,IAAI,OAAO,YAAc,EAAA;AACvB,QAAA,MAAM,YAAe,GAAA,CAAC,GAAG,MAAA,CAAO,YAAY,CAAA;AAC5C,QAAA,MAAA,CAAO,YAAe,GAAA;AAAA,UACpB,IAAA,EAAM,CAAC,MAA4B,KAAA;AACjC,YAAa,YAAA,CAAA,OAAA,CAAQ,CAAC,WAAgB,KAAA;AACpC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A,CAAO,SAAY,GAAA;AAAA,UACjB,IAAA,EAAM,CAAC,MAA4B,KAAA;AACjC,YAAU,SAAA,CAAA,OAAA,CAAQ,CAAC,QAAa,KAAA;AAC9B,cAAA,MAAA,CAAO,YAAY,QAAQ,CAAA;AAAA,aAC5B,CAAA;AAAA;AACH,SACF;AAAA;AAEF,MAAO,OAAA,MAAA;AAAA,KACR,CAAA;AACD,IAAOD,OAAAA,QAAAA;AAAA,GACR,CAAA;AACH;AAEO,MAAM,iBAAoB,GAAA;AAE1B,SAAS,oBAAoB,MAAa,EAAA;AAC/C,EAAO,OAAA;AAAA,IACL,OAAS,EAAA,iBAAA;AAAA,IACT,QAAA,EAAU,UAAU;AAAC,GACvB;AACF;AAEgB,SAAA,yBAAA,CAA0B,MAAc,GAAA,EAAI,EAAA;AAC1D,EAAI,IAAA,CAAC,OAAO,gBAAkB,EAAA;AAC5B,IAAA,MAAA,CAAO,gBAAmB,GAAA;AAAA,MACxB,EAAI,EAAA,IAAA;AAAA,MACJ,IAAM,EAAA,MAAA;AAAA,MACN,IAAM,EAAA,MAAA;AAAA,MACN,KAAO,EAAA,OAAA;AAAA,MACP,MAAQ,EAAA;AAAA,KACV;AAAA;AAEF,EAAA,OAAO,oBAAoB,MAAM,CAAA;AACnC;;;;"}
1
+ {"version":3,"file":"index8.js","sources":["../src/module.ts"],"sourcesContent":["import { findModules, provideModules } from \"@rpgjs/common\";\nimport { RpgClientEngine } from \"./RpgClientEngine\";\nimport { RpgClient } from \"./RpgClient\";\nimport { inject } from \"@signe/di\";\nimport { RpgGui } from \"./Gui/Gui\";\n\nexport function provideClientModules(modules: RpgClient[]) {\n return provideModules(modules, \"client\", (modules, context) => {\n const mainModuleClient = findModules(context, 'Client')\n modules = [...mainModuleClient, ...modules]\n modules = modules.map((module) => {\n if ('client' in module) {\n module = module.client as any;\n }\n if (module.spritesheets) {\n const spritesheets = [...module.spritesheets];\n module.spritesheets = {\n load: (engine: RpgClientEngine) => {\n spritesheets.forEach((spritesheet) => {\n engine.addSpriteSheet(spritesheet);\n });\n },\n };\n }\n if (module.sounds) {\n const sounds = [...module.sounds];\n module.sounds = {\n load: (engine: RpgClientEngine) => {\n sounds.forEach((sound) => {\n engine.addSound(sound);\n });\n },\n };\n }\n if (module.gui) {\n const gui = [...module.gui];\n module.gui = {\n load: (engine: RpgClientEngine) => {\n const guiService = inject(engine.context, RpgGui);\n gui.forEach((gui) => {\n guiService.add(gui);\n });\n },\n };\n }\n if (module.componentAnimations) {\n const componentAnimations = [...module.componentAnimations];\n module.componentAnimations = {\n load: (engine: RpgClientEngine) => {\n componentAnimations.forEach((componentAnimation) => {\n engine.addComponentAnimation(componentAnimation);\n });\n },\n };\n }\n if (module.particles) {\n const particles = [...module.particles];\n module.particles = {\n load: (engine: RpgClientEngine) => {\n particles.forEach((particle) => {\n engine.addParticle(particle);\n });\n },\n };\n }\n if (module.sprite) {\n const sprite = {...module.sprite};\n module.sprite = {\n ...sprite,\n load: (engine: RpgClientEngine) => {\n if (sprite.componentsBehind) {\n sprite.componentsBehind.forEach((component) => {\n engine.addSpriteComponentBehind(component);\n });\n }\n if (sprite.componentsInFront) {\n sprite.componentsInFront.forEach((component) => {\n engine.addSpriteComponentInFront(component);\n });\n }\n },\n };\n }\n return module;\n });\n return modules\n });\n}\n\nexport const GlobalConfigToken = \"GlobalConfigToken\";\n\nexport function provideGlobalConfig(config: any) {\n return {\n provide: GlobalConfigToken,\n useValue: config ?? {},\n };\n}\n\nexport function provideClientGlobalConfig(config: any = {}) {\n if (!config.keyboardControls) {\n config.keyboardControls = {\n up: 'up',\n down: 'down',\n left: 'left',\n right: 'right',\n action: 'space'\n }\n }\n return provideGlobalConfig(config)\n}\n\n"],"names":["modules","gui"],"mappings":";;;;AAMO,SAAS,qBAAqB,OAAsB,EAAA;AACzD,EAAA,OAAO,cAAe,CAAA,OAAA,EAAS,QAAU,EAAA,CAACA,UAAS,OAAY,KAAA;AAC7D,IAAM,MAAA,gBAAA,GAAmB,WAAY,C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,gBAAA,MAAA,CAAO,0BAA0B,SAAS,CAAA;AAAA,eAC3C,CAAA;AAAA;AACH;AACF,SACF;AAAA;AAEF,MAAO,OAAA,MAAA;AAAA,KACR,CAAA;AACD,IAAOD,OAAAA,QAAAA;AAAA,GACR,CAAA;AACH;AAEO,MAAM,iBAAoB,GAAA;AAE1B,SAAS,oBAAoB,MAAa,EAAA;AAC/C,EAAO,OAAA;AAAA,IACL,OAAS,EAAA,iBAAA;AAAA,IACT,QAAA,EAAU,UAAU;AAAC,GACvB;AACF;AAEgB,SAAA,yBAAA,CAA0B,MAAc,GAAA,EAAI,EAAA;AAC1D,EAAI,IAAA,CAAC,OAAO,gBAAkB,EAAA;AAC5B,IAAA,MAAA,CAAO,gBAAmB,GAAA;AAAA,MACxB,EAAI,EAAA,IAAA;AAAA,MACJ,IAAM,EAAA,MAAA;AAAA,MACN,IAAM,EAAA,MAAA;AAAA,MACN,KAAO,EAAA,OAAA;AAAA,MACP,MAAQ,EAAA;AAAA,KACV;AAAA;AAEF,EAAA,OAAO,oBAAoB,MAAM,CAAA;AACnC;;;;"}
package/dist/index9.js CHANGED
@@ -1,6 +1,6 @@
1
- import { inject } from './index15.js';
1
+ import { inject } from './index16.js';
2
2
  import { signal } from 'canvasengine';
3
- import { WebSocketToken } from './index16.js';
3
+ import { WebSocketToken } from './index17.js';
4
4
  import { PrebuiltGui } from './index10.js';
5
5
 
6
6
  const throwError = (id) => {
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Creates an animation spritesheet preset with automatic frame generation
3
+ *
4
+ * This function generates animation frames based on the provided width and height dimensions.
5
+ * It creates a sequence of frames that progresses through the spritesheet from left to right,
6
+ * top to bottom, with each frame having a 10ms time increment.
7
+ *
8
+ * @param {number} framesWidth - The number of frames horizontally in the spritesheet
9
+ * @param {number} framesHeight - The number of frames vertically in the spritesheet
10
+ * @returns {Object} Animation preset configuration object
11
+ *
12
+ * @example
13
+ * ```javascript
14
+ * // For a 4x4 spritesheet
15
+ * const preset = AnimationSpritesheetPreset(4, 4);
16
+ * // This will generate 16 frames with coordinates from (0,0) to (3,3)
17
+ * ```
18
+ */
19
+ export declare const AnimationSpritesheetPreset: (framesWidth: number, framesHeight: number) => {
20
+ framesWidth: number;
21
+ framesHeight: number;
22
+ textures: {
23
+ default: {
24
+ animations: () => {
25
+ time: number;
26
+ frameX: number;
27
+ frameY: number;
28
+ }[][];
29
+ };
30
+ };
31
+ };
@@ -19,4 +19,106 @@ export declare const Presets: {
19
19
  framesHeight: number;
20
20
  framesWidth: number;
21
21
  };
22
+ LPCSpritesheetPreset: (options: {
23
+ id: string;
24
+ imageSource: string;
25
+ width: number;
26
+ height: number;
27
+ ratio?: number;
28
+ }) => {
29
+ id: string;
30
+ image: string;
31
+ width: number;
32
+ height: number;
33
+ opacity: number;
34
+ rectWidth: number;
35
+ rectHeight: number;
36
+ framesWidth: number;
37
+ framesHeight: number;
38
+ spriteRealSize: {
39
+ width: number;
40
+ height: number;
41
+ };
42
+ textures: {
43
+ attack3?: {
44
+ offset: {
45
+ x: number;
46
+ y: number;
47
+ };
48
+ rectWidth: number;
49
+ rectHeight: number;
50
+ framesWidth: number;
51
+ framesHeight: number;
52
+ animations: ({ direction }: {
53
+ direction: any;
54
+ }) => any[];
55
+ } | undefined;
56
+ stand: {
57
+ offset: {
58
+ x: number;
59
+ y: number;
60
+ };
61
+ animations: ({ direction }: {
62
+ direction: any;
63
+ }) => {
64
+ time: number;
65
+ frameX: number;
66
+ frameY: number;
67
+ }[][];
68
+ };
69
+ walk: {
70
+ offset: {
71
+ x: number;
72
+ y: number;
73
+ };
74
+ framesWidth: number;
75
+ framesHeight: number;
76
+ animations: ({ direction }: {
77
+ direction: any;
78
+ }) => any[];
79
+ };
80
+ attack: {
81
+ offset: {
82
+ x: number;
83
+ y: number;
84
+ };
85
+ framesWidth: number;
86
+ framesHeight: number;
87
+ animations: ({ direction }: {
88
+ direction: any;
89
+ }) => any[];
90
+ };
91
+ skill: {
92
+ framesWidth: number;
93
+ framesHeight: number;
94
+ animations: ({ direction }: {
95
+ direction: any;
96
+ }) => any[];
97
+ };
98
+ attack2: {
99
+ offset: {
100
+ x: number;
101
+ y: number;
102
+ };
103
+ framesWidth: number;
104
+ framesHeight: number;
105
+ animations: ({ direction }: {
106
+ direction: any;
107
+ }) => any[];
108
+ };
109
+ };
110
+ };
111
+ AnimationSpritesheetPreset: (framesWidth: number, framesHeight: number) => {
112
+ framesWidth: number;
113
+ framesHeight: number;
114
+ textures: {
115
+ default: {
116
+ animations: () => {
117
+ time: number;
118
+ frameX: number;
119
+ frameY: number;
120
+ }[][];
121
+ };
122
+ };
123
+ };
22
124
  };
@@ -0,0 +1,89 @@
1
+ export declare const LPCSpritesheetPreset: (options: {
2
+ id: string;
3
+ imageSource: string;
4
+ width: number;
5
+ height: number;
6
+ ratio?: number;
7
+ }) => {
8
+ id: string;
9
+ image: string;
10
+ width: number;
11
+ height: number;
12
+ opacity: number;
13
+ rectWidth: number;
14
+ rectHeight: number;
15
+ framesWidth: number;
16
+ framesHeight: number;
17
+ spriteRealSize: {
18
+ width: number;
19
+ height: number;
20
+ };
21
+ textures: {
22
+ attack3?: {
23
+ offset: {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ rectWidth: number;
28
+ rectHeight: number;
29
+ framesWidth: number;
30
+ framesHeight: number;
31
+ animations: ({ direction }: {
32
+ direction: any;
33
+ }) => any[];
34
+ } | undefined;
35
+ stand: {
36
+ offset: {
37
+ x: number;
38
+ y: number;
39
+ };
40
+ animations: ({ direction }: {
41
+ direction: any;
42
+ }) => {
43
+ time: number;
44
+ frameX: number;
45
+ frameY: number;
46
+ }[][];
47
+ };
48
+ walk: {
49
+ offset: {
50
+ x: number;
51
+ y: number;
52
+ };
53
+ framesWidth: number;
54
+ framesHeight: number;
55
+ animations: ({ direction }: {
56
+ direction: any;
57
+ }) => any[];
58
+ };
59
+ attack: {
60
+ offset: {
61
+ x: number;
62
+ y: number;
63
+ };
64
+ framesWidth: number;
65
+ framesHeight: number;
66
+ animations: ({ direction }: {
67
+ direction: any;
68
+ }) => any[];
69
+ };
70
+ skill: {
71
+ framesWidth: number;
72
+ framesHeight: number;
73
+ animations: ({ direction }: {
74
+ direction: any;
75
+ }) => any[];
76
+ };
77
+ attack2: {
78
+ offset: {
79
+ x: number;
80
+ y: number;
81
+ };
82
+ framesWidth: number;
83
+ framesHeight: number;
84
+ animations: ({ direction }: {
85
+ direction: any;
86
+ }) => any[];
87
+ };
88
+ };
89
+ };