@rpgjs/client 5.0.0-alpha.0 → 5.0.0-alpha.10
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/RpgClient.d.ts +99 -68
- package/dist/RpgClientEngine.d.ts +86 -4
- package/dist/components/animations/index.d.ts +4 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.js +4 -4
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +6 -2
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +2 -2
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +95 -35
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +45 -186
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +187 -5
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +5 -383
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +384 -28
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +24 -17
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +147 -25
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +16 -2413
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +2395 -88
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +108 -103
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +95 -57
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +62 -12
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +18 -37
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +25 -3
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +87 -314
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +37 -21
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +3 -9
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +2 -2
- package/dist/index30.js +317 -6
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +24 -171
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +7 -497
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +8 -9
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +9 -4400
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +4397 -85
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +310 -55
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +169 -15
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +496 -15
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +61 -0
- package/dist/index39.js.map +1 -0
- package/dist/index4.js +18 -5
- package/dist/index4.js.map +1 -1
- package/dist/index40.js +20 -0
- package/dist/index40.js.map +1 -0
- package/dist/index41.js +82 -0
- package/dist/index41.js.map +1 -0
- package/dist/index5.js +2 -1
- package/dist/index5.js.map +1 -1
- package/dist/index6.js +1 -1
- package/dist/index7.js +10 -2
- package/dist/index7.js.map +1 -1
- package/dist/index8.js +24 -6
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +2 -2
- package/dist/presets/animation.d.ts +31 -0
- package/dist/presets/index.d.ts +102 -0
- package/dist/presets/lpc.d.ts +89 -0
- package/dist/services/loadMap.d.ts +123 -2
- package/dist/services/mmorpg.d.ts +7 -3
- package/package.json +14 -12
- package/src/Game/{EffectManager.ts → AnimationManager.ts} +2 -2
- package/src/Game/Object.ts +69 -0
- package/src/RpgClient.ts +101 -67
- package/src/RpgClientEngine.ts +159 -24
- package/src/components/{effects → animations}/animation.ce +3 -5
- package/src/components/{effects → animations}/index.ts +1 -1
- package/src/components/character.ce +74 -33
- package/src/components/index.ts +2 -1
- package/src/components/scenes/draw-map.ce +6 -23
- package/src/components/scenes/event-layer.ce +3 -3
- package/src/core/setup.ts +2 -0
- package/src/index.ts +1 -1
- package/src/module.ts +23 -5
- package/src/presets/animation.ts +46 -0
- package/src/presets/index.ts +5 -1
- package/src/presets/lpc.ts +108 -0
- package/src/services/loadMap.ts +131 -2
- package/src/services/mmorpg.ts +20 -4
- 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
|
@@ -1,14 +1,135 @@
|
|
|
1
1
|
import { Context } from '@signe/di';
|
|
2
2
|
export declare const LoadMapToken = "LoadMapToken";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Represents the structure of map data that should be returned by the load map callback.
|
|
5
|
+
* This interface defines all the properties that can be provided when loading a custom map.
|
|
6
|
+
*
|
|
7
|
+
* @interface MapData
|
|
8
|
+
*/
|
|
9
|
+
type MapData = {
|
|
10
|
+
/** Raw map data that will be passed to the map component */
|
|
11
|
+
data: any;
|
|
12
|
+
/** CanvasEngine component that will render the map */
|
|
13
|
+
component: any;
|
|
14
|
+
/** Optional map width in pixels, used for viewport calculations */
|
|
15
|
+
width?: number;
|
|
16
|
+
/** Optional map height in pixels, used for viewport calculations */
|
|
17
|
+
height?: number;
|
|
18
|
+
/** Optional map events data (NPCs, interactive objects, etc.) */
|
|
19
|
+
events?: any;
|
|
20
|
+
/** Optional map identifier, defaults to the mapId parameter if not provided */
|
|
21
|
+
id?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Callback function type for loading map data.
|
|
25
|
+
* This function receives a map ID and should return either a MapData object directly
|
|
26
|
+
* or a Promise that resolves to a MapData object.
|
|
27
|
+
*
|
|
28
|
+
* @callback LoadMapOptions
|
|
29
|
+
* @param {string} mapId - The identifier of the map to load
|
|
30
|
+
* @returns {Promise<MapData> | MapData} The map data object or a promise resolving to it
|
|
31
|
+
*/
|
|
32
|
+
export type LoadMapOptions = (mapId: string) => Promise<MapData> | MapData;
|
|
4
33
|
export declare class LoadMapService {
|
|
5
34
|
private context;
|
|
6
35
|
private options;
|
|
7
36
|
private updateMapService;
|
|
8
37
|
constructor(context: Context, options: LoadMapOptions);
|
|
9
|
-
load(mapId: string): Promise<
|
|
38
|
+
load(mapId: string): Promise<MapData>;
|
|
10
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a dependency injection configuration for custom map loading on the client side.
|
|
42
|
+
*
|
|
43
|
+
* This function allows you to customize how maps are loaded and displayed by providing
|
|
44
|
+
* a callback that defines custom map data and rendering components. It's designed to work
|
|
45
|
+
* with the RPG-JS dependency injection system and enables integration of custom map formats
|
|
46
|
+
* like Tiled TMX files or any other map data structure.
|
|
47
|
+
*
|
|
48
|
+
* The function sets up the necessary service providers for map loading, including:
|
|
49
|
+
* - UpdateMapToken: Handles map updates in the client context
|
|
50
|
+
* - LoadMapToken: Provides the LoadMapService with your custom loading logic
|
|
51
|
+
*
|
|
52
|
+
* **Design Concept:**
|
|
53
|
+
* The function follows the provider pattern, creating a modular way to inject custom
|
|
54
|
+
* map loading behavior into the RPG-JS client engine. It separates the concern of
|
|
55
|
+
* map data fetching from map rendering, allowing developers to focus on their specific
|
|
56
|
+
* map format while leveraging the engine's rendering capabilities.
|
|
57
|
+
*
|
|
58
|
+
* @param {LoadMapOptions} options - Callback function that handles map loading logic
|
|
59
|
+
* @returns {Array<Object>} Array of dependency injection provider configurations
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* import { provideLoadMap } from '@rpgjs/client'
|
|
64
|
+
* import { createModule } from '@rpgjs/common'
|
|
65
|
+
* import MyTiledMapComponent from './MyTiledMapComponent.ce'
|
|
66
|
+
*
|
|
67
|
+
* // Basic usage with JSON map data
|
|
68
|
+
* export function provideCustomMap() {
|
|
69
|
+
* return createModule("CustomMap", [
|
|
70
|
+
* provideLoadMap(async (mapId) => {
|
|
71
|
+
* const response = await fetch(`/maps/${mapId}.json`)
|
|
72
|
+
* const mapData = await response.json()
|
|
73
|
+
*
|
|
74
|
+
* return {
|
|
75
|
+
* data: mapData,
|
|
76
|
+
* component: MyTiledMapComponent,
|
|
77
|
+
* width: mapData.width,
|
|
78
|
+
* height: mapData.height,
|
|
79
|
+
* events: mapData.events
|
|
80
|
+
* }
|
|
81
|
+
* })
|
|
82
|
+
* ])
|
|
83
|
+
* }
|
|
84
|
+
*
|
|
85
|
+
* // Advanced usage with Tiled TMX files
|
|
86
|
+
* export function provideTiledMap() {
|
|
87
|
+
* return createModule("TiledMap", [
|
|
88
|
+
* provideLoadMap(async (mapId) => {
|
|
89
|
+
* // Load TMX file
|
|
90
|
+
* const tmxResponse = await fetch(`/tiled/${mapId}.tmx`)
|
|
91
|
+
* const tmxData = await tmxResponse.text()
|
|
92
|
+
*
|
|
93
|
+
* // Parse TMX data (using a TMX parser)
|
|
94
|
+
* const parsedMap = parseTMX(tmxData)
|
|
95
|
+
*
|
|
96
|
+
* return {
|
|
97
|
+
* data: parsedMap,
|
|
98
|
+
* component: TiledMapRenderer,
|
|
99
|
+
* width: parsedMap.width * parsedMap.tilewidth,
|
|
100
|
+
* height: parsedMap.height * parsedMap.tileheight,
|
|
101
|
+
* events: parsedMap.objectGroups?.find(g => g.name === 'events')?.objects
|
|
102
|
+
* }
|
|
103
|
+
* })
|
|
104
|
+
* ])
|
|
105
|
+
* }
|
|
106
|
+
*
|
|
107
|
+
* // Synchronous usage for static maps
|
|
108
|
+
* export function provideStaticMap() {
|
|
109
|
+
* return createModule("StaticMap", [
|
|
110
|
+
* provideLoadMap((mapId) => {
|
|
111
|
+
* const staticMaps = {
|
|
112
|
+
* 'town': { tiles: [...], npcs: [...] },
|
|
113
|
+
* 'dungeon': { tiles: [...], monsters: [...] }
|
|
114
|
+
* }
|
|
115
|
+
*
|
|
116
|
+
* return {
|
|
117
|
+
* data: staticMaps[mapId],
|
|
118
|
+
* component: StaticMapComponent,
|
|
119
|
+
* width: 800,
|
|
120
|
+
* height: 600
|
|
121
|
+
* }
|
|
122
|
+
* })
|
|
123
|
+
* ])
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* @since 4.0.0
|
|
128
|
+
* @see {@link LoadMapOptions} for callback function signature
|
|
129
|
+
* @see {@link MapData} for return data structure
|
|
130
|
+
*/
|
|
11
131
|
export declare function provideLoadMap(options: LoadMapOptions): {
|
|
12
132
|
provide: string;
|
|
13
133
|
useFactory: (context: Context) => void;
|
|
14
134
|
}[];
|
|
135
|
+
export {};
|
|
@@ -4,17 +4,21 @@ import { RpgClientEngine } from '../RpgClientEngine';
|
|
|
4
4
|
import { AbstractWebsocket } from './AbstractSocket';
|
|
5
5
|
import { UpdateMapService } from '@rpgjs/common';
|
|
6
6
|
interface MmorpgOptions {
|
|
7
|
-
host
|
|
7
|
+
host?: string;
|
|
8
8
|
}
|
|
9
9
|
declare class BridgeWebsocket extends AbstractWebsocket {
|
|
10
10
|
protected context: Context;
|
|
11
11
|
private options;
|
|
12
12
|
private socket;
|
|
13
|
-
constructor(context: Context, options
|
|
14
|
-
connection(): Promise<void>;
|
|
13
|
+
constructor(context: Context, options?: MmorpgOptions);
|
|
14
|
+
connection(listeners?: (data: any) => void): Promise<void>;
|
|
15
15
|
on(key: string, callback: (data: any) => void): void;
|
|
16
16
|
off(event: string, callback: (data: any) => void): void;
|
|
17
17
|
emit(event: string, data: any): void;
|
|
18
|
+
updateProperties({ room }: {
|
|
19
|
+
room: any;
|
|
20
|
+
}): void;
|
|
21
|
+
reconnect(listeners?: (data: any) => void): Promise<void>;
|
|
18
22
|
}
|
|
19
23
|
declare class UpdateMapStandaloneService extends UpdateMapService {
|
|
20
24
|
protected context: Context;
|
package/package.json
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpgjs/client",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.10",
|
|
4
4
|
"description": "RPGJS is a framework for creating RPG/MMORPG games",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"dev": "vite build --watch",
|
|
12
|
-
"build": "vite build"
|
|
13
|
-
},
|
|
14
10
|
"keywords": [
|
|
15
11
|
"rpg",
|
|
16
12
|
"game",
|
|
@@ -20,21 +16,27 @@
|
|
|
20
16
|
],
|
|
21
17
|
"author": "Samuel Ronce",
|
|
22
18
|
"license": "MIT",
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@canvasengine/presets": "*",
|
|
21
|
+
"canvasengine": "*",
|
|
22
|
+
"pixi.js": "^8.9.2"
|
|
23
|
+
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@rpgjs/common": "workspace:*",
|
|
25
|
+
"@rpgjs/common": "5.0.0-alpha.10",
|
|
26
26
|
"@signe/di": "^2.3.3",
|
|
27
27
|
"@signe/room": "^2.3.3",
|
|
28
28
|
"@signe/sync": "^2.3.3",
|
|
29
|
-
"canvasengine": "2.0.0-beta.22",
|
|
30
|
-
"pixi.js": "^8.10.1",
|
|
31
29
|
"rxjs": "^7.8.2"
|
|
32
30
|
},
|
|
33
31
|
"devDependencies": {
|
|
34
|
-
"@canvasengine/compiler": "2.0.0-beta.
|
|
32
|
+
"@canvasengine/compiler": "2.0.0-beta.22",
|
|
35
33
|
"vite": "^6.2.5",
|
|
36
34
|
"vite-plugin-dts": "^4.5.3",
|
|
37
35
|
"vitest": "^3.1.1"
|
|
38
36
|
},
|
|
39
|
-
"type": "module"
|
|
40
|
-
|
|
37
|
+
"type": "module",
|
|
38
|
+
"scripts": {
|
|
39
|
+
"dev": "vite build --watch",
|
|
40
|
+
"build": "vite build"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { generateUID, RpgCommonPlayer } from "@rpgjs/common";
|
|
2
2
|
import { signal } from "canvasengine";
|
|
3
3
|
|
|
4
|
-
export class
|
|
4
|
+
export class AnimationManager {
|
|
5
5
|
current = signal<any[]>([]);
|
|
6
6
|
|
|
7
|
-
displayEffect(params: any, player: RpgCommonPlayer) {
|
|
7
|
+
displayEffect(params: any, player: RpgCommonPlayer | { x: number, y: number }) {
|
|
8
8
|
const id = generateUID();
|
|
9
9
|
this.current().push({
|
|
10
10
|
...params,
|
package/src/Game/Object.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { RpgCommonPlayer } from "@rpgjs/common";
|
|
2
2
|
import { trigger, signal } from "canvasengine";
|
|
3
|
+
import { Subscription } from "rxjs";
|
|
3
4
|
|
|
4
5
|
export abstract class RpgClientObject extends RpgCommonPlayer {
|
|
5
6
|
abstract type: string;
|
|
6
7
|
emitParticleTrigger = trigger()
|
|
7
8
|
particleName = signal('')
|
|
9
|
+
animationCurrentIndex = signal(0)
|
|
10
|
+
animationIsPlaying = signal(false)
|
|
11
|
+
private animationSubscription?: Subscription
|
|
8
12
|
|
|
9
13
|
flash(color: string, duration: number = 100) {
|
|
10
14
|
const lastTint = this.tint()
|
|
@@ -13,4 +17,69 @@ export abstract class RpgClientObject extends RpgCommonPlayer {
|
|
|
13
17
|
this.tint.set(lastTint)
|
|
14
18
|
}, duration)
|
|
15
19
|
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reset animation state when animation changes externally
|
|
23
|
+
*
|
|
24
|
+
* This method should be called when the animation changes due to movement
|
|
25
|
+
* or other external factors to ensure the animation system doesn't get stuck
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* // Reset when player starts moving
|
|
30
|
+
* player.resetAnimationState();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
resetAnimationState() {
|
|
34
|
+
this.animationIsPlaying.set(false);
|
|
35
|
+
this.animationCurrentIndex.set(0);
|
|
36
|
+
if (this.animationSubscription) {
|
|
37
|
+
this.animationSubscription.unsubscribe();
|
|
38
|
+
this.animationSubscription = undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Set a custom animation for a specific number of times
|
|
44
|
+
*
|
|
45
|
+
* Plays a custom animation for the specified number of repetitions.
|
|
46
|
+
* The animation system prevents overlapping animations and automatically
|
|
47
|
+
* returns to the previous animation when complete.
|
|
48
|
+
*
|
|
49
|
+
* @param animationName - Name of the animation to play
|
|
50
|
+
* @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* // Play attack animation 3 times
|
|
55
|
+
* player.setAnimation('attack', 3);
|
|
56
|
+
*
|
|
57
|
+
* // Play continuous spell animation
|
|
58
|
+
* player.setAnimation('spell');
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
setAnimation(animationName: string, nbTimes: number = Infinity) {
|
|
62
|
+
if (this.animationIsPlaying()) return;
|
|
63
|
+
this.animationIsPlaying.set(true);
|
|
64
|
+
const previousAnimationName = this.animationName();
|
|
65
|
+
this.animationCurrentIndex.set(0);
|
|
66
|
+
|
|
67
|
+
// Clean up any existing subscription
|
|
68
|
+
if (this.animationSubscription) {
|
|
69
|
+
this.animationSubscription.unsubscribe();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.animationSubscription = this.animationCurrentIndex.observable.subscribe(index => {
|
|
73
|
+
if (index >= nbTimes) {
|
|
74
|
+
this.animationCurrentIndex.set(0);
|
|
75
|
+
this.animationName.set(previousAnimationName);
|
|
76
|
+
this.animationIsPlaying.set(false);
|
|
77
|
+
if (this.animationSubscription) {
|
|
78
|
+
this.animationSubscription.unsubscribe();
|
|
79
|
+
this.animationSubscription = undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
this.animationName.set(animationName);
|
|
84
|
+
}
|
|
16
85
|
}
|
package/src/RpgClient.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { ComponentFunction } from 'canvasengine'
|
|
1
2
|
import { RpgClientEngine } from './RpgClientEngine'
|
|
2
|
-
import { Loader } from 'pixi.js'
|
|
3
|
+
import { Loader, Container } from 'pixi.js'
|
|
3
4
|
|
|
4
5
|
type RpgClass<T = any> = new (...args: any[]) => T
|
|
5
|
-
type RpgComponent =
|
|
6
|
-
type SceneMap =
|
|
6
|
+
type RpgComponent = Container
|
|
7
|
+
type SceneMap = Container
|
|
7
8
|
|
|
8
9
|
export interface RpgClientEngineHooks {
|
|
9
10
|
/**
|
|
@@ -12,7 +13,7 @@ export interface RpgClientEngineHooks {
|
|
|
12
13
|
* @prop { (engine: RpgClientEngine) => boolean | any } [onStart]
|
|
13
14
|
* @memberof RpgEngineHooks
|
|
14
15
|
*/
|
|
15
|
-
onStart?: (engine: RpgClientEngine) => boolean | void
|
|
16
|
+
onStart?: (engine: RpgClientEngine) => boolean | void | Promise<boolean | void>
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Each frame
|
|
@@ -65,6 +66,36 @@ export interface RpgClientEngineHooks {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
export interface RpgSpriteHooks {
|
|
69
|
+
/**
|
|
70
|
+
* Array of components to render behind the sprite
|
|
71
|
+
* These components will be displayed with a lower z-index than the sprite itself
|
|
72
|
+
*
|
|
73
|
+
* @prop { ComponentFunction[] } [componentsBehind]
|
|
74
|
+
* @memberof RpgSpriteHooks
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const sprite: RpgSpriteHooks = {
|
|
78
|
+
* componentsBehind: [ShadowComponent, AuraComponent]
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
componentsBehind?: ComponentFunction[]
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Array of components to render in front of the sprite
|
|
86
|
+
* These components will be displayed with a higher z-index than the sprite itself
|
|
87
|
+
*
|
|
88
|
+
* @prop { ComponentFunction[] } [componentsInFront]
|
|
89
|
+
* @memberof RpgSpriteHooks
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const sprite: RpgSpriteHooks = {
|
|
93
|
+
* componentsInFront: [HealthBarComponent, StatusEffectComponent]
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
componentsInFront?: ComponentFunction[]
|
|
98
|
+
|
|
68
99
|
/**
|
|
69
100
|
* As soon as the sprite is initialized
|
|
70
101
|
*
|
|
@@ -178,14 +209,13 @@ export interface RpgClient {
|
|
|
178
209
|
* @example
|
|
179
210
|
*
|
|
180
211
|
* ```ts
|
|
181
|
-
* import { RpgClient,
|
|
212
|
+
* import { RpgClient, defineModule } from '@rpgjs/client'
|
|
182
213
|
*
|
|
183
|
-
*
|
|
214
|
+
* defineModule<RpgClient>({
|
|
184
215
|
* hooks: {
|
|
185
216
|
* player: ['onAuth']
|
|
186
217
|
* }
|
|
187
218
|
* })
|
|
188
|
-
* class RpgClientEngine { }
|
|
189
219
|
* ```
|
|
190
220
|
*
|
|
191
221
|
* Emit the hook:
|
|
@@ -224,7 +254,7 @@ export interface RpgClient {
|
|
|
224
254
|
* Object containing the hooks concerning the engine
|
|
225
255
|
*
|
|
226
256
|
* ```ts
|
|
227
|
-
* import { RpgClientEngine, RpgClientEngineHooks,
|
|
257
|
+
* import { RpgClientEngine, RpgClientEngineHooks, defineModule, RpgClient } from '@rpgjs/client'
|
|
228
258
|
*
|
|
229
259
|
* const engine: RpgClientEngineHooks = {
|
|
230
260
|
* onConnected(engine: RpgClientEngine) {
|
|
@@ -232,10 +262,9 @@ export interface RpgClient {
|
|
|
232
262
|
* }
|
|
233
263
|
* }
|
|
234
264
|
*
|
|
235
|
-
*
|
|
265
|
+
* defineModule<RpgClient>({
|
|
236
266
|
* engine
|
|
237
267
|
* })
|
|
238
|
-
* class RpgClientModule {}
|
|
239
268
|
* ```
|
|
240
269
|
*
|
|
241
270
|
* @prop {RpgClientEngineHooks} [engine]
|
|
@@ -245,29 +274,32 @@ export interface RpgClient {
|
|
|
245
274
|
|
|
246
275
|
/**
|
|
247
276
|
* Array containing the list of spritesheets
|
|
248
|
-
*
|
|
277
|
+
* Each element is a simple object containing spritesheet definitions
|
|
249
278
|
*
|
|
250
279
|
* ```ts
|
|
251
|
-
* import {
|
|
252
|
-
*
|
|
253
|
-
* @Spritesheet({
|
|
254
|
-
* id: 'chest',
|
|
255
|
-
* image: require('./assets/chest.png'),
|
|
256
|
-
* // other options
|
|
257
|
-
* })
|
|
258
|
-
* class Chest { }
|
|
280
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
259
281
|
*
|
|
260
|
-
*
|
|
282
|
+
* defineModule<RpgClient>({
|
|
261
283
|
* spritesheets: [
|
|
262
|
-
*
|
|
284
|
+
* {
|
|
285
|
+
* id: 'chest',
|
|
286
|
+
* image: require('./assets/chest.png'),
|
|
287
|
+
* framesWidth: 32,
|
|
288
|
+
* framesHeight: 32,
|
|
289
|
+
* animations: {
|
|
290
|
+
* default: {
|
|
291
|
+
* frames: [0, 1, 2],
|
|
292
|
+
* duration: 1000
|
|
293
|
+
* }
|
|
294
|
+
* }
|
|
295
|
+
* }
|
|
263
296
|
* ]
|
|
264
297
|
* })
|
|
265
|
-
* class RpgClientEngine {}
|
|
266
298
|
* ```
|
|
267
299
|
*
|
|
268
300
|
* [Guide: Create Sprite](/guide/create-sprite.html)
|
|
269
301
|
*
|
|
270
|
-
* @prop {Array<
|
|
302
|
+
* @prop {Array<Object>} [spritesheets]
|
|
271
303
|
* @memberof RpgClient
|
|
272
304
|
* */
|
|
273
305
|
spritesheets?: any[],
|
|
@@ -275,72 +307,49 @@ export interface RpgClient {
|
|
|
275
307
|
/**
|
|
276
308
|
* Array containing the list of VueJS components
|
|
277
309
|
*
|
|
278
|
-
* ```ts
|
|
279
|
-
* import { RpgClient, RpgModule } from '@rpgjs/client'
|
|
280
|
-
*
|
|
281
|
-
* const component = {
|
|
282
|
-
* name: 'my-gui',
|
|
283
|
-
* template: `
|
|
284
|
-
* <div>
|
|
285
|
-
* Component
|
|
286
|
-
* </div>
|
|
287
|
-
* `
|
|
288
|
-
* }
|
|
289
|
-
*
|
|
290
|
-
* @RpgModule<RpgClient>({
|
|
291
|
-
* gui: [
|
|
292
|
-
* component
|
|
293
|
-
* ]
|
|
294
|
-
* })
|
|
295
|
-
* class RpgClientEngine {}
|
|
296
|
-
* ```
|
|
297
310
|
*
|
|
298
311
|
* [Guide: Create GUI](/guide/create-gui.html)
|
|
299
312
|
*
|
|
300
|
-
* @prop {Array<Component of
|
|
313
|
+
* @prop {Array<Component of CanvasEngine>} [gui]
|
|
301
314
|
* @memberof RpgClient
|
|
302
315
|
* */
|
|
303
|
-
gui?:
|
|
316
|
+
gui?: ComponentFunction[],
|
|
304
317
|
|
|
305
318
|
/**
|
|
306
319
|
* Array containing the list of sounds
|
|
307
|
-
*
|
|
320
|
+
* Each element is a simple object containing sound definitions
|
|
308
321
|
*
|
|
309
322
|
* ```ts
|
|
310
|
-
* import {
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
* sounds:
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
* @RpgModule<RpgClient>({
|
|
320
|
-
* sounds: [ Sounds ]
|
|
323
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
324
|
+
*
|
|
325
|
+
* defineModule<RpgClient>({
|
|
326
|
+
* sounds: [
|
|
327
|
+
* {
|
|
328
|
+
* town: require('./assets/Town_Theme.ogg'),
|
|
329
|
+
* battle: require('./assets/Battle_Theme.ogg')
|
|
330
|
+
* }
|
|
331
|
+
* ]
|
|
321
332
|
* })
|
|
322
|
-
* class RpgClientEngine {}
|
|
323
333
|
* ```
|
|
324
334
|
*
|
|
325
|
-
* @prop {Array<
|
|
335
|
+
* @prop {Array<Object>} [sounds]
|
|
326
336
|
* @memberof RpgClient
|
|
327
337
|
* */
|
|
328
|
-
sounds?:
|
|
338
|
+
sounds?: any[],
|
|
329
339
|
|
|
330
340
|
/**
|
|
331
341
|
* Give the `RpgSprite` class. A Sprite represents a player or an event
|
|
332
342
|
*
|
|
333
343
|
* ```ts
|
|
334
|
-
* import { RpgSprite, RpgSpriteHooks, RpgClient,
|
|
344
|
+
* import { RpgSprite, RpgSpriteHooks, RpgClient, defineModule } from '@rpgjs/client'
|
|
335
345
|
*
|
|
336
346
|
* export const sprite: RpgSpriteHooks = {
|
|
337
347
|
* onInit(sprite: RpgSprite) {}
|
|
338
348
|
* }
|
|
339
349
|
*
|
|
340
|
-
*
|
|
350
|
+
* defineModule<RpgClient>({
|
|
341
351
|
* sprite
|
|
342
352
|
* })
|
|
343
|
-
* class RpgClientEngine {}
|
|
344
353
|
* ```
|
|
345
354
|
*
|
|
346
355
|
* @prop {RpgSpriteHooks} [sprite]
|
|
@@ -352,19 +361,18 @@ export interface RpgClient {
|
|
|
352
361
|
* Reference the scenes of the game. Here you can put your own class that inherits RpgSceneMap
|
|
353
362
|
*
|
|
354
363
|
* ```ts
|
|
355
|
-
* import { RpgSceneMapHooks, RpgClient,
|
|
364
|
+
* import { RpgSceneMapHooks, RpgClient, defineModule } from '@rpgjs/client'
|
|
356
365
|
*
|
|
357
366
|
* export const sceneMap: RpgSceneMapHooks = {
|
|
358
367
|
*
|
|
359
368
|
* }
|
|
360
369
|
*
|
|
361
|
-
*
|
|
370
|
+
* defineModule<RpgClient>({
|
|
362
371
|
* scenes: {
|
|
363
372
|
* // If you put the RpgSceneMap scene, Thhe key is called mandatory `map`
|
|
364
373
|
* map: sceneMap
|
|
365
374
|
* }
|
|
366
375
|
* })
|
|
367
|
-
* class RpgClientEngine {}
|
|
368
376
|
* ```
|
|
369
377
|
*
|
|
370
378
|
* @prop { [sceneName: string]: RpgSceneMapHooks } [scenes]
|
|
@@ -374,8 +382,34 @@ export interface RpgClient {
|
|
|
374
382
|
map: RpgSceneMapHooks
|
|
375
383
|
}
|
|
376
384
|
|
|
377
|
-
|
|
385
|
+
/**
|
|
386
|
+
* Array containing the list of component animations
|
|
387
|
+
* Each element defines a temporary component to display for animations like hits, effects, etc.
|
|
388
|
+
*
|
|
389
|
+
* ```ts
|
|
390
|
+
* import { defineModule, RpgClient } from '@rpgjs/client'
|
|
391
|
+
* import HitComponent from './hit.ce'
|
|
392
|
+
* import ExplosionComponent from './explosion.ce'
|
|
393
|
+
*
|
|
394
|
+
* defineModule<RpgClient>({
|
|
395
|
+
* componentAnimations: [
|
|
396
|
+
* {
|
|
397
|
+
* id: 'hit',
|
|
398
|
+
* component: HitComponent
|
|
399
|
+
* },
|
|
400
|
+
* {
|
|
401
|
+
* id: 'explosion',
|
|
402
|
+
* component: ExplosionComponent
|
|
403
|
+
* }
|
|
404
|
+
* ]
|
|
405
|
+
* })
|
|
406
|
+
* ```
|
|
407
|
+
*
|
|
408
|
+
* @prop {Array<{id: string, component: ComponentFunction}>} [componentAnimations]
|
|
409
|
+
* @memberof RpgClient
|
|
410
|
+
* */
|
|
411
|
+
componentAnimations?: {
|
|
378
412
|
id: string,
|
|
379
|
-
component:
|
|
413
|
+
component: ComponentFunction
|
|
380
414
|
}[]
|
|
381
415
|
}
|