@rpgjs/client 5.0.0-alpha.2 → 5.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Game/AnimationManager.d.ts +8 -0
- package/dist/Game/Map.d.ts +7 -1
- package/dist/Gui/Gui.d.ts +170 -5
- package/dist/Resource.d.ts +97 -0
- package/dist/RpgClient.d.ts +259 -59
- package/dist/RpgClientEngine.d.ts +379 -6
- package/dist/Sound.d.ts +199 -0
- package/dist/components/animations/index.d.ts +4 -0
- package/dist/components/dynamics/parse-value.d.ts +1 -0
- package/dist/components/gui/index.d.ts +3 -3
- package/dist/components/index.d.ts +3 -1
- package/dist/components/prebuilt/index.d.ts +18 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/index10.js +149 -4
- package/dist/index10.js.map +1 -1
- package/dist/index11.js +22 -7
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +6 -4
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +11 -14
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +8 -40
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +217 -180
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +104 -7
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +82 -372
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +110 -27
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +360 -18
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +726 -32
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +5 -2416
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +47 -109
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +7 -107
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +394 -65
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +40 -15
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +20 -36
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +2629 -1
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +102 -310
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +63 -17
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +18 -8
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +70 -8
- package/dist/index3.js.map +1 -1
- package/dist/index30.js +24 -8
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +88 -167
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +34 -494
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +22 -10
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +3 -4401
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +20 -1
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +18 -82
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +8 -58
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +4 -13
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +10 -18
- package/dist/index39.js.map +1 -1
- package/dist/index4.js +25 -5
- package/dist/index4.js.map +1 -1
- package/dist/index40.js +7 -0
- package/dist/index40.js.map +1 -0
- package/dist/index41.js +3690 -0
- package/dist/index41.js.map +1 -0
- package/dist/index42.js +187 -0
- package/dist/index42.js.map +1 -0
- package/dist/index43.js +504 -0
- package/dist/index43.js.map +1 -0
- package/dist/index44.js +77 -0
- package/dist/index44.js.map +1 -0
- package/dist/index45.js +6 -0
- package/dist/index45.js.map +1 -0
- package/dist/index46.js +20 -0
- package/dist/index46.js.map +1 -0
- package/dist/index47.js +146 -0
- package/dist/index47.js.map +1 -0
- package/dist/index48.js +12 -0
- package/dist/index48.js.map +1 -0
- package/dist/index49.js +113 -0
- package/dist/index49.js.map +1 -0
- package/dist/index5.js +2 -1
- package/dist/index5.js.map +1 -1
- package/dist/index50.js +136 -0
- package/dist/index50.js.map +1 -0
- package/dist/index51.js +137 -0
- package/dist/index51.js.map +1 -0
- package/dist/index52.js +112 -0
- package/dist/index52.js.map +1 -0
- package/dist/index53.js +141 -0
- package/dist/index53.js.map +1 -0
- package/dist/index54.js +9 -0
- package/dist/index54.js.map +1 -0
- package/dist/index55.js +54 -0
- package/dist/index55.js.map +1 -0
- package/dist/index6.js +1 -1
- package/dist/index6.js.map +1 -1
- package/dist/index7.js +11 -3
- package/dist/index7.js.map +1 -1
- package/dist/index8.js +68 -7
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +278 -15
- package/dist/index9.js.map +1 -1
- package/dist/presets/animation.d.ts +31 -0
- package/dist/presets/faceset.d.ts +30 -0
- package/dist/presets/index.d.ts +103 -0
- package/dist/presets/lpc.d.ts +89 -0
- package/dist/services/keyboardControls.d.ts +5 -0
- package/dist/services/loadMap.d.ts +123 -2
- package/dist/services/mmorpg.d.ts +12 -4
- package/dist/services/standalone.d.ts +54 -2
- package/package.json +22 -18
- package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
- package/src/Game/Map.ts +20 -2
- package/src/Game/Object.ts +163 -9
- package/src/Gui/Gui.ts +362 -17
- package/src/Resource.ts +150 -0
- package/src/RpgClient.ts +264 -58
- package/src/RpgClientEngine.ts +848 -36
- package/src/Sound.ts +253 -0
- package/src/components/{effects → animations}/animation.ce +3 -6
- package/src/components/{effects → animations}/index.ts +1 -1
- package/src/components/character.ce +193 -36
- package/src/components/dynamics/parse-value.ts +80 -0
- package/src/components/dynamics/text.ce +183 -0
- package/src/components/gui/box.ce +17 -0
- package/src/components/gui/dialogbox/index.ce +73 -35
- package/src/components/gui/dialogbox/selection.ce +16 -1
- package/src/components/gui/index.ts +3 -4
- package/src/components/index.ts +5 -1
- package/src/components/prebuilt/hp-bar.ce +255 -0
- package/src/components/prebuilt/index.ts +22 -0
- package/src/components/scenes/canvas.ce +12 -10
- package/src/components/scenes/draw-map.ce +6 -23
- package/src/components/scenes/event-layer.ce +9 -3
- package/src/core/setup.ts +2 -0
- package/src/index.ts +7 -2
- package/src/module.ts +72 -6
- package/src/presets/animation.ts +46 -0
- package/src/presets/faceset.ts +60 -0
- package/src/presets/index.ts +7 -1
- package/src/presets/lpc.ts +108 -0
- package/src/services/keyboardControls.ts +8 -0
- package/src/services/loadMap.ts +132 -3
- package/src/services/mmorpg.ts +29 -5
- package/src/services/standalone.ts +70 -6
- package/tsconfig.json +1 -1
- package/vite.config.ts +1 -1
- package/dist/Game/EffectManager.d.ts +0 -5
- package/dist/components/effects/index.d.ts +0 -4
- package/src/components/scenes/element-map.ce +0 -23
- /package/src/components/{effects → animations}/hit.ce +0 -0
package/dist/Game/Map.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { RpgCommonMap } from '@rpgjs/common';
|
|
2
2
|
import { RpgClientPlayer } from './Player';
|
|
3
3
|
import { RpgClientEvent } from './Event';
|
|
4
|
-
|
|
4
|
+
import { RpgClientEngine } from '../RpgClientEngine';
|
|
5
|
+
export declare class RpgClientMap extends RpgCommonMap<any> {
|
|
6
|
+
engine: RpgClientEngine;
|
|
5
7
|
players: import('canvasengine').WritableObjectSignal<Record<string, RpgClientPlayer>>;
|
|
6
8
|
events: import('canvasengine').WritableObjectSignal<Record<string, RpgClientEvent>>;
|
|
9
|
+
currentPlayer: import('canvasengine').ComputedSignal<RpgClientPlayer>;
|
|
10
|
+
getCurrentPlayer(): RpgClientPlayer;
|
|
11
|
+
reset(): void;
|
|
12
|
+
stepPredictionTick(): void;
|
|
7
13
|
}
|
package/dist/Gui/Gui.d.ts
CHANGED
|
@@ -1,23 +1,188 @@
|
|
|
1
1
|
import { Context } from '@signe/di';
|
|
2
|
+
import { Signal, WritableSignal } from 'canvasengine';
|
|
3
|
+
import { Subscription } from 'rxjs';
|
|
2
4
|
interface GuiOptions {
|
|
3
|
-
name
|
|
5
|
+
name?: string;
|
|
6
|
+
id?: string;
|
|
4
7
|
component: any;
|
|
5
8
|
display?: boolean;
|
|
6
9
|
data?: any;
|
|
10
|
+
/**
|
|
11
|
+
* Auto display the GUI when added to the system
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
autoDisplay?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Function that returns an array of Signal dependencies
|
|
17
|
+
* The GUI will only display when all dependencies are resolved (!= undefined)
|
|
18
|
+
* @returns Array of Signal dependencies
|
|
19
|
+
*/
|
|
20
|
+
dependencies?: () => Signal[];
|
|
21
|
+
/**
|
|
22
|
+
* Attach the GUI to sprites instead of displaying globally
|
|
23
|
+
* When true, the GUI will be rendered in character.ce for each sprite
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
attachToSprite?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface GuiInstance {
|
|
29
|
+
name: string;
|
|
30
|
+
component: any;
|
|
31
|
+
display: WritableSignal<boolean>;
|
|
32
|
+
data: WritableSignal<any>;
|
|
33
|
+
autoDisplay: boolean;
|
|
34
|
+
dependencies?: () => Signal[];
|
|
35
|
+
subscription?: Subscription;
|
|
36
|
+
attachToSprite?: boolean;
|
|
7
37
|
}
|
|
8
38
|
export declare class RpgGui {
|
|
9
39
|
private context;
|
|
10
40
|
private webSocket;
|
|
11
|
-
gui: import('canvasengine').
|
|
41
|
+
gui: import('canvasengine').WritableObjectSignal<Record<string, GuiInstance>>;
|
|
42
|
+
extraGuis: GuiInstance[];
|
|
43
|
+
private vueGuiInstance;
|
|
44
|
+
/**
|
|
45
|
+
* Signal tracking which player IDs should display attached GUIs
|
|
46
|
+
* Key: player ID, Value: boolean (true = show, false = hide)
|
|
47
|
+
*/
|
|
48
|
+
attachedGuiDisplayState: import('canvasengine').WritableObjectSignal<Record<string, boolean>>;
|
|
12
49
|
constructor(context: Context);
|
|
13
50
|
_initialize(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Set the VueGui instance reference for Vue component management
|
|
53
|
+
* This is called by VueGui when it's initialized
|
|
54
|
+
*
|
|
55
|
+
* @param vueGuiInstance - The VueGui instance
|
|
56
|
+
*/
|
|
57
|
+
_setVueGuiInstance(vueGuiInstance: any): void;
|
|
58
|
+
/**
|
|
59
|
+
* Notify VueGui about GUI state changes
|
|
60
|
+
* This synchronizes the Vue component display state
|
|
61
|
+
*
|
|
62
|
+
* @param guiId - The GUI component ID
|
|
63
|
+
* @param display - Display state
|
|
64
|
+
* @param data - Component data
|
|
65
|
+
*/
|
|
66
|
+
private _notifyVueGui;
|
|
67
|
+
/**
|
|
68
|
+
* Initialize Vue components in the VueGui instance
|
|
69
|
+
* This should be called after VueGui is mounted
|
|
70
|
+
*/
|
|
71
|
+
_initializeVueComponents(): void;
|
|
14
72
|
guiInteraction(guiId: string, name: string, data: any): void;
|
|
15
73
|
guiClose(guiId: string, data?: any): void;
|
|
74
|
+
/**
|
|
75
|
+
* Add a GUI component to the system
|
|
76
|
+
*
|
|
77
|
+
* By default, only CanvasEngine components (.ce files) are accepted.
|
|
78
|
+
* Vue components should be handled by the @rpgjs/vue package.
|
|
79
|
+
*
|
|
80
|
+
* @param gui - GUI configuration options
|
|
81
|
+
* @param gui.name - Name or ID of the GUI component
|
|
82
|
+
* @param gui.id - Alternative ID if name is not provided
|
|
83
|
+
* @param gui.component - The component to render (must be a CanvasEngine component)
|
|
84
|
+
* @param gui.display - Initial display state (default: false)
|
|
85
|
+
* @param gui.data - Initial data for the component
|
|
86
|
+
* @param gui.autoDisplay - Auto display when added (default: false)
|
|
87
|
+
* @param gui.dependencies - Function returning Signal dependencies
|
|
88
|
+
* @param gui.attachToSprite - Attach GUI to sprites instead of global display (default: false)
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* gui.add({
|
|
93
|
+
* name: 'inventory',
|
|
94
|
+
* component: InventoryComponent, // Must be a .ce component
|
|
95
|
+
* autoDisplay: true,
|
|
96
|
+
* dependencies: () => [playerSignal, inventorySignal]
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* // Attach to sprites
|
|
100
|
+
* gui.add({
|
|
101
|
+
* name: 'tooltip',
|
|
102
|
+
* component: TooltipComponent,
|
|
103
|
+
* attachToSprite: true
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
16
107
|
add(gui: GuiOptions): void;
|
|
17
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Get all attached GUI components (attachToSprite: true)
|
|
110
|
+
*
|
|
111
|
+
* Returns all GUI instances that are configured to be attached to sprites.
|
|
112
|
+
* These GUIs should be rendered in character.ce instead of canvas.ce.
|
|
113
|
+
*
|
|
114
|
+
* @returns Array of GUI instances with attachToSprite: true
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const attachedGuis = gui.getAttachedGuis();
|
|
119
|
+
* // Use in character.ce to render tooltips
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
getAttachedGuis(): GuiInstance[];
|
|
123
|
+
/**
|
|
124
|
+
* Check if a player should display attached GUIs
|
|
125
|
+
*
|
|
126
|
+
* @param playerId - The player ID to check
|
|
127
|
+
* @returns true if attached GUIs should be displayed for this player
|
|
128
|
+
*/
|
|
129
|
+
shouldDisplayAttachedGui(playerId: string): boolean;
|
|
130
|
+
get(id: string): GuiInstance | undefined;
|
|
18
131
|
exists(id: string): boolean;
|
|
19
|
-
getAll():
|
|
20
|
-
|
|
132
|
+
getAll(): Record<string, GuiInstance>;
|
|
133
|
+
/**
|
|
134
|
+
* Display a GUI component
|
|
135
|
+
*
|
|
136
|
+
* Displays the GUI immediately if no dependencies are configured,
|
|
137
|
+
* or waits for all dependencies to be resolved if dependencies are present.
|
|
138
|
+
* Automatically manages subscriptions to prevent memory leaks.
|
|
139
|
+
* Works with both CanvasEngine components and Vue components.
|
|
140
|
+
*
|
|
141
|
+
* @param id - The GUI component ID
|
|
142
|
+
* @param data - Data to pass to the component
|
|
143
|
+
* @param dependencies - Optional runtime dependencies (overrides config dependencies)
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* // Display immediately
|
|
148
|
+
* gui.display('inventory', { items: [] });
|
|
149
|
+
*
|
|
150
|
+
* // Display with runtime dependencies
|
|
151
|
+
* gui.display('shop', { shopId: 1 }, [playerSignal, shopSignal]);
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
display(id: string, data?: {}, dependencies?: Signal[]): void;
|
|
155
|
+
/**
|
|
156
|
+
* Handle Vue component display logic
|
|
157
|
+
*
|
|
158
|
+
* @param id - GUI component ID
|
|
159
|
+
* @param data - Component data
|
|
160
|
+
* @param dependencies - Runtime dependencies
|
|
161
|
+
* @param guiInstance - GUI instance
|
|
162
|
+
*/
|
|
163
|
+
private _handleVueComponentDisplay;
|
|
164
|
+
/**
|
|
165
|
+
* Handle CanvasEngine component display logic
|
|
166
|
+
*
|
|
167
|
+
* @param id - GUI component ID
|
|
168
|
+
* @param data - Component data
|
|
169
|
+
* @param dependencies - Runtime dependencies
|
|
170
|
+
* @param guiInstance - GUI instance
|
|
171
|
+
*/
|
|
172
|
+
private _handleCanvasComponentDisplay;
|
|
173
|
+
/**
|
|
174
|
+
* Hide a GUI component
|
|
175
|
+
*
|
|
176
|
+
* Hides the GUI and cleans up any active subscriptions.
|
|
177
|
+
* Works with both CanvasEngine components and Vue components.
|
|
178
|
+
*
|
|
179
|
+
* @param id - The GUI component ID
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* gui.hide('inventory');
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
21
186
|
hide(id: string): void;
|
|
22
187
|
}
|
|
23
188
|
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { RpgClientEngine } from './RpgClientEngine';
|
|
2
|
+
/**
|
|
3
|
+
* RpgResource class
|
|
4
|
+
*
|
|
5
|
+
* Provides a unified API to access resource file links (images and sounds) in the game.
|
|
6
|
+
* Resources are stored as Maps of resource IDs to file paths/URLs.
|
|
7
|
+
*
|
|
8
|
+
* ## Design
|
|
9
|
+
*
|
|
10
|
+
* RpgResource acts as a facade over the engine's resource storage, providing
|
|
11
|
+
* easy access to resource file links. It maintains Maps that are synchronized
|
|
12
|
+
* with the engine's internal storage, but only stores the file paths/URLs,
|
|
13
|
+
* not the full resource objects.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { RpgResource } from '@rpgjs/client'
|
|
18
|
+
*
|
|
19
|
+
* // Get spritesheet image link
|
|
20
|
+
* const imageLink = RpgResource.spritesheets.get('hero')
|
|
21
|
+
*
|
|
22
|
+
* // Get sound file link
|
|
23
|
+
* const soundLink = RpgResource.sounds.get('town-music')
|
|
24
|
+
*
|
|
25
|
+
* // Set a new resource link
|
|
26
|
+
* RpgResource.spritesheets.set('new-sprite', './assets/new-sprite.png')
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare class RpgResource {
|
|
30
|
+
private static engine;
|
|
31
|
+
private static _spritesheets;
|
|
32
|
+
private static _sounds;
|
|
33
|
+
/**
|
|
34
|
+
* Initialize RpgResource with the engine instance
|
|
35
|
+
*
|
|
36
|
+
* This is called automatically by the engine during initialization.
|
|
37
|
+
* It synchronizes the resource Maps with the engine's internal storage.
|
|
38
|
+
*
|
|
39
|
+
* @param engine - The RpgClientEngine instance
|
|
40
|
+
*/
|
|
41
|
+
static init(engine: RpgClientEngine): void;
|
|
42
|
+
/**
|
|
43
|
+
* Synchronize resource Maps with the engine's internal storage
|
|
44
|
+
*
|
|
45
|
+
* Extracts file links from spritesheets and sounds stored in the engine
|
|
46
|
+
* and updates the Maps accordingly.
|
|
47
|
+
*
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
private static syncResources;
|
|
51
|
+
/**
|
|
52
|
+
* Get/Set image links for spritesheets
|
|
53
|
+
*
|
|
54
|
+
* Map of spritesheet IDs to their image file paths/URLs.
|
|
55
|
+
* This Map is synchronized with the engine's spritesheet storage.
|
|
56
|
+
*
|
|
57
|
+
* @type {Map<string, string>}
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // Get an image link
|
|
62
|
+
* const imageLink = RpgResource.spritesheets.get('hero')
|
|
63
|
+
*
|
|
64
|
+
* // Set a new image link
|
|
65
|
+
* RpgResource.spritesheets.set('new-sprite', './assets/new-sprite.png')
|
|
66
|
+
*
|
|
67
|
+
* // Check if a spritesheet exists
|
|
68
|
+
* if (RpgResource.spritesheets.has('monster')) {
|
|
69
|
+
* const link = RpgResource.spritesheets.get('monster')
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
static get spritesheets(): Map<string, string>;
|
|
74
|
+
/**
|
|
75
|
+
* Get/Set sound file links
|
|
76
|
+
*
|
|
77
|
+
* Map of sound IDs to their audio file paths/URLs.
|
|
78
|
+
* This Map is synchronized with the engine's sound storage.
|
|
79
|
+
*
|
|
80
|
+
* @type {Map<string, string>}
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* // Get a sound link
|
|
85
|
+
* const soundLink = RpgResource.sounds.get('town-music')
|
|
86
|
+
*
|
|
87
|
+
* // Set a new sound link
|
|
88
|
+
* RpgResource.sounds.set('new-sound', './assets/new-sound.ogg')
|
|
89
|
+
*
|
|
90
|
+
* // Iterate over all sounds
|
|
91
|
+
* RpgResource.sounds.forEach((link, id) => {
|
|
92
|
+
* console.log(`Sound ${id}: ${link}`)
|
|
93
|
+
* })
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
static get sounds(): Map<string, string>;
|
|
97
|
+
}
|