@rpgjs/server 5.0.0-alpha.17 → 5.0.0-alpha.18

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.
@@ -1,10 +1,15 @@
1
- import { PlayerCtor } from '@rpgjs/common';
1
+ import { Constructor, RpgCommonPlayer } from '@rpgjs/common';
2
+ import { ComponentInput, ComponentLayout } from './Components';
3
+ type ComponentPosition = 'top' | 'center' | 'bottom' | 'left' | 'right';
2
4
  /**
3
5
  * Component Manager Mixin
4
6
  *
5
- * Provides graphic management capabilities to any class. This mixin allows
7
+ * Provides graphic and component management capabilities to any class. This mixin allows
6
8
  * setting single or multiple graphics for player representation, enabling
7
- * dynamic visual changes and animation sequences.
9
+ * dynamic visual changes and animation sequences. It also provides methods to
10
+ * display UI components around the player graphic (top, bottom, center, left, right).
11
+ *
12
+ * Components are stored as JSON strings for efficient synchronization.
8
13
  *
9
14
  * @param Base - The base class to extend with component management
10
15
  * @returns Extended class with component management methods
@@ -20,41 +25,99 @@ import { PlayerCtor } from '@rpgjs/common';
20
25
  *
21
26
  * const player = new MyPlayer();
22
27
  * player.setGraphic(["hero_idle", "hero_walk"]);
28
+ * player.setComponentsTop(Components.text('{name}'));
23
29
  * ```
24
30
  */
25
- export declare function WithComponentManager<TBase extends PlayerCtor>(Base: TBase): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & IComponentManager;
31
+ export declare function WithComponentManager<TBase extends Constructor<RpgCommonPlayer>>(Base: TBase): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & IComponentManager;
26
32
  /**
27
33
  * Interface for component management capabilities
28
- * Defines the method signature that will be available on the player
34
+ * Defines the method signatures that will be available on the player
29
35
  */
30
36
  export interface IComponentManager {
31
37
  /**
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
- */
38
+ * Set the graphic(s) for this player
39
+ *
40
+ * Allows setting either a single graphic or multiple graphics for the player.
41
+ * When multiple graphics are provided, they are used for animation sequences.
42
+ * The graphics system provides flexible visual representation that can be
43
+ * dynamically changed during gameplay for different states, equipment, or animations.
44
+ *
45
+ * @param graphic - Single graphic name or array of graphic names for animation sequences
46
+ * @returns void
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * // Set a single graphic for static representation
51
+ * player.setGraphic("hero");
52
+ *
53
+ * // Set multiple graphics for animation sequences
54
+ * player.setGraphic(["hero_idle", "hero_walk", "hero_run"]);
55
+ *
56
+ * // Dynamic graphic changes based on equipment
57
+ * if (player.hasArmor('platemail')) {
58
+ * player.setGraphic("hero_armored");
59
+ * }
60
+ *
61
+ * // Animation sequences for different actions
62
+ * player.setGraphic(["mage_cast_1", "mage_cast_2", "mage_cast_3"]);
63
+ * ```
64
+ */
59
65
  setGraphic(graphic: string | string[]): void;
66
+ /**
67
+ * Set components to display above the player graphic
68
+ *
69
+ * @param layout - Component(s) to display, can be single, array, or 2D array
70
+ * @param options - Optional layout options for positioning and sizing
71
+ * @returns void
72
+ */
73
+ setComponentsTop(layout: ComponentInput, options?: ComponentLayout): void;
74
+ /**
75
+ * Set components to display below the player graphic
76
+ *
77
+ * @param layout - Component(s) to display, can be single, array, or 2D array
78
+ * @param options - Optional layout options for positioning and sizing
79
+ * @returns void
80
+ */
81
+ setComponentsBottom(layout: ComponentInput, options?: ComponentLayout): void;
82
+ /**
83
+ * Set components to display at the center of the player graphic
84
+ *
85
+ * @param layout - Component(s) to display, can be single, array, or 2D array
86
+ * @param options - Optional layout options for positioning and sizing
87
+ * @returns void
88
+ */
89
+ setComponentsCenter(layout: ComponentInput, options?: ComponentLayout): void;
90
+ /**
91
+ * Set components to display to the left of the player graphic
92
+ *
93
+ * @param layout - Component(s) to display, can be single, array, or 2D array
94
+ * @param options - Optional layout options for positioning and sizing
95
+ * @returns void
96
+ */
97
+ setComponentsLeft(layout: ComponentInput, options?: ComponentLayout): void;
98
+ /**
99
+ * Set components to display to the right of the player graphic
100
+ *
101
+ * @param layout - Component(s) to display, can be single, array, or 2D array
102
+ * @param options - Optional layout options for positioning and sizing
103
+ * @returns void
104
+ */
105
+ setComponentsRight(layout: ComponentInput, options?: ComponentLayout): void;
106
+ /**
107
+ * Remove components from a specific position
108
+ *
109
+ * @param position - Position of the components: 'top', 'center', 'bottom', 'left', or 'right'
110
+ * @returns void
111
+ */
112
+ removeComponents(position: ComponentPosition): void;
113
+ /**
114
+ * Merge components with existing components at a specific position
115
+ *
116
+ * @param position - Position of the components: 'top', 'center', 'bottom', 'left', or 'right'
117
+ * @param layout - Component(s) to merge, can be single, array, or 2D array
118
+ * @param options - Optional layout options for positioning and sizing
119
+ * @returns void
120
+ */
121
+ mergeComponents(position: ComponentPosition, layout: ComponentInput, options?: ComponentLayout): void;
60
122
  }
123
+ export {};
@@ -0,0 +1,345 @@
1
+ /**
2
+ * Component definitions for player UI elements
3
+ *
4
+ * This module provides factory functions to create component definitions
5
+ * that can be displayed above or below player graphics. Components are
6
+ * synchronized from server to client and rendered using CanvasEngine.
7
+ *
8
+ * ## Design
9
+ *
10
+ * Components are defined as data structures that describe UI elements
11
+ * (text, bars, shapes) with their properties and layout options. The
12
+ * server creates these definitions and they are automatically synchronized
13
+ * to all clients on the map.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { Components } from '@rpgjs/server';
18
+ *
19
+ * // Create a text component
20
+ * const nameComponent = Components.text('{name}');
21
+ *
22
+ * // Create an HP bar
23
+ * const hpBar = Components.hpBar();
24
+ *
25
+ * // Set components on player
26
+ * player.setComponentsTop([nameComponent, hpBar]);
27
+ * ```
28
+ */
29
+ export interface ComponentLayout {
30
+ /** Width of the component block in pixels */
31
+ width?: number;
32
+ /** Height of the component block in pixels */
33
+ height?: number;
34
+ /** Margin from the top of the player in pixels */
35
+ marginTop?: number;
36
+ /** Margin from the bottom of the player in pixels */
37
+ marginBottom?: number;
38
+ /** Margin from the left of the player in pixels */
39
+ marginLeft?: number;
40
+ /** Margin from the right of the player in pixels */
41
+ marginRight?: number;
42
+ }
43
+ export interface TextComponentOptions {
44
+ /** Text color in hexadecimal format (e.g., '#000000') */
45
+ fill?: string;
46
+ /** Font size in pixels */
47
+ fontSize?: number;
48
+ /** Font family */
49
+ fontFamily?: string;
50
+ /** Font style: 'normal', 'italic', 'oblique' */
51
+ fontStyle?: 'normal' | 'italic' | 'oblique';
52
+ /** Font weight: 'normal', 'bold', 'bolder', 'lighter', or numeric values */
53
+ fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number;
54
+ /** Stroke color in hexadecimal format */
55
+ stroke?: string;
56
+ /** Opacity between 0 and 1 */
57
+ opacity?: number;
58
+ /** Word wrap */
59
+ wordWrap?: boolean;
60
+ /** Text alignment */
61
+ align?: 'left' | 'center' | 'right' | 'justify';
62
+ }
63
+ export interface BarComponentOptions {
64
+ /** Background color in hexadecimal format */
65
+ bgColor?: string;
66
+ /** Fill color in hexadecimal format */
67
+ fillColor?: string;
68
+ /** Border color in hexadecimal format */
69
+ borderColor?: string;
70
+ /** Border width */
71
+ borderWidth?: number;
72
+ /** Height of the bar in pixels */
73
+ height?: number;
74
+ /** Width of the bar in pixels */
75
+ width?: number;
76
+ /** Border radius */
77
+ borderRadius?: number;
78
+ /** Opacity between 0 and 1 */
79
+ opacity?: number;
80
+ }
81
+ export interface ShapeComponentOptions {
82
+ /** Fill color in hexadecimal format */
83
+ fill: string;
84
+ /** Type of shape */
85
+ type: 'circle' | 'rectangle' | 'ellipse' | 'polygon' | 'line' | 'rounded-rectangle';
86
+ /** Radius (for circle) */
87
+ radius?: number | string;
88
+ /** Width (for rectangle, ellipse) */
89
+ width?: number | string;
90
+ /** Height (for rectangle, ellipse) */
91
+ height?: number | string;
92
+ /** X1 position (for line) */
93
+ x1?: number | string;
94
+ /** Y1 position (for line) */
95
+ y1?: number | string;
96
+ /** X2 position (for line) */
97
+ x2?: number | string;
98
+ /** Y2 position (for line) */
99
+ y2?: number | string;
100
+ /** Points array (for polygon) */
101
+ points?: number[];
102
+ /** Opacity between 0 and 1 */
103
+ opacity?: number | string;
104
+ /** Line/border style */
105
+ line?: {
106
+ color?: string;
107
+ width?: number;
108
+ alpha?: number;
109
+ };
110
+ }
111
+ export type ComponentDefinition = {
112
+ type: 'text';
113
+ value: string;
114
+ style?: TextComponentOptions;
115
+ } | {
116
+ type: 'hpBar';
117
+ style?: BarComponentOptions;
118
+ text?: string | null;
119
+ } | {
120
+ type: 'spBar';
121
+ style?: BarComponentOptions;
122
+ text?: string | null;
123
+ } | {
124
+ type: 'bar';
125
+ current: string;
126
+ max: string;
127
+ style?: BarComponentOptions;
128
+ text?: string | null;
129
+ } | {
130
+ type: 'shape';
131
+ value: ShapeComponentOptions;
132
+ } | {
133
+ type: 'image';
134
+ value: string;
135
+ } | {
136
+ type: 'tile';
137
+ value: number | string;
138
+ };
139
+ export type ComponentInput = ComponentDefinition | ComponentDefinition[] | ComponentDefinition[][];
140
+ /**
141
+ * Components factory for creating component definitions
142
+ *
143
+ * Provides factory methods to create various UI components that can be
144
+ * displayed above or below player graphics. Components support template
145
+ * strings with placeholders like {name}, {hp}, etc. that are replaced
146
+ * with actual player property values on the client.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * // Create a text component
151
+ * Components.text('Player: {name}');
152
+ *
153
+ * // Create an HP bar with custom text
154
+ * Components.hpBar({}, '{$percent}%');
155
+ *
156
+ * // Create a custom bar
157
+ * Components.bar('wood', 'param.maxWood');
158
+ * ```
159
+ */
160
+ export declare const Components: {
161
+ /**
162
+ * Create a text component
163
+ *
164
+ * Creates a text component that displays text with optional styling.
165
+ * Supports template strings with placeholders like {name}, {hp}, etc.
166
+ * that are replaced with actual player property values.
167
+ *
168
+ * ## Design
169
+ *
170
+ * Text components use template strings to allow dynamic content without
171
+ * resending the entire component structure when values change. Only the
172
+ * property values are synchronized, reducing bandwidth usage.
173
+ *
174
+ * @param text - Text to display, can include placeholders like {name}, {hp}
175
+ * @param options - Text styling options
176
+ * @returns Component definition for text
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * // Simple text
181
+ * Components.text('Player Name');
182
+ *
183
+ * // Text with placeholder
184
+ * Components.text('{name}');
185
+ *
186
+ * // Text with styling
187
+ * Components.text('{name}', {
188
+ * fill: '#000000',
189
+ * fontSize: 20
190
+ * });
191
+ * ```
192
+ */
193
+ text(value: string, style?: TextComponentOptions): ComponentDefinition;
194
+ /**
195
+ * Create an HP bar component
196
+ *
197
+ * Creates a health point bar that automatically displays the player's
198
+ * current HP relative to their maximum HP. The bar updates automatically
199
+ * as HP changes.
200
+ *
201
+ * ## Design
202
+ *
203
+ * HP bars read from the player's hp and param.maxHp properties. The
204
+ * bar can optionally display text above it showing current, max, or
205
+ * percentage values.
206
+ *
207
+ * @param options - Bar styling options
208
+ * @param text - Optional text to display above the bar. Can use placeholders:
209
+ * - {$current} - Current HP value
210
+ * - {$max} - Maximum HP value
211
+ * - {$percent} - Percentage value
212
+ * Set to null to hide text
213
+ * @returns Component definition for HP bar
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * // Simple HP bar
218
+ * Components.hpBar();
219
+ *
220
+ * // HP bar with percentage text
221
+ * Components.hpBar({}, '{$percent}%');
222
+ *
223
+ * // HP bar with custom styling
224
+ * Components.hpBar({
225
+ * fillColor: '#ff0000',
226
+ * height: 8
227
+ * });
228
+ * ```
229
+ */
230
+ hpBar(style?: BarComponentOptions, text?: string | null): ComponentDefinition;
231
+ /**
232
+ * Create an SP bar component
233
+ *
234
+ * Creates a skill point bar that automatically displays the player's
235
+ * current SP relative to their maximum SP. The bar updates automatically
236
+ * as SP changes.
237
+ *
238
+ * @param style - Bar styling options
239
+ * @param text - Optional text to display above the bar. Can use placeholders:
240
+ * - {$current} - Current SP value
241
+ * - {$max} - Maximum SP value
242
+ * - {$percent} - Percentage value
243
+ * Set to null to hide text
244
+ * @returns Component definition for SP bar
245
+ *
246
+ * @example
247
+ * ```ts
248
+ * // Simple SP bar
249
+ * Components.spBar();
250
+ *
251
+ * // SP bar with text
252
+ * Components.spBar({}, 'SP: {$current}/{$max}');
253
+ * ```
254
+ */
255
+ spBar(style?: BarComponentOptions, text?: string | null): ComponentDefinition;
256
+ /**
257
+ * Create a custom bar component
258
+ *
259
+ * Creates a bar that displays a custom property value relative to a maximum.
260
+ * Useful for displaying custom resources like wood, mana, energy, etc.
261
+ *
262
+ * @param current - Property path for current value (e.g., 'wood', 'mana')
263
+ * @param max - Property path for maximum value (e.g., 'param.maxWood', 'param.maxMana')
264
+ * @param style - Bar styling options
265
+ * @param text - Optional text to display above the bar. Can use placeholders:
266
+ * - {$current} - Current value
267
+ * - {$max} - Maximum value
268
+ * - {$percent} - Percentage value
269
+ * Set to null to hide text
270
+ * @returns Component definition for custom bar
271
+ *
272
+ * @example
273
+ * ```ts
274
+ * // Bar for custom property
275
+ * Components.bar('wood', 'param.maxWood');
276
+ *
277
+ * // Bar with text
278
+ * Components.bar('mana', 'param.maxMana', {}, 'Mana: {$current}/{$max}');
279
+ * ```
280
+ */
281
+ bar(current: string, max: string, style?: BarComponentOptions, text?: string | null): ComponentDefinition;
282
+ /**
283
+ * Create a shape component
284
+ *
285
+ * Creates a geometric shape that can be displayed above or below the player.
286
+ * Useful for visual indicators, backgrounds, or decorative elements.
287
+ *
288
+ * @param value - Shape configuration options
289
+ * @returns Component definition for shape
290
+ *
291
+ * @example
292
+ * ```ts
293
+ * // Circle shape
294
+ * Components.shape({
295
+ * fill: '#ffffff',
296
+ * type: 'circle',
297
+ * radius: 10
298
+ * });
299
+ *
300
+ * // Rectangle shape
301
+ * Components.shape({
302
+ * fill: '#ff0000',
303
+ * type: 'rectangle',
304
+ * width: 32,
305
+ * height: 32
306
+ * });
307
+ *
308
+ * // Using parameters
309
+ * Components.shape({
310
+ * fill: '#ffffff',
311
+ * type: 'circle',
312
+ * radius: 'hp' // radius will be the same as hp value
313
+ * });
314
+ * ```
315
+ */
316
+ shape(value: ShapeComponentOptions): ComponentDefinition;
317
+ /**
318
+ * Create an image component
319
+ *
320
+ * Displays an image from a URL or spritesheet identifier.
321
+ *
322
+ * @param value - Image source URL or spritesheet identifier
323
+ * @returns Component definition for image
324
+ *
325
+ * @example
326
+ * ```ts
327
+ * Components.image('mygraphic.png');
328
+ * ```
329
+ */
330
+ image(value: string): ComponentDefinition;
331
+ /**
332
+ * Create a tile component
333
+ *
334
+ * Displays a tile from a tileset by ID.
335
+ *
336
+ * @param value - Tile ID in the tileset
337
+ * @returns Component definition for tile
338
+ *
339
+ * @example
340
+ * ```ts
341
+ * Components.tile(3); // Use tile #3
342
+ * ```
343
+ */
344
+ tile(value: number | string): ComponentDefinition;
345
+ };
@@ -1,4 +1,4 @@
1
- import { Hooks, RpgCommonPlayer, Direction } from '@rpgjs/common';
1
+ import { Hooks, RpgCommonPlayer, Constructor, Direction, AttachShapeOptions, RpgShape } from '@rpgjs/common';
2
2
  import { IComponentManager } from './ComponentManager';
3
3
  import { RpgMap } from '../rooms/map';
4
4
  import { Context } from '@signe/di';
@@ -15,16 +15,7 @@ import { ISkillManager } from './SkillManager';
15
15
  import { IBattleManager } from './BattleManager';
16
16
  import { IClassManager } from './ClassManager';
17
17
  import { IStateManager } from './StateManager';
18
- interface ZoneOptions {
19
- x?: number;
20
- y?: number;
21
- radius: number;
22
- angle?: number;
23
- direction?: any;
24
- linkedTo?: string;
25
- limitedByWalls?: boolean;
26
- }
27
- declare const RpgPlayer_base: typeof RpgCommonPlayer;
18
+ declare const RpgPlayer_base: Constructor<RpgCommonPlayer>;
28
19
  /**
29
20
  * RPG Player class with component management capabilities
30
21
  *
@@ -49,6 +40,10 @@ export declare class RpgPlayer extends RpgPlayer_base {
49
40
  context?: Context;
50
41
  conn: MockConnection | null;
51
42
  touchSide: boolean;
43
+ /** Internal: Shapes attached to this player */
44
+ private _attachedShapes;
45
+ /** Internal: Shapes where this player is currently located */
46
+ private _inShapes;
52
47
  /** Last processed client input timestamp for reconciliation */
53
48
  lastProcessedInputTs: number;
54
49
  /** Last processed client input frame for reconciliation with server tick */
@@ -162,7 +157,79 @@ export declare class RpgPlayer extends RpgPlayer_base {
162
157
  syncChanges(): void;
163
158
  databaseById(id: string): any;
164
159
  private _eventChanges;
165
- attachShape(id: string, options: ZoneOptions): void;
160
+ /**
161
+ * Attach a zone shape to this player using the physic zone system
162
+ *
163
+ * This method creates a zone attached to the player's entity in the physics engine.
164
+ * The zone can be circular or cone-shaped and will detect other entities (players/events)
165
+ * entering or exiting the zone.
166
+ *
167
+ * @param id - Optional zone identifier. If not provided, a unique ID will be generated
168
+ * @param options - Zone configuration options
169
+ *
170
+ * @example
171
+ * ```ts
172
+ * // Create a circular detection zone
173
+ * player.attachShape("vision", {
174
+ * radius: 150,
175
+ * angle: 360,
176
+ * });
177
+ *
178
+ * // Create a cone-shaped vision zone
179
+ * player.attachShape("vision", {
180
+ * radius: 200,
181
+ * angle: 120,
182
+ * direction: Direction.Right,
183
+ * limitedByWalls: true,
184
+ * });
185
+ *
186
+ * // Create a zone with width/height (radius calculated automatically)
187
+ * player.attachShape({
188
+ * width: 100,
189
+ * height: 100,
190
+ * positioning: "center",
191
+ * });
192
+ * ```
193
+ */
194
+ attachShape(idOrOptions: string | AttachShapeOptions, options?: AttachShapeOptions): RpgShape | undefined;
195
+ /**
196
+ * Get all shapes attached to this player
197
+ *
198
+ * Returns all shapes that were created using `attachShape()` on this player.
199
+ *
200
+ * @returns Array of RpgShape instances attached to this player
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * player.attachShape("vision", { radius: 150 });
205
+ * player.attachShape("detection", { radius: 100 });
206
+ *
207
+ * const shapes = player.getShapes();
208
+ * console.log(shapes.length); // 2
209
+ * ```
210
+ */
211
+ getShapes(): RpgShape[];
212
+ /**
213
+ * Get all shapes where this player is currently located
214
+ *
215
+ * Returns all shapes (from any player/event) where this player is currently inside.
216
+ * This is updated automatically when the player enters or exits shapes.
217
+ *
218
+ * @returns Array of RpgShape instances where this player is located
219
+ *
220
+ * @example
221
+ * ```ts
222
+ * // Another player has a detection zone
223
+ * otherPlayer.attachShape("detection", { radius: 200 });
224
+ *
225
+ * // Check if this player is in any shape
226
+ * const inShapes = player.getInShapes();
227
+ * if (inShapes.length > 0) {
228
+ * console.log("Player is being detected!");
229
+ * }
230
+ * ```
231
+ */
232
+ getInShapes(): RpgShape[];
166
233
  /**
167
234
  * Show a temporary component animation on this player
168
235
  *
@@ -189,6 +256,60 @@ export declare class RpgPlayer extends RpgPlayer_base {
189
256
  */
190
257
  showComponentAnimation(id: string, params?: any): void;
191
258
  showHit(text: string): void;
259
+ /**
260
+ * Play a sound on the client side for this player only
261
+ *
262
+ * This method emits an event to play a sound only for this specific player.
263
+ * The sound must be defined on the client side (in the client module configuration).
264
+ *
265
+ * ## Design
266
+ *
267
+ * The sound is sent only to this player's client connection, making it ideal
268
+ * for personal feedback sounds like UI interactions, notifications, or personal
269
+ * achievements. For map-wide sounds that all players should hear, use `map.playSound()` instead.
270
+ *
271
+ * @param soundId - Sound identifier, defined on the client side
272
+ * @param options - Optional sound configuration
273
+ * @param options.volume - Volume level (0.0 to 1.0, default: 1.0)
274
+ * @param options.loop - Whether the sound should loop (default: false)
275
+ *
276
+ * @example
277
+ * ```ts
278
+ * // Play a sound for this player only (default behavior)
279
+ * player.playSound("item-pickup");
280
+ *
281
+ * // Play a sound with volume and loop
282
+ * player.playSound("background-music", {
283
+ * volume: 0.5,
284
+ * loop: true
285
+ * });
286
+ *
287
+ * // Play a notification sound at low volume
288
+ * player.playSound("notification", { volume: 0.3 });
289
+ * ```
290
+ */
291
+ playSound(soundId: string, options?: {
292
+ volume?: number;
293
+ loop?: boolean;
294
+ }): void;
295
+ /**
296
+ * Stop a sound that is currently playing for this player
297
+ *
298
+ * This method stops a sound that was previously started with `playSound()`.
299
+ * The sound must be defined on the client side.
300
+ *
301
+ * @param soundId - Sound identifier to stop
302
+ *
303
+ * @example
304
+ * ```ts
305
+ * // Start a looping background music
306
+ * player.playSound("background-music", { loop: true });
307
+ *
308
+ * // Later, stop it
309
+ * player.stopSound("background-music");
310
+ * ```
311
+ */
312
+ stopSound(soundId: string): void;
192
313
  /**
193
314
  * Set the sync schema for the map
194
315
  * @param schema - The schema to set
package/dist/index.d.ts CHANGED
@@ -4,8 +4,10 @@ export * from './RpgServer';
4
4
  export * from './core/setup';
5
5
  export * from './core/inject';
6
6
  export * from './Player/Player';
7
+ export * from './Player/Components';
7
8
  export * from './module';
8
9
  export * from './rooms/map';
9
10
  export * from './presets';
10
11
  export * from '@signe/reactive';
11
12
  export * from './Gui';
13
+ export { RpgShape } from '@rpgjs/common';