@rpgjs/client 5.0.0-alpha.10 → 5.0.0-alpha.2
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/EffectManager.d.ts +5 -0
- package/dist/RpgClient.d.ts +68 -99
- package/dist/RpgClientEngine.d.ts +4 -86
- package/dist/components/effects/index.d.ts +4 -0
- package/dist/components/index.d.ts +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- 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 +2 -6
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +2 -2
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +35 -95
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +186 -45
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +5 -187
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +383 -5
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +28 -384
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +17 -24
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +25 -147
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +2413 -16
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +88 -2395
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +103 -108
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +57 -95
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +12 -62
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +37 -18
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +3 -25
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +314 -87
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +21 -37
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +9 -3
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +2 -2
- package/dist/index30.js +6 -317
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +171 -24
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +497 -7
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +9 -8
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +4400 -9
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +307 -4394
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +85 -310
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +56 -169
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +16 -497
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +10 -51
- package/dist/index39.js.map +1 -1
- package/dist/index4.js +5 -18
- package/dist/index4.js.map +1 -1
- package/dist/index5.js +1 -2
- package/dist/index5.js.map +1 -1
- package/dist/index6.js +1 -1
- package/dist/index7.js +2 -10
- package/dist/index7.js.map +1 -1
- package/dist/index8.js +6 -24
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +2 -2
- package/dist/presets/index.d.ts +0 -102
- package/dist/services/loadMap.d.ts +2 -123
- package/dist/services/mmorpg.d.ts +3 -7
- package/package.json +12 -14
- package/src/Game/{AnimationManager.ts → EffectManager.ts} +2 -2
- package/src/Game/Object.ts +0 -69
- package/src/RpgClient.ts +67 -101
- package/src/RpgClientEngine.ts +24 -159
- package/src/components/character.ce +33 -74
- package/src/components/{animations → effects}/animation.ce +5 -3
- package/src/components/{animations → effects}/index.ts +1 -1
- package/src/components/index.ts +1 -2
- package/src/components/scenes/draw-map.ce +23 -6
- package/src/components/scenes/element-map.ce +23 -0
- package/src/components/scenes/event-layer.ce +3 -3
- package/src/core/setup.ts +0 -2
- package/src/index.ts +1 -1
- package/src/module.ts +5 -23
- package/src/presets/index.ts +1 -5
- package/src/services/loadMap.ts +2 -131
- package/src/services/mmorpg.ts +4 -20
- package/tsconfig.json +1 -1
- package/vite.config.ts +1 -1
- package/dist/Game/AnimationManager.d.ts +0 -8
- package/dist/components/animations/index.d.ts +0 -4
- package/dist/index40.js +0 -20
- package/dist/index40.js.map +0 -1
- package/dist/index41.js +0 -82
- package/dist/index41.js.map +0 -1
- package/dist/presets/animation.d.ts +0 -31
- package/dist/presets/lpc.d.ts +0 -89
- package/src/presets/animation.ts +0 -46
- package/src/presets/lpc.ts +0 -108
- /package/src/components/{animations → effects}/hit.ce +0 -0
package/dist/index4.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import { connectionRoom } from './
|
|
1
|
+
import { connectionRoom } from './index21.js';
|
|
2
2
|
import { RpgGui } from './index9.js';
|
|
3
3
|
import { RpgClientEngine } from './index2.js';
|
|
4
|
-
import { WebSocketToken, AbstractWebsocket } from './
|
|
4
|
+
import { WebSocketToken, AbstractWebsocket } from './index16.js';
|
|
5
5
|
import { UpdateMapToken, UpdateMapService } from '@rpgjs/common';
|
|
6
6
|
|
|
7
7
|
class BridgeWebsocket extends AbstractWebsocket {
|
|
8
|
-
constructor(context, options
|
|
8
|
+
constructor(context, options) {
|
|
9
9
|
super(context);
|
|
10
10
|
this.context = context;
|
|
11
11
|
this.options = options;
|
|
12
12
|
}
|
|
13
|
-
async connection(
|
|
13
|
+
async connection() {
|
|
14
14
|
class Room {
|
|
15
15
|
}
|
|
16
16
|
const instance = new Room();
|
|
17
|
-
this.socket = await connectionRoom(
|
|
18
|
-
host: this.options.host || window.location.host,
|
|
19
|
-
room: "lobby-1"
|
|
20
|
-
}, instance);
|
|
21
|
-
listeners?.(this.socket);
|
|
17
|
+
this.socket = await connectionRoom(this.options, instance);
|
|
22
18
|
}
|
|
23
19
|
on(key, callback) {
|
|
24
20
|
this.socket.on(key, callback);
|
|
@@ -29,15 +25,6 @@ class BridgeWebsocket extends AbstractWebsocket {
|
|
|
29
25
|
emit(event, data) {
|
|
30
26
|
this.socket.emit(event, data);
|
|
31
27
|
}
|
|
32
|
-
updateProperties({ room }) {
|
|
33
|
-
this.socket.conn.updateProperties({
|
|
34
|
-
room,
|
|
35
|
-
host: this.options.host
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
async reconnect(listeners) {
|
|
39
|
-
this.socket.conn.reconnect();
|
|
40
|
-
}
|
|
41
28
|
}
|
|
42
29
|
class UpdateMapStandaloneService extends UpdateMapService {
|
|
43
30
|
constructor(context, options) {
|
package/dist/index4.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index4.js","sources":["../src/services/mmorpg.ts"],"sourcesContent":["import { Context } from \"@signe/di\";\nimport { connectionRoom } from \"@signe/sync/client\";\nimport { RpgGui } from \"../Gui/Gui\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { AbstractWebsocket, WebSocketToken } from \"./AbstractSocket\";\nimport { UpdateMapService, UpdateMapToken } from \"@rpgjs/common\";\n\ninterface MmorpgOptions {\n host
|
|
1
|
+
{"version":3,"file":"index4.js","sources":["../src/services/mmorpg.ts"],"sourcesContent":["import { Context } from \"@signe/di\";\nimport { connectionRoom } from \"@signe/sync/client\";\nimport { RpgGui } from \"../Gui/Gui\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { AbstractWebsocket, WebSocketToken } from \"./AbstractSocket\";\nimport { UpdateMapService, UpdateMapToken } from \"@rpgjs/common\";\n\ninterface MmorpgOptions {\n host: string;\n}\n\nclass BridgeWebsocket extends AbstractWebsocket {\n private socket: any;\n\n constructor(protected context: Context, private options: MmorpgOptions) {\n super(context);\n }\n\n async connection() {\n // tmp\n class Room {\n \n }\n const instance = new Room()\n this.socket = await connectionRoom(this.options, instance)\n }\n\n on(key: string, callback: (data: any) => void) {\n this.socket.on(key, callback);\n }\n\n off(event: string, callback: (data: any) => void) {\n this.socket.off(event, callback);\n }\n\n emit(event: string, data: any) {\n this.socket.emit(event, data);\n }\n}\n\nclass UpdateMapStandaloneService extends UpdateMapService {\n constructor(protected context: Context, private options: MmorpgOptions) {\n super(context);\n }\n\n async update(map: any) {\n // nothing\n }\n}\n\nexport function provideMmorpg(options: MmorpgOptions) {\n return [\n {\n provide: WebSocketToken,\n useFactory: (context: Context) => new BridgeWebsocket(context, options),\n },\n {\n provide: UpdateMapToken,\n useFactory: (context: Context) => new UpdateMapStandaloneService(context, options),\n },\n RpgGui,\n RpgClientEngine,\n ];\n}\n"],"names":[],"mappings":";;;;;;AAWA,MAAM,wBAAwB,iBAAkB,CAAA;AAAA,EAG9C,WAAA,CAAsB,SAA0B,OAAwB,EAAA;AACtE,IAAA,KAAA,CAAM,OAAO,CAAA;AADO,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAA0B,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA;AAEhD,EAEA,MAAM,UAAa,GAAA;AAAA,IAEjB,MAAM,IAAK,CAAA;AAAA;AAGX,IAAM,MAAA,QAAA,GAAW,IAAI,IAAK,EAAA;AAC1B,IAAA,IAAA,CAAK,MAAS,GAAA,MAAM,cAAe,CAAA,IAAA,CAAK,SAAS,QAAQ,CAAA;AAAA;AAC3D,EAEA,EAAA,CAAG,KAAa,QAA+B,EAAA;AAC7C,IAAK,IAAA,CAAA,MAAA,CAAO,EAAG,CAAA,GAAA,EAAK,QAAQ,CAAA;AAAA;AAC9B,EAEA,GAAA,CAAI,OAAe,QAA+B,EAAA;AAChD,IAAK,IAAA,CAAA,MAAA,CAAO,GAAI,CAAA,KAAA,EAAO,QAAQ,CAAA;AAAA;AACjC,EAEA,IAAA,CAAK,OAAe,IAAW,EAAA;AAC7B,IAAK,IAAA,CAAA,MAAA,CAAO,IAAK,CAAA,KAAA,EAAO,IAAI,CAAA;AAAA;AAEhC;AAEA,MAAM,mCAAmC,gBAAiB,CAAA;AAAA,EACxD,WAAA,CAAsB,SAA0B,OAAwB,EAAA;AACtE,IAAA,KAAA,CAAM,OAAO,CAAA;AADO,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAA0B,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA;AAEhD,EAEA,MAAM,OAAO,GAAU,EAAA;AAAA;AAGzB;AAEO,SAAS,cAAc,OAAwB,EAAA;AACpD,EAAO,OAAA;AAAA,IACL;AAAA,MACE,OAAS,EAAA,cAAA;AAAA,MACT,YAAY,CAAC,OAAA,KAAqB,IAAI,eAAA,CAAgB,SAAS,OAAO;AAAA,KACxE;AAAA,IACA;AAAA,MACE,OAAS,EAAA,cAAA;AAAA,MACT,YAAY,CAAC,OAAA,KAAqB,IAAI,0BAAA,CAA2B,SAAS,OAAO;AAAA,KACnF;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
package/dist/index5.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { injector, inject, Context } from './index15.js';
|
|
2
2
|
import { RpgClientEngine } from './index2.js';
|
|
3
3
|
import { setInject } from './index6.js';
|
|
4
4
|
|
|
5
5
|
async function startGame(options) {
|
|
6
6
|
const context = new Context();
|
|
7
|
-
context["side"] = "client";
|
|
8
7
|
setInject(context);
|
|
9
8
|
await injector(context, options.providers);
|
|
10
9
|
const engine = inject(context, RpgClientEngine);
|
package/dist/index5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index5.js","sources":["../src/core/setup.ts"],"sourcesContent":["import { Context, FactoryProvider, findProvider, findProviders, inject, injector, Providers } from \"@signe/di\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { setInject } from \"./inject\";\n\ninterface SetupOptions {\n providers: Providers;\n}\n\
|
|
1
|
+
{"version":3,"file":"index5.js","sources":["../src/core/setup.ts"],"sourcesContent":["import { Context, FactoryProvider, findProvider, findProviders, inject, injector, Providers } from \"@signe/di\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { setInject } from \"./inject\";\n\ninterface SetupOptions {\n providers: Providers;\n}\n\nexport async function startGame(options: SetupOptions) {\n const context = new Context();\n setInject(context);\n\n await injector(context, options.providers);\n\n const engine = inject(context, RpgClientEngine);\n await engine.start();\n return context;\n}"],"names":[],"mappings":";;;;AAQA,eAAsB,UAAU,OAAuB,EAAA;AACrD,EAAM,MAAA,OAAA,GAAU,IAAI,OAAQ,EAAA;AAC5B,EAAA,SAAA,CAAU,OAAO,CAAA;AAEjB,EAAM,MAAA,QAAA,CAAS,OAAS,EAAA,OAAA,CAAQ,SAAS,CAAA;AAEzC,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,OAAA,EAAS,eAAe,CAAA;AAC9C,EAAA,MAAM,OAAO,KAAM,EAAA;AACnB,EAAO,OAAA,OAAA;AACT;;;;"}
|
package/dist/index6.js
CHANGED
package/dist/index7.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject } from './
|
|
1
|
+
import { inject } from './index15.js';
|
|
2
2
|
import { UpdateMapToken } from '@rpgjs/common';
|
|
3
3
|
|
|
4
4
|
const LoadMapToken = "LoadMapToken";
|
|
@@ -6,9 +6,6 @@ class LoadMapService {
|
|
|
6
6
|
constructor(context, options) {
|
|
7
7
|
this.context = context;
|
|
8
8
|
this.options = options;
|
|
9
|
-
if (context["side"] === "server") {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
9
|
this.updateMapService = inject(context, UpdateMapToken);
|
|
13
10
|
}
|
|
14
11
|
async load(mapId) {
|
|
@@ -21,12 +18,7 @@ function provideLoadMap(options) {
|
|
|
21
18
|
return [
|
|
22
19
|
{
|
|
23
20
|
provide: UpdateMapToken,
|
|
24
|
-
useFactory: (context) =>
|
|
25
|
-
if (context["side"] === "client") {
|
|
26
|
-
console.warn("UpdateMapToken is not overridden");
|
|
27
|
-
}
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
21
|
+
useFactory: (context) => console.warn("UpdateMapToken is not overridden")
|
|
30
22
|
},
|
|
31
23
|
{
|
|
32
24
|
provide: LoadMapToken,
|
package/dist/index7.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index7.js","sources":["../src/services/loadMap.ts"],"sourcesContent":["import { Context, inject } from \"@signe/di\";\nimport { UpdateMapToken, UpdateMapService } from \"@rpgjs/common\";\n\nexport const LoadMapToken = 'LoadMapToken'\n\
|
|
1
|
+
{"version":3,"file":"index7.js","sources":["../src/services/loadMap.ts"],"sourcesContent":["import { Context, inject } from \"@signe/di\";\nimport { UpdateMapToken, UpdateMapService } from \"@rpgjs/common\";\n\nexport const LoadMapToken = 'LoadMapToken'\n\nexport type LoadMapOptions = (mapId: string) => Promise<void>\n\nexport class LoadMapService {\n private updateMapService: UpdateMapService;\n\n constructor(private context: Context, private options: LoadMapOptions) {\n this.updateMapService = inject(context, UpdateMapToken);\n }\n\n async load(mapId: string) {\n const map = await this.options(mapId.replace('map-', ''))\n await this.updateMapService.update(mapId, map);\n return map;\n }\n}\n\nexport function provideLoadMap(options: LoadMapOptions) {\n return [\n {\n provide: UpdateMapToken,\n useFactory: (context: Context) => console.warn('UpdateMapToken is not overridden'),\n },\n {\n provide: LoadMapToken,\n useFactory: (context: Context) => new LoadMapService(context, options),\n },\n ];\n}\n"],"names":[],"mappings":";;;AAGO,MAAM,YAAe,GAAA;AAIrB,MAAM,cAAe,CAAA;AAAA,EAG1B,WAAA,CAAoB,SAA0B,OAAyB,EAAA;AAAnD,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAA0B,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAC5C,IAAK,IAAA,CAAA,gBAAA,GAAmB,MAAO,CAAA,OAAA,EAAS,cAAc,CAAA;AAAA;AACxD,EAEA,MAAM,KAAK,KAAe,EAAA;AACxB,IAAM,MAAA,GAAA,GAAM,MAAM,IAAK,CAAA,OAAA,CAAQ,MAAM,OAAQ,CAAA,MAAA,EAAQ,EAAE,CAAC,CAAA;AACxD,IAAA,MAAM,IAAK,CAAA,gBAAA,CAAiB,MAAO,CAAA,KAAA,EAAO,GAAG,CAAA;AAC7C,IAAO,OAAA,GAAA;AAAA;AAEX;AAEO,SAAS,eAAe,OAAyB,EAAA;AACtD,EAAO,OAAA;AAAA,IACL;AAAA,MACE,OAAS,EAAA,cAAA;AAAA,MACT,UAAY,EAAA,CAAC,OAAqB,KAAA,OAAA,CAAQ,KAAK,kCAAkC;AAAA,KACnF;AAAA,IACA;AAAA,MACE,OAAS,EAAA,YAAA;AAAA,MACT,YAAY,CAAC,OAAA,KAAqB,IAAI,cAAA,CAAe,SAAS,OAAO;AAAA;AACvE,GACF;AACF;;;;"}
|
package/dist/index8.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { provideModules, findModules } from '@rpgjs/common';
|
|
2
|
-
import { inject } from './
|
|
2
|
+
import { inject } from './index15.js';
|
|
3
3
|
import { RpgGui } from './index9.js';
|
|
4
4
|
|
|
5
5
|
function provideClientModules(modules) {
|
|
@@ -41,12 +41,12 @@ function provideClientModules(modules) {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
if (module.
|
|
45
|
-
const
|
|
46
|
-
module.
|
|
44
|
+
if (module.effects) {
|
|
45
|
+
const effects = [...module.effects];
|
|
46
|
+
module.effects = {
|
|
47
47
|
load: (engine) => {
|
|
48
|
-
|
|
49
|
-
engine.
|
|
48
|
+
effects.forEach((effect) => {
|
|
49
|
+
engine.addEffect(effect);
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
};
|
|
@@ -61,24 +61,6 @@ function provideClientModules(modules) {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
if (module.sprite) {
|
|
65
|
-
const sprite = { ...module.sprite };
|
|
66
|
-
module.sprite = {
|
|
67
|
-
...sprite,
|
|
68
|
-
load: (engine) => {
|
|
69
|
-
if (sprite.componentsBehind) {
|
|
70
|
-
sprite.componentsBehind.forEach((component) => {
|
|
71
|
-
engine.addSpriteComponentBehind(component);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
if (sprite.componentsInFront) {
|
|
75
|
-
sprite.componentsInFront.forEach((component) => {
|
|
76
|
-
engine.addSpriteComponentInFront(component);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
64
|
return module;
|
|
83
65
|
});
|
|
84
66
|
return modules2;
|
package/dist/index8.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index8.js","sources":["../src/module.ts"],"sourcesContent":["import { findModules, provideModules } from \"@rpgjs/common\";\nimport { RpgClientEngine } from \"./RpgClientEngine\";\nimport { RpgClient } from \"./RpgClient\";\nimport { inject } from \"@signe/di\";\nimport { RpgGui } from \"./Gui/Gui\";\n\nexport function provideClientModules(modules: RpgClient[]) {\n return provideModules(modules, \"client\", (modules, context) => {\n const mainModuleClient = findModules(context, 'Client')\n modules = [...mainModuleClient, ...modules]\n modules = modules.map((module) => {\n if ('client' in module) {\n module = module.client as any;\n }\n if (module.spritesheets) {\n const spritesheets = [...module.spritesheets];\n module.spritesheets = {\n load: (engine: RpgClientEngine) => {\n spritesheets.forEach((spritesheet) => {\n engine.addSpriteSheet(spritesheet);\n });\n },\n };\n }\n if (module.sounds) {\n const sounds = [...module.sounds];\n module.sounds = {\n load: (engine: RpgClientEngine) => {\n sounds.forEach((sound) => {\n engine.addSound(sound);\n });\n },\n };\n }\n if (module.gui) {\n const gui = [...module.gui];\n module.gui = {\n load: (engine: RpgClientEngine) => {\n const guiService = inject(engine.context, RpgGui);\n gui.forEach((gui) => {\n guiService.add(gui);\n });\n },\n };\n }\n if (module.
|
|
1
|
+
{"version":3,"file":"index8.js","sources":["../src/module.ts"],"sourcesContent":["import { findModules, provideModules } from \"@rpgjs/common\";\nimport { RpgClientEngine } from \"./RpgClientEngine\";\nimport { RpgClient } from \"./RpgClient\";\nimport { inject } from \"@signe/di\";\nimport { RpgGui } from \"./Gui/Gui\";\n\nexport function provideClientModules(modules: RpgClient[]) {\n return provideModules(modules, \"client\", (modules, context) => {\n const mainModuleClient = findModules(context, 'Client')\n modules = [...mainModuleClient, ...modules]\n modules = modules.map((module) => {\n if ('client' in module) {\n module = module.client as any;\n }\n if (module.spritesheets) {\n const spritesheets = [...module.spritesheets];\n module.spritesheets = {\n load: (engine: RpgClientEngine) => {\n spritesheets.forEach((spritesheet) => {\n engine.addSpriteSheet(spritesheet);\n });\n },\n };\n }\n if (module.sounds) {\n const sounds = [...module.sounds];\n module.sounds = {\n load: (engine: RpgClientEngine) => {\n sounds.forEach((sound) => {\n engine.addSound(sound);\n });\n },\n };\n }\n if (module.gui) {\n const gui = [...module.gui];\n module.gui = {\n load: (engine: RpgClientEngine) => {\n const guiService = inject(engine.context, RpgGui);\n gui.forEach((gui) => {\n guiService.add(gui);\n });\n },\n };\n }\n if (module.effects) {\n const effects = [...module.effects];\n module.effects = {\n load: (engine: RpgClientEngine) => {\n effects.forEach((effect) => {\n engine.addEffect(effect);\n });\n },\n };\n }\n if (module.particles) {\n const particles = [...module.particles];\n module.particles = {\n load: (engine: RpgClientEngine) => {\n particles.forEach((particle) => {\n engine.addParticle(particle);\n });\n },\n };\n }\n return module;\n });\n return modules\n });\n}\n\nexport const GlobalConfigToken = \"GlobalConfigToken\";\n\nexport function provideGlobalConfig(config: any) {\n return {\n provide: GlobalConfigToken,\n useValue: config ?? {},\n };\n}\n\nexport function provideClientGlobalConfig(config: any = {}) {\n if (!config.keyboardControls) {\n config.keyboardControls = {\n up: 'up',\n down: 'down',\n left: 'left',\n right: 'right',\n action: 'space'\n }\n }\n return provideGlobalConfig(config)\n}\n\n"],"names":["modules","gui"],"mappings":"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"}
|
package/dist/index9.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { inject } from './
|
|
1
|
+
import { inject } from './index15.js';
|
|
2
2
|
import { signal } from 'canvasengine';
|
|
3
|
-
import { WebSocketToken } from './
|
|
3
|
+
import { WebSocketToken } from './index16.js';
|
|
4
4
|
import { PrebuiltGui } from './index10.js';
|
|
5
5
|
|
|
6
6
|
const throwError = (id) => {
|
package/dist/presets/index.d.ts
CHANGED
|
@@ -19,106 +19,4 @@ export declare const Presets: {
|
|
|
19
19
|
framesHeight: number;
|
|
20
20
|
framesWidth: number;
|
|
21
21
|
};
|
|
22
|
-
LPCSpritesheetPreset: (options: {
|
|
23
|
-
id: string;
|
|
24
|
-
imageSource: string;
|
|
25
|
-
width: number;
|
|
26
|
-
height: number;
|
|
27
|
-
ratio?: number;
|
|
28
|
-
}) => {
|
|
29
|
-
id: string;
|
|
30
|
-
image: string;
|
|
31
|
-
width: number;
|
|
32
|
-
height: number;
|
|
33
|
-
opacity: number;
|
|
34
|
-
rectWidth: number;
|
|
35
|
-
rectHeight: number;
|
|
36
|
-
framesWidth: number;
|
|
37
|
-
framesHeight: number;
|
|
38
|
-
spriteRealSize: {
|
|
39
|
-
width: number;
|
|
40
|
-
height: number;
|
|
41
|
-
};
|
|
42
|
-
textures: {
|
|
43
|
-
attack3?: {
|
|
44
|
-
offset: {
|
|
45
|
-
x: number;
|
|
46
|
-
y: number;
|
|
47
|
-
};
|
|
48
|
-
rectWidth: number;
|
|
49
|
-
rectHeight: number;
|
|
50
|
-
framesWidth: number;
|
|
51
|
-
framesHeight: number;
|
|
52
|
-
animations: ({ direction }: {
|
|
53
|
-
direction: any;
|
|
54
|
-
}) => any[];
|
|
55
|
-
} | undefined;
|
|
56
|
-
stand: {
|
|
57
|
-
offset: {
|
|
58
|
-
x: number;
|
|
59
|
-
y: number;
|
|
60
|
-
};
|
|
61
|
-
animations: ({ direction }: {
|
|
62
|
-
direction: any;
|
|
63
|
-
}) => {
|
|
64
|
-
time: number;
|
|
65
|
-
frameX: number;
|
|
66
|
-
frameY: number;
|
|
67
|
-
}[][];
|
|
68
|
-
};
|
|
69
|
-
walk: {
|
|
70
|
-
offset: {
|
|
71
|
-
x: number;
|
|
72
|
-
y: number;
|
|
73
|
-
};
|
|
74
|
-
framesWidth: number;
|
|
75
|
-
framesHeight: number;
|
|
76
|
-
animations: ({ direction }: {
|
|
77
|
-
direction: any;
|
|
78
|
-
}) => any[];
|
|
79
|
-
};
|
|
80
|
-
attack: {
|
|
81
|
-
offset: {
|
|
82
|
-
x: number;
|
|
83
|
-
y: number;
|
|
84
|
-
};
|
|
85
|
-
framesWidth: number;
|
|
86
|
-
framesHeight: number;
|
|
87
|
-
animations: ({ direction }: {
|
|
88
|
-
direction: any;
|
|
89
|
-
}) => any[];
|
|
90
|
-
};
|
|
91
|
-
skill: {
|
|
92
|
-
framesWidth: number;
|
|
93
|
-
framesHeight: number;
|
|
94
|
-
animations: ({ direction }: {
|
|
95
|
-
direction: any;
|
|
96
|
-
}) => any[];
|
|
97
|
-
};
|
|
98
|
-
attack2: {
|
|
99
|
-
offset: {
|
|
100
|
-
x: number;
|
|
101
|
-
y: number;
|
|
102
|
-
};
|
|
103
|
-
framesWidth: number;
|
|
104
|
-
framesHeight: number;
|
|
105
|
-
animations: ({ direction }: {
|
|
106
|
-
direction: any;
|
|
107
|
-
}) => any[];
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
AnimationSpritesheetPreset: (framesWidth: number, framesHeight: number) => {
|
|
112
|
-
framesWidth: number;
|
|
113
|
-
framesHeight: number;
|
|
114
|
-
textures: {
|
|
115
|
-
default: {
|
|
116
|
-
animations: () => {
|
|
117
|
-
time: number;
|
|
118
|
-
frameX: number;
|
|
119
|
-
frameY: number;
|
|
120
|
-
}[][];
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
22
|
};
|
|
@@ -1,135 +1,14 @@
|
|
|
1
1
|
import { Context } from '@signe/di';
|
|
2
2
|
export declare const LoadMapToken = "LoadMapToken";
|
|
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;
|
|
3
|
+
export type LoadMapOptions = (mapId: string) => Promise<void>;
|
|
33
4
|
export declare class LoadMapService {
|
|
34
5
|
private context;
|
|
35
6
|
private options;
|
|
36
7
|
private updateMapService;
|
|
37
8
|
constructor(context: Context, options: LoadMapOptions);
|
|
38
|
-
load(mapId: string): Promise<
|
|
9
|
+
load(mapId: string): Promise<void>;
|
|
39
10
|
}
|
|
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
|
-
*/
|
|
131
11
|
export declare function provideLoadMap(options: LoadMapOptions): {
|
|
132
12
|
provide: string;
|
|
133
13
|
useFactory: (context: Context) => void;
|
|
134
14
|
}[];
|
|
135
|
-
export {};
|
|
@@ -4,21 +4,17 @@ 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(
|
|
13
|
+
constructor(context: Context, options: MmorpgOptions);
|
|
14
|
+
connection(): 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>;
|
|
22
18
|
}
|
|
23
19
|
declare class UpdateMapStandaloneService extends UpdateMapService {
|
|
24
20
|
protected context: Context;
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpgjs/client",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.2",
|
|
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
|
+
},
|
|
10
14
|
"keywords": [
|
|
11
15
|
"rpg",
|
|
12
16
|
"game",
|
|
@@ -16,27 +20,21 @@
|
|
|
16
20
|
],
|
|
17
21
|
"author": "Samuel Ronce",
|
|
18
22
|
"license": "MIT",
|
|
19
|
-
"peerDependencies": {
|
|
20
|
-
"@canvasengine/presets": "*",
|
|
21
|
-
"canvasengine": "*",
|
|
22
|
-
"pixi.js": "^8.9.2"
|
|
23
|
-
},
|
|
24
23
|
"dependencies": {
|
|
25
|
-
"@
|
|
24
|
+
"@canvasengine/presets": "2.0.0-beta.22",
|
|
25
|
+
"@rpgjs/common": "workspace:*",
|
|
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",
|
|
29
31
|
"rxjs": "^7.8.2"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
|
-
"@canvasengine/compiler": "2.0.0-beta.
|
|
34
|
+
"@canvasengine/compiler": "2.0.0-beta.21",
|
|
33
35
|
"vite": "^6.2.5",
|
|
34
36
|
"vite-plugin-dts": "^4.5.3",
|
|
35
37
|
"vitest": "^3.1.1"
|
|
36
38
|
},
|
|
37
|
-
"type": "module"
|
|
38
|
-
|
|
39
|
-
"dev": "vite build --watch",
|
|
40
|
-
"build": "vite build"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
39
|
+
"type": "module"
|
|
40
|
+
}
|
|
@@ -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 EffectManager {
|
|
5
5
|
current = signal<any[]>([]);
|
|
6
6
|
|
|
7
|
-
displayEffect(params: any, player: RpgCommonPlayer
|
|
7
|
+
displayEffect(params: any, player: RpgCommonPlayer) {
|
|
8
8
|
const id = generateUID();
|
|
9
9
|
this.current().push({
|
|
10
10
|
...params,
|
package/src/Game/Object.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { RpgCommonPlayer } from "@rpgjs/common";
|
|
2
2
|
import { trigger, signal } from "canvasengine";
|
|
3
|
-
import { Subscription } from "rxjs";
|
|
4
3
|
|
|
5
4
|
export abstract class RpgClientObject extends RpgCommonPlayer {
|
|
6
5
|
abstract type: string;
|
|
7
6
|
emitParticleTrigger = trigger()
|
|
8
7
|
particleName = signal('')
|
|
9
|
-
animationCurrentIndex = signal(0)
|
|
10
|
-
animationIsPlaying = signal(false)
|
|
11
|
-
private animationSubscription?: Subscription
|
|
12
8
|
|
|
13
9
|
flash(color: string, duration: number = 100) {
|
|
14
10
|
const lastTint = this.tint()
|
|
@@ -17,69 +13,4 @@ export abstract class RpgClientObject extends RpgCommonPlayer {
|
|
|
17
13
|
this.tint.set(lastTint)
|
|
18
14
|
}, duration)
|
|
19
15
|
}
|
|
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
|
-
}
|
|
85
16
|
}
|