@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/dist/RpgClient.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { ComponentFunction, Signal } from 'canvasengine';
|
|
1
2
|
import { RpgClientEngine } from './RpgClientEngine';
|
|
2
|
-
import { Loader } from 'pixi.js';
|
|
3
|
-
|
|
4
|
-
type RpgComponent =
|
|
5
|
-
type SceneMap =
|
|
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,
|
|
195
|
+
* import { RpgClient, defineModule } from '@rpgjs/client'
|
|
167
196
|
*
|
|
168
|
-
*
|
|
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,
|
|
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
|
-
*
|
|
246
|
+
* defineModule<RpgClient>({
|
|
219
247
|
* engine
|
|
220
248
|
* })
|
|
221
|
-
* class RpgClientModule {}
|
|
222
249
|
* ```
|
|
223
250
|
*
|
|
224
251
|
* @prop {RpgClientEngineHooks} [engine]
|
|
@@ -227,99 +254,246 @@ export interface RpgClient {
|
|
|
227
254
|
engine?: RpgClientEngineHooks;
|
|
228
255
|
/**
|
|
229
256
|
* Array containing the list of spritesheets
|
|
230
|
-
*
|
|
257
|
+
* Each element is a simple object containing spritesheet definitions
|
|
231
258
|
*
|
|
232
259
|
* ```ts
|
|
233
|
-
* import {
|
|
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
|
-
*
|
|
262
|
+
* defineModule<RpgClient>({
|
|
243
263
|
* spritesheets: [
|
|
244
|
-
*
|
|
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<
|
|
282
|
+
* @prop {Array<Object>} [spritesheets]
|
|
253
283
|
* @memberof RpgClient
|
|
254
284
|
* */
|
|
255
285
|
spritesheets?: any[];
|
|
256
286
|
/**
|
|
257
|
-
*
|
|
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 {
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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<
|
|
370
|
+
* @prop {Array<GuiOptions>} [gui]
|
|
282
371
|
* @memberof RpgClient
|
|
283
372
|
* */
|
|
284
|
-
gui?:
|
|
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
|
+
/**
|
|
387
|
+
* Attach the GUI to sprites instead of displaying globally
|
|
388
|
+
*
|
|
389
|
+
* When set to `true`, the GUI component will be rendered directly on each sprite
|
|
390
|
+
* in the game world, rather than being displayed as a fixed overlay on the screen.
|
|
391
|
+
* This is useful for tooltips, health bars, name tags, or any UI element that
|
|
392
|
+
* should follow a specific sprite.
|
|
393
|
+
*
|
|
394
|
+
* The GUI will be rendered in the `character.ce` component for each sprite.
|
|
395
|
+
* You can control the display state of attached GUIs from the server side using
|
|
396
|
+
* `player.showAttachedGui()` and `player.hideAttachedGui()` methods.
|
|
397
|
+
*
|
|
398
|
+
* @default false
|
|
399
|
+
* @example
|
|
400
|
+
* ```ts
|
|
401
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
402
|
+
* import TooltipComponent from './tooltip.ce'
|
|
403
|
+
*
|
|
404
|
+
* defineModule<RpgClient>({
|
|
405
|
+
* gui: [
|
|
406
|
+
* {
|
|
407
|
+
* id: "my-tooltip",
|
|
408
|
+
* component: TooltipComponent,
|
|
409
|
+
* attachToSprite: true
|
|
410
|
+
* }
|
|
411
|
+
* ]
|
|
412
|
+
* })
|
|
413
|
+
* ```
|
|
414
|
+
*
|
|
415
|
+
* On the server side, control the display:
|
|
416
|
+
* ```ts
|
|
417
|
+
* // Show the tooltip for this player
|
|
418
|
+
* player.showAttachedGui()
|
|
419
|
+
*
|
|
420
|
+
* // Hide the tooltip for this player
|
|
421
|
+
* player.hideAttachedGui()
|
|
422
|
+
*
|
|
423
|
+
* // Show tooltip for other players
|
|
424
|
+
* player.showAttachedGui([otherPlayer1, otherPlayer2])
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
attachToSprite?: boolean;
|
|
428
|
+
} | any)[];
|
|
285
429
|
/**
|
|
286
430
|
* Array containing the list of sounds
|
|
287
|
-
*
|
|
431
|
+
* Each element can be:
|
|
432
|
+
* - A simple object containing sound definitions
|
|
433
|
+
* - A class decorated with @Sound
|
|
288
434
|
*
|
|
289
435
|
* ```ts
|
|
290
|
-
* import {
|
|
436
|
+
* import { defineModule, RpgClient, Sound } from '@rpgjs/client'
|
|
437
|
+
*
|
|
438
|
+
* // Using simple objects
|
|
439
|
+
* defineModule<RpgClient>({
|
|
440
|
+
* sounds: [
|
|
441
|
+
* {
|
|
442
|
+
* id: 'typewriter',
|
|
443
|
+
* src: 'typewriter.wav'
|
|
444
|
+
* },
|
|
445
|
+
* {
|
|
446
|
+
* id: 'cursor',
|
|
447
|
+
* src: 'cursor.wav'
|
|
448
|
+
* }
|
|
449
|
+
* ]
|
|
450
|
+
* })
|
|
291
451
|
*
|
|
452
|
+
* // Using @Sound decorator
|
|
292
453
|
* @Sound({
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
454
|
+
* id: 'town-music',
|
|
455
|
+
* sound: require('./sound/town.ogg'),
|
|
456
|
+
* loop: true,
|
|
457
|
+
* volume: 0.5
|
|
458
|
+
* })
|
|
459
|
+
* export class TownMusic {}
|
|
460
|
+
*
|
|
461
|
+
* defineModule<RpgClient>({
|
|
462
|
+
* sounds: [TownMusic]
|
|
463
|
+
* })
|
|
464
|
+
*
|
|
465
|
+
* // Multiple sounds in one class
|
|
466
|
+
* @Sound({
|
|
467
|
+
* sounds: {
|
|
468
|
+
* hero: require('./assets/hero.ogg'),
|
|
469
|
+
* monster: require('./assets/monster.ogg')
|
|
470
|
+
* },
|
|
471
|
+
* loop: true
|
|
296
472
|
* })
|
|
297
|
-
* class
|
|
473
|
+
* export class CharacterSounds {}
|
|
298
474
|
*
|
|
299
|
-
*
|
|
300
|
-
* sounds: [
|
|
475
|
+
* defineModule<RpgClient>({
|
|
476
|
+
* sounds: [CharacterSounds]
|
|
301
477
|
* })
|
|
302
|
-
* class RpgClientEngine {}
|
|
303
478
|
* ```
|
|
304
479
|
*
|
|
305
|
-
* @prop {Array<Class>} [sounds]
|
|
480
|
+
* @prop {Array<Object | Class>} [sounds]
|
|
306
481
|
* @memberof RpgClient
|
|
307
482
|
* */
|
|
308
|
-
sounds?:
|
|
483
|
+
sounds?: any[];
|
|
309
484
|
/**
|
|
310
485
|
* Give the `RpgSprite` class. A Sprite represents a player or an event
|
|
311
486
|
*
|
|
312
487
|
* ```ts
|
|
313
|
-
* import { RpgSprite, RpgSpriteHooks, RpgClient,
|
|
488
|
+
* import { RpgSprite, RpgSpriteHooks, RpgClient, defineModule } from '@rpgjs/client'
|
|
314
489
|
*
|
|
315
490
|
* export const sprite: RpgSpriteHooks = {
|
|
316
491
|
* onInit(sprite: RpgSprite) {}
|
|
317
492
|
* }
|
|
318
493
|
*
|
|
319
|
-
*
|
|
494
|
+
* defineModule<RpgClient>({
|
|
320
495
|
* sprite
|
|
321
496
|
* })
|
|
322
|
-
* class RpgClientEngine {}
|
|
323
497
|
* ```
|
|
324
498
|
*
|
|
325
499
|
* @prop {RpgSpriteHooks} [sprite]
|
|
@@ -330,19 +504,18 @@ export interface RpgClient {
|
|
|
330
504
|
* Reference the scenes of the game. Here you can put your own class that inherits RpgSceneMap
|
|
331
505
|
*
|
|
332
506
|
* ```ts
|
|
333
|
-
* import { RpgSceneMapHooks, RpgClient,
|
|
507
|
+
* import { RpgSceneMapHooks, RpgClient, defineModule } from '@rpgjs/client'
|
|
334
508
|
*
|
|
335
509
|
* export const sceneMap: RpgSceneMapHooks = {
|
|
336
510
|
*
|
|
337
511
|
* }
|
|
338
512
|
*
|
|
339
|
-
*
|
|
513
|
+
* defineModule<RpgClient>({
|
|
340
514
|
* scenes: {
|
|
341
515
|
* // If you put the RpgSceneMap scene, Thhe key is called mandatory `map`
|
|
342
516
|
* map: sceneMap
|
|
343
517
|
* }
|
|
344
518
|
* })
|
|
345
|
-
* class RpgClientEngine {}
|
|
346
519
|
* ```
|
|
347
520
|
*
|
|
348
521
|
* @prop { [sceneName: string]: RpgSceneMapHooks } [scenes]
|
|
@@ -351,9 +524,36 @@ export interface RpgClient {
|
|
|
351
524
|
scenes?: {
|
|
352
525
|
map: RpgSceneMapHooks;
|
|
353
526
|
};
|
|
354
|
-
|
|
527
|
+
sceneMap?: RpgSceneMapHooks;
|
|
528
|
+
/**
|
|
529
|
+
* Array containing the list of component animations
|
|
530
|
+
* Each element defines a temporary component to display for animations like hits, effects, etc.
|
|
531
|
+
*
|
|
532
|
+
* ```ts
|
|
533
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
534
|
+
* import HitComponent from './hit.ce'
|
|
535
|
+
* import ExplosionComponent from './explosion.ce'
|
|
536
|
+
*
|
|
537
|
+
* defineModule<RpgClient>({
|
|
538
|
+
* componentAnimations: [
|
|
539
|
+
* {
|
|
540
|
+
* id: 'hit',
|
|
541
|
+
* component: HitComponent
|
|
542
|
+
* },
|
|
543
|
+
* {
|
|
544
|
+
* id: 'explosion',
|
|
545
|
+
* component: ExplosionComponent
|
|
546
|
+
* }
|
|
547
|
+
* ]
|
|
548
|
+
* })
|
|
549
|
+
* ```
|
|
550
|
+
*
|
|
551
|
+
* @prop {Array<{id: string, component: ComponentFunction}>} [componentAnimations]
|
|
552
|
+
* @memberof RpgClient
|
|
553
|
+
* */
|
|
554
|
+
componentAnimations?: {
|
|
355
555
|
id: string;
|
|
356
|
-
component:
|
|
556
|
+
component: ComponentFunction;
|
|
357
557
|
}[];
|
|
358
558
|
}
|
|
359
559
|
export {};
|