@rpgjs/server 5.0.0-alpha.4 → 5.0.0-alpha.41
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/Gui/DialogGui.d.ts +5 -0
- package/dist/Gui/GameoverGui.d.ts +23 -0
- package/dist/Gui/Gui.d.ts +6 -0
- package/dist/Gui/MenuGui.d.ts +22 -3
- package/dist/Gui/NotificationGui.d.ts +1 -2
- package/dist/Gui/SaveLoadGui.d.ts +13 -0
- package/dist/Gui/ShopGui.d.ts +28 -3
- package/dist/Gui/TitleGui.d.ts +23 -0
- package/dist/Gui/index.d.ts +10 -1
- package/dist/Player/BattleManager.d.ts +34 -12
- package/dist/Player/ClassManager.d.ts +46 -13
- package/dist/Player/ComponentManager.d.ts +123 -0
- package/dist/Player/Components.d.ts +345 -0
- package/dist/Player/EffectManager.d.ts +86 -0
- package/dist/Player/ElementManager.d.ts +104 -0
- package/dist/Player/GoldManager.d.ts +22 -0
- package/dist/Player/GuiManager.d.ts +259 -0
- package/dist/Player/ItemFixture.d.ts +6 -0
- package/dist/Player/ItemManager.d.ts +450 -9
- package/dist/Player/MoveManager.d.ts +324 -69
- package/dist/Player/ParameterManager.d.ts +344 -14
- package/dist/Player/Player.d.ts +460 -8
- package/dist/Player/SkillManager.d.ts +197 -15
- package/dist/Player/StateManager.d.ts +89 -25
- package/dist/Player/VariableManager.d.ts +74 -0
- package/dist/RpgServer.d.ts +502 -64
- package/dist/RpgServerEngine.d.ts +2 -1
- package/dist/decorators/event.d.ts +46 -0
- package/dist/decorators/map.d.ts +287 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +21653 -20900
- package/dist/index.js.map +1 -1
- package/dist/logs/log.d.ts +2 -3
- package/dist/module.d.ts +43 -1
- package/dist/presets/index.d.ts +0 -9
- package/dist/rooms/BaseRoom.d.ts +132 -0
- package/dist/rooms/lobby.d.ts +10 -2
- package/dist/rooms/map.d.ts +1236 -17
- package/dist/services/save.d.ts +43 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/localStorage.d.ts +23 -0
- package/package.json +14 -10
- package/src/Gui/DialogGui.ts +19 -4
- package/src/Gui/GameoverGui.ts +39 -0
- package/src/Gui/Gui.ts +23 -1
- package/src/Gui/MenuGui.ts +155 -6
- package/src/Gui/NotificationGui.ts +1 -2
- package/src/Gui/SaveLoadGui.ts +60 -0
- package/src/Gui/ShopGui.ts +146 -16
- package/src/Gui/TitleGui.ts +39 -0
- package/src/Gui/index.ts +15 -2
- package/src/Player/BattleManager.ts +91 -49
- package/src/Player/ClassManager.ts +118 -50
- package/src/Player/ComponentManager.ts +425 -19
- package/src/Player/Components.ts +380 -0
- package/src/Player/EffectManager.ts +81 -44
- package/src/Player/ElementManager.ts +109 -86
- package/src/Player/GoldManager.ts +32 -35
- package/src/Player/GuiManager.ts +308 -150
- package/src/Player/ItemFixture.ts +4 -5
- package/src/Player/ItemManager.ts +774 -355
- package/src/Player/MoveManager.ts +1544 -774
- package/src/Player/ParameterManager.ts +546 -104
- package/src/Player/Player.ts +1163 -88
- package/src/Player/SkillManager.ts +520 -195
- package/src/Player/StateManager.ts +170 -182
- package/src/Player/VariableManager.ts +101 -63
- package/src/RpgServer.ts +525 -63
- package/src/core/context.ts +1 -0
- package/src/decorators/event.ts +61 -0
- package/src/decorators/map.ts +327 -0
- package/src/index.ts +11 -1
- package/src/logs/log.ts +10 -3
- package/src/module.ts +126 -3
- package/src/presets/index.ts +1 -10
- package/src/rooms/BaseRoom.ts +232 -0
- package/src/rooms/lobby.ts +25 -7
- package/src/rooms/map.ts +2502 -194
- package/src/services/save.ts +147 -0
- package/src/storage/index.ts +1 -0
- package/src/storage/localStorage.ts +76 -0
- package/tests/battle.spec.ts +375 -0
- package/tests/change-map.spec.ts +72 -0
- package/tests/class.spec.ts +274 -0
- package/tests/effect.spec.ts +219 -0
- package/tests/element.spec.ts +221 -0
- package/tests/event.spec.ts +80 -0
- package/tests/gold.spec.ts +99 -0
- package/tests/item.spec.ts +609 -0
- package/tests/module.spec.ts +38 -0
- package/tests/move.spec.ts +601 -0
- package/tests/player-param.spec.ts +28 -0
- package/tests/prediction-reconciliation.spec.ts +182 -0
- package/tests/random-move.spec.ts +65 -0
- package/tests/skill.spec.ts +658 -0
- package/tests/state.spec.ts +467 -0
- package/tests/variable.spec.ts +185 -0
- package/tests/world-maps.spec.ts +896 -0
- package/vite.config.ts +16 -0
- package/dist/Player/Event.d.ts +0 -0
- package/src/Player/Event.ts +0 -0
package/dist/Player/Player.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Hooks, RpgCommonPlayer, Constructor, Direction, AttachShapeOptions, RpgShape } from '../../../common/src';
|
|
2
|
+
import { Vector2 } from '../../../physic/src';
|
|
2
3
|
import { IComponentManager } from './ComponentManager';
|
|
3
4
|
import { RpgMap } from '../rooms/map';
|
|
4
5
|
import { Context } from '@signe/di';
|
|
@@ -6,19 +7,98 @@ import { IGuiManager } from './GuiManager';
|
|
|
6
7
|
import { MockConnection } from '@signe/room';
|
|
7
8
|
import { IMoveManager } from './MoveManager';
|
|
8
9
|
import { IGoldManager } from './GoldManager';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { IVariableManager } from './VariableManager';
|
|
11
|
+
import { IParameterManager } from './ParameterManager';
|
|
12
|
+
import { IItemManager } from './ItemManager';
|
|
13
|
+
import { IEffectManager } from './EffectManager';
|
|
14
|
+
import { IElementManager } from './ElementManager';
|
|
15
|
+
import { ISkillManager } from './SkillManager';
|
|
16
|
+
import { IBattleManager } from './BattleManager';
|
|
17
|
+
import { IClassManager } from './ClassManager';
|
|
18
|
+
import { IStateManager } from './StateManager';
|
|
19
|
+
import { SaveRequestContext, SaveSlotIndex, SaveSlotMeta } from '../services/save';
|
|
12
20
|
declare const RpgPlayer_base: Constructor<RpgCommonPlayer>;
|
|
13
21
|
/**
|
|
14
22
|
* RPG Player class with component management capabilities
|
|
23
|
+
*
|
|
24
|
+
* Combines all player mixins to provide a complete player implementation
|
|
25
|
+
* with graphics, movement, inventory, skills, and battle capabilities.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* // Create a new player
|
|
30
|
+
* const player = new RpgPlayer();
|
|
31
|
+
*
|
|
32
|
+
* // Set player graphics
|
|
33
|
+
* player.setGraphic("hero");
|
|
34
|
+
*
|
|
35
|
+
* // Add parameters and items
|
|
36
|
+
* player.addParameter("strength", { start: 10, end: 100 });
|
|
37
|
+
* player.addItem(sword);
|
|
38
|
+
* ```
|
|
15
39
|
*/
|
|
16
40
|
export declare class RpgPlayer extends RpgPlayer_base {
|
|
17
41
|
map: RpgMap | null;
|
|
18
42
|
context?: Context;
|
|
19
43
|
conn: MockConnection | null;
|
|
44
|
+
touchSide: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Computed signal for world X position
|
|
47
|
+
*
|
|
48
|
+
* Calculates the absolute world X position from the map's world position
|
|
49
|
+
* plus the player's local X position. Returns 0 if no map is assigned.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const worldX = player.worldX();
|
|
54
|
+
* console.log(`Player is at world X: ${worldX}`);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
get worldPositionX(): any;
|
|
58
|
+
/**
|
|
59
|
+
* Computed signal for world Y position
|
|
60
|
+
*
|
|
61
|
+
* Calculates the absolute world Y position from the map's world position
|
|
62
|
+
* plus the player's local Y position. Returns 0 if no map is assigned.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const worldY = player.worldY();
|
|
67
|
+
* console.log(`Player is at world Y: ${worldY}`);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
get worldPositionY(): any;
|
|
71
|
+
private _worldPositionSignals;
|
|
72
|
+
private _getComputedWorldPosition;
|
|
73
|
+
/** Internal: Shapes attached to this player */
|
|
74
|
+
private _attachedShapes;
|
|
75
|
+
/** Internal: Shapes where this player is currently located */
|
|
76
|
+
private _inShapes;
|
|
77
|
+
/** Last processed client input timestamp for reconciliation */
|
|
78
|
+
lastProcessedInputTs: number;
|
|
79
|
+
/** Last processed client input frame for reconciliation with server tick */
|
|
80
|
+
_lastFramePositions: {
|
|
81
|
+
frame: number;
|
|
82
|
+
position: {
|
|
83
|
+
x: number;
|
|
84
|
+
y: number;
|
|
85
|
+
direction: Direction;
|
|
86
|
+
};
|
|
87
|
+
serverTick?: number;
|
|
88
|
+
} | null;
|
|
89
|
+
frames: {
|
|
90
|
+
x: number;
|
|
91
|
+
y: number;
|
|
92
|
+
ts: number;
|
|
93
|
+
}[];
|
|
20
94
|
events: import('@signe/reactive').WritableArraySignal<RpgEvent[]>;
|
|
21
95
|
constructor();
|
|
96
|
+
_onInit(): void;
|
|
97
|
+
onGameStart(): void;
|
|
98
|
+
get hooks(): Hooks;
|
|
99
|
+
get server(): RpgMap | null;
|
|
100
|
+
setMap(map: RpgMap): void;
|
|
101
|
+
applyFrames(): void;
|
|
22
102
|
execMethod(method: string, methodData?: any[], target?: any): Promise<any>;
|
|
23
103
|
/**
|
|
24
104
|
* Change the map for this player
|
|
@@ -41,13 +121,81 @@ export declare class RpgPlayer extends RpgPlayer_base {
|
|
|
41
121
|
y: number;
|
|
42
122
|
z?: number;
|
|
43
123
|
} | string): Promise<any | null | boolean>;
|
|
124
|
+
autoChangeMap(nextPosition: Vector2): Promise<boolean>;
|
|
44
125
|
teleport(positions: {
|
|
45
126
|
x: number;
|
|
46
127
|
y: number;
|
|
47
128
|
}): Promise<false | undefined>;
|
|
48
129
|
getCurrentMap<T extends RpgMap = RpgMap>(): T | null;
|
|
49
130
|
emit(type: string, value?: any): void;
|
|
50
|
-
|
|
131
|
+
snapshot(): Record<string, any>;
|
|
132
|
+
applySnapshot(snapshot: string | object): Promise<any>;
|
|
133
|
+
save(slot?: SaveSlotIndex, meta?: SaveSlotMeta, context?: SaveRequestContext): Promise<{
|
|
134
|
+
index: number;
|
|
135
|
+
meta: import('../../../common/src').SaveSlotMeta;
|
|
136
|
+
} | null>;
|
|
137
|
+
load(slot?: SaveSlotIndex, context?: SaveRequestContext, options?: {
|
|
138
|
+
changeMap?: boolean;
|
|
139
|
+
}): Promise<{
|
|
140
|
+
ok: boolean;
|
|
141
|
+
slot?: undefined;
|
|
142
|
+
index?: undefined;
|
|
143
|
+
} | {
|
|
144
|
+
ok: boolean;
|
|
145
|
+
slot: {
|
|
146
|
+
[key: string]: any;
|
|
147
|
+
level?: number;
|
|
148
|
+
exp?: number;
|
|
149
|
+
map?: string;
|
|
150
|
+
date?: string;
|
|
151
|
+
};
|
|
152
|
+
index: number;
|
|
153
|
+
}>;
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated Use setGraphicAnimation instead.
|
|
156
|
+
* @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
|
|
157
|
+
* @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
|
|
158
|
+
*/
|
|
159
|
+
setAnimation(animationName: string, nbTimes?: number): void;
|
|
160
|
+
/**
|
|
161
|
+
* @deprecated Use setGraphicAnimation instead.
|
|
162
|
+
* @param graphic - The graphic to use for the animation (e.g., 'attack', 'skill', 'walk')
|
|
163
|
+
* @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
|
|
164
|
+
* @param replaceGraphic - Whether to replace the player's graphic (default: false)
|
|
165
|
+
*/
|
|
166
|
+
showAnimation(graphic: string, animationName: string, replaceGraphic?: boolean): void;
|
|
167
|
+
/**
|
|
168
|
+
* Set the current animation of the player's sprite
|
|
169
|
+
*
|
|
170
|
+
* This method changes the animation state of the player's current sprite.
|
|
171
|
+
* It's used to trigger character animations like attack, skill, or custom movements.
|
|
172
|
+
* When `nbTimes` is set to a finite number, the animation will play that many times
|
|
173
|
+
* before returning to the previous animation state.
|
|
174
|
+
*
|
|
175
|
+
* If `animationFixed` is true, this method will not change the animation.
|
|
176
|
+
*
|
|
177
|
+
* @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
|
|
178
|
+
* @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
|
|
179
|
+
*/
|
|
180
|
+
setGraphicAnimation(animationName: string, nbTimes: number): void;
|
|
181
|
+
/**
|
|
182
|
+
* Set the current animation of the player's sprite with a temporary graphic change
|
|
183
|
+
*
|
|
184
|
+
* This method changes the animation state of the player's current sprite and temporarily
|
|
185
|
+
* changes the player's graphic (sprite sheet) during the animation. The graphic is
|
|
186
|
+
* automatically reset when the animation finishes.
|
|
187
|
+
*
|
|
188
|
+
* When `nbTimes` is set to a finite number, the animation will play that many times
|
|
189
|
+
* before returning to the previous animation state and graphic.
|
|
190
|
+
*
|
|
191
|
+
* If `animationFixed` is true, this method will not change the animation.
|
|
192
|
+
*
|
|
193
|
+
* @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
|
|
194
|
+
* @param graphic - The graphic(s) to temporarily use during the animation
|
|
195
|
+
* @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
|
|
196
|
+
*/
|
|
197
|
+
setGraphicAnimation(animationName: string, graphic: string | string[], nbTimes: number): void;
|
|
198
|
+
setGraphicAnimation(animationName: string, graphic: string | string[]): void;
|
|
51
199
|
/**
|
|
52
200
|
* Run the change detection cycle. Normally, as soon as a hook is called in a class, the cycle is started. But you can start it manually
|
|
53
201
|
* The method calls the `onChanges` method on events and synchronizes all map data with the client.
|
|
@@ -60,14 +208,318 @@ export declare class RpgPlayer extends RpgPlayer_base {
|
|
|
60
208
|
syncChanges(): void;
|
|
61
209
|
databaseById(id: string): any;
|
|
62
210
|
private _eventChanges;
|
|
63
|
-
|
|
64
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Attach a zone shape to this player using the physic zone system
|
|
213
|
+
*
|
|
214
|
+
* This method creates a zone attached to the player's entity in the physics engine.
|
|
215
|
+
* The zone can be circular or cone-shaped and will detect other entities (players/events)
|
|
216
|
+
* entering or exiting the zone.
|
|
217
|
+
*
|
|
218
|
+
* @param id - Optional zone identifier. If not provided, a unique ID will be generated
|
|
219
|
+
* @param options - Zone configuration options
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* // Create a circular detection zone
|
|
224
|
+
* player.attachShape("vision", {
|
|
225
|
+
* radius: 150,
|
|
226
|
+
* angle: 360,
|
|
227
|
+
* });
|
|
228
|
+
*
|
|
229
|
+
* // Create a cone-shaped vision zone
|
|
230
|
+
* player.attachShape("vision", {
|
|
231
|
+
* radius: 200,
|
|
232
|
+
* angle: 120,
|
|
233
|
+
* direction: Direction.Right,
|
|
234
|
+
* limitedByWalls: true,
|
|
235
|
+
* });
|
|
236
|
+
*
|
|
237
|
+
* // Create a zone with width/height (radius calculated automatically)
|
|
238
|
+
* player.attachShape({
|
|
239
|
+
* width: 100,
|
|
240
|
+
* height: 100,
|
|
241
|
+
* positioning: "center",
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
attachShape(idOrOptions: string | AttachShapeOptions, options?: AttachShapeOptions): RpgShape | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* Get all shapes attached to this player
|
|
248
|
+
*
|
|
249
|
+
* Returns all shapes that were created using `attachShape()` on this player.
|
|
250
|
+
*
|
|
251
|
+
* @returns Array of RpgShape instances attached to this player
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```ts
|
|
255
|
+
* player.attachShape("vision", { radius: 150 });
|
|
256
|
+
* player.attachShape("detection", { radius: 100 });
|
|
257
|
+
*
|
|
258
|
+
* const shapes = player.getShapes();
|
|
259
|
+
* console.log(shapes.length); // 2
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
getShapes(): RpgShape[];
|
|
263
|
+
/**
|
|
264
|
+
* Get all shapes where this player is currently located
|
|
265
|
+
*
|
|
266
|
+
* Returns all shapes (from any player/event) where this player is currently inside.
|
|
267
|
+
* This is updated automatically when the player enters or exits shapes.
|
|
268
|
+
*
|
|
269
|
+
* @returns Array of RpgShape instances where this player is located
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* // Another player has a detection zone
|
|
274
|
+
* otherPlayer.attachShape("detection", { radius: 200 });
|
|
275
|
+
*
|
|
276
|
+
* // Check if this player is in any shape
|
|
277
|
+
* const inShapes = player.getInShapes();
|
|
278
|
+
* if (inShapes.length > 0) {
|
|
279
|
+
* console.log("Player is being detected!");
|
|
280
|
+
* }
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
getInShapes(): RpgShape[];
|
|
284
|
+
/**
|
|
285
|
+
* Show a temporary component animation on this player
|
|
286
|
+
*
|
|
287
|
+
* This method broadcasts a component animation to all clients, allowing
|
|
288
|
+
* temporary visual effects like hit indicators, spell effects, or status animations
|
|
289
|
+
* to be displayed on the player.
|
|
290
|
+
*
|
|
291
|
+
* @param id - The ID of the component animation to display
|
|
292
|
+
* @param params - Parameters to pass to the component animation
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* // Show a hit animation with damage text
|
|
297
|
+
* player.showComponentAnimation("hit", {
|
|
298
|
+
* text: "150",
|
|
299
|
+
* color: "red"
|
|
300
|
+
* });
|
|
301
|
+
*
|
|
302
|
+
* // Show a heal animation
|
|
303
|
+
* player.showComponentAnimation("heal", {
|
|
304
|
+
* amount: 50
|
|
305
|
+
* });
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
showComponentAnimation(id: string, params?: any): void;
|
|
65
309
|
showHit(text: string): void;
|
|
310
|
+
/**
|
|
311
|
+
* Play a sound on the client side for this player only
|
|
312
|
+
*
|
|
313
|
+
* This method emits an event to play a sound only for this specific player.
|
|
314
|
+
* The sound must be defined on the client side (in the client module configuration).
|
|
315
|
+
*
|
|
316
|
+
* ## Design
|
|
317
|
+
*
|
|
318
|
+
* The sound is sent only to this player's client connection, making it ideal
|
|
319
|
+
* for personal feedback sounds like UI interactions, notifications, or personal
|
|
320
|
+
* achievements. For map-wide sounds that all players should hear, use `map.playSound()` instead.
|
|
321
|
+
*
|
|
322
|
+
* @param soundId - Sound identifier, defined on the client side
|
|
323
|
+
* @param options - Optional sound configuration
|
|
324
|
+
* @param options.volume - Volume level (0.0 to 1.0, default: 1.0)
|
|
325
|
+
* @param options.loop - Whether the sound should loop (default: false)
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```ts
|
|
329
|
+
* // Play a sound for this player only (default behavior)
|
|
330
|
+
* player.playSound("item-pickup");
|
|
331
|
+
*
|
|
332
|
+
* // Play a sound with volume and loop
|
|
333
|
+
* player.playSound("background-music", {
|
|
334
|
+
* volume: 0.5,
|
|
335
|
+
* loop: true
|
|
336
|
+
* });
|
|
337
|
+
*
|
|
338
|
+
* // Play a notification sound at low volume
|
|
339
|
+
* player.playSound("notification", { volume: 0.3 });
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
playSound(soundId: string, options?: {
|
|
343
|
+
volume?: number;
|
|
344
|
+
loop?: boolean;
|
|
345
|
+
}): void;
|
|
346
|
+
/**
|
|
347
|
+
* Stop a sound that is currently playing for this player
|
|
348
|
+
*
|
|
349
|
+
* This method stops a sound that was previously started with `playSound()`.
|
|
350
|
+
* The sound must be defined on the client side.
|
|
351
|
+
*
|
|
352
|
+
* @param soundId - Sound identifier to stop
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* ```ts
|
|
356
|
+
* // Start a looping background music
|
|
357
|
+
* player.playSound("background-music", { loop: true });
|
|
358
|
+
*
|
|
359
|
+
* // Later, stop it
|
|
360
|
+
* player.stopSound("background-music");
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
stopSound(soundId: string): void;
|
|
364
|
+
/**
|
|
365
|
+
* Stop all currently playing sounds for this player
|
|
366
|
+
*
|
|
367
|
+
* This method stops all sounds that are currently playing for the player.
|
|
368
|
+
* Useful when changing maps to prevent sound overlap.
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```ts
|
|
372
|
+
* // Stop all sounds before changing map
|
|
373
|
+
* player.stopAllSounds();
|
|
374
|
+
* await player.changeMap("new-map");
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
stopAllSounds(): void;
|
|
378
|
+
/**
|
|
379
|
+
* Make the camera follow another player or event
|
|
380
|
+
*
|
|
381
|
+
* This method sends an instruction to the client to fix the viewport on another sprite.
|
|
382
|
+
* The camera will follow the specified player or event, with optional smooth animation.
|
|
383
|
+
*
|
|
384
|
+
* ## Design
|
|
385
|
+
*
|
|
386
|
+
* The camera follow instruction is sent only to this player's client connection.
|
|
387
|
+
* This allows each player to have their own camera target, useful for cutscenes,
|
|
388
|
+
* following NPCs, or focusing on specific events.
|
|
389
|
+
*
|
|
390
|
+
* @param otherPlayer - The player or event that the camera should follow
|
|
391
|
+
* @param options - Camera follow options
|
|
392
|
+
* @param options.smoothMove - Enable smooth animation. Can be a boolean (default: true) or an object with animation parameters
|
|
393
|
+
* @param options.smoothMove.time - Time duration for the animation in milliseconds (optional)
|
|
394
|
+
* @param options.smoothMove.ease - Easing function name. Visit https://easings.net for available functions (optional)
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* // Follow another player with default smooth animation
|
|
399
|
+
* player.cameraFollow(otherPlayer, { smoothMove: true });
|
|
400
|
+
*
|
|
401
|
+
* // Follow an event with custom smooth animation
|
|
402
|
+
* player.cameraFollow(npcEvent, {
|
|
403
|
+
* smoothMove: {
|
|
404
|
+
* time: 1000,
|
|
405
|
+
* ease: "easeInOutQuad"
|
|
406
|
+
* }
|
|
407
|
+
* });
|
|
408
|
+
*
|
|
409
|
+
* // Follow without animation (instant)
|
|
410
|
+
* player.cameraFollow(targetPlayer, { smoothMove: false });
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
cameraFollow(otherPlayer: RpgPlayer | RpgEvent, options?: {
|
|
414
|
+
smoothMove?: boolean | {
|
|
415
|
+
time?: number;
|
|
416
|
+
ease?: string;
|
|
417
|
+
};
|
|
418
|
+
}): void;
|
|
419
|
+
/**
|
|
420
|
+
* Trigger a flash animation on this player
|
|
421
|
+
*
|
|
422
|
+
* This method sends a flash animation event to the client, creating a visual
|
|
423
|
+
* feedback effect on the player's sprite. The flash can be configured with
|
|
424
|
+
* various options including type (alpha, tint, or both), duration, cycles, and color.
|
|
425
|
+
*
|
|
426
|
+
* ## Design
|
|
427
|
+
*
|
|
428
|
+
* The flash is sent as a broadcast event to all clients viewing this player.
|
|
429
|
+
* This is useful for visual feedback when the player takes damage, receives
|
|
430
|
+
* a buff, or when an important event occurs.
|
|
431
|
+
*
|
|
432
|
+
* @param options - Flash configuration options
|
|
433
|
+
* @param options.type - Type of flash effect: 'alpha' (opacity), 'tint' (color), or 'both' (default: 'alpha')
|
|
434
|
+
* @param options.duration - Duration of the flash animation in milliseconds (default: 300)
|
|
435
|
+
* @param options.cycles - Number of flash cycles (flash on/off) (default: 1)
|
|
436
|
+
* @param options.alpha - Alpha value when flashing, from 0 to 1 (default: 0.3)
|
|
437
|
+
* @param options.tint - Tint color when flashing as hex value or color name (default: 0xffffff - white)
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```ts
|
|
441
|
+
* // Simple flash with default settings (alpha flash)
|
|
442
|
+
* player.flash();
|
|
443
|
+
*
|
|
444
|
+
* // Flash with red tint when taking damage
|
|
445
|
+
* player.flash({ type: 'tint', tint: 0xff0000 });
|
|
446
|
+
*
|
|
447
|
+
* // Flash with both alpha and tint for dramatic effect
|
|
448
|
+
* player.flash({
|
|
449
|
+
* type: 'both',
|
|
450
|
+
* alpha: 0.5,
|
|
451
|
+
* tint: 0xff0000,
|
|
452
|
+
* duration: 200,
|
|
453
|
+
* cycles: 2
|
|
454
|
+
* });
|
|
455
|
+
*
|
|
456
|
+
* // Quick damage flash
|
|
457
|
+
* player.flash({
|
|
458
|
+
* type: 'tint',
|
|
459
|
+
* tint: 'red',
|
|
460
|
+
* duration: 150,
|
|
461
|
+
* cycles: 1
|
|
462
|
+
* });
|
|
463
|
+
* ```
|
|
464
|
+
*/
|
|
465
|
+
flash(options?: {
|
|
466
|
+
type?: 'alpha' | 'tint' | 'both';
|
|
467
|
+
duration?: number;
|
|
468
|
+
cycles?: number;
|
|
469
|
+
alpha?: number;
|
|
470
|
+
tint?: number | string;
|
|
471
|
+
}): void;
|
|
472
|
+
/**
|
|
473
|
+
* Set the hitbox of the player for collision detection
|
|
474
|
+
*
|
|
475
|
+
* This method defines the hitbox used for collision detection in the physics engine.
|
|
476
|
+
* The hitbox can be smaller or larger than the visual representation of the player,
|
|
477
|
+
* allowing for precise collision detection.
|
|
478
|
+
*
|
|
479
|
+
* ## Design
|
|
480
|
+
*
|
|
481
|
+
* The hitbox is used by the physics engine to detect collisions with other entities,
|
|
482
|
+
* static obstacles, and shapes. Changing the hitbox will immediately update the
|
|
483
|
+
* collision detection without affecting the visual appearance of the player.
|
|
484
|
+
*
|
|
485
|
+
* @param width - Width of the hitbox in pixels
|
|
486
|
+
* @param height - Height of the hitbox in pixels
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* ```ts
|
|
490
|
+
* // Set a 20x20 hitbox for precise collision detection
|
|
491
|
+
* player.setHitbox(20, 20);
|
|
492
|
+
*
|
|
493
|
+
* // Set a larger hitbox for easier collision detection
|
|
494
|
+
* player.setHitbox(40, 40);
|
|
495
|
+
* ```
|
|
496
|
+
*/
|
|
497
|
+
setHitbox(width: number, height: number): void;
|
|
498
|
+
/**
|
|
499
|
+
* Set the sync schema for the map
|
|
500
|
+
* @param schema - The schema to set
|
|
501
|
+
*/
|
|
502
|
+
setSync(schema: any): void;
|
|
503
|
+
isEvent(): boolean;
|
|
66
504
|
}
|
|
67
505
|
export declare class RpgEvent extends RpgPlayer {
|
|
506
|
+
constructor();
|
|
68
507
|
execMethod(methodName: string, methodData?: any[], instance?: this): Promise<any>;
|
|
508
|
+
/**
|
|
509
|
+
* Remove this event from the map
|
|
510
|
+
*
|
|
511
|
+
* Stops all movements before removing to prevent "unable to resolve entity" errors
|
|
512
|
+
* from the MovementManager when the entity is destroyed while moving.
|
|
513
|
+
*/
|
|
69
514
|
remove(): void;
|
|
515
|
+
isEvent(): boolean;
|
|
70
516
|
}
|
|
71
|
-
|
|
517
|
+
/**
|
|
518
|
+
* Interface extension for RpgPlayer
|
|
519
|
+
*
|
|
520
|
+
* Extends the RpgPlayer class with additional interfaces from mixins.
|
|
521
|
+
* This provides proper TypeScript support for all mixin methods and properties.
|
|
522
|
+
*/
|
|
523
|
+
export interface RpgPlayer extends IVariableManager, IMoveManager, IGoldManager, IComponentManager, IGuiManager, IItemManager, IEffectManager, IParameterManager, IElementManager, ISkillManager, IBattleManager, IClassManager, IStateManager {
|
|
72
524
|
}
|
|
73
525
|
export {};
|