@rpgjs/client 5.0.0-alpha.2 → 5.0.0-alpha.20

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 (163) hide show
  1. package/dist/Game/AnimationManager.d.ts +8 -0
  2. package/dist/Game/Map.d.ts +7 -1
  3. package/dist/Gui/Gui.d.ts +128 -5
  4. package/dist/RpgClient.d.ts +217 -59
  5. package/dist/RpgClientEngine.d.ts +345 -6
  6. package/dist/Sound.d.ts +199 -0
  7. package/dist/components/animations/index.d.ts +4 -0
  8. package/dist/components/dynamics/parse-value.d.ts +1 -0
  9. package/dist/components/gui/index.d.ts +3 -3
  10. package/dist/components/index.d.ts +3 -1
  11. package/dist/components/prebuilt/index.d.ts +18 -0
  12. package/dist/index.d.ts +4 -1
  13. package/dist/index.js +9 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/index10.js +149 -4
  16. package/dist/index10.js.map +1 -1
  17. package/dist/index11.js +21 -7
  18. package/dist/index11.js.map +1 -1
  19. package/dist/index12.js +6 -4
  20. package/dist/index12.js.map +1 -1
  21. package/dist/index13.js +11 -14
  22. package/dist/index13.js.map +1 -1
  23. package/dist/index14.js +8 -40
  24. package/dist/index14.js.map +1 -1
  25. package/dist/index15.js +187 -180
  26. package/dist/index15.js.map +1 -1
  27. package/dist/index16.js +104 -7
  28. package/dist/index16.js.map +1 -1
  29. package/dist/index17.js +82 -372
  30. package/dist/index17.js.map +1 -1
  31. package/dist/index18.js +361 -26
  32. package/dist/index18.js.map +1 -1
  33. package/dist/index19.js +46 -20
  34. package/dist/index19.js.map +1 -1
  35. package/dist/index2.js +683 -32
  36. package/dist/index2.js.map +1 -1
  37. package/dist/index20.js +5 -2417
  38. package/dist/index20.js.map +1 -1
  39. package/dist/index21.js +383 -97
  40. package/dist/index21.js.map +1 -1
  41. package/dist/index22.js +41 -104
  42. package/dist/index22.js.map +1 -1
  43. package/dist/index23.js +21 -67
  44. package/dist/index23.js.map +1 -1
  45. package/dist/index24.js +2632 -20
  46. package/dist/index24.js.map +1 -1
  47. package/dist/index25.js +107 -34
  48. package/dist/index25.js.map +1 -1
  49. package/dist/index26.js +69 -3
  50. package/dist/index26.js.map +1 -1
  51. package/dist/index27.js +17 -318
  52. package/dist/index27.js.map +1 -1
  53. package/dist/index28.js +24 -22
  54. package/dist/index28.js.map +1 -1
  55. package/dist/index29.js +92 -8
  56. package/dist/index29.js.map +1 -1
  57. package/dist/index3.js +68 -8
  58. package/dist/index3.js.map +1 -1
  59. package/dist/index30.js +37 -7
  60. package/dist/index30.js.map +1 -1
  61. package/dist/index31.js +18 -168
  62. package/dist/index31.js.map +1 -1
  63. package/dist/index32.js +3 -499
  64. package/dist/index32.js.map +1 -1
  65. package/dist/index33.js +332 -9
  66. package/dist/index33.js.map +1 -1
  67. package/dist/index34.js +24 -4400
  68. package/dist/index34.js.map +1 -1
  69. package/dist/index35.js +6 -311
  70. package/dist/index35.js.map +1 -1
  71. package/dist/index36.js +8 -88
  72. package/dist/index36.js.map +1 -1
  73. package/dist/index37.js +182 -56
  74. package/dist/index37.js.map +1 -1
  75. package/dist/index38.js +500 -16
  76. package/dist/index38.js.map +1 -1
  77. package/dist/index39.js +10 -18
  78. package/dist/index39.js.map +1 -1
  79. package/dist/index4.js +23 -5
  80. package/dist/index4.js.map +1 -1
  81. package/dist/index40.js +7 -0
  82. package/dist/index40.js.map +1 -0
  83. package/dist/index41.js +3690 -0
  84. package/dist/index41.js.map +1 -0
  85. package/dist/index42.js +77 -0
  86. package/dist/index42.js.map +1 -0
  87. package/dist/index43.js +6 -0
  88. package/dist/index43.js.map +1 -0
  89. package/dist/index44.js +20 -0
  90. package/dist/index44.js.map +1 -0
  91. package/dist/index45.js +146 -0
  92. package/dist/index45.js.map +1 -0
  93. package/dist/index46.js +12 -0
  94. package/dist/index46.js.map +1 -0
  95. package/dist/index47.js +113 -0
  96. package/dist/index47.js.map +1 -0
  97. package/dist/index48.js +136 -0
  98. package/dist/index48.js.map +1 -0
  99. package/dist/index49.js +137 -0
  100. package/dist/index49.js.map +1 -0
  101. package/dist/index5.js +2 -1
  102. package/dist/index5.js.map +1 -1
  103. package/dist/index50.js +112 -0
  104. package/dist/index50.js.map +1 -0
  105. package/dist/index51.js +141 -0
  106. package/dist/index51.js.map +1 -0
  107. package/dist/index52.js +9 -0
  108. package/dist/index52.js.map +1 -0
  109. package/dist/index53.js +54 -0
  110. package/dist/index53.js.map +1 -0
  111. package/dist/index6.js +1 -1
  112. package/dist/index6.js.map +1 -1
  113. package/dist/index7.js +11 -3
  114. package/dist/index7.js.map +1 -1
  115. package/dist/index8.js +68 -7
  116. package/dist/index8.js.map +1 -1
  117. package/dist/index9.js +230 -15
  118. package/dist/index9.js.map +1 -1
  119. package/dist/presets/animation.d.ts +31 -0
  120. package/dist/presets/faceset.d.ts +30 -0
  121. package/dist/presets/index.d.ts +103 -0
  122. package/dist/presets/lpc.d.ts +89 -0
  123. package/dist/services/loadMap.d.ts +123 -2
  124. package/dist/services/mmorpg.d.ts +9 -4
  125. package/dist/services/standalone.d.ts +51 -2
  126. package/package.json +22 -18
  127. package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
  128. package/src/Game/Map.ts +20 -2
  129. package/src/Game/Object.ts +163 -9
  130. package/src/Gui/Gui.ts +300 -17
  131. package/src/RpgClient.ts +222 -58
  132. package/src/RpgClientEngine.ts +804 -36
  133. package/src/Sound.ts +253 -0
  134. package/src/components/{effects → animations}/animation.ce +3 -6
  135. package/src/components/{effects → animations}/index.ts +1 -1
  136. package/src/components/character.ce +165 -37
  137. package/src/components/dynamics/parse-value.ts +80 -0
  138. package/src/components/dynamics/text.ce +183 -0
  139. package/src/components/gui/box.ce +17 -0
  140. package/src/components/gui/dialogbox/index.ce +73 -35
  141. package/src/components/gui/dialogbox/selection.ce +16 -1
  142. package/src/components/gui/index.ts +3 -4
  143. package/src/components/index.ts +5 -1
  144. package/src/components/prebuilt/hp-bar.ce +255 -0
  145. package/src/components/prebuilt/index.ts +21 -0
  146. package/src/components/scenes/draw-map.ce +6 -23
  147. package/src/components/scenes/event-layer.ce +9 -3
  148. package/src/core/setup.ts +2 -0
  149. package/src/index.ts +5 -2
  150. package/src/module.ts +72 -6
  151. package/src/presets/animation.ts +46 -0
  152. package/src/presets/faceset.ts +60 -0
  153. package/src/presets/index.ts +7 -1
  154. package/src/presets/lpc.ts +108 -0
  155. package/src/services/loadMap.ts +132 -3
  156. package/src/services/mmorpg.ts +27 -5
  157. package/src/services/standalone.ts +68 -6
  158. package/tsconfig.json +1 -1
  159. package/vite.config.ts +1 -1
  160. package/dist/Game/EffectManager.d.ts +0 -5
  161. package/dist/components/effects/index.d.ts +0 -4
  162. package/src/components/scenes/element-map.ce +0 -23
  163. /package/src/components/{effects → animations}/hit.ce +0 -0
@@ -0,0 +1,8 @@
1
+ import { RpgCommonPlayer } from '@rpgjs/common';
2
+ export declare class AnimationManager {
3
+ current: import('canvasengine').WritableArraySignal<any[]>;
4
+ displayEffect(params: any, player: RpgCommonPlayer | {
5
+ x: number;
6
+ y: number;
7
+ }): void;
8
+ }
@@ -1,7 +1,13 @@
1
1
  import { RpgCommonMap } from '@rpgjs/common';
2
2
  import { RpgClientPlayer } from './Player';
3
3
  import { RpgClientEvent } from './Event';
4
- export declare class RpgClientMap extends RpgCommonMap<RpgClientPlayer> {
4
+ import { RpgClientEngine } from '../RpgClientEngine';
5
+ export declare class RpgClientMap extends RpgCommonMap<any> {
6
+ engine: RpgClientEngine;
5
7
  players: import('canvasengine').WritableObjectSignal<Record<string, RpgClientPlayer>>;
6
8
  events: import('canvasengine').WritableObjectSignal<Record<string, RpgClientEvent>>;
9
+ currentPlayer: import('canvasengine').ComputedSignal<RpgClientPlayer>;
10
+ getCurrentPlayer(): RpgClientPlayer;
11
+ reset(): void;
12
+ stepPredictionTick(): void;
7
13
  }
package/dist/Gui/Gui.d.ts CHANGED
@@ -1,23 +1,146 @@
1
1
  import { Context } from '@signe/di';
2
+ import { Signal, WritableSignal } from 'canvasengine';
3
+ import { Subscription } from 'rxjs';
2
4
  interface GuiOptions {
3
- name: string;
5
+ name?: string;
6
+ id?: string;
4
7
  component: any;
5
8
  display?: boolean;
6
9
  data?: any;
10
+ /**
11
+ * Auto display the GUI when added to the system
12
+ * @default false
13
+ */
14
+ autoDisplay?: boolean;
15
+ /**
16
+ * Function that returns an array of Signal dependencies
17
+ * The GUI will only display when all dependencies are resolved (!= undefined)
18
+ * @returns Array of Signal dependencies
19
+ */
20
+ dependencies?: () => Signal[];
21
+ }
22
+ interface GuiInstance {
23
+ name: string;
24
+ component: any;
25
+ display: WritableSignal<boolean>;
26
+ data: WritableSignal<any>;
27
+ autoDisplay: boolean;
28
+ dependencies?: () => Signal[];
29
+ subscription?: Subscription;
7
30
  }
8
31
  export declare class RpgGui {
9
32
  private context;
10
33
  private webSocket;
11
- gui: import('canvasengine').WritableArraySignal<any>;
34
+ gui: import('canvasengine').WritableObjectSignal<Record<string, GuiInstance>>;
35
+ extraGuis: GuiInstance[];
36
+ private vueGuiInstance;
12
37
  constructor(context: Context);
13
38
  _initialize(): Promise<void>;
39
+ /**
40
+ * Set the VueGui instance reference for Vue component management
41
+ * This is called by VueGui when it's initialized
42
+ *
43
+ * @param vueGuiInstance - The VueGui instance
44
+ */
45
+ _setVueGuiInstance(vueGuiInstance: any): void;
46
+ /**
47
+ * Notify VueGui about GUI state changes
48
+ * This synchronizes the Vue component display state
49
+ *
50
+ * @param guiId - The GUI component ID
51
+ * @param display - Display state
52
+ * @param data - Component data
53
+ */
54
+ private _notifyVueGui;
55
+ /**
56
+ * Initialize Vue components in the VueGui instance
57
+ * This should be called after VueGui is mounted
58
+ */
59
+ _initializeVueComponents(): void;
14
60
  guiInteraction(guiId: string, name: string, data: any): void;
15
61
  guiClose(guiId: string, data?: any): void;
62
+ /**
63
+ * Add a GUI component to the system
64
+ *
65
+ * By default, only CanvasEngine components (.ce files) are accepted.
66
+ * Vue components should be handled by the @rpgjs/vue package.
67
+ *
68
+ * @param gui - GUI configuration options
69
+ * @param gui.name - Name or ID of the GUI component
70
+ * @param gui.id - Alternative ID if name is not provided
71
+ * @param gui.component - The component to render (must be a CanvasEngine component)
72
+ * @param gui.display - Initial display state (default: false)
73
+ * @param gui.data - Initial data for the component
74
+ * @param gui.autoDisplay - Auto display when added (default: false)
75
+ * @param gui.dependencies - Function returning Signal dependencies
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * gui.add({
80
+ * name: 'inventory',
81
+ * component: InventoryComponent, // Must be a .ce component
82
+ * autoDisplay: true,
83
+ * dependencies: () => [playerSignal, inventorySignal]
84
+ * });
85
+ * ```
86
+ */
16
87
  add(gui: GuiOptions): void;
17
- get(id: string | GuiOptions): any;
88
+ get(id: string): GuiInstance | undefined;
18
89
  exists(id: string): boolean;
19
- getAll(): any;
20
- display(id: string, data?: {}): void;
90
+ getAll(): Record<string, GuiInstance>;
91
+ /**
92
+ * Display a GUI component
93
+ *
94
+ * Displays the GUI immediately if no dependencies are configured,
95
+ * or waits for all dependencies to be resolved if dependencies are present.
96
+ * Automatically manages subscriptions to prevent memory leaks.
97
+ * Works with both CanvasEngine components and Vue components.
98
+ *
99
+ * @param id - The GUI component ID
100
+ * @param data - Data to pass to the component
101
+ * @param dependencies - Optional runtime dependencies (overrides config dependencies)
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * // Display immediately
106
+ * gui.display('inventory', { items: [] });
107
+ *
108
+ * // Display with runtime dependencies
109
+ * gui.display('shop', { shopId: 1 }, [playerSignal, shopSignal]);
110
+ * ```
111
+ */
112
+ display(id: string, data?: {}, dependencies?: Signal[]): void;
113
+ /**
114
+ * Handle Vue component display logic
115
+ *
116
+ * @param id - GUI component ID
117
+ * @param data - Component data
118
+ * @param dependencies - Runtime dependencies
119
+ * @param guiInstance - GUI instance
120
+ */
121
+ private _handleVueComponentDisplay;
122
+ /**
123
+ * Handle CanvasEngine component display logic
124
+ *
125
+ * @param id - GUI component ID
126
+ * @param data - Component data
127
+ * @param dependencies - Runtime dependencies
128
+ * @param guiInstance - GUI instance
129
+ */
130
+ private _handleCanvasComponentDisplay;
131
+ /**
132
+ * Hide a GUI component
133
+ *
134
+ * Hides the GUI and cleans up any active subscriptions.
135
+ * Works with both CanvasEngine components and Vue components.
136
+ *
137
+ * @param id - The GUI component ID
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * gui.hide('inventory');
142
+ * ```
143
+ */
21
144
  hide(id: string): void;
22
145
  }
23
146
  export {};
@@ -1,8 +1,9 @@
1
+ import { ComponentFunction, Signal } from 'canvasengine';
1
2
  import { RpgClientEngine } from './RpgClientEngine';
2
- import { Loader } from 'pixi.js';
3
- type RpgClass<T = any> = new (...args: any[]) => T;
4
- type RpgComponent = any;
5
- type SceneMap = any;
3
+ import { Loader, Container } from 'pixi.js';
4
+ import { RpgClientObject } from './Game/Object';
5
+ type RpgComponent = RpgClientObject;
6
+ type SceneMap = Container;
6
7
  export interface RpgClientEngineHooks {
7
8
  /**
8
9
  * When the engine is started. If you send false, you prevent the client from connecting to the server
@@ -10,7 +11,7 @@ export interface RpgClientEngineHooks {
10
11
  * @prop { (engine: RpgClientEngine) => boolean | any } [onStart]
11
12
  * @memberof RpgEngineHooks
12
13
  */
13
- onStart?: (engine: RpgClientEngine) => boolean | void;
14
+ onStart?: (engine: RpgClientEngine) => boolean | void | Promise<boolean | void>;
14
15
  /**
15
16
  * Each frame
16
17
  *
@@ -59,6 +60,34 @@ export interface RpgClientEngineHooks {
59
60
  onWindowResize?: () => any;
60
61
  }
61
62
  export interface RpgSpriteHooks {
63
+ /**
64
+ * Array of components to render behind the sprite
65
+ * These components will be displayed with a lower z-index than the sprite itself
66
+ *
67
+ * @prop { ComponentFunction[] } [componentsBehind]
68
+ * @memberof RpgSpriteHooks
69
+ * @example
70
+ * ```ts
71
+ * const sprite: RpgSpriteHooks = {
72
+ * componentsBehind: [ShadowComponent, AuraComponent]
73
+ * }
74
+ * ```
75
+ */
76
+ componentsBehind?: ComponentFunction[];
77
+ /**
78
+ * Array of components to render in front of the sprite
79
+ * These components will be displayed with a higher z-index than the sprite itself
80
+ *
81
+ * @prop { ComponentFunction[] } [componentsInFront]
82
+ * @memberof RpgSpriteHooks
83
+ * @example
84
+ * ```ts
85
+ * const sprite: RpgSpriteHooks = {
86
+ * componentsInFront: [HealthBarComponent, StatusEffectComponent]
87
+ * }
88
+ * ```
89
+ */
90
+ componentsInFront?: ComponentFunction[];
62
91
  /**
63
92
  * As soon as the sprite is initialized
64
93
  *
@@ -163,14 +192,13 @@ export interface RpgClient {
163
192
  * @example
164
193
  *
165
194
  * ```ts
166
- * import { RpgClient, RpgModule } from '@rpgjs/client'
195
+ * import { RpgClient, defineModule } from '@rpgjs/client'
167
196
  *
168
- * @RpgModule<RpgClient>({
197
+ * defineModule<RpgClient>({
169
198
  * hooks: {
170
199
  * player: ['onAuth']
171
200
  * }
172
201
  * })
173
- * class RpgClientEngine { }
174
202
  * ```
175
203
  *
176
204
  * Emit the hook:
@@ -207,7 +235,7 @@ export interface RpgClient {
207
235
  * Object containing the hooks concerning the engine
208
236
  *
209
237
  * ```ts
210
- * import { RpgClientEngine, RpgClientEngineHooks, RpgModule, RpgClient } from '@rpgjs/client'
238
+ * import { RpgClientEngine, RpgClientEngineHooks, defineModule, RpgClient } from '@rpgjs/client'
211
239
  *
212
240
  * const engine: RpgClientEngineHooks = {
213
241
  * onConnected(engine: RpgClientEngine) {
@@ -215,10 +243,9 @@ export interface RpgClient {
215
243
  * }
216
244
  * }
217
245
  *
218
- * @RpgModule<RpgClient>({
246
+ * defineModule<RpgClient>({
219
247
  * engine
220
248
  * })
221
- * class RpgClientModule {}
222
249
  * ```
223
250
  *
224
251
  * @prop {RpgClientEngineHooks} [engine]
@@ -227,99 +254,204 @@ export interface RpgClient {
227
254
  engine?: RpgClientEngineHooks;
228
255
  /**
229
256
  * Array containing the list of spritesheets
230
- * An element contains a class with the `@Spritesheet` decorator
257
+ * Each element is a simple object containing spritesheet definitions
231
258
  *
232
259
  * ```ts
233
- * import { Spritesheet, Animation, Direction, RpgClient, RpgModule } from '@rpgjs/client'
234
- *
235
- * @Spritesheet({
236
- * id: 'chest',
237
- * image: require('./assets/chest.png'),
238
- * // other options
239
- * })
240
- * class Chest { }
260
+ * import { defineModule, RpgClient } from '@rpgjs/client'
241
261
  *
242
- * @RpgModule<RpgClient>({
262
+ * defineModule<RpgClient>({
243
263
  * spritesheets: [
244
- * Chest
264
+ * {
265
+ * id: 'chest',
266
+ * image: require('./assets/chest.png'),
267
+ * framesWidth: 32,
268
+ * framesHeight: 32,
269
+ * animations: {
270
+ * default: {
271
+ * frames: [0, 1, 2],
272
+ * duration: 1000
273
+ * }
274
+ * }
275
+ * }
245
276
  * ]
246
277
  * })
247
- * class RpgClientEngine {}
248
278
  * ```
249
279
  *
250
280
  * [Guide: Create Sprite](/guide/create-sprite.html)
251
281
  *
252
- * @prop {Array<Class>} [spritesheets]
282
+ * @prop {Array<Object>} [spritesheets]
253
283
  * @memberof RpgClient
254
284
  * */
255
285
  spritesheets?: any[];
256
286
  /**
257
- * Array containing the list of VueJS components
287
+ * Resolver function for dynamically creating spritesheets
288
+ *
289
+ * This function is called when a spritesheet is requested but not found in the cache.
290
+ * It can be synchronous (returns directly) or asynchronous (returns a Promise).
291
+ * The resolved spritesheet is automatically cached for future use.
258
292
  *
259
293
  * ```ts
260
- * import { RpgClient, RpgModule } from '@rpgjs/client'
261
- *
262
- * const component = {
263
- * name: 'my-gui',
264
- * template: `
265
- * <div>
266
- * Component
267
- * </div>
268
- * `
269
- * }
294
+ * import { defineModule, RpgClient } from '@rpgjs/client'
295
+ *
296
+ * defineModule<RpgClient>({
297
+ * spritesheetResolver: (id: string) => {
298
+ * // Synchronous resolver
299
+ * if (id === 'dynamic-sprite') {
300
+ * return {
301
+ * id: 'dynamic-sprite',
302
+ * image: 'path/to/image.png',
303
+ * framesWidth: 32,
304
+ * framesHeight: 32
305
+ * };
306
+ * }
307
+ * return undefined;
308
+ * }
309
+ * })
270
310
  *
271
- * @RpgModule<RpgClient>({
311
+ * // Or asynchronous resolver
312
+ * defineModule<RpgClient>({
313
+ * spritesheetResolver: async (id: string) => {
314
+ * const response = await fetch(`/api/spritesheets/${id}`);
315
+ * const data = await response.json();
316
+ * return data;
317
+ * }
318
+ * })
319
+ * ```
320
+ *
321
+ * @prop {(id: string) => any | Promise<any>} [spritesheetResolver]
322
+ * @memberof RpgClient
323
+ * */
324
+ spritesheetResolver?: (id: string) => any | Promise<any>;
325
+ /**
326
+ * Resolver function for dynamically loading sounds
327
+ *
328
+ * The resolver is called when a sound is requested but not found in the cache.
329
+ * It can be synchronous (returns directly) or asynchronous (returns a Promise).
330
+ * The resolved sound is automatically cached for future use.
331
+ *
332
+ * ```ts
333
+ * import { defineModule, RpgClient } from '@rpgjs/client'
334
+ *
335
+ * defineModule<RpgClient>({
336
+ * soundResolver: (id: string) => {
337
+ * if (id === 'dynamic-sound') {
338
+ * return { id: 'dynamic-sound', src: 'path/to/sound.mp3' };
339
+ * }
340
+ * return undefined;
341
+ * }
342
+ * })
343
+ * ```
344
+ *
345
+ * @prop {(id: string) => any | Promise<any>} [soundResolver]
346
+ * @memberof RpgClient
347
+ * */
348
+ soundResolver?: (id: string) => any | Promise<any>;
349
+ /**
350
+ * Array containing the list of GUI components
351
+ *
352
+ * ```ts
353
+ * import { defineModule, RpgClient } from '@rpgjs/client'
354
+ * import InventoryComponent from './inventory.ce'
355
+ *
356
+ * defineModule<RpgClient>({
272
357
  * gui: [
273
- * component
358
+ * {
359
+ * id: 'inventory',
360
+ * component: InventoryComponent,
361
+ * autoDisplay: true,
362
+ * dependencies: () => [playerSignal, inventorySignal]
363
+ * }
274
364
  * ]
275
365
  * })
276
- * class RpgClientEngine {}
277
366
  * ```
278
367
  *
279
368
  * [Guide: Create GUI](/guide/create-gui.html)
280
369
  *
281
- * @prop {Array<Component of VueJS>} [gui]
370
+ * @prop {Array<GuiOptions>} [gui]
282
371
  * @memberof RpgClient
283
372
  * */
284
- gui?: any[];
373
+ gui?: ({
374
+ id: string;
375
+ component: ComponentFunction;
376
+ /**
377
+ * Auto display the GUI when added to the system
378
+ * @default false
379
+ */
380
+ autoDisplay?: boolean;
381
+ /**
382
+ * Function that returns an array of Signal dependencies
383
+ * The GUI will only display when all dependencies are resolved (!= undefined)
384
+ */
385
+ dependencies?: () => Signal[];
386
+ } | any)[];
285
387
  /**
286
388
  * Array containing the list of sounds
287
- * An element contains a class with the `@Sound` decorator
389
+ * Each element can be:
390
+ * - A simple object containing sound definitions
391
+ * - A class decorated with @Sound
288
392
  *
289
393
  * ```ts
290
- * import { Sound, RpgModule, RpgClient } from '@rpgjs/client'
394
+ * import { defineModule, RpgClient, Sound } from '@rpgjs/client'
395
+ *
396
+ * // Using simple objects
397
+ * defineModule<RpgClient>({
398
+ * sounds: [
399
+ * {
400
+ * id: 'typewriter',
401
+ * src: 'typewriter.wav'
402
+ * },
403
+ * {
404
+ * id: 'cursor',
405
+ * src: 'cursor.wav'
406
+ * }
407
+ * ]
408
+ * })
291
409
  *
410
+ * // Using @Sound decorator
292
411
  * @Sound({
293
- * sounds: {
294
- * town: require('./assets/Town_Theme.ogg')
295
- * }
412
+ * id: 'town-music',
413
+ * sound: require('./sound/town.ogg'),
414
+ * loop: true,
415
+ * volume: 0.5
416
+ * })
417
+ * export class TownMusic {}
418
+ *
419
+ * defineModule<RpgClient>({
420
+ * sounds: [TownMusic]
421
+ * })
422
+ *
423
+ * // Multiple sounds in one class
424
+ * @Sound({
425
+ * sounds: {
426
+ * hero: require('./assets/hero.ogg'),
427
+ * monster: require('./assets/monster.ogg')
428
+ * },
429
+ * loop: true
296
430
  * })
297
- * class Sounds {}
431
+ * export class CharacterSounds {}
298
432
  *
299
- * @RpgModule<RpgClient>({
300
- * sounds: [ Sounds ]
433
+ * defineModule<RpgClient>({
434
+ * sounds: [CharacterSounds]
301
435
  * })
302
- * class RpgClientEngine {}
303
436
  * ```
304
437
  *
305
- * @prop {Array<Class>} [sounds]
438
+ * @prop {Array<Object | Class>} [sounds]
306
439
  * @memberof RpgClient
307
440
  * */
308
- sounds?: RpgClass[];
441
+ sounds?: any[];
309
442
  /**
310
443
  * Give the `RpgSprite` class. A Sprite represents a player or an event
311
444
  *
312
445
  * ```ts
313
- * import { RpgSprite, RpgSpriteHooks, RpgClient, RpgModule } from '@rpgjs/client'
446
+ * import { RpgSprite, RpgSpriteHooks, RpgClient, defineModule } from '@rpgjs/client'
314
447
  *
315
448
  * export const sprite: RpgSpriteHooks = {
316
449
  * onInit(sprite: RpgSprite) {}
317
450
  * }
318
451
  *
319
- * @RpgModule<RpgClient>({
452
+ * defineModule<RpgClient>({
320
453
  * sprite
321
454
  * })
322
- * class RpgClientEngine {}
323
455
  * ```
324
456
  *
325
457
  * @prop {RpgSpriteHooks} [sprite]
@@ -330,19 +462,18 @@ export interface RpgClient {
330
462
  * Reference the scenes of the game. Here you can put your own class that inherits RpgSceneMap
331
463
  *
332
464
  * ```ts
333
- * import { RpgSceneMapHooks, RpgClient, RpgModule } from '@rpgjs/client'
465
+ * import { RpgSceneMapHooks, RpgClient, defineModule } from '@rpgjs/client'
334
466
  *
335
467
  * export const sceneMap: RpgSceneMapHooks = {
336
468
  *
337
469
  * }
338
470
  *
339
- * @RpgModule<RpgClient>({
471
+ * defineModule<RpgClient>({
340
472
  * scenes: {
341
473
  * // If you put the RpgSceneMap scene, Thhe key is called mandatory `map`
342
474
  * map: sceneMap
343
475
  * }
344
476
  * })
345
- * class RpgClientEngine {}
346
477
  * ```
347
478
  *
348
479
  * @prop { [sceneName: string]: RpgSceneMapHooks } [scenes]
@@ -351,9 +482,36 @@ export interface RpgClient {
351
482
  scenes?: {
352
483
  map: RpgSceneMapHooks;
353
484
  };
354
- effects?: {
485
+ sceneMap?: RpgSceneMapHooks;
486
+ /**
487
+ * Array containing the list of component animations
488
+ * Each element defines a temporary component to display for animations like hits, effects, etc.
489
+ *
490
+ * ```ts
491
+ * import { defineModule, RpgClient } from '@rpgjs/client'
492
+ * import HitComponent from './hit.ce'
493
+ * import ExplosionComponent from './explosion.ce'
494
+ *
495
+ * defineModule<RpgClient>({
496
+ * componentAnimations: [
497
+ * {
498
+ * id: 'hit',
499
+ * component: HitComponent
500
+ * },
501
+ * {
502
+ * id: 'explosion',
503
+ * component: ExplosionComponent
504
+ * }
505
+ * ]
506
+ * })
507
+ * ```
508
+ *
509
+ * @prop {Array<{id: string, component: ComponentFunction}>} [componentAnimations]
510
+ * @memberof RpgClient
511
+ * */
512
+ componentAnimations?: {
355
513
  id: string;
356
- component: any;
514
+ component: ComponentFunction;
357
515
  }[];
358
516
  }
359
517
  export {};