@rpgjs/client 5.0.0-alpha.8 → 5.0.0-beta.1
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/AnimationManager.js +26 -0
- package/dist/Game/AnimationManager.js.map +1 -0
- package/dist/Game/Event.d.ts +1 -1
- package/dist/Game/Event.js +12 -0
- package/dist/Game/Event.js.map +1 -0
- package/dist/Game/Map.d.ts +23 -2
- package/dist/Game/Map.js +80 -0
- package/dist/Game/Map.js.map +1 -0
- package/dist/Game/Object.d.ts +157 -0
- package/dist/Game/Object.js +211 -0
- package/dist/Game/Object.js.map +1 -0
- package/dist/Game/Player.d.ts +1 -1
- package/dist/Game/Player.js +12 -0
- package/dist/Game/Player.js.map +1 -0
- package/dist/Gui/Gui.d.ts +177 -5
- package/dist/Gui/Gui.js +445 -0
- package/dist/Gui/Gui.js.map +1 -0
- package/dist/Gui/NotificationManager.d.ts +23 -0
- package/dist/Gui/NotificationManager.js +49 -0
- package/dist/Gui/NotificationManager.js.map +1 -0
- package/dist/Resource.d.ts +97 -0
- package/dist/Resource.js +133 -0
- package/dist/Resource.js.map +1 -0
- package/dist/RpgClient.d.ts +290 -58
- package/dist/RpgClientEngine.d.ts +649 -9
- package/dist/RpgClientEngine.js +1334 -0
- package/dist/RpgClientEngine.js.map +1 -0
- package/dist/Sound.d.ts +199 -0
- package/dist/Sound.js +167 -0
- package/dist/Sound.js.map +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js +6 -0
- package/dist/components/animations/animation.ce.js +24 -0
- package/dist/components/animations/animation.ce.js.map +1 -0
- package/dist/components/animations/hit.ce.js +70 -0
- package/dist/components/animations/hit.ce.js.map +1 -0
- package/dist/components/animations/index.d.ts +4 -0
- package/dist/components/animations/index.js +11 -0
- package/dist/components/animations/index.js.map +1 -0
- package/dist/components/character.ce.js +392 -0
- package/dist/components/character.ce.js.map +1 -0
- package/dist/components/dynamics/parse-value.d.ts +1 -0
- package/dist/components/dynamics/parse-value.js +44 -0
- package/dist/components/dynamics/parse-value.js.map +1 -0
- package/dist/components/dynamics/text.ce.js +73 -0
- package/dist/components/dynamics/text.ce.js.map +1 -0
- package/dist/components/gui/box.ce.js +28 -0
- package/dist/components/gui/box.ce.js.map +1 -0
- package/dist/components/gui/dialogbox/index.ce.js +205 -0
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -0
- package/dist/components/gui/gameover.ce.js +193 -0
- package/dist/components/gui/gameover.ce.js.map +1 -0
- package/dist/components/gui/hud/hud.ce.js +92 -0
- package/dist/components/gui/hud/hud.ce.js.map +1 -0
- package/dist/components/gui/index.d.ts +15 -3
- package/dist/components/gui/index.js +14 -0
- package/dist/components/gui/menu/equip-menu.ce.js +481 -0
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/exit-menu.ce.js +54 -0
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/items-menu.ce.js +344 -0
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/main-menu.ce.js +417 -0
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/options-menu.ce.js +48 -0
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/skills-menu.ce.js +107 -0
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -0
- package/dist/components/gui/mobile/index.d.ts +8 -0
- package/dist/components/gui/mobile/index.js +21 -0
- package/dist/components/gui/mobile/index.js.map +1 -0
- package/dist/components/gui/mobile/mobile.ce.js +78 -0
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -0
- package/dist/components/gui/notification/notification.ce.js +64 -0
- package/dist/components/gui/notification/notification.ce.js.map +1 -0
- package/dist/components/gui/save-load.ce.js +389 -0
- package/dist/components/gui/save-load.ce.js.map +1 -0
- package/dist/components/gui/shop/shop.ce.js +652 -0
- package/dist/components/gui/shop/shop.ce.js.map +1 -0
- package/dist/components/gui/title-screen.ce.js +190 -0
- package/dist/components/gui/title-screen.ce.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +4 -0
- package/dist/components/prebuilt/hp-bar.ce.js +116 -0
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -0
- package/dist/components/prebuilt/index.d.ts +19 -0
- package/dist/components/prebuilt/index.js +2 -0
- package/dist/components/prebuilt/light-halo.ce.js +94 -0
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -0
- package/dist/components/scenes/canvas.ce.js +60 -0
- package/dist/components/scenes/canvas.ce.js.map +1 -0
- package/dist/components/scenes/draw-map.ce.js +89 -0
- package/dist/components/scenes/draw-map.ce.js.map +1 -0
- package/dist/components/scenes/event-layer.ce.js +28 -0
- package/dist/components/scenes/event-layer.ce.js.map +1 -0
- package/dist/core/inject.js +18 -0
- package/dist/core/inject.js.map +1 -0
- package/dist/core/setup.js +16 -0
- package/dist/core/setup.js.map +1 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +44 -14
- package/dist/module.d.ts +43 -4
- package/dist/module.js +176 -0
- package/dist/module.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js +277 -0
- package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +457 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +463 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +2191 -0
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +10 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +91 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js +325 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +14 -0
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +115 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +401 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3756 -0
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -0
- package/dist/presets/animation.d.ts +31 -0
- package/dist/presets/animation.js +39 -0
- package/dist/presets/animation.js.map +1 -0
- package/dist/presets/faceset.d.ts +30 -0
- package/dist/presets/faceset.js +51 -0
- package/dist/presets/faceset.js.map +1 -0
- package/dist/presets/icon.d.ts +20 -0
- package/dist/presets/icon.js +15 -0
- package/dist/presets/icon.js.map +1 -0
- package/dist/presets/index.d.ts +123 -0
- package/dist/presets/index.js +17 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/lpc.d.ts +89 -0
- package/dist/presets/lpc.js +98 -0
- package/dist/presets/lpc.js.map +1 -0
- package/dist/presets/rmspritesheet.js +42 -0
- package/dist/presets/rmspritesheet.js.map +1 -0
- package/dist/services/AbstractSocket.d.ts +9 -5
- package/dist/services/AbstractSocket.js +11 -0
- package/dist/services/AbstractSocket.js.map +1 -0
- package/dist/services/keyboardControls.d.ts +15 -0
- package/dist/services/keyboardControls.js +23 -0
- package/dist/services/keyboardControls.js.map +1 -0
- package/dist/services/loadMap.js +123 -0
- package/dist/services/loadMap.js.map +1 -0
- package/dist/services/mmorpg.d.ts +21 -9
- package/dist/services/mmorpg.js +131 -0
- package/dist/services/mmorpg.js.map +1 -0
- package/dist/services/save.d.ts +19 -0
- package/dist/services/save.js +77 -0
- package/dist/services/save.js.map +1 -0
- package/dist/services/standalone.d.ts +67 -7
- package/dist/services/standalone.js +168 -0
- package/dist/services/standalone.js.map +1 -0
- package/dist/utils/getEntityProp.d.ts +39 -0
- package/dist/utils/getEntityProp.js +52 -0
- package/dist/utils/getEntityProp.js.map +1 -0
- package/package.json +13 -9
- package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
- package/src/Game/Event.ts +1 -1
- package/src/Game/Map.ts +95 -3
- package/src/Game/Object.ts +330 -14
- package/src/Game/Player.ts +1 -1
- package/src/Gui/Gui.ts +506 -18
- package/src/Gui/NotificationManager.ts +69 -0
- package/src/Resource.ts +150 -0
- package/src/RpgClient.ts +300 -58
- package/src/RpgClientEngine.ts +1707 -48
- 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 +406 -40
- 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 +204 -187
- package/src/components/gui/gameover.ce +158 -0
- package/src/components/gui/hud/hud.ce +61 -0
- package/src/components/gui/index.ts +30 -4
- package/src/components/gui/menu/equip-menu.ce +410 -0
- package/src/components/gui/menu/exit-menu.ce +41 -0
- package/src/components/gui/menu/items-menu.ce +317 -0
- package/src/components/gui/menu/main-menu.ce +294 -0
- package/src/components/gui/menu/options-menu.ce +35 -0
- package/src/components/gui/menu/skills-menu.ce +83 -0
- package/src/components/gui/mobile/index.ts +24 -0
- package/src/components/gui/mobile/mobile.ce +80 -0
- package/src/components/gui/notification/notification.ce +51 -0
- package/src/components/gui/save-load.ce +208 -0
- package/src/components/gui/shop/shop.ce +493 -0
- package/src/components/gui/title-screen.ce +163 -0
- package/src/components/index.ts +3 -0
- package/src/components/prebuilt/hp-bar.ce +255 -0
- package/src/components/prebuilt/index.ts +24 -0
- package/src/components/prebuilt/light-halo.ce +148 -0
- package/src/components/scenes/canvas.ce +20 -15
- package/src/components/scenes/draw-map.ce +60 -13
- package/src/components/scenes/event-layer.ce +9 -2
- package/src/components/scenes/transition.ce +60 -0
- package/src/index.ts +16 -2
- package/src/module.ts +145 -9
- package/src/presets/animation.ts +46 -0
- package/src/presets/faceset.ts +60 -0
- package/src/presets/icon.ts +17 -0
- package/src/presets/index.ts +9 -1
- package/src/presets/lpc.ts +108 -0
- package/src/services/AbstractSocket.ts +10 -2
- package/src/services/keyboardControls.ts +20 -0
- package/src/services/loadMap.ts +1 -1
- package/src/services/mmorpg.ts +100 -12
- package/src/services/save.ts +103 -0
- package/src/services/standalone.ts +110 -18
- package/src/utils/getEntityProp.ts +87 -0
- package/tsconfig.json +1 -1
- package/vite.config.ts +4 -2
- package/dist/Game/EffectManager.d.ts +0 -5
- package/dist/components/effects/index.d.ts +0 -4
- package/dist/index.js.map +0 -1
- package/dist/index10.js +0 -8
- package/dist/index10.js.map +0 -1
- package/dist/index11.js +0 -10
- package/dist/index11.js.map +0 -1
- package/dist/index12.js +0 -8
- package/dist/index12.js.map +0 -1
- package/dist/index13.js +0 -17
- package/dist/index13.js.map +0 -1
- package/dist/index14.js +0 -91
- package/dist/index14.js.map +0 -1
- package/dist/index15.js +0 -50
- package/dist/index15.js.map +0 -1
- package/dist/index16.js +0 -191
- package/dist/index16.js.map +0 -1
- package/dist/index17.js +0 -9
- package/dist/index17.js.map +0 -1
- package/dist/index18.js +0 -387
- package/dist/index18.js.map +0 -1
- package/dist/index19.js +0 -31
- package/dist/index19.js.map +0 -1
- package/dist/index2.js +0 -112
- package/dist/index2.js.map +0 -1
- package/dist/index20.js +0 -24
- package/dist/index20.js.map +0 -1
- package/dist/index21.js +0 -2421
- package/dist/index21.js.map +0 -1
- package/dist/index22.js +0 -114
- package/dist/index22.js.map +0 -1
- package/dist/index23.js +0 -109
- package/dist/index23.js.map +0 -1
- package/dist/index24.js +0 -71
- package/dist/index24.js.map +0 -1
- package/dist/index25.js +0 -21
- package/dist/index25.js.map +0 -1
- package/dist/index26.js +0 -41
- package/dist/index26.js.map +0 -1
- package/dist/index27.js +0 -5
- package/dist/index27.js.map +0 -1
- package/dist/index28.js +0 -322
- package/dist/index28.js.map +0 -1
- package/dist/index29.js +0 -27
- package/dist/index29.js.map +0 -1
- package/dist/index3.js +0 -87
- package/dist/index3.js.map +0 -1
- package/dist/index30.js +0 -11
- package/dist/index30.js.map +0 -1
- package/dist/index31.js +0 -11
- package/dist/index31.js.map +0 -1
- package/dist/index32.js +0 -12
- package/dist/index32.js.map +0 -1
- package/dist/index33.js +0 -4403
- package/dist/index33.js.map +0 -1
- package/dist/index34.js +0 -316
- package/dist/index34.js.map +0 -1
- package/dist/index35.js +0 -174
- package/dist/index35.js.map +0 -1
- package/dist/index36.js +0 -501
- package/dist/index36.js.map +0 -1
- package/dist/index37.js +0 -61
- package/dist/index37.js.map +0 -1
- package/dist/index38.js +0 -20
- package/dist/index38.js.map +0 -1
- package/dist/index39.js +0 -20
- package/dist/index39.js.map +0 -1
- package/dist/index4.js +0 -67
- package/dist/index4.js.map +0 -1
- package/dist/index5.js +0 -16
- package/dist/index5.js.map +0 -1
- package/dist/index6.js +0 -17
- package/dist/index6.js.map +0 -1
- package/dist/index7.js +0 -39
- package/dist/index7.js.map +0 -1
- package/dist/index8.js +0 -90
- package/dist/index8.js.map +0 -1
- package/dist/index9.js +0 -76
- package/dist/index9.js.map +0 -1
- package/src/components/gui/dialogbox/itemMenu.ce +0 -23
- package/src/components/gui/dialogbox/selection.ce +0 -67
- /package/src/components/{effects → animations}/hit.ce +0 -0
package/dist/RpgClient.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { ComponentFunction, Signal } from 'canvasengine';
|
|
1
2
|
import { RpgClientEngine } from './RpgClientEngine';
|
|
2
|
-
import { Loader } from 'pixi.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type
|
|
3
|
+
import { Loader, Container } from 'pixi.js';
|
|
4
|
+
import { RpgClientObject } from './Game/Object';
|
|
5
|
+
import { MapPhysicsEntityContext, MapPhysicsInitContext } from '@rpgjs/common';
|
|
6
|
+
type RpgComponent = RpgClientObject;
|
|
7
|
+
type SceneMap = Container;
|
|
6
8
|
export interface RpgClientEngineHooks {
|
|
7
9
|
/**
|
|
8
10
|
* When the engine is started. If you send false, you prevent the client from connecting to the server
|
|
@@ -59,6 +61,34 @@ export interface RpgClientEngineHooks {
|
|
|
59
61
|
onWindowResize?: () => any;
|
|
60
62
|
}
|
|
61
63
|
export interface RpgSpriteHooks {
|
|
64
|
+
/**
|
|
65
|
+
* Array of components to render behind the sprite
|
|
66
|
+
* These components will be displayed with a lower z-index than the sprite itself
|
|
67
|
+
*
|
|
68
|
+
* @prop { ComponentFunction[] } [componentsBehind]
|
|
69
|
+
* @memberof RpgSpriteHooks
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const sprite: RpgSpriteHooks = {
|
|
73
|
+
* componentsBehind: [ShadowComponent, AuraComponent]
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
componentsBehind?: ComponentFunction[];
|
|
78
|
+
/**
|
|
79
|
+
* Array of components to render in front of the sprite
|
|
80
|
+
* These components will be displayed with a higher z-index than the sprite itself
|
|
81
|
+
*
|
|
82
|
+
* @prop { ComponentFunction[] } [componentsInFront]
|
|
83
|
+
* @memberof RpgSpriteHooks
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const sprite: RpgSpriteHooks = {
|
|
87
|
+
* componentsInFront: [HealthBarComponent, StatusEffectComponent]
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
componentsInFront?: ComponentFunction[];
|
|
62
92
|
/**
|
|
63
93
|
* As soon as the sprite is initialized
|
|
64
94
|
*
|
|
@@ -151,6 +181,37 @@ export interface RpgSceneMapHooks extends RpgSceneHooks<SceneMap> {
|
|
|
151
181
|
* @memberof RpgSceneHooks
|
|
152
182
|
*/
|
|
153
183
|
onMapLoading?: (scene: SceneMap, loader: Loader) => any;
|
|
184
|
+
/**
|
|
185
|
+
* Called when client physics has been initialized for the current map.
|
|
186
|
+
*
|
|
187
|
+
* Use this hook to initialize shared physics extensions based on map data
|
|
188
|
+
* (for example, tile-based collision rules used by client prediction).
|
|
189
|
+
*
|
|
190
|
+
* @prop { (scene: SceneMap, context: MapPhysicsInitContext) => any } [onPhysicsInit]
|
|
191
|
+
* @memberof RpgSceneMapHooks
|
|
192
|
+
*/
|
|
193
|
+
onPhysicsInit?: (scene: SceneMap, context: MapPhysicsInitContext) => any;
|
|
194
|
+
/**
|
|
195
|
+
* Called when a character physics body is added to the map.
|
|
196
|
+
*
|
|
197
|
+
* @prop { (scene: SceneMap, context: MapPhysicsEntityContext) => any } [onPhysicsEntityAdd]
|
|
198
|
+
* @memberof RpgSceneMapHooks
|
|
199
|
+
*/
|
|
200
|
+
onPhysicsEntityAdd?: (scene: SceneMap, context: MapPhysicsEntityContext) => any;
|
|
201
|
+
/**
|
|
202
|
+
* Called when a character physics body is removed from the map.
|
|
203
|
+
*
|
|
204
|
+
* @prop { (scene: SceneMap, context: MapPhysicsEntityContext) => any } [onPhysicsEntityRemove]
|
|
205
|
+
* @memberof RpgSceneMapHooks
|
|
206
|
+
*/
|
|
207
|
+
onPhysicsEntityRemove?: (scene: SceneMap, context: MapPhysicsEntityContext) => any;
|
|
208
|
+
/**
|
|
209
|
+
* Called when the physics world is reset (e.g. before a map physics reload).
|
|
210
|
+
*
|
|
211
|
+
* @prop { (scene: SceneMap) => any } [onPhysicsReset]
|
|
212
|
+
* @memberof RpgSceneMapHooks
|
|
213
|
+
*/
|
|
214
|
+
onPhysicsReset?: (scene: SceneMap) => any;
|
|
154
215
|
}
|
|
155
216
|
export interface RpgClient {
|
|
156
217
|
/**
|
|
@@ -163,14 +224,13 @@ export interface RpgClient {
|
|
|
163
224
|
* @example
|
|
164
225
|
*
|
|
165
226
|
* ```ts
|
|
166
|
-
* import { RpgClient,
|
|
227
|
+
* import { RpgClient, defineModule } from '@rpgjs/client'
|
|
167
228
|
*
|
|
168
|
-
*
|
|
229
|
+
* defineModule<RpgClient>({
|
|
169
230
|
* hooks: {
|
|
170
231
|
* player: ['onAuth']
|
|
171
232
|
* }
|
|
172
233
|
* })
|
|
173
|
-
* class RpgClientEngine { }
|
|
174
234
|
* ```
|
|
175
235
|
*
|
|
176
236
|
* Emit the hook:
|
|
@@ -207,7 +267,7 @@ export interface RpgClient {
|
|
|
207
267
|
* Object containing the hooks concerning the engine
|
|
208
268
|
*
|
|
209
269
|
* ```ts
|
|
210
|
-
* import { RpgClientEngine, RpgClientEngineHooks,
|
|
270
|
+
* import { RpgClientEngine, RpgClientEngineHooks, defineModule, RpgClient } from '@rpgjs/client'
|
|
211
271
|
*
|
|
212
272
|
* const engine: RpgClientEngineHooks = {
|
|
213
273
|
* onConnected(engine: RpgClientEngine) {
|
|
@@ -215,10 +275,9 @@ export interface RpgClient {
|
|
|
215
275
|
* }
|
|
216
276
|
* }
|
|
217
277
|
*
|
|
218
|
-
*
|
|
278
|
+
* defineModule<RpgClient>({
|
|
219
279
|
* engine
|
|
220
280
|
* })
|
|
221
|
-
* class RpgClientModule {}
|
|
222
281
|
* ```
|
|
223
282
|
*
|
|
224
283
|
* @prop {RpgClientEngineHooks} [engine]
|
|
@@ -227,99 +286,246 @@ export interface RpgClient {
|
|
|
227
286
|
engine?: RpgClientEngineHooks;
|
|
228
287
|
/**
|
|
229
288
|
* Array containing the list of spritesheets
|
|
230
|
-
*
|
|
289
|
+
* Each element is a simple object containing spritesheet definitions
|
|
231
290
|
*
|
|
232
291
|
* ```ts
|
|
233
|
-
* import {
|
|
234
|
-
*
|
|
235
|
-
* @Spritesheet({
|
|
236
|
-
* id: 'chest',
|
|
237
|
-
* image: require('./assets/chest.png'),
|
|
238
|
-
* // other options
|
|
239
|
-
* })
|
|
240
|
-
* class Chest { }
|
|
292
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
241
293
|
*
|
|
242
|
-
*
|
|
294
|
+
* defineModule<RpgClient>({
|
|
243
295
|
* spritesheets: [
|
|
244
|
-
*
|
|
296
|
+
* {
|
|
297
|
+
* id: 'chest',
|
|
298
|
+
* image: require('./assets/chest.png'),
|
|
299
|
+
* framesWidth: 32,
|
|
300
|
+
* framesHeight: 32,
|
|
301
|
+
* animations: {
|
|
302
|
+
* default: {
|
|
303
|
+
* frames: [0, 1, 2],
|
|
304
|
+
* duration: 1000
|
|
305
|
+
* }
|
|
306
|
+
* }
|
|
307
|
+
* }
|
|
245
308
|
* ]
|
|
246
309
|
* })
|
|
247
|
-
* class RpgClientEngine {}
|
|
248
310
|
* ```
|
|
249
311
|
*
|
|
250
312
|
* [Guide: Create Sprite](/guide/create-sprite.html)
|
|
251
313
|
*
|
|
252
|
-
* @prop {Array<
|
|
314
|
+
* @prop {Array<Object>} [spritesheets]
|
|
253
315
|
* @memberof RpgClient
|
|
254
316
|
* */
|
|
255
317
|
spritesheets?: any[];
|
|
256
318
|
/**
|
|
257
|
-
*
|
|
319
|
+
* Resolver function for dynamically creating spritesheets
|
|
320
|
+
*
|
|
321
|
+
* This function is called when a spritesheet is requested but not found in the cache.
|
|
322
|
+
* It can be synchronous (returns directly) or asynchronous (returns a Promise).
|
|
323
|
+
* The resolved spritesheet is automatically cached for future use.
|
|
258
324
|
*
|
|
259
325
|
* ```ts
|
|
260
|
-
* import {
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
326
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
327
|
+
*
|
|
328
|
+
* defineModule<RpgClient>({
|
|
329
|
+
* spritesheetResolver: (id: string) => {
|
|
330
|
+
* // Synchronous resolver
|
|
331
|
+
* if (id === 'dynamic-sprite') {
|
|
332
|
+
* return {
|
|
333
|
+
* id: 'dynamic-sprite',
|
|
334
|
+
* image: 'path/to/image.png',
|
|
335
|
+
* framesWidth: 32,
|
|
336
|
+
* framesHeight: 32
|
|
337
|
+
* };
|
|
338
|
+
* }
|
|
339
|
+
* return undefined;
|
|
340
|
+
* }
|
|
341
|
+
* })
|
|
270
342
|
*
|
|
271
|
-
*
|
|
343
|
+
* // Or asynchronous resolver
|
|
344
|
+
* defineModule<RpgClient>({
|
|
345
|
+
* spritesheetResolver: async (id: string) => {
|
|
346
|
+
* const response = await fetch(`/api/spritesheets/${id}`);
|
|
347
|
+
* const data = await response.json();
|
|
348
|
+
* return data;
|
|
349
|
+
* }
|
|
350
|
+
* })
|
|
351
|
+
* ```
|
|
352
|
+
*
|
|
353
|
+
* @prop {(id: string) => any | Promise<any>} [spritesheetResolver]
|
|
354
|
+
* @memberof RpgClient
|
|
355
|
+
* */
|
|
356
|
+
spritesheetResolver?: (id: string) => any | Promise<any>;
|
|
357
|
+
/**
|
|
358
|
+
* Resolver function for dynamically loading sounds
|
|
359
|
+
*
|
|
360
|
+
* The resolver is called when a sound is requested but not found in the cache.
|
|
361
|
+
* It can be synchronous (returns directly) or asynchronous (returns a Promise).
|
|
362
|
+
* The resolved sound is automatically cached for future use.
|
|
363
|
+
*
|
|
364
|
+
* ```ts
|
|
365
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
366
|
+
*
|
|
367
|
+
* defineModule<RpgClient>({
|
|
368
|
+
* soundResolver: (id: string) => {
|
|
369
|
+
* if (id === 'dynamic-sound') {
|
|
370
|
+
* return { id: 'dynamic-sound', src: 'path/to/sound.mp3' };
|
|
371
|
+
* }
|
|
372
|
+
* return undefined;
|
|
373
|
+
* }
|
|
374
|
+
* })
|
|
375
|
+
* ```
|
|
376
|
+
*
|
|
377
|
+
* @prop {(id: string) => any | Promise<any>} [soundResolver]
|
|
378
|
+
* @memberof RpgClient
|
|
379
|
+
* */
|
|
380
|
+
soundResolver?: (id: string) => any | Promise<any>;
|
|
381
|
+
/**
|
|
382
|
+
* Array containing the list of GUI components
|
|
383
|
+
*
|
|
384
|
+
* ```ts
|
|
385
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
386
|
+
* import InventoryComponent from './inventory.ce'
|
|
387
|
+
*
|
|
388
|
+
* defineModule<RpgClient>({
|
|
272
389
|
* gui: [
|
|
273
|
-
*
|
|
390
|
+
* {
|
|
391
|
+
* id: 'inventory',
|
|
392
|
+
* component: InventoryComponent,
|
|
393
|
+
* autoDisplay: true,
|
|
394
|
+
* dependencies: () => [playerSignal, inventorySignal]
|
|
395
|
+
* }
|
|
274
396
|
* ]
|
|
275
397
|
* })
|
|
276
|
-
* class RpgClientEngine {}
|
|
277
398
|
* ```
|
|
278
399
|
*
|
|
279
400
|
* [Guide: Create GUI](/guide/create-gui.html)
|
|
280
401
|
*
|
|
281
|
-
* @prop {Array<
|
|
402
|
+
* @prop {Array<GuiOptions>} [gui]
|
|
282
403
|
* @memberof RpgClient
|
|
283
404
|
* */
|
|
284
|
-
gui?:
|
|
405
|
+
gui?: ({
|
|
406
|
+
id: string;
|
|
407
|
+
component: ComponentFunction;
|
|
408
|
+
/**
|
|
409
|
+
* Auto display the GUI when added to the system
|
|
410
|
+
* @default false
|
|
411
|
+
*/
|
|
412
|
+
autoDisplay?: boolean;
|
|
413
|
+
/**
|
|
414
|
+
* Function that returns an array of Signal dependencies
|
|
415
|
+
* The GUI will only display when all dependencies are resolved (!= undefined)
|
|
416
|
+
*/
|
|
417
|
+
dependencies?: () => Signal[];
|
|
418
|
+
/**
|
|
419
|
+
* Attach the GUI to sprites instead of displaying globally
|
|
420
|
+
*
|
|
421
|
+
* When set to `true`, the GUI component will be rendered directly on each sprite
|
|
422
|
+
* in the game world, rather than being displayed as a fixed overlay on the screen.
|
|
423
|
+
* This is useful for tooltips, health bars, name tags, or any UI element that
|
|
424
|
+
* should follow a specific sprite.
|
|
425
|
+
*
|
|
426
|
+
* The GUI will be rendered in the `character.ce` component for each sprite.
|
|
427
|
+
* You can control the display state of attached GUIs from the server side using
|
|
428
|
+
* `player.showAttachedGui()` and `player.hideAttachedGui()` methods.
|
|
429
|
+
*
|
|
430
|
+
* @default false
|
|
431
|
+
* @example
|
|
432
|
+
* ```ts
|
|
433
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
434
|
+
* import TooltipComponent from './tooltip.ce'
|
|
435
|
+
*
|
|
436
|
+
* defineModule<RpgClient>({
|
|
437
|
+
* gui: [
|
|
438
|
+
* {
|
|
439
|
+
* id: "my-tooltip",
|
|
440
|
+
* component: TooltipComponent,
|
|
441
|
+
* attachToSprite: true
|
|
442
|
+
* }
|
|
443
|
+
* ]
|
|
444
|
+
* })
|
|
445
|
+
* ```
|
|
446
|
+
*
|
|
447
|
+
* On the server side, control the display:
|
|
448
|
+
* ```ts
|
|
449
|
+
* // Show the tooltip for this player
|
|
450
|
+
* player.showAttachedGui()
|
|
451
|
+
*
|
|
452
|
+
* // Hide the tooltip for this player
|
|
453
|
+
* player.hideAttachedGui()
|
|
454
|
+
*
|
|
455
|
+
* // Show tooltip for other players
|
|
456
|
+
* player.showAttachedGui([otherPlayer1, otherPlayer2])
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
attachToSprite?: boolean;
|
|
460
|
+
} | any)[];
|
|
285
461
|
/**
|
|
286
462
|
* Array containing the list of sounds
|
|
287
|
-
*
|
|
463
|
+
* Each element can be:
|
|
464
|
+
* - A simple object containing sound definitions
|
|
465
|
+
* - A class decorated with @Sound
|
|
288
466
|
*
|
|
289
467
|
* ```ts
|
|
290
|
-
* import {
|
|
468
|
+
* import { defineModule, RpgClient, Sound } from '@rpgjs/client'
|
|
469
|
+
*
|
|
470
|
+
* // Using simple objects
|
|
471
|
+
* defineModule<RpgClient>({
|
|
472
|
+
* sounds: [
|
|
473
|
+
* {
|
|
474
|
+
* id: 'typewriter',
|
|
475
|
+
* src: 'typewriter.wav'
|
|
476
|
+
* },
|
|
477
|
+
* {
|
|
478
|
+
* id: 'cursor',
|
|
479
|
+
* src: 'cursor.wav'
|
|
480
|
+
* }
|
|
481
|
+
* ]
|
|
482
|
+
* })
|
|
291
483
|
*
|
|
484
|
+
* // Using @Sound decorator
|
|
292
485
|
* @Sound({
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
486
|
+
* id: 'town-music',
|
|
487
|
+
* sound: require('./sound/town.ogg'),
|
|
488
|
+
* loop: true,
|
|
489
|
+
* volume: 0.5
|
|
490
|
+
* })
|
|
491
|
+
* export class TownMusic {}
|
|
492
|
+
*
|
|
493
|
+
* defineModule<RpgClient>({
|
|
494
|
+
* sounds: [TownMusic]
|
|
495
|
+
* })
|
|
496
|
+
*
|
|
497
|
+
* // Multiple sounds in one class
|
|
498
|
+
* @Sound({
|
|
499
|
+
* sounds: {
|
|
500
|
+
* hero: require('./assets/hero.ogg'),
|
|
501
|
+
* monster: require('./assets/monster.ogg')
|
|
502
|
+
* },
|
|
503
|
+
* loop: true
|
|
296
504
|
* })
|
|
297
|
-
* class
|
|
505
|
+
* export class CharacterSounds {}
|
|
298
506
|
*
|
|
299
|
-
*
|
|
300
|
-
* sounds: [
|
|
507
|
+
* defineModule<RpgClient>({
|
|
508
|
+
* sounds: [CharacterSounds]
|
|
301
509
|
* })
|
|
302
|
-
* class RpgClientEngine {}
|
|
303
510
|
* ```
|
|
304
511
|
*
|
|
305
|
-
* @prop {Array<Class>} [sounds]
|
|
512
|
+
* @prop {Array<Object | Class>} [sounds]
|
|
306
513
|
* @memberof RpgClient
|
|
307
514
|
* */
|
|
308
|
-
sounds?:
|
|
515
|
+
sounds?: any[];
|
|
309
516
|
/**
|
|
310
517
|
* Give the `RpgSprite` class. A Sprite represents a player or an event
|
|
311
518
|
*
|
|
312
519
|
* ```ts
|
|
313
|
-
* import { RpgSprite, RpgSpriteHooks, RpgClient,
|
|
520
|
+
* import { RpgSprite, RpgSpriteHooks, RpgClient, defineModule } from '@rpgjs/client'
|
|
314
521
|
*
|
|
315
522
|
* export const sprite: RpgSpriteHooks = {
|
|
316
523
|
* onInit(sprite: RpgSprite) {}
|
|
317
524
|
* }
|
|
318
525
|
*
|
|
319
|
-
*
|
|
526
|
+
* defineModule<RpgClient>({
|
|
320
527
|
* sprite
|
|
321
528
|
* })
|
|
322
|
-
* class RpgClientEngine {}
|
|
323
529
|
* ```
|
|
324
530
|
*
|
|
325
531
|
* @prop {RpgSpriteHooks} [sprite]
|
|
@@ -330,19 +536,18 @@ export interface RpgClient {
|
|
|
330
536
|
* Reference the scenes of the game. Here you can put your own class that inherits RpgSceneMap
|
|
331
537
|
*
|
|
332
538
|
* ```ts
|
|
333
|
-
* import { RpgSceneMapHooks, RpgClient,
|
|
539
|
+
* import { RpgSceneMapHooks, RpgClient, defineModule } from '@rpgjs/client'
|
|
334
540
|
*
|
|
335
541
|
* export const sceneMap: RpgSceneMapHooks = {
|
|
336
542
|
*
|
|
337
543
|
* }
|
|
338
544
|
*
|
|
339
|
-
*
|
|
545
|
+
* defineModule<RpgClient>({
|
|
340
546
|
* scenes: {
|
|
341
547
|
* // If you put the RpgSceneMap scene, Thhe key is called mandatory `map`
|
|
342
548
|
* map: sceneMap
|
|
343
549
|
* }
|
|
344
550
|
* })
|
|
345
|
-
* class RpgClientEngine {}
|
|
346
551
|
* ```
|
|
347
552
|
*
|
|
348
553
|
* @prop { [sceneName: string]: RpgSceneMapHooks } [scenes]
|
|
@@ -351,9 +556,36 @@ export interface RpgClient {
|
|
|
351
556
|
scenes?: {
|
|
352
557
|
map: RpgSceneMapHooks;
|
|
353
558
|
};
|
|
354
|
-
|
|
559
|
+
sceneMap?: RpgSceneMapHooks;
|
|
560
|
+
/**
|
|
561
|
+
* Array containing the list of component animations
|
|
562
|
+
* Each element defines a temporary component to display for animations like hits, effects, etc.
|
|
563
|
+
*
|
|
564
|
+
* ```ts
|
|
565
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
566
|
+
* import HitComponent from './hit.ce'
|
|
567
|
+
* import ExplosionComponent from './explosion.ce'
|
|
568
|
+
*
|
|
569
|
+
* defineModule<RpgClient>({
|
|
570
|
+
* componentAnimations: [
|
|
571
|
+
* {
|
|
572
|
+
* id: 'hit',
|
|
573
|
+
* component: HitComponent
|
|
574
|
+
* },
|
|
575
|
+
* {
|
|
576
|
+
* id: 'explosion',
|
|
577
|
+
* component: ExplosionComponent
|
|
578
|
+
* }
|
|
579
|
+
* ]
|
|
580
|
+
* })
|
|
581
|
+
* ```
|
|
582
|
+
*
|
|
583
|
+
* @prop {Array<{id: string, component: ComponentFunction}>} [componentAnimations]
|
|
584
|
+
* @memberof RpgClient
|
|
585
|
+
* */
|
|
586
|
+
componentAnimations?: {
|
|
355
587
|
id: string;
|
|
356
|
-
component:
|
|
588
|
+
component: ComponentFunction;
|
|
357
589
|
}[];
|
|
358
590
|
}
|
|
359
591
|
export {};
|