@rpgjs/client 5.0.0-alpha.2 → 5.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Game/AnimationManager.d.ts +8 -0
- package/dist/Game/Map.d.ts +7 -1
- package/dist/Gui/Gui.d.ts +170 -5
- package/dist/Resource.d.ts +97 -0
- package/dist/RpgClient.d.ts +259 -59
- package/dist/RpgClientEngine.d.ts +379 -6
- package/dist/Sound.d.ts +199 -0
- package/dist/components/animations/index.d.ts +4 -0
- package/dist/components/dynamics/parse-value.d.ts +1 -0
- package/dist/components/gui/index.d.ts +3 -3
- package/dist/components/index.d.ts +3 -1
- package/dist/components/prebuilt/index.d.ts +18 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/index10.js +149 -4
- package/dist/index10.js.map +1 -1
- package/dist/index11.js +22 -7
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +6 -4
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +11 -14
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +8 -40
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +217 -180
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +104 -7
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +82 -372
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +110 -27
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +360 -18
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +726 -32
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +5 -2416
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +47 -109
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +7 -107
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +394 -65
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +40 -15
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +20 -36
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +2629 -1
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +102 -310
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +63 -17
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +18 -8
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +70 -8
- package/dist/index3.js.map +1 -1
- package/dist/index30.js +24 -8
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +88 -167
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +34 -494
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +22 -10
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +3 -4401
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +20 -1
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +18 -82
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +8 -58
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +4 -13
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +10 -18
- package/dist/index39.js.map +1 -1
- package/dist/index4.js +25 -5
- package/dist/index4.js.map +1 -1
- package/dist/index40.js +7 -0
- package/dist/index40.js.map +1 -0
- package/dist/index41.js +3690 -0
- package/dist/index41.js.map +1 -0
- package/dist/index42.js +187 -0
- package/dist/index42.js.map +1 -0
- package/dist/index43.js +504 -0
- package/dist/index43.js.map +1 -0
- package/dist/index44.js +77 -0
- package/dist/index44.js.map +1 -0
- package/dist/index45.js +6 -0
- package/dist/index45.js.map +1 -0
- package/dist/index46.js +20 -0
- package/dist/index46.js.map +1 -0
- package/dist/index47.js +146 -0
- package/dist/index47.js.map +1 -0
- package/dist/index48.js +12 -0
- package/dist/index48.js.map +1 -0
- package/dist/index49.js +113 -0
- package/dist/index49.js.map +1 -0
- package/dist/index5.js +2 -1
- package/dist/index5.js.map +1 -1
- package/dist/index50.js +136 -0
- package/dist/index50.js.map +1 -0
- package/dist/index51.js +137 -0
- package/dist/index51.js.map +1 -0
- package/dist/index52.js +112 -0
- package/dist/index52.js.map +1 -0
- package/dist/index53.js +141 -0
- package/dist/index53.js.map +1 -0
- package/dist/index54.js +9 -0
- package/dist/index54.js.map +1 -0
- package/dist/index55.js +54 -0
- package/dist/index55.js.map +1 -0
- package/dist/index6.js +1 -1
- package/dist/index6.js.map +1 -1
- package/dist/index7.js +11 -3
- package/dist/index7.js.map +1 -1
- package/dist/index8.js +68 -7
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +278 -15
- package/dist/index9.js.map +1 -1
- package/dist/presets/animation.d.ts +31 -0
- package/dist/presets/faceset.d.ts +30 -0
- package/dist/presets/index.d.ts +103 -0
- package/dist/presets/lpc.d.ts +89 -0
- package/dist/services/keyboardControls.d.ts +5 -0
- package/dist/services/loadMap.d.ts +123 -2
- package/dist/services/mmorpg.d.ts +12 -4
- package/dist/services/standalone.d.ts +54 -2
- package/package.json +22 -18
- package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
- package/src/Game/Map.ts +20 -2
- package/src/Game/Object.ts +163 -9
- package/src/Gui/Gui.ts +362 -17
- package/src/Resource.ts +150 -0
- package/src/RpgClient.ts +264 -58
- package/src/RpgClientEngine.ts +848 -36
- package/src/Sound.ts +253 -0
- package/src/components/{effects → animations}/animation.ce +3 -6
- package/src/components/{effects → animations}/index.ts +1 -1
- package/src/components/character.ce +193 -36
- package/src/components/dynamics/parse-value.ts +80 -0
- package/src/components/dynamics/text.ce +183 -0
- package/src/components/gui/box.ce +17 -0
- package/src/components/gui/dialogbox/index.ce +73 -35
- package/src/components/gui/dialogbox/selection.ce +16 -1
- package/src/components/gui/index.ts +3 -4
- package/src/components/index.ts +5 -1
- package/src/components/prebuilt/hp-bar.ce +255 -0
- package/src/components/prebuilt/index.ts +22 -0
- package/src/components/scenes/canvas.ce +12 -10
- package/src/components/scenes/draw-map.ce +6 -23
- package/src/components/scenes/event-layer.ce +9 -3
- package/src/core/setup.ts +2 -0
- package/src/index.ts +7 -2
- package/src/module.ts +72 -6
- package/src/presets/animation.ts +46 -0
- package/src/presets/faceset.ts +60 -0
- package/src/presets/index.ts +7 -1
- package/src/presets/lpc.ts +108 -0
- package/src/services/keyboardControls.ts +8 -0
- package/src/services/loadMap.ts +132 -3
- package/src/services/mmorpg.ts +29 -5
- package/src/services/standalone.ts +70 -6
- package/tsconfig.json +1 -1
- package/vite.config.ts +1 -1
- package/dist/Game/EffectManager.d.ts +0 -5
- package/dist/components/effects/index.d.ts +0 -4
- package/src/components/scenes/element-map.ce +0 -23
- /package/src/components/{effects → animations}/hit.ce +0 -0
package/src/RpgClient.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { ComponentFunction, Signal } from 'canvasengine'
|
|
1
2
|
import { RpgClientEngine } from './RpgClientEngine'
|
|
2
|
-
import { Loader } from 'pixi.js'
|
|
3
|
+
import { Loader, Container } from 'pixi.js'
|
|
4
|
+
import { RpgClientObject } from './Game/Object'
|
|
3
5
|
|
|
4
6
|
type RpgClass<T = any> = new (...args: any[]) => T
|
|
5
|
-
type RpgComponent =
|
|
6
|
-
type SceneMap =
|
|
7
|
+
type RpgComponent = RpgClientObject
|
|
8
|
+
type SceneMap = Container
|
|
7
9
|
|
|
8
10
|
export interface RpgClientEngineHooks {
|
|
9
11
|
/**
|
|
@@ -12,7 +14,7 @@ export interface RpgClientEngineHooks {
|
|
|
12
14
|
* @prop { (engine: RpgClientEngine) => boolean | any } [onStart]
|
|
13
15
|
* @memberof RpgEngineHooks
|
|
14
16
|
*/
|
|
15
|
-
onStart?: (engine: RpgClientEngine) => boolean | void
|
|
17
|
+
onStart?: (engine: RpgClientEngine) => boolean | void | Promise<boolean | void>
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Each frame
|
|
@@ -65,6 +67,36 @@ export interface RpgClientEngineHooks {
|
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
export interface RpgSpriteHooks {
|
|
70
|
+
/**
|
|
71
|
+
* Array of components to render behind the sprite
|
|
72
|
+
* These components will be displayed with a lower z-index than the sprite itself
|
|
73
|
+
*
|
|
74
|
+
* @prop { ComponentFunction[] } [componentsBehind]
|
|
75
|
+
* @memberof RpgSpriteHooks
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const sprite: RpgSpriteHooks = {
|
|
79
|
+
* componentsBehind: [ShadowComponent, AuraComponent]
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
componentsBehind?: ComponentFunction[]
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Array of components to render in front of the sprite
|
|
87
|
+
* These components will be displayed with a higher z-index than the sprite itself
|
|
88
|
+
*
|
|
89
|
+
* @prop { ComponentFunction[] } [componentsInFront]
|
|
90
|
+
* @memberof RpgSpriteHooks
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const sprite: RpgSpriteHooks = {
|
|
94
|
+
* componentsInFront: [HealthBarComponent, StatusEffectComponent]
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
componentsInFront?: ComponentFunction[]
|
|
99
|
+
|
|
68
100
|
/**
|
|
69
101
|
* As soon as the sprite is initialized
|
|
70
102
|
*
|
|
@@ -178,14 +210,13 @@ export interface RpgClient {
|
|
|
178
210
|
* @example
|
|
179
211
|
*
|
|
180
212
|
* ```ts
|
|
181
|
-
* import { RpgClient,
|
|
213
|
+
* import { RpgClient, defineModule } from '@rpgjs/client'
|
|
182
214
|
*
|
|
183
|
-
*
|
|
215
|
+
* defineModule<RpgClient>({
|
|
184
216
|
* hooks: {
|
|
185
217
|
* player: ['onAuth']
|
|
186
218
|
* }
|
|
187
219
|
* })
|
|
188
|
-
* class RpgClientEngine { }
|
|
189
220
|
* ```
|
|
190
221
|
*
|
|
191
222
|
* Emit the hook:
|
|
@@ -224,7 +255,7 @@ export interface RpgClient {
|
|
|
224
255
|
* Object containing the hooks concerning the engine
|
|
225
256
|
*
|
|
226
257
|
* ```ts
|
|
227
|
-
* import { RpgClientEngine, RpgClientEngineHooks,
|
|
258
|
+
* import { RpgClientEngine, RpgClientEngineHooks, defineModule, RpgClient } from '@rpgjs/client'
|
|
228
259
|
*
|
|
229
260
|
* const engine: RpgClientEngineHooks = {
|
|
230
261
|
* onConnected(engine: RpgClientEngine) {
|
|
@@ -232,10 +263,9 @@ export interface RpgClient {
|
|
|
232
263
|
* }
|
|
233
264
|
* }
|
|
234
265
|
*
|
|
235
|
-
*
|
|
266
|
+
* defineModule<RpgClient>({
|
|
236
267
|
* engine
|
|
237
268
|
* })
|
|
238
|
-
* class RpgClientModule {}
|
|
239
269
|
* ```
|
|
240
270
|
*
|
|
241
271
|
* @prop {RpgClientEngineHooks} [engine]
|
|
@@ -245,102 +275,251 @@ export interface RpgClient {
|
|
|
245
275
|
|
|
246
276
|
/**
|
|
247
277
|
* Array containing the list of spritesheets
|
|
248
|
-
*
|
|
278
|
+
* Each element is a simple object containing spritesheet definitions
|
|
249
279
|
*
|
|
250
280
|
* ```ts
|
|
251
|
-
* import {
|
|
252
|
-
*
|
|
253
|
-
* @Spritesheet({
|
|
254
|
-
* id: 'chest',
|
|
255
|
-
* image: require('./assets/chest.png'),
|
|
256
|
-
* // other options
|
|
257
|
-
* })
|
|
258
|
-
* class Chest { }
|
|
281
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
259
282
|
*
|
|
260
|
-
*
|
|
283
|
+
* defineModule<RpgClient>({
|
|
261
284
|
* spritesheets: [
|
|
262
|
-
*
|
|
285
|
+
* {
|
|
286
|
+
* id: 'chest',
|
|
287
|
+
* image: require('./assets/chest.png'),
|
|
288
|
+
* framesWidth: 32,
|
|
289
|
+
* framesHeight: 32,
|
|
290
|
+
* animations: {
|
|
291
|
+
* default: {
|
|
292
|
+
* frames: [0, 1, 2],
|
|
293
|
+
* duration: 1000
|
|
294
|
+
* }
|
|
295
|
+
* }
|
|
296
|
+
* }
|
|
263
297
|
* ]
|
|
264
298
|
* })
|
|
265
|
-
* class RpgClientEngine {}
|
|
266
299
|
* ```
|
|
267
300
|
*
|
|
268
301
|
* [Guide: Create Sprite](/guide/create-sprite.html)
|
|
269
302
|
*
|
|
270
|
-
* @prop {Array<
|
|
303
|
+
* @prop {Array<Object>} [spritesheets]
|
|
271
304
|
* @memberof RpgClient
|
|
272
305
|
* */
|
|
273
306
|
spritesheets?: any[],
|
|
274
307
|
|
|
275
308
|
/**
|
|
276
|
-
*
|
|
309
|
+
* Resolver function for dynamically creating spritesheets
|
|
310
|
+
*
|
|
311
|
+
* This function is called when a spritesheet is requested but not found in the cache.
|
|
312
|
+
* It can be synchronous (returns directly) or asynchronous (returns a Promise).
|
|
313
|
+
* The resolved spritesheet is automatically cached for future use.
|
|
277
314
|
*
|
|
278
315
|
* ```ts
|
|
279
|
-
* import {
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
316
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
317
|
+
*
|
|
318
|
+
* defineModule<RpgClient>({
|
|
319
|
+
* spritesheetResolver: (id: string) => {
|
|
320
|
+
* // Synchronous resolver
|
|
321
|
+
* if (id === 'dynamic-sprite') {
|
|
322
|
+
* return {
|
|
323
|
+
* id: 'dynamic-sprite',
|
|
324
|
+
* image: 'path/to/image.png',
|
|
325
|
+
* framesWidth: 32,
|
|
326
|
+
* framesHeight: 32
|
|
327
|
+
* };
|
|
328
|
+
* }
|
|
329
|
+
* return undefined;
|
|
330
|
+
* }
|
|
331
|
+
* })
|
|
332
|
+
*
|
|
333
|
+
* // Or asynchronous resolver
|
|
334
|
+
* defineModule<RpgClient>({
|
|
335
|
+
* spritesheetResolver: async (id: string) => {
|
|
336
|
+
* const response = await fetch(`/api/spritesheets/${id}`);
|
|
337
|
+
* const data = await response.json();
|
|
338
|
+
* return data;
|
|
339
|
+
* }
|
|
340
|
+
* })
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* @prop {(id: string) => any | Promise<any>} [spritesheetResolver]
|
|
344
|
+
* @memberof RpgClient
|
|
345
|
+
* */
|
|
346
|
+
spritesheetResolver?: (id: string) => any | Promise<any>,
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Resolver function for dynamically loading sounds
|
|
350
|
+
*
|
|
351
|
+
* The resolver is called when a sound is requested but not found in the cache.
|
|
352
|
+
* It can be synchronous (returns directly) or asynchronous (returns a Promise).
|
|
353
|
+
* The resolved sound is automatically cached for future use.
|
|
354
|
+
*
|
|
355
|
+
* ```ts
|
|
356
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
357
|
+
*
|
|
358
|
+
* defineModule<RpgClient>({
|
|
359
|
+
* soundResolver: (id: string) => {
|
|
360
|
+
* if (id === 'dynamic-sound') {
|
|
361
|
+
* return { id: 'dynamic-sound', src: 'path/to/sound.mp3' };
|
|
362
|
+
* }
|
|
363
|
+
* return undefined;
|
|
364
|
+
* }
|
|
365
|
+
* })
|
|
366
|
+
* ```
|
|
367
|
+
*
|
|
368
|
+
* @prop {(id: string) => any | Promise<any>} [soundResolver]
|
|
369
|
+
* @memberof RpgClient
|
|
370
|
+
* */
|
|
371
|
+
soundResolver?: (id: string) => any | Promise<any>,
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Array containing the list of GUI components
|
|
375
|
+
*
|
|
376
|
+
* ```ts
|
|
377
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
378
|
+
* import InventoryComponent from './inventory.ce'
|
|
289
379
|
*
|
|
290
|
-
*
|
|
380
|
+
* defineModule<RpgClient>({
|
|
291
381
|
* gui: [
|
|
292
|
-
*
|
|
382
|
+
* {
|
|
383
|
+
* id: 'inventory',
|
|
384
|
+
* component: InventoryComponent,
|
|
385
|
+
* autoDisplay: true,
|
|
386
|
+
* dependencies: () => [playerSignal, inventorySignal]
|
|
387
|
+
* }
|
|
293
388
|
* ]
|
|
294
389
|
* })
|
|
295
|
-
* class RpgClientEngine {}
|
|
296
390
|
* ```
|
|
297
391
|
*
|
|
298
392
|
* [Guide: Create GUI](/guide/create-gui.html)
|
|
299
393
|
*
|
|
300
|
-
* @prop {Array<
|
|
394
|
+
* @prop {Array<GuiOptions>} [gui]
|
|
301
395
|
* @memberof RpgClient
|
|
302
396
|
* */
|
|
303
|
-
gui?:
|
|
397
|
+
gui?: ({
|
|
398
|
+
id: string,
|
|
399
|
+
component: ComponentFunction,
|
|
400
|
+
/**
|
|
401
|
+
* Auto display the GUI when added to the system
|
|
402
|
+
* @default false
|
|
403
|
+
*/
|
|
404
|
+
autoDisplay?: boolean,
|
|
405
|
+
/**
|
|
406
|
+
* Function that returns an array of Signal dependencies
|
|
407
|
+
* The GUI will only display when all dependencies are resolved (!= undefined)
|
|
408
|
+
*/
|
|
409
|
+
dependencies?: () => Signal[]
|
|
410
|
+
/**
|
|
411
|
+
* Attach the GUI to sprites instead of displaying globally
|
|
412
|
+
*
|
|
413
|
+
* When set to `true`, the GUI component will be rendered directly on each sprite
|
|
414
|
+
* in the game world, rather than being displayed as a fixed overlay on the screen.
|
|
415
|
+
* This is useful for tooltips, health bars, name tags, or any UI element that
|
|
416
|
+
* should follow a specific sprite.
|
|
417
|
+
*
|
|
418
|
+
* The GUI will be rendered in the `character.ce` component for each sprite.
|
|
419
|
+
* You can control the display state of attached GUIs from the server side using
|
|
420
|
+
* `player.showAttachedGui()` and `player.hideAttachedGui()` methods.
|
|
421
|
+
*
|
|
422
|
+
* @default false
|
|
423
|
+
* @example
|
|
424
|
+
* ```ts
|
|
425
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
426
|
+
* import TooltipComponent from './tooltip.ce'
|
|
427
|
+
*
|
|
428
|
+
* defineModule<RpgClient>({
|
|
429
|
+
* gui: [
|
|
430
|
+
* {
|
|
431
|
+
* id: "my-tooltip",
|
|
432
|
+
* component: TooltipComponent,
|
|
433
|
+
* attachToSprite: true
|
|
434
|
+
* }
|
|
435
|
+
* ]
|
|
436
|
+
* })
|
|
437
|
+
* ```
|
|
438
|
+
*
|
|
439
|
+
* On the server side, control the display:
|
|
440
|
+
* ```ts
|
|
441
|
+
* // Show the tooltip for this player
|
|
442
|
+
* player.showAttachedGui()
|
|
443
|
+
*
|
|
444
|
+
* // Hide the tooltip for this player
|
|
445
|
+
* player.hideAttachedGui()
|
|
446
|
+
*
|
|
447
|
+
* // Show tooltip for other players
|
|
448
|
+
* player.showAttachedGui([otherPlayer1, otherPlayer2])
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
attachToSprite?: boolean
|
|
452
|
+
} | any)[],
|
|
304
453
|
|
|
305
454
|
/**
|
|
306
455
|
* Array containing the list of sounds
|
|
307
|
-
*
|
|
456
|
+
* Each element can be:
|
|
457
|
+
* - A simple object containing sound definitions
|
|
458
|
+
* - A class decorated with @Sound
|
|
308
459
|
*
|
|
309
460
|
* ```ts
|
|
310
|
-
* import {
|
|
461
|
+
* import { defineModule, RpgClient, Sound } from '@rpgjs/client'
|
|
462
|
+
*
|
|
463
|
+
* // Using simple objects
|
|
464
|
+
* defineModule<RpgClient>({
|
|
465
|
+
* sounds: [
|
|
466
|
+
* {
|
|
467
|
+
* id: 'typewriter',
|
|
468
|
+
* src: 'typewriter.wav'
|
|
469
|
+
* },
|
|
470
|
+
* {
|
|
471
|
+
* id: 'cursor',
|
|
472
|
+
* src: 'cursor.wav'
|
|
473
|
+
* }
|
|
474
|
+
* ]
|
|
475
|
+
* })
|
|
311
476
|
*
|
|
477
|
+
* // Using @Sound decorator
|
|
312
478
|
* @Sound({
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
479
|
+
* id: 'town-music',
|
|
480
|
+
* sound: require('./sound/town.ogg'),
|
|
481
|
+
* loop: true,
|
|
482
|
+
* volume: 0.5
|
|
483
|
+
* })
|
|
484
|
+
* export class TownMusic {}
|
|
485
|
+
*
|
|
486
|
+
* defineModule<RpgClient>({
|
|
487
|
+
* sounds: [TownMusic]
|
|
488
|
+
* })
|
|
489
|
+
*
|
|
490
|
+
* // Multiple sounds in one class
|
|
491
|
+
* @Sound({
|
|
492
|
+
* sounds: {
|
|
493
|
+
* hero: require('./assets/hero.ogg'),
|
|
494
|
+
* monster: require('./assets/monster.ogg')
|
|
495
|
+
* },
|
|
496
|
+
* loop: true
|
|
316
497
|
* })
|
|
317
|
-
* class
|
|
498
|
+
* export class CharacterSounds {}
|
|
318
499
|
*
|
|
319
|
-
*
|
|
320
|
-
* sounds: [
|
|
500
|
+
* defineModule<RpgClient>({
|
|
501
|
+
* sounds: [CharacterSounds]
|
|
321
502
|
* })
|
|
322
|
-
* class RpgClientEngine {}
|
|
323
503
|
* ```
|
|
324
504
|
*
|
|
325
|
-
* @prop {Array<Class>} [sounds]
|
|
505
|
+
* @prop {Array<Object | Class>} [sounds]
|
|
326
506
|
* @memberof RpgClient
|
|
327
507
|
* */
|
|
328
|
-
sounds?:
|
|
508
|
+
sounds?: any[],
|
|
329
509
|
|
|
330
510
|
/**
|
|
331
511
|
* Give the `RpgSprite` class. A Sprite represents a player or an event
|
|
332
512
|
*
|
|
333
513
|
* ```ts
|
|
334
|
-
* import { RpgSprite, RpgSpriteHooks, RpgClient,
|
|
514
|
+
* import { RpgSprite, RpgSpriteHooks, RpgClient, defineModule } from '@rpgjs/client'
|
|
335
515
|
*
|
|
336
516
|
* export const sprite: RpgSpriteHooks = {
|
|
337
517
|
* onInit(sprite: RpgSprite) {}
|
|
338
518
|
* }
|
|
339
519
|
*
|
|
340
|
-
*
|
|
520
|
+
* defineModule<RpgClient>({
|
|
341
521
|
* sprite
|
|
342
522
|
* })
|
|
343
|
-
* class RpgClientEngine {}
|
|
344
523
|
* ```
|
|
345
524
|
*
|
|
346
525
|
* @prop {RpgSpriteHooks} [sprite]
|
|
@@ -352,19 +531,18 @@ export interface RpgClient {
|
|
|
352
531
|
* Reference the scenes of the game. Here you can put your own class that inherits RpgSceneMap
|
|
353
532
|
*
|
|
354
533
|
* ```ts
|
|
355
|
-
* import { RpgSceneMapHooks, RpgClient,
|
|
534
|
+
* import { RpgSceneMapHooks, RpgClient, defineModule } from '@rpgjs/client'
|
|
356
535
|
*
|
|
357
536
|
* export const sceneMap: RpgSceneMapHooks = {
|
|
358
537
|
*
|
|
359
538
|
* }
|
|
360
539
|
*
|
|
361
|
-
*
|
|
540
|
+
* defineModule<RpgClient>({
|
|
362
541
|
* scenes: {
|
|
363
542
|
* // If you put the RpgSceneMap scene, Thhe key is called mandatory `map`
|
|
364
543
|
* map: sceneMap
|
|
365
544
|
* }
|
|
366
545
|
* })
|
|
367
|
-
* class RpgClientEngine {}
|
|
368
546
|
* ```
|
|
369
547
|
*
|
|
370
548
|
* @prop { [sceneName: string]: RpgSceneMapHooks } [scenes]
|
|
@@ -374,8 +552,36 @@ export interface RpgClient {
|
|
|
374
552
|
map: RpgSceneMapHooks
|
|
375
553
|
}
|
|
376
554
|
|
|
377
|
-
|
|
555
|
+
sceneMap?: RpgSceneMapHooks
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Array containing the list of component animations
|
|
559
|
+
* Each element defines a temporary component to display for animations like hits, effects, etc.
|
|
560
|
+
*
|
|
561
|
+
* ```ts
|
|
562
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
563
|
+
* import HitComponent from './hit.ce'
|
|
564
|
+
* import ExplosionComponent from './explosion.ce'
|
|
565
|
+
*
|
|
566
|
+
* defineModule<RpgClient>({
|
|
567
|
+
* componentAnimations: [
|
|
568
|
+
* {
|
|
569
|
+
* id: 'hit',
|
|
570
|
+
* component: HitComponent
|
|
571
|
+
* },
|
|
572
|
+
* {
|
|
573
|
+
* id: 'explosion',
|
|
574
|
+
* component: ExplosionComponent
|
|
575
|
+
* }
|
|
576
|
+
* ]
|
|
577
|
+
* })
|
|
578
|
+
* ```
|
|
579
|
+
*
|
|
580
|
+
* @prop {Array<{id: string, component: ComponentFunction}>} [componentAnimations]
|
|
581
|
+
* @memberof RpgClient
|
|
582
|
+
* */
|
|
583
|
+
componentAnimations?: {
|
|
378
584
|
id: string,
|
|
379
|
-
component:
|
|
585
|
+
component: ComponentFunction
|
|
380
586
|
}[]
|
|
381
587
|
}
|