@rpgjs/server 5.0.0-alpha.7 → 5.0.0-alpha.9
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/Player/ComponentManager.d.ts +34 -4
- package/dist/Player/GuiManager.d.ts +149 -4
- package/dist/RpgServer.d.ts +224 -1
- package/dist/index.js +4 -158
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Player/ComponentManager.ts +18 -16
- package/src/Player/GuiManager.ts +163 -139
- package/src/RpgServer.ts +232 -1
- package/src/core/context.ts +1 -0
- package/dist/Player/Event.d.ts +0 -0
- package/src/Player/Event.ts +0 -0
|
@@ -22,9 +22,39 @@ import { PlayerCtor } from '@rpgjs/common';
|
|
|
22
22
|
* player.setGraphic(["hero_idle", "hero_walk"]);
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
export declare function WithComponentManager<TBase extends PlayerCtor>(Base: TBase): TBase;
|
|
25
|
+
export declare function WithComponentManager<TBase extends PlayerCtor>(Base: TBase): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & IComponentManager;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
* Interface for component management capabilities
|
|
28
|
+
* Defines the method signature that will be available on the player
|
|
29
29
|
*/
|
|
30
|
-
export
|
|
30
|
+
export interface IComponentManager {
|
|
31
|
+
/**
|
|
32
|
+
* Set the graphic(s) for this player
|
|
33
|
+
*
|
|
34
|
+
* Allows setting either a single graphic or multiple graphics for the player.
|
|
35
|
+
* When multiple graphics are provided, they are used for animation sequences.
|
|
36
|
+
* The graphics system provides flexible visual representation that can be
|
|
37
|
+
* dynamically changed during gameplay for different states, equipment, or animations.
|
|
38
|
+
*
|
|
39
|
+
* @param graphic - Single graphic name or array of graphic names for animation sequences
|
|
40
|
+
* @returns void
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* // Set a single graphic for static representation
|
|
45
|
+
* player.setGraphic("hero");
|
|
46
|
+
*
|
|
47
|
+
* // Set multiple graphics for animation sequences
|
|
48
|
+
* player.setGraphic(["hero_idle", "hero_walk", "hero_run"]);
|
|
49
|
+
*
|
|
50
|
+
* // Dynamic graphic changes based on equipment
|
|
51
|
+
* if (player.hasArmor('platemail')) {
|
|
52
|
+
* player.setGraphic("hero_armored");
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* // Animation sequences for different actions
|
|
56
|
+
* player.setGraphic(["mage_cast_1", "mage_cast_2", "mage_cast_3"]);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
setGraphic(graphic: string | string[]): void;
|
|
60
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { RpgPlayer } from './Player';
|
|
2
|
+
import { Gui } from '../Gui';
|
|
3
|
+
import { DialogOptions, Choice } from '../Gui/DialogGui';
|
|
1
4
|
import { PlayerCtor } from '@rpgjs/common';
|
|
2
5
|
/**
|
|
3
6
|
* GUI Manager Mixin
|
|
@@ -23,9 +26,151 @@ import { PlayerCtor } from '@rpgjs/common';
|
|
|
23
26
|
* player.callMainMenu();
|
|
24
27
|
* ```
|
|
25
28
|
*/
|
|
26
|
-
export declare function WithGuiManager<TBase extends PlayerCtor>(Base: TBase): TBase;
|
|
29
|
+
export declare function WithGuiManager<TBase extends PlayerCtor>(Base: TBase): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & IGuiManager;
|
|
27
30
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
31
|
+
* Interface for GUI management capabilities
|
|
32
|
+
* Defines the methods that will be available on the player
|
|
30
33
|
*/
|
|
31
|
-
export
|
|
34
|
+
export interface IGuiManager {
|
|
35
|
+
/**
|
|
36
|
+
* Show a text. This is a graphical interface already built. Opens the GUI named `rpg-dialog`
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* player.showText('Hello World')
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* The method returns a promise. It is resolved when the dialog box is closed.
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* await player.showText('Hello World')
|
|
46
|
+
* // dialog box is closed, then ...
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* **Option: position**
|
|
50
|
+
*
|
|
51
|
+
* You can define how the dialog box is displayed:
|
|
52
|
+
* - top
|
|
53
|
+
* - middle
|
|
54
|
+
* - bottom
|
|
55
|
+
*
|
|
56
|
+
* (bottom by default)
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* player.showText('Hello World', {
|
|
60
|
+
* position: 'top'
|
|
61
|
+
* })
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* **Option: fullWidth**
|
|
65
|
+
*
|
|
66
|
+
* `boolean` (true by default)
|
|
67
|
+
*
|
|
68
|
+
* Indicate that the dialog box will take the full width of the screen.
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* player.showText('Hello World', {
|
|
72
|
+
* fullWidth: true
|
|
73
|
+
* })
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* **Option: autoClose**
|
|
77
|
+
*
|
|
78
|
+
* `boolean` (false by default)
|
|
79
|
+
*
|
|
80
|
+
* If false, the user will have to press Enter to close the dialog box.
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* player.showText('Hello World', {
|
|
84
|
+
* autoClose: true
|
|
85
|
+
* })
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* **Option: typewriterEffect**
|
|
89
|
+
*
|
|
90
|
+
* `boolean` (true by default)
|
|
91
|
+
*
|
|
92
|
+
* Performs a typewriter effect
|
|
93
|
+
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* player.showText('Hello World', {
|
|
96
|
+
* typewriterEffect: false
|
|
97
|
+
* })
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* **Option: talkWith**
|
|
101
|
+
*
|
|
102
|
+
* `RpgPlayer` (nothing by default)
|
|
103
|
+
*
|
|
104
|
+
* If you specify the event or another player, the other player will stop his or her movement and look in the player's direction.
|
|
105
|
+
*
|
|
106
|
+
* ```ts
|
|
107
|
+
* // Code in an event
|
|
108
|
+
* player.showText('Hello World', {
|
|
109
|
+
* talkWith: this
|
|
110
|
+
* })
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @title Show Text
|
|
114
|
+
* @method player.showText(text,options)
|
|
115
|
+
* @param {string} text
|
|
116
|
+
* @param {object} [options] the different options, see usage below
|
|
117
|
+
* @returns {Promise}
|
|
118
|
+
* @memberof GuiManager
|
|
119
|
+
*/
|
|
120
|
+
showText(msg: string, options?: DialogOptions): Promise<any>;
|
|
121
|
+
/**
|
|
122
|
+
* Shows a dialog box with a choice. Opens the GUI named `rpg-dialog`
|
|
123
|
+
*
|
|
124
|
+
* ```ts
|
|
125
|
+
* const choice = await player.showChoices('What color do you prefer?', [
|
|
126
|
+
* { text: 'Black', value: 'black' },
|
|
127
|
+
* { text: 'Rather the blue', value: 'blue' },
|
|
128
|
+
* { text: 'I don\'t have a preference!', value: 'none' }
|
|
129
|
+
* ])
|
|
130
|
+
*
|
|
131
|
+
* // If the player selects the first
|
|
132
|
+
* console.log(choice) // { text: 'Black', value: 'black' }
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @title Show Choices
|
|
136
|
+
* @method player.showChoices(text,choices)
|
|
137
|
+
* @param {string} text
|
|
138
|
+
* @param {Array<{ text: string, value: any }>} choices
|
|
139
|
+
* @param {object} [options] Same options as the openDialog method
|
|
140
|
+
* @returns {Promise<Choice | null>}
|
|
141
|
+
* @memberof GuiManager
|
|
142
|
+
*/
|
|
143
|
+
showChoices(msg: string, choices: Choice[], options?: DialogOptions): Promise<Choice | null>;
|
|
144
|
+
/**
|
|
145
|
+
* Displays a notification . Opens the GUI named `rpg-notification`
|
|
146
|
+
*
|
|
147
|
+
* @title Displays a notification
|
|
148
|
+
* @method player.showNotification()
|
|
149
|
+
* @param {string} message - The message to display in the notification
|
|
150
|
+
* @param {object} options - An object containing options for the notification
|
|
151
|
+
* @param {number} options.time - The time to display the notification for (in ms). Default: 2000ms
|
|
152
|
+
* @param {string} options.icon - The icon to display in the notification. Put the identifier of the spritesheet (defined on the client side)
|
|
153
|
+
* @param {string} options.sound - The sound to play when the notification is shown. Set the sound ID (defined on the client side)
|
|
154
|
+
* @returns {void}
|
|
155
|
+
* @memberof GuiManager
|
|
156
|
+
*/
|
|
157
|
+
showNotification(message: string, options?: {
|
|
158
|
+
time?: number;
|
|
159
|
+
icon?: string;
|
|
160
|
+
sound?: string;
|
|
161
|
+
}): Promise<any>;
|
|
162
|
+
/**
|
|
163
|
+
* Calls main menu. Opens the GUI named `rpg-main-menu`
|
|
164
|
+
*
|
|
165
|
+
* @title Call Main Menu
|
|
166
|
+
* @method player.callMainMenu()
|
|
167
|
+
* @returns {void}
|
|
168
|
+
* @memberof GuiManager
|
|
169
|
+
*/
|
|
170
|
+
callMainMenu(): void;
|
|
171
|
+
callShop(items: any[]): void;
|
|
172
|
+
gui(guiId: string): Gui;
|
|
173
|
+
removeGui(guiId: string, data?: any): void;
|
|
174
|
+
showAttachedGui(players?: RpgPlayer[] | RpgPlayer): void;
|
|
175
|
+
hideAttachedGui(players?: RpgPlayer[] | RpgPlayer): void;
|
|
176
|
+
}
|
package/dist/RpgServer.d.ts
CHANGED
|
@@ -210,19 +210,242 @@ export interface RpgPlayerHooks {
|
|
|
210
210
|
*/
|
|
211
211
|
canChangeMap?: (player: RpgPlayer, nextMap: RpgClassMap<RpgMap>) => boolean | Promise<boolean>;
|
|
212
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Event hooks interface for handling various event lifecycle methods
|
|
215
|
+
*
|
|
216
|
+
* @interface RpgEventHooks
|
|
217
|
+
* @since 4.0.0
|
|
218
|
+
*/
|
|
213
219
|
export interface RpgEventHooks {
|
|
220
|
+
/**
|
|
221
|
+
* Called as soon as the event is created on the map
|
|
222
|
+
*
|
|
223
|
+
* @param {RpgEvent} event - The event instance being initialized
|
|
224
|
+
* @returns {any}
|
|
225
|
+
* @memberof RpgEventHooks
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* const eventHooks: RpgEventHooks = {
|
|
229
|
+
* onInit(event) {
|
|
230
|
+
* console.log(`Event ${event.name} initialized`)
|
|
231
|
+
* event.graphic('default-sprite')
|
|
232
|
+
* }
|
|
233
|
+
* }
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
214
236
|
onInit?: (event: RpgEvent) => any;
|
|
237
|
+
/**
|
|
238
|
+
* Called when the event collides with a player and the player presses the action key
|
|
239
|
+
*
|
|
240
|
+
* @param {RpgEvent} event - The event being interacted with
|
|
241
|
+
* @param {RpgPlayer} player - The player performing the action
|
|
242
|
+
* @returns {any}
|
|
243
|
+
* @memberof RpgEventHooks
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* const eventHooks: RpgEventHooks = {
|
|
247
|
+
* onAction(event, player) {
|
|
248
|
+
* player.showText('You activated the chest!')
|
|
249
|
+
* player.addItem('POTION', 1)
|
|
250
|
+
* }
|
|
251
|
+
* }
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
215
254
|
onAction?: (event: RpgEvent, player: RpgPlayer) => any;
|
|
255
|
+
/**
|
|
256
|
+
* Called before an event object is created and added to the map
|
|
257
|
+
* Allows modification of event properties before instantiation
|
|
258
|
+
*
|
|
259
|
+
* @param {any} object - The event object data before creation
|
|
260
|
+
* @param {RpgMap} map - The map where the event will be created
|
|
261
|
+
* @returns {any}
|
|
262
|
+
* @memberof RpgEventHooks
|
|
263
|
+
* @example
|
|
264
|
+
* ```ts
|
|
265
|
+
* const eventHooks: RpgEventHooks = {
|
|
266
|
+
* onBeforeCreated(object, map) {
|
|
267
|
+
* // Modify event properties based on map conditions
|
|
268
|
+
* if (map.id === 'dungeon') {
|
|
269
|
+
* object.graphic = 'monster-sprite'
|
|
270
|
+
* }
|
|
271
|
+
* }
|
|
272
|
+
* }
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
216
275
|
onBeforeCreated?: (object: any, map: RpgMap) => any;
|
|
276
|
+
/**
|
|
277
|
+
* Called when a player or another event enters a shape attached to this event
|
|
278
|
+
*
|
|
279
|
+
* @param {RpgEvent} event - The event with the attached shape
|
|
280
|
+
* @param {RpgPlayer} player - The player entering the shape
|
|
281
|
+
* @param {RpgShape} shape - The shape being entered
|
|
282
|
+
* @returns {any}
|
|
283
|
+
* @since 4.1.0
|
|
284
|
+
* @memberof RpgEventHooks
|
|
285
|
+
* @example
|
|
286
|
+
* ```ts
|
|
287
|
+
* const eventHooks: RpgEventHooks = {
|
|
288
|
+
* onDetectInShape(event, player, shape) {
|
|
289
|
+
* console.log(`Player ${player.name} entered detection zone`)
|
|
290
|
+
* player.showText('You are being watched...')
|
|
291
|
+
* }
|
|
292
|
+
* }
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
217
295
|
onDetectInShape?: (event: RpgEvent, player: RpgPlayer, shape: RpgShape) => any;
|
|
296
|
+
/**
|
|
297
|
+
* Called when a player or another event leaves a shape attached to this event
|
|
298
|
+
*
|
|
299
|
+
* @param {RpgEvent} event - The event with the attached shape
|
|
300
|
+
* @param {RpgPlayer} player - The player leaving the shape
|
|
301
|
+
* @param {RpgShape} shape - The shape being left
|
|
302
|
+
* @returns {any}
|
|
303
|
+
* @since 4.1.0
|
|
304
|
+
* @memberof RpgEventHooks
|
|
305
|
+
* @example
|
|
306
|
+
* ```ts
|
|
307
|
+
* const eventHooks: RpgEventHooks = {
|
|
308
|
+
* onDetectOutShape(event, player, shape) {
|
|
309
|
+
* console.log(`Player ${player.name} left detection zone`)
|
|
310
|
+
* player.showText('You escaped the watch...')
|
|
311
|
+
* }
|
|
312
|
+
* }
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
218
315
|
onDetectOutShape?: (event: RpgEvent, player: RpgPlayer, shape: RpgShape) => any;
|
|
316
|
+
/**
|
|
317
|
+
* Called when the event enters a shape on the map
|
|
318
|
+
*
|
|
319
|
+
* @param {RpgEvent} event - The event entering the shape
|
|
320
|
+
* @param {RpgShape} shape - The shape being entered
|
|
321
|
+
* @returns {any}
|
|
322
|
+
* @memberof RpgEventHooks
|
|
323
|
+
* @example
|
|
324
|
+
* ```ts
|
|
325
|
+
* const eventHooks: RpgEventHooks = {
|
|
326
|
+
* onInShape(event, shape) {
|
|
327
|
+
* console.log(`Event entered shape: ${shape.id}`)
|
|
328
|
+
* event.speed = 1 // Slow down in this area
|
|
329
|
+
* }
|
|
330
|
+
* }
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
219
333
|
onInShape?: (event: RpgEvent, shape: RpgShape) => any;
|
|
334
|
+
/**
|
|
335
|
+
* Called when the event leaves a shape on the map
|
|
336
|
+
*
|
|
337
|
+
* @param {RpgEvent} event - The event leaving the shape
|
|
338
|
+
* @param {RpgShape} shape - The shape being left
|
|
339
|
+
* @returns {any}
|
|
340
|
+
* @memberof RpgEventHooks
|
|
341
|
+
* @example
|
|
342
|
+
* ```ts
|
|
343
|
+
* const eventHooks: RpgEventHooks = {
|
|
344
|
+
* onOutShape(event, shape) {
|
|
345
|
+
* console.log(`Event left shape: ${shape.id}`)
|
|
346
|
+
* event.speed = 3 // Resume normal speed
|
|
347
|
+
* }
|
|
348
|
+
* }
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
220
351
|
onOutShape?: (event: RpgEvent, shape: RpgShape) => any;
|
|
352
|
+
/**
|
|
353
|
+
* Called when the event collides with a player (without requiring action key press)
|
|
354
|
+
*
|
|
355
|
+
* @param {RpgEvent} event - The event touching the player
|
|
356
|
+
* @param {RpgPlayer} player - The player being touched
|
|
357
|
+
* @returns {any}
|
|
358
|
+
* @memberof RpgEventHooks
|
|
359
|
+
* @example
|
|
360
|
+
* ```ts
|
|
361
|
+
* const eventHooks: RpgEventHooks = {
|
|
362
|
+
* onPlayerTouch(event, player) {
|
|
363
|
+
* player.hp -= 10 // Damage on touch
|
|
364
|
+
* player.showText('Ouch! You touched a spike!')
|
|
365
|
+
* }
|
|
366
|
+
* }
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
221
369
|
onPlayerTouch?: (event: RpgEvent, player: RpgPlayer) => any;
|
|
370
|
+
/**
|
|
371
|
+
* Called whenever any event on the map (including itself) is executed or changes state
|
|
372
|
+
* Useful for creating reactive events that respond to map state changes
|
|
373
|
+
*
|
|
374
|
+
* @param {RpgEvent} event - The event listening for changes
|
|
375
|
+
* @param {RpgPlayer} player - The player involved in the change
|
|
376
|
+
* @returns {any}
|
|
377
|
+
* @memberof RpgEventHooks
|
|
378
|
+
* @example
|
|
379
|
+
* ```ts
|
|
380
|
+
* const eventHooks: RpgEventHooks = {
|
|
381
|
+
* onChanges(event, player) {
|
|
382
|
+
* // Change chest graphic based on game state
|
|
383
|
+
* if (player.getVariable('BATTLE_END')) {
|
|
384
|
+
* event.graphic('chest-open')
|
|
385
|
+
* } else {
|
|
386
|
+
* event.graphic('chest-close')
|
|
387
|
+
* }
|
|
388
|
+
* }
|
|
389
|
+
* }
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
222
392
|
onChanges?: (event: RpgEvent, player: RpgPlayer) => any;
|
|
223
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Map hooks interface for handling map lifecycle events
|
|
396
|
+
*
|
|
397
|
+
* @interface RpgMapHooks
|
|
398
|
+
* @since 4.0.0
|
|
399
|
+
*/
|
|
224
400
|
export interface RpgMapHooks {
|
|
225
|
-
|
|
401
|
+
/**
|
|
402
|
+
* Called before a map is updated with new data
|
|
403
|
+
* Allows modification of map data before the update is applied
|
|
404
|
+
*
|
|
405
|
+
* The `mapData` parameter contains the loaded map data (retrieved from request body)
|
|
406
|
+
* You can modify the map before the update is processed
|
|
407
|
+
*
|
|
408
|
+
* @template T - Type of the incoming map data
|
|
409
|
+
* @template U - Type of the map instance (defaults to RpgMap)
|
|
410
|
+
* @param {T} mapData - The map data loaded from external source (e.g., request body)
|
|
411
|
+
* @param {U} map - The current map instance being updated
|
|
412
|
+
* @returns {U | Promise<U>} The modified map instance or a promise resolving to it
|
|
413
|
+
* @memberof RpgMapHooks
|
|
414
|
+
* @example
|
|
415
|
+
* ```ts
|
|
416
|
+
* const mapHooks: RpgMapHooks = {
|
|
417
|
+
* onBeforeUpdate(mapData, map) {
|
|
418
|
+
* // Modify map properties based on incoming data
|
|
419
|
+
* if (mapData.weather === 'rain') {
|
|
420
|
+
* map.setWeatherEffect('rain')
|
|
421
|
+
* }
|
|
422
|
+
*
|
|
423
|
+
* // Add custom properties from external data
|
|
424
|
+
* map.customProperty = mapData.customValue
|
|
425
|
+
*
|
|
426
|
+
* return map
|
|
427
|
+
* }
|
|
428
|
+
* }
|
|
429
|
+
* ```
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```ts
|
|
433
|
+
* // Async example with database operations
|
|
434
|
+
* const mapHooks: RpgMapHooks = {
|
|
435
|
+
* async onBeforeUpdate(mapData, map) {
|
|
436
|
+
* // Load additional data from database
|
|
437
|
+
* const additionalData = await database.getMapExtras(map.id)
|
|
438
|
+
*
|
|
439
|
+
* // Apply modifications
|
|
440
|
+
* map.events = [...map.events, ...additionalData.events]
|
|
441
|
+
* map.npcs = additionalData.npcs
|
|
442
|
+
*
|
|
443
|
+
* return map
|
|
444
|
+
* }
|
|
445
|
+
* }
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
onBeforeUpdate<T, U = RpgMap>(mapData: T, map: U): U | Promise<U>;
|
|
226
449
|
}
|
|
227
450
|
export interface RpgServer {
|
|
228
451
|
/**
|
package/dist/index.js
CHANGED
|
@@ -25651,34 +25651,6 @@ var PrebuiltGui = /* @__PURE__ */ ((PrebuiltGui2) => {
|
|
|
25651
25651
|
|
|
25652
25652
|
function WithComponentManager(Base) {
|
|
25653
25653
|
return class extends Base {
|
|
25654
|
-
/**
|
|
25655
|
-
* Set the graphic(s) for this player
|
|
25656
|
-
*
|
|
25657
|
-
* Allows setting either a single graphic or multiple graphics for the player.
|
|
25658
|
-
* When multiple graphics are provided, they are used for animation sequences.
|
|
25659
|
-
* The graphics system provides flexible visual representation that can be
|
|
25660
|
-
* dynamically changed during gameplay for different states, equipment, or animations.
|
|
25661
|
-
*
|
|
25662
|
-
* @param graphic - Single graphic name or array of graphic names for animation sequences
|
|
25663
|
-
* @returns void
|
|
25664
|
-
*
|
|
25665
|
-
* @example
|
|
25666
|
-
* ```ts
|
|
25667
|
-
* // Set a single graphic for static representation
|
|
25668
|
-
* player.setGraphic("hero");
|
|
25669
|
-
*
|
|
25670
|
-
* // Set multiple graphics for animation sequences
|
|
25671
|
-
* player.setGraphic(["hero_idle", "hero_walk", "hero_run"]);
|
|
25672
|
-
*
|
|
25673
|
-
* // Dynamic graphic changes based on equipment
|
|
25674
|
-
* if (player.hasArmor('platemail')) {
|
|
25675
|
-
* player.setGraphic("hero_armored");
|
|
25676
|
-
* }
|
|
25677
|
-
*
|
|
25678
|
-
* // Animation sequences for different actions
|
|
25679
|
-
* player.setGraphic(["mage_cast_1", "mage_cast_2", "mage_cast_3"]);
|
|
25680
|
-
* ```
|
|
25681
|
-
*/
|
|
25682
25654
|
setGraphic(graphic) {
|
|
25683
25655
|
if (Array.isArray(graphic)) {
|
|
25684
25656
|
this.graphics.set(graphic);
|
|
@@ -26990,123 +26962,16 @@ class NotificationGui extends Gui {
|
|
|
26990
26962
|
}
|
|
26991
26963
|
|
|
26992
26964
|
function WithGuiManager(Base) {
|
|
26993
|
-
|
|
26965
|
+
class GuiManagerMixin extends Base {
|
|
26994
26966
|
constructor() {
|
|
26995
26967
|
super(...arguments);
|
|
26996
26968
|
this._gui = {};
|
|
26997
26969
|
}
|
|
26998
|
-
/**
|
|
26999
|
-
* Show a text. This is a graphical interface already built. Opens the GUI named `rpg-dialog`
|
|
27000
|
-
*
|
|
27001
|
-
* ```ts
|
|
27002
|
-
* player.showText('Hello World')
|
|
27003
|
-
* ```
|
|
27004
|
-
*
|
|
27005
|
-
* The method returns a promise. It is resolved when the dialog box is closed.
|
|
27006
|
-
*
|
|
27007
|
-
* ```ts
|
|
27008
|
-
* await player.showText('Hello World')
|
|
27009
|
-
* // dialog box is closed, then ...
|
|
27010
|
-
* ```
|
|
27011
|
-
*
|
|
27012
|
-
* **Option: position**
|
|
27013
|
-
*
|
|
27014
|
-
* You can define how the dialog box is displayed:
|
|
27015
|
-
* - top
|
|
27016
|
-
* - middle
|
|
27017
|
-
* - bottom
|
|
27018
|
-
*
|
|
27019
|
-
* (bottom by default)
|
|
27020
|
-
*
|
|
27021
|
-
* ```ts
|
|
27022
|
-
* player.showText('Hello World', {
|
|
27023
|
-
* position: 'top'
|
|
27024
|
-
* })
|
|
27025
|
-
* ```
|
|
27026
|
-
*
|
|
27027
|
-
* **Option: fullWidth**
|
|
27028
|
-
*
|
|
27029
|
-
* `boolean` (true by default)
|
|
27030
|
-
*
|
|
27031
|
-
* Indicate that the dialog box will take the full width of the screen.
|
|
27032
|
-
*
|
|
27033
|
-
* ```ts
|
|
27034
|
-
* player.showText('Hello World', {
|
|
27035
|
-
* fullWidth: true
|
|
27036
|
-
* })
|
|
27037
|
-
* ```
|
|
27038
|
-
*
|
|
27039
|
-
* **Option: autoClose**
|
|
27040
|
-
*
|
|
27041
|
-
* `boolean` (false by default)
|
|
27042
|
-
*
|
|
27043
|
-
* If false, the user will have to press Enter to close the dialog box.
|
|
27044
|
-
*
|
|
27045
|
-
* ```ts
|
|
27046
|
-
* player.showText('Hello World', {
|
|
27047
|
-
* autoClose: true
|
|
27048
|
-
* })
|
|
27049
|
-
* ```
|
|
27050
|
-
*
|
|
27051
|
-
* **Option: typewriterEffect**
|
|
27052
|
-
*
|
|
27053
|
-
* `boolean` (true by default)
|
|
27054
|
-
*
|
|
27055
|
-
* Performs a typewriter effect
|
|
27056
|
-
*
|
|
27057
|
-
* ```ts
|
|
27058
|
-
* player.showText('Hello World', {
|
|
27059
|
-
* typewriterEffect: false
|
|
27060
|
-
* })
|
|
27061
|
-
* ```
|
|
27062
|
-
*
|
|
27063
|
-
* **Option: talkWith**
|
|
27064
|
-
*
|
|
27065
|
-
* `RpgPlayer` (nothing by default)
|
|
27066
|
-
*
|
|
27067
|
-
* If you specify the event or another player, the other player will stop his or her movement and look in the player's direction.
|
|
27068
|
-
*
|
|
27069
|
-
* ```ts
|
|
27070
|
-
* // Code in an event
|
|
27071
|
-
* player.showText('Hello World', {
|
|
27072
|
-
* talkWith: this
|
|
27073
|
-
* })
|
|
27074
|
-
* ```
|
|
27075
|
-
*
|
|
27076
|
-
* @title Show Text
|
|
27077
|
-
* @method player.showText(text,options)
|
|
27078
|
-
* @param {string} text
|
|
27079
|
-
* @param {object} [options] the different options, see usage below
|
|
27080
|
-
* @returns {Promise}
|
|
27081
|
-
* @memberof GuiManager
|
|
27082
|
-
*/
|
|
27083
26970
|
showText(msg, options = {}) {
|
|
27084
26971
|
const gui = new DialogGui(this);
|
|
27085
26972
|
this._gui[gui.id] = gui;
|
|
27086
26973
|
return gui.openDialog(msg, options);
|
|
27087
26974
|
}
|
|
27088
|
-
/**
|
|
27089
|
-
* Shows a dialog box with a choice. Opens the GUI named `rpg-dialog`
|
|
27090
|
-
*
|
|
27091
|
-
* ```ts
|
|
27092
|
-
* const choice = await player.showChoices('What color do you prefer?', [
|
|
27093
|
-
* { text: 'Black', value: 'black' },
|
|
27094
|
-
* { text: 'Rather the blue', value: 'blue' },
|
|
27095
|
-
* { text: 'I don\'t have a preference!', value: 'none' }
|
|
27096
|
-
* ])
|
|
27097
|
-
*
|
|
27098
|
-
* // If the player selects the first
|
|
27099
|
-
* console.log(choice) // { text: 'Black', value: 'black' }
|
|
27100
|
-
* ```
|
|
27101
|
-
*
|
|
27102
|
-
* @title Show Choices
|
|
27103
|
-
* @method player.showChoices(text,choices)
|
|
27104
|
-
* @param {string} text
|
|
27105
|
-
* @param {Array<{ text: string, value: any }>} choices
|
|
27106
|
-
* @param {object} [options] Same options as the openDialog method
|
|
27107
|
-
* @returns {Promise<Choice | null>}
|
|
27108
|
-
* @memberof GuiManager
|
|
27109
|
-
*/
|
|
27110
26975
|
showChoices(msg, choices, options) {
|
|
27111
26976
|
return this.showText(msg, {
|
|
27112
26977
|
choices,
|
|
@@ -27116,19 +26981,6 @@ function WithGuiManager(Base) {
|
|
|
27116
26981
|
return choices[indexSelected];
|
|
27117
26982
|
});
|
|
27118
26983
|
}
|
|
27119
|
-
/**
|
|
27120
|
-
* Displays a notification . Opens the GUI named `rpg-notification`
|
|
27121
|
-
*
|
|
27122
|
-
* @title Displays a notification
|
|
27123
|
-
* @method player.showNotification()
|
|
27124
|
-
* @param {string} message - The message to display in the notification
|
|
27125
|
-
* @param {object} options - An object containing options for the notification
|
|
27126
|
-
* @param {number} options.time - The time to display the notification for (in ms). Default: 2000ms
|
|
27127
|
-
* @param {string} options.icon - The icon to display in the notification. Put the identifier of the spritesheet (defined on the client side)
|
|
27128
|
-
* @param {string} options.sound - The sound to play when the notification is shown. Set the sound ID (defined on the client side)
|
|
27129
|
-
* @returns {void}
|
|
27130
|
-
* @memberof GuiManager
|
|
27131
|
-
*/
|
|
27132
26984
|
showNotification(message, options = {}) {
|
|
27133
26985
|
const gui = new NotificationGui(this);
|
|
27134
26986
|
this._gui[gui.id] = gui;
|
|
@@ -27138,14 +26990,6 @@ function WithGuiManager(Base) {
|
|
|
27138
26990
|
};
|
|
27139
26991
|
return gui.open(data);
|
|
27140
26992
|
}
|
|
27141
|
-
/**
|
|
27142
|
-
* Calls main menu. Opens the GUI named `rpg-main-menu`
|
|
27143
|
-
*
|
|
27144
|
-
* @title Call Main Menu
|
|
27145
|
-
* @method player.callMainMenu()
|
|
27146
|
-
* @returns {void}
|
|
27147
|
-
* @memberof GuiManager
|
|
27148
|
-
*/
|
|
27149
26993
|
callMainMenu() {
|
|
27150
26994
|
const gui = new MenuGui(this);
|
|
27151
26995
|
this._gui[gui.id] = gui;
|
|
@@ -27278,7 +27122,8 @@ function WithGuiManager(Base) {
|
|
|
27278
27122
|
const _players = players || this;
|
|
27279
27123
|
this._attachedGui(_players, false);
|
|
27280
27124
|
}
|
|
27281
|
-
}
|
|
27125
|
+
}
|
|
27126
|
+
return GuiManagerMixin;
|
|
27282
27127
|
}
|
|
27283
27128
|
|
|
27284
27129
|
function WithGoldManager(Base) {
|
|
@@ -29791,6 +29636,7 @@ class RpgEvent extends RpgPlayer {
|
|
|
29791
29636
|
}
|
|
29792
29637
|
|
|
29793
29638
|
const context$1 = new Context();
|
|
29639
|
+
context$1["side"] = "server";
|
|
29794
29640
|
|
|
29795
29641
|
var __defProp$1 = Object.defineProperty;
|
|
29796
29642
|
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|