@rpgjs/client 5.0.0-alpha.21 → 5.0.0-alpha.23
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/Object.d.ts +111 -0
- package/dist/Game/TransitionManager.d.ts +56 -0
- package/dist/RpgClientEngine.d.ts +306 -9
- package/dist/components/gui/mobile/index.d.ts +8 -0
- package/dist/components/prebuilt/index.d.ts +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.js +6 -5
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +2 -2
- package/dist/index13.js +102 -10
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +68 -9
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +10 -224
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +9 -97
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +300 -89
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +63 -80
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +96 -348
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +387 -21
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +361 -5
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +19 -50
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +212 -5
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +6 -395
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +4 -39
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +19 -20
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +44 -2624
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +5 -110
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +394 -65
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +40 -15
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +3 -3
- package/dist/index30.js +21 -23
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +49 -91
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +2624 -32
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +108 -18
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +69 -3
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +17 -331
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +24 -24
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +92 -8
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +37 -7
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +22 -10
- package/dist/index39.js.map +1 -1
- package/dist/index4.js +3 -3
- package/dist/index40.js +140 -6
- package/dist/index40.js.map +1 -1
- package/dist/index41.js +31 -3678
- package/dist/index41.js.map +1 -1
- package/dist/index42.js +3 -185
- package/dist/index42.js.map +1 -1
- package/dist/index43.js +172 -489
- package/dist/index43.js.map +1 -1
- package/dist/index44.js +498 -71
- package/dist/index44.js.map +1 -1
- package/dist/index45.js +331 -2
- package/dist/index45.js.map +1 -1
- package/dist/index46.js +25 -11
- package/dist/index46.js.map +1 -1
- package/dist/index47.js +70 -139
- package/dist/index47.js.map +1 -1
- package/dist/index48.js +9 -9
- package/dist/index48.js.map +1 -1
- package/dist/index49.js +6 -112
- package/dist/index49.js.map +1 -1
- package/dist/index5.js +1 -1
- package/dist/index50.js +3678 -124
- package/dist/index50.js.map +1 -1
- package/dist/index51.js +48 -131
- package/dist/index51.js.map +1 -1
- package/dist/index52.js +17 -109
- package/dist/index52.js.map +1 -1
- package/dist/index53.js +3 -138
- package/dist/index53.js.map +1 -1
- package/dist/index54.js +10 -7
- package/dist/index54.js.map +1 -1
- package/dist/index55.js +107 -48
- package/dist/index55.js.map +1 -1
- package/dist/index56.js +136 -0
- package/dist/index56.js.map +1 -0
- package/dist/index57.js +137 -0
- package/dist/index57.js.map +1 -0
- package/dist/index58.js +112 -0
- package/dist/index58.js.map +1 -0
- package/dist/index59.js +9 -0
- package/dist/index59.js.map +1 -0
- package/dist/index6.js +1 -1
- package/dist/index7.js +1 -1
- package/dist/index8.js +20 -2
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +11 -27
- package/dist/index9.js.map +1 -1
- package/dist/module.d.ts +43 -4
- package/dist/services/keyboardControls.d.ts +11 -1
- package/package.json +11 -10
- package/src/Game/Object.ts +90 -8
- package/src/Game/TransitionManager.ts +75 -0
- package/src/Gui/Gui.ts +5 -31
- package/src/RpgClientEngine.ts +430 -16
- package/src/components/character.ce +212 -11
- package/src/components/gui/mobile/index.ts +24 -0
- package/src/components/gui/mobile/mobile.ce +95 -0
- package/src/components/prebuilt/index.ts +2 -0
- package/src/components/prebuilt/light-halo.ce +217 -0
- package/src/components/scenes/canvas.ce +12 -2
- package/src/components/scenes/draw-map.ce +12 -3
- package/src/components/scenes/transition.ce +60 -0
- package/src/index.ts +7 -1
- package/src/module.ts +66 -2
- package/src/services/keyboardControls.ts +14 -2
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Hooks, RpgCommonPlayer } from '@rpgjs/common';
|
|
2
|
+
import { RpgClientEngine } from '../RpgClientEngine';
|
|
3
|
+
export declare abstract class RpgClientObject extends RpgCommonPlayer {
|
|
4
|
+
abstract type: string;
|
|
5
|
+
emitParticleTrigger: import('canvasengine').Trigger<any>;
|
|
6
|
+
particleName: import('canvasengine').WritableSignal<string>;
|
|
7
|
+
animationCurrentIndex: import('canvasengine').WritableSignal<number>;
|
|
8
|
+
animationIsPlaying: import('canvasengine').WritableSignal<boolean>;
|
|
9
|
+
_param: import('canvasengine').WritableObjectSignal<{}>;
|
|
10
|
+
frames: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
ts: number;
|
|
14
|
+
}[];
|
|
15
|
+
graphicsSignals: import('canvasengine').WritableArraySignal<any[]>;
|
|
16
|
+
_component: {};
|
|
17
|
+
flashTrigger: import('canvasengine').Trigger<any>;
|
|
18
|
+
constructor();
|
|
19
|
+
get hooks(): Hooks;
|
|
20
|
+
get engine(): RpgClientEngine<unknown>;
|
|
21
|
+
private animationSubscription?;
|
|
22
|
+
/**
|
|
23
|
+
* Trigger a flash animation on this sprite
|
|
24
|
+
*
|
|
25
|
+
* This method triggers a flash effect using CanvasEngine's flash directive.
|
|
26
|
+
* The flash can be configured with various options including type (alpha, tint, or both),
|
|
27
|
+
* duration, cycles, and color.
|
|
28
|
+
*
|
|
29
|
+
* ## Design
|
|
30
|
+
*
|
|
31
|
+
* The flash uses a trigger system that is connected to the flash directive in the
|
|
32
|
+
* character component. This allows for flexible configuration and can be triggered
|
|
33
|
+
* from both server events and client-side code.
|
|
34
|
+
*
|
|
35
|
+
* @param options - Flash configuration options
|
|
36
|
+
* @param options.type - Type of flash effect: 'alpha' (opacity), 'tint' (color), or 'both' (default: 'alpha')
|
|
37
|
+
* @param options.duration - Duration of the flash animation in milliseconds (default: 300)
|
|
38
|
+
* @param options.cycles - Number of flash cycles (flash on/off) (default: 1)
|
|
39
|
+
* @param options.alpha - Alpha value when flashing, from 0 to 1 (default: 0.3)
|
|
40
|
+
* @param options.tint - Tint color when flashing as hex value or color name (default: 0xffffff - white)
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* // Simple flash with default settings (alpha flash)
|
|
45
|
+
* player.flash();
|
|
46
|
+
*
|
|
47
|
+
* // Flash with red tint
|
|
48
|
+
* player.flash({ type: 'tint', tint: 0xff0000 });
|
|
49
|
+
*
|
|
50
|
+
* // Flash with both alpha and tint
|
|
51
|
+
* player.flash({
|
|
52
|
+
* type: 'both',
|
|
53
|
+
* alpha: 0.5,
|
|
54
|
+
* tint: 0xff0000,
|
|
55
|
+
* duration: 200,
|
|
56
|
+
* cycles: 2
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* // Quick damage flash
|
|
60
|
+
* player.flash({
|
|
61
|
+
* type: 'tint',
|
|
62
|
+
* tint: 0xff0000,
|
|
63
|
+
* duration: 150,
|
|
64
|
+
* cycles: 1
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
flash(options?: {
|
|
69
|
+
type?: 'alpha' | 'tint' | 'both';
|
|
70
|
+
duration?: number;
|
|
71
|
+
cycles?: number;
|
|
72
|
+
alpha?: number;
|
|
73
|
+
tint?: number | string;
|
|
74
|
+
}): void;
|
|
75
|
+
/**
|
|
76
|
+
* Reset animation state when animation changes externally
|
|
77
|
+
*
|
|
78
|
+
* This method should be called when the animation changes due to movement
|
|
79
|
+
* or other external factors to ensure the animation system doesn't get stuck
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* // Reset when player starts moving
|
|
84
|
+
* player.resetAnimationState();
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
resetAnimationState(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Set a custom animation for a specific number of times
|
|
90
|
+
*
|
|
91
|
+
* Plays a custom animation for the specified number of repetitions.
|
|
92
|
+
* The animation system prevents overlapping animations and automatically
|
|
93
|
+
* returns to the previous animation when complete.
|
|
94
|
+
*
|
|
95
|
+
* @param animationName - Name of the animation to play
|
|
96
|
+
* @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* // Play attack animation 3 times
|
|
101
|
+
* player.setAnimation('attack', 3);
|
|
102
|
+
*
|
|
103
|
+
* // Play continuous spell animation
|
|
104
|
+
* player.setAnimation('spell');
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
setAnimation(animationName: string, nbTimes?: number): void;
|
|
108
|
+
showComponentAnimation(id: string, params: any): void;
|
|
109
|
+
isEvent(): boolean;
|
|
110
|
+
isPlayer(): boolean;
|
|
111
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages active transitions in the game
|
|
3
|
+
*
|
|
4
|
+
* This class handles the lifecycle of screen transitions, such as fade effects,
|
|
5
|
+
* slide transitions, or any custom transition components. It maintains a list
|
|
6
|
+
* of currently active transitions and provides methods to start and finish them.
|
|
7
|
+
*
|
|
8
|
+
* ## Design
|
|
9
|
+
*
|
|
10
|
+
* - Uses signals to track active transitions reactively
|
|
11
|
+
* - Each transition has a unique ID for identification
|
|
12
|
+
* - Transitions automatically remove themselves when finished via onFinish callback
|
|
13
|
+
* - Supports multiple simultaneous transitions if needed
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const manager = new TransitionManager();
|
|
18
|
+
*
|
|
19
|
+
* // Start a fade transition
|
|
20
|
+
* manager.start('fade', { duration: 1000 });
|
|
21
|
+
*
|
|
22
|
+
* // Check active transitions
|
|
23
|
+
* console.log(manager.current()); // Array of active transitions
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class TransitionManager {
|
|
27
|
+
/**
|
|
28
|
+
* Signal containing all currently active transitions
|
|
29
|
+
*
|
|
30
|
+
* Each transition object contains:
|
|
31
|
+
* - id: Unique identifier
|
|
32
|
+
* - props: Properties passed to the transition component
|
|
33
|
+
* - onFinish: Callback to remove the transition when complete
|
|
34
|
+
*/
|
|
35
|
+
current: import('canvasengine').WritableArraySignal<any[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Start a new transition
|
|
38
|
+
*
|
|
39
|
+
* Creates a new transition instance with the given props and adds it to
|
|
40
|
+
* the active transitions list. The transition will be automatically removed
|
|
41
|
+
* when it calls its onFinish callback.
|
|
42
|
+
*
|
|
43
|
+
* @param props - Properties to pass to the transition component (must include onFinish)
|
|
44
|
+
* @returns The created transition object with id and onFinish callback
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const transition = manager.start({
|
|
49
|
+
* duration: 1000,
|
|
50
|
+
* color: 'black',
|
|
51
|
+
* onFinish: () => console.log('Transition complete')
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
start(props: any): any;
|
|
56
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Context } from '@signe/di';
|
|
2
1
|
import { AbstractWebsocket } from './services/AbstractSocket';
|
|
3
2
|
import { Direction } from '@rpgjs/common';
|
|
4
3
|
import { RpgClientMap } from './Game/Map';
|
|
5
4
|
import { AnimationManager } from './Game/AnimationManager';
|
|
5
|
+
import { TransitionManager } from './Game/TransitionManager';
|
|
6
6
|
import { Observable } from 'rxjs';
|
|
7
7
|
import * as PIXI from "pixi.js";
|
|
8
8
|
export declare class RpgClientEngine<T = any> {
|
|
9
|
-
context:
|
|
9
|
+
context: any;
|
|
10
10
|
private guiService;
|
|
11
11
|
private webSocket;
|
|
12
12
|
private loadMapService;
|
|
@@ -21,6 +21,7 @@ export declare class RpgClientEngine<T = any> {
|
|
|
21
21
|
spritesheets: Map<string, any>;
|
|
22
22
|
sounds: Map<string, any>;
|
|
23
23
|
componentAnimations: any[];
|
|
24
|
+
transitions: any[];
|
|
24
25
|
private spritesheetResolver?;
|
|
25
26
|
private soundResolver?;
|
|
26
27
|
particleSettings: {
|
|
@@ -31,6 +32,10 @@ export declare class RpgClientEngine<T = any> {
|
|
|
31
32
|
playerIdSignal: import('canvasengine').WritableSignal<string | null>;
|
|
32
33
|
spriteComponentsBehind: import('canvasengine').WritableArraySignal<any[]>;
|
|
33
34
|
spriteComponentsInFront: import('canvasengine').WritableArraySignal<any[]>;
|
|
35
|
+
/** ID of the sprite that the camera should follow. null means follow the current player */
|
|
36
|
+
cameraFollowTargetId: import('canvasengine').WritableSignal<string | null>;
|
|
37
|
+
/** Trigger for map shake animation */
|
|
38
|
+
mapShakeTrigger: import('canvasengine').Trigger<any>;
|
|
34
39
|
private predictionEnabled;
|
|
35
40
|
private prediction?;
|
|
36
41
|
private readonly SERVER_CORRECTION_THRESHOLD;
|
|
@@ -40,7 +45,7 @@ export declare class RpgClientEngine<T = any> {
|
|
|
40
45
|
private pingInterval;
|
|
41
46
|
private readonly PING_INTERVAL_MS;
|
|
42
47
|
private lastInputTime;
|
|
43
|
-
constructor(context:
|
|
48
|
+
constructor(context: any);
|
|
44
49
|
/**
|
|
45
50
|
* Assigns a CanvasEngine KeyboardControls instance to the dependency injection context
|
|
46
51
|
*
|
|
@@ -291,18 +296,96 @@ export declare class RpgClientEngine<T = any> {
|
|
|
291
296
|
* ```
|
|
292
297
|
*/
|
|
293
298
|
stopSound(soundId: string): void;
|
|
299
|
+
/**
|
|
300
|
+
* Stop all currently playing sounds
|
|
301
|
+
*
|
|
302
|
+
* This method stops all sounds that are currently playing.
|
|
303
|
+
* Useful when changing maps to prevent sound overlap.
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```ts
|
|
307
|
+
* // Stop all sounds
|
|
308
|
+
* engine.stopAllSounds();
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
stopAllSounds(): void;
|
|
312
|
+
/**
|
|
313
|
+
* Set the camera to follow a specific sprite
|
|
314
|
+
*
|
|
315
|
+
* This method changes which sprite the camera viewport should follow.
|
|
316
|
+
* The camera will smoothly animate to the target sprite if smoothMove options are provided.
|
|
317
|
+
*
|
|
318
|
+
* ## Design
|
|
319
|
+
*
|
|
320
|
+
* The camera follow target is stored in a signal that is read by sprite components.
|
|
321
|
+
* Each sprite checks if it should be followed by comparing its ID with the target ID.
|
|
322
|
+
* When smoothMove options are provided, the viewport animation is handled by CanvasEngine's
|
|
323
|
+
* viewport system.
|
|
324
|
+
*
|
|
325
|
+
* @param targetId - The ID of the sprite to follow. Set to null to follow the current player
|
|
326
|
+
* @param smoothMove - Animation options. Can be a boolean (default: true) or an object with time and ease
|
|
327
|
+
* @param smoothMove.time - Duration of the animation in milliseconds (optional)
|
|
328
|
+
* @param smoothMove.ease - Easing function name from https://easings.net (optional)
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* // Follow another player with default smooth animation
|
|
333
|
+
* engine.setCameraFollow(otherPlayerId, true);
|
|
334
|
+
*
|
|
335
|
+
* // Follow an event with custom smooth animation
|
|
336
|
+
* engine.setCameraFollow(eventId, {
|
|
337
|
+
* time: 1000,
|
|
338
|
+
* ease: "easeInOutQuad"
|
|
339
|
+
* });
|
|
340
|
+
*
|
|
341
|
+
* // Follow without animation (instant)
|
|
342
|
+
* engine.setCameraFollow(targetId, false);
|
|
343
|
+
*
|
|
344
|
+
* // Return to following current player
|
|
345
|
+
* engine.setCameraFollow(null);
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
setCameraFollow(targetId: string | null, smoothMove?: boolean | {
|
|
349
|
+
time?: number;
|
|
350
|
+
ease?: string;
|
|
351
|
+
}): void;
|
|
294
352
|
addParticle(particle: any): any;
|
|
295
353
|
/**
|
|
296
354
|
* Add a component to render behind sprites
|
|
297
355
|
* Components added with this method will be displayed with a lower z-index than the sprite
|
|
298
356
|
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
357
|
+
* Supports multiple formats:
|
|
358
|
+
* 1. Direct component: `ShadowComponent`
|
|
359
|
+
* 2. Configuration object: `{ component: LightHalo, props: {...} }`
|
|
360
|
+
* 3. With dynamic props: `{ component: LightHalo, props: (object) => {...} }`
|
|
361
|
+
* 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`
|
|
362
|
+
*
|
|
363
|
+
* Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).
|
|
364
|
+
* The object (sprite) is passed to the dependencies function to allow sprite-specific dependency resolution.
|
|
365
|
+
*
|
|
366
|
+
* @param component - The component to add behind sprites, or a configuration object
|
|
367
|
+
* @param component.component - The component function to render
|
|
368
|
+
* @param component.props - Static props object or function that receives the sprite object and returns props
|
|
369
|
+
* @param component.dependencies - Function that receives the sprite object and returns an array of Signals
|
|
370
|
+
* @returns The added component or configuration
|
|
301
371
|
*
|
|
302
372
|
* @example
|
|
303
373
|
* ```ts
|
|
304
374
|
* // Add a shadow component behind all sprites
|
|
305
375
|
* engine.addSpriteComponentBehind(ShadowComponent);
|
|
376
|
+
*
|
|
377
|
+
* // Add a component with static props
|
|
378
|
+
* engine.addSpriteComponentBehind({
|
|
379
|
+
* component: LightHalo,
|
|
380
|
+
* props: { radius: 30 }
|
|
381
|
+
* });
|
|
382
|
+
*
|
|
383
|
+
* // Add a component with dynamic props and dependencies
|
|
384
|
+
* engine.addSpriteComponentBehind({
|
|
385
|
+
* component: HealthBar,
|
|
386
|
+
* props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),
|
|
387
|
+
* dependencies: (object) => [object.hp, object.param.maxHp]
|
|
388
|
+
* });
|
|
306
389
|
* ```
|
|
307
390
|
*/
|
|
308
391
|
addSpriteComponentBehind(component: any): any;
|
|
@@ -310,16 +393,45 @@ export declare class RpgClientEngine<T = any> {
|
|
|
310
393
|
* Add a component to render in front of sprites
|
|
311
394
|
* Components added with this method will be displayed with a higher z-index than the sprite
|
|
312
395
|
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
396
|
+
* Supports multiple formats:
|
|
397
|
+
* 1. Direct component: `HealthBarComponent`
|
|
398
|
+
* 2. Configuration object: `{ component: StatusIndicator, props: {...} }`
|
|
399
|
+
* 3. With dynamic props: `{ component: HealthBar, props: (object) => {...} }`
|
|
400
|
+
* 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`
|
|
401
|
+
*
|
|
402
|
+
* Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).
|
|
403
|
+
* The object (sprite) is passed to the dependencies function to allow sprite-specific dependency resolution.
|
|
404
|
+
*
|
|
405
|
+
* @param component - The component to add in front of sprites, or a configuration object
|
|
406
|
+
* @param component.component - The component function to render
|
|
407
|
+
* @param component.props - Static props object or function that receives the sprite object and returns props
|
|
408
|
+
* @param component.dependencies - Function that receives the sprite object and returns an array of Signals
|
|
409
|
+
* @returns The added component or configuration
|
|
315
410
|
*
|
|
316
411
|
* @example
|
|
317
412
|
* ```ts
|
|
318
413
|
* // Add a health bar component in front of all sprites
|
|
319
414
|
* engine.addSpriteComponentInFront(HealthBarComponent);
|
|
415
|
+
*
|
|
416
|
+
* // Add a component with static props
|
|
417
|
+
* engine.addSpriteComponentInFront({
|
|
418
|
+
* component: StatusIndicator,
|
|
419
|
+
* props: { type: 'poison' }
|
|
420
|
+
* });
|
|
421
|
+
*
|
|
422
|
+
* // Add a component with dynamic props and dependencies
|
|
423
|
+
* engine.addSpriteComponentInFront({
|
|
424
|
+
* component: HealthBar,
|
|
425
|
+
* props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),
|
|
426
|
+
* dependencies: (object) => [object.hp, object.param.maxHp]
|
|
427
|
+
* });
|
|
320
428
|
* ```
|
|
321
429
|
*/
|
|
322
|
-
addSpriteComponentInFront(component: any
|
|
430
|
+
addSpriteComponentInFront(component: any | {
|
|
431
|
+
component: any;
|
|
432
|
+
props: (object: any) => any;
|
|
433
|
+
dependencies?: (object: any) => any[];
|
|
434
|
+
}): any;
|
|
323
435
|
/**
|
|
324
436
|
* Add a component animation to the engine
|
|
325
437
|
*
|
|
@@ -371,6 +483,137 @@ export declare class RpgClientEngine<T = any> {
|
|
|
371
483
|
* ```
|
|
372
484
|
*/
|
|
373
485
|
getComponentAnimation(id: string): AnimationManager;
|
|
486
|
+
/**
|
|
487
|
+
* Add a transition to the engine
|
|
488
|
+
*
|
|
489
|
+
* Transitions are screen effects that can be displayed during scene changes,
|
|
490
|
+
* map loading, or any other moment where a visual transition is needed.
|
|
491
|
+
* They are displayed on top of the entire canvas and can have custom props
|
|
492
|
+
* that can be functions (similar to ComponentAnimation).
|
|
493
|
+
*
|
|
494
|
+
* @param transition - The transition configuration
|
|
495
|
+
* @param transition.id - Unique identifier for the transition
|
|
496
|
+
* @param transition.component - The component function to render
|
|
497
|
+
* @param transition.props - Optional props to pass to the component (can be a function)
|
|
498
|
+
* @returns The added transition configuration
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```ts
|
|
502
|
+
* // Add a fade transition
|
|
503
|
+
* engine.addTransition({
|
|
504
|
+
* id: 'fade',
|
|
505
|
+
* component: FadeComponent
|
|
506
|
+
* });
|
|
507
|
+
*
|
|
508
|
+
* // Add a transition with props
|
|
509
|
+
* engine.addTransition({
|
|
510
|
+
* id: 'slide',
|
|
511
|
+
* component: SlideComponent,
|
|
512
|
+
* props: { direction: 'left', duration: 500 }
|
|
513
|
+
* });
|
|
514
|
+
*
|
|
515
|
+
* // Add a transition with function props
|
|
516
|
+
* engine.addTransition({
|
|
517
|
+
* id: 'custom',
|
|
518
|
+
* component: CustomTransition,
|
|
519
|
+
* props: (engine) => ({ width: engine.width(), height: engine.height() })
|
|
520
|
+
* });
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
|
+
addTransition(transition: {
|
|
524
|
+
component: any;
|
|
525
|
+
id: string;
|
|
526
|
+
props?: any | ((engine: RpgClientEngine) => any);
|
|
527
|
+
}): {
|
|
528
|
+
component: any;
|
|
529
|
+
id: string;
|
|
530
|
+
props?: any | ((engine: RpgClientEngine) => any);
|
|
531
|
+
};
|
|
532
|
+
/**
|
|
533
|
+
* Remove a transition from the engine
|
|
534
|
+
*
|
|
535
|
+
* Removes a transition by its ID. This will not affect any currently
|
|
536
|
+
* running transitions, only prevent new ones from being started.
|
|
537
|
+
*
|
|
538
|
+
* @param id - The unique identifier of the transition to remove
|
|
539
|
+
* @returns true if the transition was found and removed, false otherwise
|
|
540
|
+
*
|
|
541
|
+
* @example
|
|
542
|
+
* ```ts
|
|
543
|
+
* // Remove a transition
|
|
544
|
+
* engine.removeTransition('fade');
|
|
545
|
+
* ```
|
|
546
|
+
*/
|
|
547
|
+
removeTransition(id: string): boolean;
|
|
548
|
+
/**
|
|
549
|
+
* Modify an existing transition
|
|
550
|
+
*
|
|
551
|
+
* Updates the component or props of an existing transition. This will
|
|
552
|
+
* not affect any currently running transitions, only future ones.
|
|
553
|
+
*
|
|
554
|
+
* @param id - The unique identifier of the transition to modify
|
|
555
|
+
* @param updates - The updates to apply (component and/or props)
|
|
556
|
+
* @returns true if the transition was found and modified, false otherwise
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* ```ts
|
|
560
|
+
* // Update transition props
|
|
561
|
+
* engine.modifyTransition('fade', {
|
|
562
|
+
* props: { duration: 2000, color: 'white' }
|
|
563
|
+
* });
|
|
564
|
+
*
|
|
565
|
+
* // Update transition component
|
|
566
|
+
* engine.modifyTransition('fade', {
|
|
567
|
+
* component: NewFadeComponent
|
|
568
|
+
* });
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
571
|
+
modifyTransition(id: string, updates: {
|
|
572
|
+
component?: any;
|
|
573
|
+
props?: any | ((engine: RpgClientEngine) => any);
|
|
574
|
+
}): boolean;
|
|
575
|
+
/**
|
|
576
|
+
* Get a transition by its ID
|
|
577
|
+
*
|
|
578
|
+
* Retrieves the TransitionManager instance for a specific transition,
|
|
579
|
+
* which can be used to start the transition.
|
|
580
|
+
*
|
|
581
|
+
* @param id - The unique identifier of the transition
|
|
582
|
+
* @returns The TransitionManager instance for the transition
|
|
583
|
+
* @throws Error if the transition is not found
|
|
584
|
+
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```ts
|
|
587
|
+
* // Get a transition and start it
|
|
588
|
+
* const fadeTransition = engine.getTransition('fade');
|
|
589
|
+
* fadeTransition.start({ duration: 1000 });
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
getTransition(id: string): TransitionManager;
|
|
593
|
+
/**
|
|
594
|
+
* Start a transition
|
|
595
|
+
*
|
|
596
|
+
* Convenience method to start a transition by its ID. This combines
|
|
597
|
+
* getTransition and start into a single call. The transition will
|
|
598
|
+
* automatically receive an onFinish callback to remove itself when done.
|
|
599
|
+
*
|
|
600
|
+
* @param id - The unique identifier of the transition to start
|
|
601
|
+
* @param props - Additional props to pass to the transition component
|
|
602
|
+
* @returns The created transition object
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* ```ts
|
|
606
|
+
* // Start a fade transition
|
|
607
|
+
* engine.startTransition('fade', { duration: 1000, color: 'black' });
|
|
608
|
+
*
|
|
609
|
+
* // Start with onFinish callback
|
|
610
|
+
* engine.startTransition('fade', {
|
|
611
|
+
* duration: 1000,
|
|
612
|
+
* onFinish: () => console.log('Fade complete')
|
|
613
|
+
* });
|
|
614
|
+
* ```
|
|
615
|
+
*/
|
|
616
|
+
startTransition(id: string, props?: any): any;
|
|
374
617
|
processInput({ input }: {
|
|
375
618
|
input: Direction;
|
|
376
619
|
}): Promise<void>;
|
|
@@ -385,7 +628,7 @@ export declare class RpgClientEngine<T = any> {
|
|
|
385
628
|
private getLocalPlayerState;
|
|
386
629
|
private applyAuthoritativeState;
|
|
387
630
|
private initializePredictionController;
|
|
388
|
-
getCurrentPlayer(): import('
|
|
631
|
+
getCurrentPlayer(): import('.').RpgClientPlayer;
|
|
389
632
|
/**
|
|
390
633
|
* Clear client prediction states for cleanup
|
|
391
634
|
*
|
|
@@ -399,6 +642,60 @@ export declare class RpgClientEngine<T = any> {
|
|
|
399
642
|
* ```
|
|
400
643
|
*/
|
|
401
644
|
clearClientPredictionStates(): void;
|
|
645
|
+
/**
|
|
646
|
+
* Trigger a flash animation on a sprite
|
|
647
|
+
*
|
|
648
|
+
* This method allows you to trigger a flash effect on any sprite from client-side code.
|
|
649
|
+
* The flash can be configured with various options including type (alpha, tint, or both),
|
|
650
|
+
* duration, cycles, and color.
|
|
651
|
+
*
|
|
652
|
+
* ## Design
|
|
653
|
+
*
|
|
654
|
+
* The flash is applied directly to the sprite object using its flash trigger.
|
|
655
|
+
* This is useful for client-side visual feedback, UI interactions, or local effects
|
|
656
|
+
* that don't need to be synchronized with the server.
|
|
657
|
+
*
|
|
658
|
+
* @param spriteId - The ID of the sprite to flash. If not provided, flashes the current player
|
|
659
|
+
* @param options - Flash configuration options
|
|
660
|
+
* @param options.type - Type of flash effect: 'alpha' (opacity), 'tint' (color), or 'both' (default: 'alpha')
|
|
661
|
+
* @param options.duration - Duration of the flash animation in milliseconds (default: 300)
|
|
662
|
+
* @param options.cycles - Number of flash cycles (flash on/off) (default: 1)
|
|
663
|
+
* @param options.alpha - Alpha value when flashing, from 0 to 1 (default: 0.3)
|
|
664
|
+
* @param options.tint - Tint color when flashing as hex value or color name (default: 0xffffff - white)
|
|
665
|
+
*
|
|
666
|
+
* @example
|
|
667
|
+
* ```ts
|
|
668
|
+
* // Flash the current player with default settings
|
|
669
|
+
* engine.flash();
|
|
670
|
+
*
|
|
671
|
+
* // Flash a specific sprite with red tint
|
|
672
|
+
* engine.flash('sprite-id', { type: 'tint', tint: 0xff0000 });
|
|
673
|
+
*
|
|
674
|
+
* // Flash with both alpha and tint for dramatic effect
|
|
675
|
+
* engine.flash(undefined, {
|
|
676
|
+
* type: 'both',
|
|
677
|
+
* alpha: 0.5,
|
|
678
|
+
* tint: 0xff0000,
|
|
679
|
+
* duration: 200,
|
|
680
|
+
* cycles: 2
|
|
681
|
+
* });
|
|
682
|
+
*
|
|
683
|
+
* // Quick damage flash on current player
|
|
684
|
+
* engine.flash(undefined, {
|
|
685
|
+
* type: 'tint',
|
|
686
|
+
* tint: 'red',
|
|
687
|
+
* duration: 150,
|
|
688
|
+
* cycles: 1
|
|
689
|
+
* });
|
|
690
|
+
* ```
|
|
691
|
+
*/
|
|
692
|
+
flash(spriteId?: string, options?: {
|
|
693
|
+
type?: 'alpha' | 'tint' | 'both';
|
|
694
|
+
duration?: number;
|
|
695
|
+
cycles?: number;
|
|
696
|
+
alpha?: number;
|
|
697
|
+
tint?: number | string;
|
|
698
|
+
}): void;
|
|
402
699
|
private applyServerAck;
|
|
403
700
|
/**
|
|
404
701
|
* Replay unacknowledged inputs from a given frame to resimulate client prediction
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const withMobile: () => {
|
|
2
|
+
gui: {
|
|
3
|
+
id: string;
|
|
4
|
+
component: any;
|
|
5
|
+
autoDisplay: boolean;
|
|
6
|
+
dependencies: () => (import('canvasengine').ComputedSignal<import('../../..').RpgClientPlayer> | import('canvasengine').WritableSignal<true | undefined>)[];
|
|
7
|
+
}[];
|
|
8
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -9,10 +9,16 @@ export * from './module';
|
|
|
9
9
|
export * from './Gui/Gui';
|
|
10
10
|
export * from './components/gui';
|
|
11
11
|
export * from './components/animations';
|
|
12
|
+
export * from './components/prebuilt';
|
|
12
13
|
export * from './presets';
|
|
13
14
|
export * from './components';
|
|
14
15
|
export * from './components/gui';
|
|
15
16
|
export * from './Sound';
|
|
16
17
|
export * from './Resource';
|
|
17
18
|
export { Context } from '@signe/di';
|
|
18
|
-
export
|
|
19
|
+
export { KeyboardControls, Input } from 'canvasengine';
|
|
20
|
+
export { Control } from './services/keyboardControls';
|
|
21
|
+
export { RpgClientObject } from './Game/Object';
|
|
22
|
+
export { RpgClientPlayer } from './Game/Player';
|
|
23
|
+
export { RpgClientEvent } from './Game/Event';
|
|
24
|
+
export { withMobile } from './components/gui/mobile';
|
package/dist/index.js
CHANGED
|
@@ -9,12 +9,18 @@ export { RpgGui } from './index9.js';
|
|
|
9
9
|
export { default as DialogboxComponent } from './index10.js';
|
|
10
10
|
export { default as BoxComponent } from './index11.js';
|
|
11
11
|
export { PrebuiltComponentAnimations } from './index12.js';
|
|
12
|
-
export {
|
|
13
|
-
export { default as
|
|
14
|
-
export {
|
|
15
|
-
export { default as
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
12
|
+
export { default as HpBar } from './index13.js';
|
|
13
|
+
export { default as LightHalo } from './index14.js';
|
|
14
|
+
export { Presets } from './index15.js';
|
|
15
|
+
export { default as EventLayerComponent } from './index16.js';
|
|
16
|
+
export { default as CharacterComponent } from './index17.js';
|
|
17
|
+
export { RpgSound, Sound, getSoundMetadata } from './index18.js';
|
|
18
|
+
export { RpgResource } from './index19.js';
|
|
19
|
+
export { Context } from './index20.js';
|
|
20
|
+
export { Input, KeyboardControls } from 'canvasengine';
|
|
21
|
+
export { Control } from './index21.js';
|
|
22
|
+
export { RpgClientObject } from './index22.js';
|
|
23
|
+
export { RpgClientPlayer } from './index23.js';
|
|
24
|
+
export { RpgClientEvent } from './index24.js';
|
|
25
|
+
export { withMobile } from './index25.js';
|
|
20
26
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index10.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useProps, useDefineProps, signal, animatedSignal, computed, trigger, mount, effect, h, Container, Rect, cond, Text, Sprite } from 'canvasengine';
|
|
2
|
-
import component$1 from './
|
|
2
|
+
import component$1 from './index47.js';
|
|
3
3
|
import { inject } from './index6.js';
|
|
4
4
|
import { RpgClientEngine } from './index2.js';
|
|
5
5
|
|
package/dist/index11.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { useProps, useDefineProps, computed, h, Container, Rect } from 'canvasengine';
|
|
2
2
|
import { RpgClientEngine } from './index2.js';
|
|
3
|
-
import './
|
|
3
|
+
import './index32.js';
|
|
4
4
|
import '@rpgjs/common';
|
|
5
|
-
import './
|
|
5
|
+
import './index20.js';
|
|
6
6
|
import { inject } from './index6.js';
|
|
7
7
|
import 'rxjs';
|
|
8
|
-
import './
|
|
9
|
-
import './index17.js';
|
|
10
|
-
import '@canvasengine/presets';
|
|
8
|
+
import './index33.js';
|
|
11
9
|
import './index18.js';
|
|
10
|
+
import 'pixi.js';
|
|
11
|
+
import '@canvasengine/presets';
|
|
12
|
+
import './index19.js';
|
|
12
13
|
|
|
13
14
|
function component($$props) {
|
|
14
15
|
useProps($$props);
|
package/dist/index11.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index11.js","sources":["../src/components/gui/box.ce"],"sourcesContent":["<Container positionType=\"absolute\" top={top} left={left}>\n <Container\n anchor={[0.5, 0.5]}\n >\n <Rect width height color={_color} />\n <Container attach={child}></Container>\n </Container> \n</Container>\n\n<script>\n import { RpgClientEngine, inject } from \"../../index\";\n\n const { width, height, children, color, top, left } = defineProps();\n const engine = inject(RpgClientEngine)\n const child = children[0]\n const _color = computed(() => engine.globalConfig.gui?.windowColor || color?.() || \"#1a1a2e\")\n</script>"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index11.js","sources":["../src/components/gui/box.ce"],"sourcesContent":["<Container positionType=\"absolute\" top={top} left={left}>\n <Container\n anchor={[0.5, 0.5]}\n >\n <Rect width height color={_color} />\n <Container attach={child}></Container>\n </Container> \n</Container>\n\n<script>\n import { RpgClientEngine, inject } from \"../../index\";\n\n const { width, height, children, color, top, left } = defineProps();\n const engine = inject(RpgClientEngine)\n const child = children[0]\n const _color = computed(() => engine.globalConfig.gui?.windowColor || color?.() || \"#1a1a2e\")\n</script>"],"names":[],"mappings":";;;;;;;;;;;;;AAOqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,EAAE,GAAG,WAAW,EAAE,EAAE,KAAK,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI;AAC5I,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AACpC,IAAI,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC;AACvB,IAAI,MAAM,GAAG,QAAQ,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,WAAW,MAAM,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC;AAClN,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACvM,QAAQ,OAAO;AACf,MAAM;;;;"}
|
package/dist/index12.js
CHANGED