@rpgjs/server 4.3.0 → 5.0.0-alpha.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/{lib → dist}/Gui/DialogGui.d.ts +1 -2
- package/{lib → dist}/Gui/Gui.d.ts +1 -2
- package/dist/Player/BattleManager.d.ts +22 -0
- package/dist/Player/ClassManager.d.ts +18 -0
- package/dist/Player/Event.d.ts +0 -0
- package/dist/Player/ItemManager.d.ts +17 -0
- package/dist/Player/MoveManager.d.ts +177 -0
- package/dist/Player/ParameterManager.d.ts +42 -0
- package/dist/Player/Player.d.ts +73 -0
- package/dist/Player/SkillManager.d.ts +23 -0
- package/dist/Player/StateManager.d.ts +39 -0
- package/{lib → dist}/RpgServer.d.ts +32 -15
- package/dist/RpgServerEngine.d.ts +5 -0
- package/dist/core/context.d.ts +2 -0
- package/dist/core/inject.d.ts +5 -0
- package/dist/core/setup.d.ts +6 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +29673 -0
- package/dist/index.js.map +1 -0
- package/dist/module.d.ts +2 -0
- package/dist/rooms/lobby.d.ts +6 -0
- package/dist/rooms/map.d.ts +110 -0
- package/package.json +15 -37
- package/src/Gui/DialogGui.ts +3 -4
- package/src/Gui/Gui.ts +4 -6
- package/src/Player/BattleManager.ts +108 -99
- package/src/Player/ClassManager.ts +47 -46
- package/src/Player/ComponentManager.ts +26 -535
- package/src/Player/EffectManager.ts +44 -59
- package/src/Player/ElementManager.ts +70 -72
- package/src/Player/Event.ts +0 -0
- package/src/Player/GoldManager.ts +24 -6
- package/src/Player/GuiManager.ts +106 -97
- package/src/Player/ItemFixture.ts +22 -17
- package/src/Player/ItemManager.ts +234 -225
- package/src/Player/MoveManager.ts +1047 -457
- package/src/Player/ParameterManager.ts +59 -37
- package/src/Player/Player.ts +272 -1058
- package/src/Player/SkillManager.ts +146 -137
- package/src/Player/StateManager.ts +124 -98
- package/src/Player/VariableManager.ts +23 -3
- package/src/RpgServer.ts +36 -12
- package/src/RpgServerEngine.ts +7 -0
- package/src/core/context.ts +3 -0
- package/src/core/inject.ts +17 -0
- package/src/core/setup.ts +20 -0
- package/src/index.ts +9 -31
- package/src/module.ts +32 -0
- package/src/presets/index.ts +1 -3
- package/src/rooms/lobby.ts +24 -0
- package/src/rooms/map.ts +311 -0
- package/tsconfig.json +26 -23
- package/vite.config.ts +21 -0
- package/CHANGELOG.md +0 -174
- package/LICENSE +0 -19
- package/browser/manifest.json +0 -7
- package/browser/rpg.server.js +0 -22379
- package/browser/rpg.server.umd.cjs +0 -22410
- package/lib/Game/EventManager.d.ts +0 -54
- package/lib/Game/EventManager.js +0 -107
- package/lib/Game/EventManager.js.map +0 -1
- package/lib/Game/Map.d.ts +0 -191
- package/lib/Game/Map.js +0 -419
- package/lib/Game/Map.js.map +0 -1
- package/lib/Game/WorldMaps.d.ts +0 -17
- package/lib/Game/WorldMaps.js +0 -28
- package/lib/Game/WorldMaps.js.map +0 -1
- package/lib/Gui/DialogGui.js +0 -57
- package/lib/Gui/DialogGui.js.map +0 -1
- package/lib/Gui/Gui.js +0 -37
- package/lib/Gui/Gui.js.map +0 -1
- package/lib/Gui/MenuGui.js +0 -23
- package/lib/Gui/MenuGui.js.map +0 -1
- package/lib/Gui/NotificationGui.js +0 -8
- package/lib/Gui/NotificationGui.js.map +0 -1
- package/lib/Gui/ShopGui.js +0 -40
- package/lib/Gui/ShopGui.js.map +0 -1
- package/lib/Gui/index.js +0 -7
- package/lib/Gui/index.js.map +0 -1
- package/lib/Interfaces/Gui.d.ts +0 -4
- package/lib/Interfaces/Gui.js +0 -2
- package/lib/Interfaces/Gui.js.map +0 -1
- package/lib/Interfaces/StateStore.d.ts +0 -5
- package/lib/Interfaces/StateStore.js +0 -2
- package/lib/Interfaces/StateStore.js.map +0 -1
- package/lib/MatchMaker.d.ts +0 -24
- package/lib/MatchMaker.js +0 -42
- package/lib/MatchMaker.js.map +0 -1
- package/lib/Monitor/index.d.ts +0 -17
- package/lib/Monitor/index.js +0 -72
- package/lib/Monitor/index.js.map +0 -1
- package/lib/Player/BattleManager.d.ts +0 -36
- package/lib/Player/BattleManager.js +0 -101
- package/lib/Player/BattleManager.js.map +0 -1
- package/lib/Player/ClassManager.d.ts +0 -47
- package/lib/Player/ClassManager.js +0 -65
- package/lib/Player/ClassManager.js.map +0 -1
- package/lib/Player/ComponentManager.d.ts +0 -397
- package/lib/Player/ComponentManager.js +0 -505
- package/lib/Player/ComponentManager.js.map +0 -1
- package/lib/Player/EffectManager.d.ts +0 -46
- package/lib/Player/EffectManager.js +0 -75
- package/lib/Player/EffectManager.js.map +0 -1
- package/lib/Player/ElementManager.d.ts +0 -108
- package/lib/Player/ElementManager.js +0 -120
- package/lib/Player/ElementManager.js.map +0 -1
- package/lib/Player/GoldManager.d.ts +0 -17
- package/lib/Player/GoldManager.js +0 -27
- package/lib/Player/GoldManager.js.map +0 -1
- package/lib/Player/GuiManager.d.ts +0 -247
- package/lib/Player/GuiManager.js +0 -291
- package/lib/Player/GuiManager.js.map +0 -1
- package/lib/Player/ItemFixture.d.ts +0 -7
- package/lib/Player/ItemFixture.js +0 -19
- package/lib/Player/ItemFixture.js.map +0 -1
- package/lib/Player/ItemManager.d.ts +0 -331
- package/lib/Player/ItemManager.js +0 -475
- package/lib/Player/ItemManager.js.map +0 -1
- package/lib/Player/MoveManager.d.ts +0 -333
- package/lib/Player/MoveManager.js +0 -450
- package/lib/Player/MoveManager.js.map +0 -1
- package/lib/Player/ParameterManager.d.ts +0 -316
- package/lib/Player/ParameterManager.js +0 -408
- package/lib/Player/ParameterManager.js.map +0 -1
- package/lib/Player/Player.d.ts +0 -828
- package/lib/Player/Player.js +0 -927
- package/lib/Player/Player.js.map +0 -1
- package/lib/Player/SkillManager.d.ts +0 -163
- package/lib/Player/SkillManager.js +0 -223
- package/lib/Player/SkillManager.js.map +0 -1
- package/lib/Player/StateManager.d.ts +0 -185
- package/lib/Player/StateManager.js +0 -228
- package/lib/Player/StateManager.js.map +0 -1
- package/lib/Player/VariableManager.d.ts +0 -46
- package/lib/Player/VariableManager.js +0 -52
- package/lib/Player/VariableManager.js.map +0 -1
- package/lib/Query.d.ts +0 -127
- package/lib/Query.js +0 -159
- package/lib/Query.js.map +0 -1
- package/lib/RpgServer.js +0 -2
- package/lib/RpgServer.js.map +0 -1
- package/lib/Scenes/Map.d.ts +0 -136
- package/lib/Scenes/Map.js +0 -273
- package/lib/Scenes/Map.js.map +0 -1
- package/lib/decorators/event.d.ts +0 -43
- package/lib/decorators/event.js +0 -13
- package/lib/decorators/event.js.map +0 -1
- package/lib/decorators/map.d.ts +0 -178
- package/lib/decorators/map.js +0 -43
- package/lib/decorators/map.js.map +0 -1
- package/lib/entry-point.d.ts +0 -34
- package/lib/entry-point.js +0 -70
- package/lib/entry-point.js.map +0 -1
- package/lib/express/api.d.ts +0 -3
- package/lib/express/api.js +0 -105
- package/lib/express/api.js.map +0 -1
- package/lib/express/errors/NotAuthorized.d.ts +0 -4
- package/lib/express/errors/NotAuthorized.js +0 -7
- package/lib/express/errors/NotAuthorized.js.map +0 -1
- package/lib/express/errors/NotFound.d.ts +0 -4
- package/lib/express/errors/NotFound.js +0 -7
- package/lib/express/errors/NotFound.js.map +0 -1
- package/lib/express/server.d.ts +0 -18
- package/lib/express/server.js +0 -70
- package/lib/express/server.js.map +0 -1
- package/lib/index.d.ts +0 -20
- package/lib/index.js +0 -19
- package/lib/index.js.map +0 -1
- package/lib/inject.d.ts +0 -22
- package/lib/inject.js +0 -29
- package/lib/inject.js.map +0 -1
- package/lib/logs/index.js +0 -6
- package/lib/logs/index.js.map +0 -1
- package/lib/logs/item.js +0 -34
- package/lib/logs/item.js.map +0 -1
- package/lib/logs/log.js +0 -7
- package/lib/logs/log.js.map +0 -1
- package/lib/logs/skill.js +0 -19
- package/lib/logs/skill.js.map +0 -1
- package/lib/logs/state.js +0 -13
- package/lib/logs/state.js.map +0 -1
- package/lib/models/Item.d.ts +0 -10
- package/lib/models/Item.js +0 -2
- package/lib/models/Item.js.map +0 -1
- package/lib/presets/index.js +0 -65
- package/lib/presets/index.js.map +0 -1
- package/lib/server.d.ts +0 -137
- package/lib/server.js +0 -443
- package/lib/server.js.map +0 -1
- package/rpg.toml +0 -14
- package/src/Game/EventManager.ts +0 -125
- package/src/Game/Map.ts +0 -500
- package/src/Game/WorldMaps.ts +0 -45
- package/src/Interfaces/Gui.ts +0 -4
- package/src/Interfaces/StateStore.ts +0 -5
- package/src/MatchMaker.ts +0 -65
- package/src/Monitor/index.ts +0 -78
- package/src/Query.ts +0 -172
- package/src/Scenes/Map.ts +0 -310
- package/src/decorators/event.ts +0 -58
- package/src/decorators/map.ts +0 -226
- package/src/entry-point.ts +0 -111
- package/src/express/api.ts +0 -118
- package/src/express/errors/NotAuthorized.ts +0 -6
- package/src/express/errors/NotFound.ts +0 -6
- package/src/express/server.ts +0 -94
- package/src/inject.ts +0 -33
- package/src/models/Item.ts +0 -11
- package/src/server.ts +0 -459
- /package/{lib → dist}/Gui/MenuGui.d.ts +0 -0
- /package/{lib → dist}/Gui/NotificationGui.d.ts +0 -0
- /package/{lib → dist}/Gui/ShopGui.d.ts +0 -0
- /package/{lib → dist}/Gui/index.d.ts +0 -0
- /package/{lib → dist}/logs/index.d.ts +0 -0
- /package/{lib → dist}/logs/item.d.ts +0 -0
- /package/{lib → dist}/logs/log.d.ts +0 -0
- /package/{lib → dist}/logs/skill.d.ts +0 -0
- /package/{lib → dist}/logs/state.d.ts +0 -0
- /package/{lib → dist}/presets/index.d.ts +0 -0
package/lib/Scenes/Map.d.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { TiledMap } from '@rpgjs/tiled';
|
|
2
|
-
import { MapOptions } from '../decorators/map';
|
|
3
|
-
import { RpgMap } from '../Game/Map';
|
|
4
|
-
import { RpgWorldMaps, WorldMap } from '../Game/WorldMaps';
|
|
5
|
-
import { RpgEvent, RpgPlayer } from '../Player/Player';
|
|
6
|
-
export interface RpgClassMap<T> {
|
|
7
|
-
id?: string;
|
|
8
|
-
file?: string;
|
|
9
|
-
new (server: any): T;
|
|
10
|
-
}
|
|
11
|
-
type SceneMapObject = {
|
|
12
|
-
maps: any[];
|
|
13
|
-
worldMaps: WorldMap[];
|
|
14
|
-
events: RpgEvent[];
|
|
15
|
-
};
|
|
16
|
-
export declare class SceneMap {
|
|
17
|
-
static readonly id: string;
|
|
18
|
-
private maps;
|
|
19
|
-
private mapsById;
|
|
20
|
-
private worldMaps;
|
|
21
|
-
private server;
|
|
22
|
-
constructor(sceneMapObject: SceneMapObject);
|
|
23
|
-
/**
|
|
24
|
-
* Returns an array of RpgClassMap objects that represent maps with static properties.
|
|
25
|
-
*
|
|
26
|
-
* @title Get maps
|
|
27
|
-
* @method sceneMap.getMaps()
|
|
28
|
-
* @returns {RpgClassMap<RpgMap>[]} Array of RpgClassMap objects.
|
|
29
|
-
* @since 4.0.0
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* const maps = scene.getMaps();
|
|
33
|
-
* console.log(maps);
|
|
34
|
-
* // Output: [
|
|
35
|
-
* // { file: 'maps/level1.tmx', id: 'level1', type: 'map' },
|
|
36
|
-
* // { file: 'maps/level2.tmx', id: 'level1', type: 'map' },
|
|
37
|
-
* // { file: 'maps/level3.tmx', id: 'level1', type: 'map' }
|
|
38
|
-
* // ]
|
|
39
|
-
* ```
|
|
40
|
-
* @memberof SceneMap
|
|
41
|
-
*/
|
|
42
|
-
getMaps(): RpgClassMap<RpgMap>[];
|
|
43
|
-
getMapBydId(id: string): RpgClassMap<RpgMap> | null;
|
|
44
|
-
loadMap(id: string): Promise<RpgMap | undefined>;
|
|
45
|
-
/**
|
|
46
|
-
* Loads the content of a `.world` file from Tiled Map Editor into the map scene
|
|
47
|
-
*
|
|
48
|
-
* > Note, that if the map already exists (i.e. you have already defined an RpgMap), the world will retrieve the already existing map. Otherwise it will create a new map
|
|
49
|
-
*
|
|
50
|
-
* @title Create worlds dynamically
|
|
51
|
-
* @method sceneMap.createDynamicWorldMaps(world)
|
|
52
|
-
* @param {object} world
|
|
53
|
-
* object is
|
|
54
|
-
* ```ts
|
|
55
|
-
* {
|
|
56
|
-
* id?: string
|
|
57
|
-
* maps: {
|
|
58
|
-
* id?: string
|
|
59
|
-
* properties?: object
|
|
60
|
-
* fileName: string;
|
|
61
|
-
height: number;
|
|
62
|
-
width: number;
|
|
63
|
-
x: number;
|
|
64
|
-
y: number;
|
|
65
|
-
* }[],
|
|
66
|
-
onlyShowAdjacentMaps: boolean, // only for Tiled Map Editor
|
|
67
|
-
type: 'world' // only for Tiled Map Editor
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* @since 3.0.0-beta.8
|
|
72
|
-
* @memberof SceneMap
|
|
73
|
-
*/
|
|
74
|
-
createDynamicWorldMaps(world: WorldMap): RpgWorldMaps;
|
|
75
|
-
/**
|
|
76
|
-
* Recover a world
|
|
77
|
-
*
|
|
78
|
-
* @title Recover a world
|
|
79
|
-
* @method sceneMap.getWorldMaps(id)
|
|
80
|
-
* @param {string} id world id
|
|
81
|
-
* @return { RpgWorldMaps | undefined }
|
|
82
|
-
* @since 3.0.0-beta.8
|
|
83
|
-
* @memberof SceneMap
|
|
84
|
-
*/
|
|
85
|
-
getWorldMaps(id: string): RpgWorldMaps | undefined;
|
|
86
|
-
/**
|
|
87
|
-
* Delete a world
|
|
88
|
-
*
|
|
89
|
-
* @title Delete a world
|
|
90
|
-
* @method sceneMap.deleteWorldMaps(id)
|
|
91
|
-
* @param {string} id world id
|
|
92
|
-
* @since 3.0.0-beta.8
|
|
93
|
-
* @memberof SceneMap
|
|
94
|
-
*/
|
|
95
|
-
deleteWorldMaps(id: string): void;
|
|
96
|
-
/**
|
|
97
|
-
* Create a dynamic map
|
|
98
|
-
*
|
|
99
|
-
* Since version 3.0.0-beta.8, you can just pass the path to the file. The identifier will then be the name of the file
|
|
100
|
-
*
|
|
101
|
-
* @method sceneMap.createDynamicMap(mapData)
|
|
102
|
-
* @title Create a dynamic map
|
|
103
|
-
* @param {object | RpgMap | string} mapData The same property as [@MapData decorator](https://docs.rpgjs.dev/classes/map.html#mapdata-decorator)
|
|
104
|
-
* @returns {RpgMap}
|
|
105
|
-
* @since 3.0.0-beta.4
|
|
106
|
-
* @memberof SceneMap
|
|
107
|
-
* @example
|
|
108
|
-
* ```ts
|
|
109
|
-
* sceneMap.createDynamicMap({
|
|
110
|
-
* id: 'myid',
|
|
111
|
-
* file: require('./tmx/mymap.tmx')
|
|
112
|
-
* })
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* And later, on the player:
|
|
116
|
-
*
|
|
117
|
-
* ```ts
|
|
118
|
-
* player.changeMap('myid')
|
|
119
|
-
* ```
|
|
120
|
-
*
|
|
121
|
-
* ---
|
|
122
|
-
*
|
|
123
|
-
* since beta.8
|
|
124
|
-
*
|
|
125
|
-
* ```ts
|
|
126
|
-
* sceneMap.createDynamicMap(require('./tmx/mymap.tmx')) // id is "mymap"
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
createDynamicMap(mapData: MapOptions | string | RpgClassMap<RpgMap> | TiledMap): RpgClassMap<RpgMap> | never;
|
|
130
|
-
changeMap(mapId: string, player: RpgPlayer, positions?: {
|
|
131
|
-
x: number;
|
|
132
|
-
y: number;
|
|
133
|
-
z?: number;
|
|
134
|
-
} | string): Promise<RpgMap | null | boolean>;
|
|
135
|
-
}
|
|
136
|
-
export {};
|
package/lib/Scenes/Map.js
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { HookServer, RpgCommonMap, RpgPlugin, Utils } from '@rpgjs/common';
|
|
8
|
-
import { World } from 'simple-room';
|
|
9
|
-
import { isTiledFormat } from '@rpgjs/tiled';
|
|
10
|
-
import { MapData } from '../decorators/map.js';
|
|
11
|
-
import { RpgMap } from '../Game/Map.js';
|
|
12
|
-
import { RpgWorldMaps } from '../Game/WorldMaps.js';
|
|
13
|
-
import { RpgPlayer } from '../Player/Player.js';
|
|
14
|
-
import { RpgServerEngine } from '../server.js';
|
|
15
|
-
import { inject } from '../inject.js';
|
|
16
|
-
class SceneMap {
|
|
17
|
-
constructor(sceneMapObject) {
|
|
18
|
-
this.maps = [];
|
|
19
|
-
this.mapsById = {};
|
|
20
|
-
this.worldMaps = new Map();
|
|
21
|
-
this.server = inject(RpgServerEngine);
|
|
22
|
-
const { maps, worldMaps, events } = sceneMapObject;
|
|
23
|
-
this.maps = maps;
|
|
24
|
-
this.mapsById = {};
|
|
25
|
-
RpgCommonMap.buffer.clear();
|
|
26
|
-
if (this.maps) {
|
|
27
|
-
for (let map of this.maps) {
|
|
28
|
-
this.createDynamicMap(map);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (worldMaps) {
|
|
32
|
-
for (let worldMap of worldMaps) {
|
|
33
|
-
this.createDynamicWorldMaps(worldMap);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Returns an array of RpgClassMap objects that represent maps with static properties.
|
|
39
|
-
*
|
|
40
|
-
* @title Get maps
|
|
41
|
-
* @method sceneMap.getMaps()
|
|
42
|
-
* @returns {RpgClassMap<RpgMap>[]} Array of RpgClassMap objects.
|
|
43
|
-
* @since 4.0.0
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* const maps = scene.getMaps();
|
|
47
|
-
* console.log(maps);
|
|
48
|
-
* // Output: [
|
|
49
|
-
* // { file: 'maps/level1.tmx', id: 'level1', type: 'map' },
|
|
50
|
-
* // { file: 'maps/level2.tmx', id: 'level1', type: 'map' },
|
|
51
|
-
* // { file: 'maps/level3.tmx', id: 'level1', type: 'map' }
|
|
52
|
-
* // ]
|
|
53
|
-
* ```
|
|
54
|
-
* @memberof SceneMap
|
|
55
|
-
*/
|
|
56
|
-
getMaps() {
|
|
57
|
-
return Object.values(this.mapsById);
|
|
58
|
-
}
|
|
59
|
-
getMapBydId(id) {
|
|
60
|
-
let mapClass = this.mapsById[id];
|
|
61
|
-
if (!mapClass) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
if (!Utils.isClass(mapClass))
|
|
65
|
-
mapClass = Utils.createConstructor(mapClass);
|
|
66
|
-
return mapClass;
|
|
67
|
-
}
|
|
68
|
-
async loadMap(id) {
|
|
69
|
-
const mapClass = this.getMapBydId(id);
|
|
70
|
-
if (!mapClass) {
|
|
71
|
-
console.log(`Map ${id} not exists`);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
let mapInstance;
|
|
75
|
-
if (mapClass['buffer'].has(id)) {
|
|
76
|
-
return mapClass['buffer'].get(id);
|
|
77
|
-
}
|
|
78
|
-
if (RpgCommonMap.buffer.has(id)) {
|
|
79
|
-
mapInstance = RpgCommonMap.buffer.get(id);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
const room = new mapClass(this.server);
|
|
83
|
-
room.$schema.users = [
|
|
84
|
-
{
|
|
85
|
-
...RpgPlayer.schemas,
|
|
86
|
-
...this.server['playerProps']
|
|
87
|
-
}
|
|
88
|
-
];
|
|
89
|
-
mapInstance = World.addRoom(id, room);
|
|
90
|
-
await mapInstance.load();
|
|
91
|
-
}
|
|
92
|
-
return mapInstance;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Loads the content of a `.world` file from Tiled Map Editor into the map scene
|
|
96
|
-
*
|
|
97
|
-
* > Note, that if the map already exists (i.e. you have already defined an RpgMap), the world will retrieve the already existing map. Otherwise it will create a new map
|
|
98
|
-
*
|
|
99
|
-
* @title Create worlds dynamically
|
|
100
|
-
* @method sceneMap.createDynamicWorldMaps(world)
|
|
101
|
-
* @param {object} world
|
|
102
|
-
* object is
|
|
103
|
-
* ```ts
|
|
104
|
-
* {
|
|
105
|
-
* id?: string
|
|
106
|
-
* maps: {
|
|
107
|
-
* id?: string
|
|
108
|
-
* properties?: object
|
|
109
|
-
* fileName: string;
|
|
110
|
-
height: number;
|
|
111
|
-
width: number;
|
|
112
|
-
x: number;
|
|
113
|
-
y: number;
|
|
114
|
-
* }[],
|
|
115
|
-
onlyShowAdjacentMaps: boolean, // only for Tiled Map Editor
|
|
116
|
-
type: 'world' // only for Tiled Map Editor
|
|
117
|
-
* }
|
|
118
|
-
* ```
|
|
119
|
-
*
|
|
120
|
-
* @since 3.0.0-beta.8
|
|
121
|
-
* @memberof SceneMap
|
|
122
|
-
*/
|
|
123
|
-
createDynamicWorldMaps(world) {
|
|
124
|
-
world.id = world.id || Utils.generateUID();
|
|
125
|
-
const worldMap = new RpgWorldMaps(world.id).load(world, this);
|
|
126
|
-
this.worldMaps.set(world.id, worldMap);
|
|
127
|
-
return worldMap;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Recover a world
|
|
131
|
-
*
|
|
132
|
-
* @title Recover a world
|
|
133
|
-
* @method sceneMap.getWorldMaps(id)
|
|
134
|
-
* @param {string} id world id
|
|
135
|
-
* @return { RpgWorldMaps | undefined }
|
|
136
|
-
* @since 3.0.0-beta.8
|
|
137
|
-
* @memberof SceneMap
|
|
138
|
-
*/
|
|
139
|
-
getWorldMaps(id) {
|
|
140
|
-
return this.worldMaps.get(id);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Delete a world
|
|
144
|
-
*
|
|
145
|
-
* @title Delete a world
|
|
146
|
-
* @method sceneMap.deleteWorldMaps(id)
|
|
147
|
-
* @param {string} id world id
|
|
148
|
-
* @since 3.0.0-beta.8
|
|
149
|
-
* @memberof SceneMap
|
|
150
|
-
*/
|
|
151
|
-
deleteWorldMaps(id) {
|
|
152
|
-
this.worldMaps.delete(id);
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Create a dynamic map
|
|
156
|
-
*
|
|
157
|
-
* Since version 3.0.0-beta.8, you can just pass the path to the file. The identifier will then be the name of the file
|
|
158
|
-
*
|
|
159
|
-
* @method sceneMap.createDynamicMap(mapData)
|
|
160
|
-
* @title Create a dynamic map
|
|
161
|
-
* @param {object | RpgMap | string} mapData The same property as [@MapData decorator](https://docs.rpgjs.dev/classes/map.html#mapdata-decorator)
|
|
162
|
-
* @returns {RpgMap}
|
|
163
|
-
* @since 3.0.0-beta.4
|
|
164
|
-
* @memberof SceneMap
|
|
165
|
-
* @example
|
|
166
|
-
* ```ts
|
|
167
|
-
* sceneMap.createDynamicMap({
|
|
168
|
-
* id: 'myid',
|
|
169
|
-
* file: require('./tmx/mymap.tmx')
|
|
170
|
-
* })
|
|
171
|
-
* ```
|
|
172
|
-
*
|
|
173
|
-
* And later, on the player:
|
|
174
|
-
*
|
|
175
|
-
* ```ts
|
|
176
|
-
* player.changeMap('myid')
|
|
177
|
-
* ```
|
|
178
|
-
*
|
|
179
|
-
* ---
|
|
180
|
-
*
|
|
181
|
-
* since beta.8
|
|
182
|
-
*
|
|
183
|
-
* ```ts
|
|
184
|
-
* sceneMap.createDynamicMap(require('./tmx/mymap.tmx')) // id is "mymap"
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
|
-
createDynamicMap(mapData) {
|
|
188
|
-
if (Utils.isString(mapData)) {
|
|
189
|
-
const id = Utils.extractId(mapData);
|
|
190
|
-
if (!id) {
|
|
191
|
-
throw new Error('Unable to extract the file identifier. Check that the file has only the following characters: [a-zA-Z0-9-_$!]+');
|
|
192
|
-
}
|
|
193
|
-
mapData = {
|
|
194
|
-
id: id[1],
|
|
195
|
-
file: mapData
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
if (isTiledFormat(mapData)) {
|
|
199
|
-
const tiledData = mapData;
|
|
200
|
-
mapData = {
|
|
201
|
-
file: { ...tiledData }
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
if (!mapData.id)
|
|
205
|
-
mapData.id = Utils.generateUID();
|
|
206
|
-
if (!Utils.isClass(mapData)) {
|
|
207
|
-
let DynamicMap = class DynamicMap extends RpgMap {
|
|
208
|
-
};
|
|
209
|
-
DynamicMap = __decorate([
|
|
210
|
-
MapData(mapData)
|
|
211
|
-
], DynamicMap);
|
|
212
|
-
mapData = DynamicMap;
|
|
213
|
-
}
|
|
214
|
-
const map = mapData;
|
|
215
|
-
this.mapsById[map.id] = map;
|
|
216
|
-
return map;
|
|
217
|
-
}
|
|
218
|
-
async changeMap(mapId, player, positions) {
|
|
219
|
-
const boolArray = await RpgPlugin.emit(HookServer.PlayerCanChangeMap, [player, this.getMapBydId(mapId)], true);
|
|
220
|
-
if (boolArray.some(el => el === false)) {
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
// if just teleport, not change map
|
|
224
|
-
if (player.map === mapId) {
|
|
225
|
-
await player.teleport(positions || 'start');
|
|
226
|
-
return null;
|
|
227
|
-
}
|
|
228
|
-
player.emit('preLoadScene', {
|
|
229
|
-
id: mapId
|
|
230
|
-
});
|
|
231
|
-
player.prevMap = player.map;
|
|
232
|
-
if (player.prevMap) {
|
|
233
|
-
await player.execMethod('onLeaveMap', [player.getCurrentMap()]);
|
|
234
|
-
World.leaveRoom(player.prevMap, player.id);
|
|
235
|
-
}
|
|
236
|
-
player.map = mapId;
|
|
237
|
-
player.events = {};
|
|
238
|
-
player.tmpPositions = positions;
|
|
239
|
-
const scalabilityArray = await RpgPlugin.emit(HookServer.ScalabilityChangeServer, player);
|
|
240
|
-
if (scalabilityArray.some(el => el === true)) {
|
|
241
|
-
return true;
|
|
242
|
-
}
|
|
243
|
-
player.tmpPositions = null;
|
|
244
|
-
const mapInstance = await this.loadMap(mapId);
|
|
245
|
-
if (!mapInstance)
|
|
246
|
-
return null;
|
|
247
|
-
if (!player.height)
|
|
248
|
-
player.height = mapInstance.tileHeight;
|
|
249
|
-
if (!player.width)
|
|
250
|
-
player.width = mapInstance.tileWidth;
|
|
251
|
-
if (!player.hitbox.h)
|
|
252
|
-
player.hitbox.h = mapInstance.tileHeight;
|
|
253
|
-
if (!player.hitbox.w)
|
|
254
|
-
player.hitbox.w = mapInstance.tileWidth;
|
|
255
|
-
player.emitSceneMap();
|
|
256
|
-
// if room is removed after load map (for unit tests)
|
|
257
|
-
if (!World.getRoom(mapId)) {
|
|
258
|
-
return null;
|
|
259
|
-
}
|
|
260
|
-
player.teleport(positions || 'start');
|
|
261
|
-
World.joinRoom(mapId, player.id);
|
|
262
|
-
player = World.getUser(player.id);
|
|
263
|
-
if (player) {
|
|
264
|
-
mapInstance.loadCommonEvents(this.server.inputOptions.events, player);
|
|
265
|
-
player.createDynamicEvent(mapInstance._events, false);
|
|
266
|
-
await player.execMethod('onJoinMap', [mapInstance]);
|
|
267
|
-
}
|
|
268
|
-
return mapInstance;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
SceneMap.id = 'map';
|
|
272
|
-
export { SceneMap };
|
|
273
|
-
//# sourceMappingURL=Map.js.map
|
package/lib/Scenes/Map.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Map.js","sourceRoot":"","sources":["../../src/Scenes/Map.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,aAAa,EAAY,MAAM,cAAc,CAAA;AACtD,OAAO,EAAc,OAAO,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,MAAM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M,CAAC,CAAA;YACrE,MAAM,CAAC,kBAAkB,CAAM,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;YAC1D,MAAM,MAAM,CAAC,UAAU,CAAC,WAAW,EAAO,CAAC,WAAW,CAAC,CAAC,CAAA;SAC3D;QAED,OAAO,WAAW,CAAA;IACtB,CAAC;;AA5Re,WAAE,GAAW,KAAK,AAAhB,CAAgB;SADzB,QAAQ"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { EventMode } from "../Game/EventManager";
|
|
2
|
-
export interface EventOptions {
|
|
3
|
-
/**
|
|
4
|
-
* The mode of the event, shared evening or scenario
|
|
5
|
-
*
|
|
6
|
-
* The scenario mode allows you to have events specific to the player. Thus, the graphics, the positions of the event will be different for each player. Beware of performance! The event is duplicated by each player.
|
|
7
|
-
*
|
|
8
|
-
* `shared` mode by default
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { RpgEvent, EventData, RpgPlayer, EventMode } from '@rpgjs/server'
|
|
12
|
-
* @EventData({
|
|
13
|
-
* name: 'EV-1',
|
|
14
|
-
* mode: EventMode.Scenario // or EventMode.Shared
|
|
15
|
-
* })
|
|
16
|
-
* export class CharaEvent extends RpgEvent { }
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @prop {string} [mode] Either "shared" or "scenario".
|
|
20
|
-
* @memberof EventData
|
|
21
|
-
* */
|
|
22
|
-
mode?: EventMode;
|
|
23
|
-
width?: number;
|
|
24
|
-
height?: number;
|
|
25
|
-
/**
|
|
26
|
-
* The hitbox of the event. By default, this is the size of the tile of the map
|
|
27
|
-
*
|
|
28
|
-
* @prop { { width: number, height: number }} [hitbox]
|
|
29
|
-
* @memberof EventData
|
|
30
|
-
* */
|
|
31
|
-
hitbox?: {
|
|
32
|
-
width?: number;
|
|
33
|
-
height?: number;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Name of the event. This is its identifier. it allows you to retrieve an event and place it on the map
|
|
37
|
-
*
|
|
38
|
-
* @prop {string} name
|
|
39
|
-
* @memberof EventData
|
|
40
|
-
* */
|
|
41
|
-
name: string;
|
|
42
|
-
}
|
|
43
|
-
export declare function EventData(options: EventOptions): (target: any) => void;
|
package/lib/decorators/event.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { EventMode } from "../Game/EventManager.js";
|
|
2
|
-
export function EventData(options) {
|
|
3
|
-
return (target) => {
|
|
4
|
-
target.mode = options.mode || EventMode.Shared;
|
|
5
|
-
target.width = options.width;
|
|
6
|
-
target.height = options.height;
|
|
7
|
-
target.hitbox = options.hitbox;
|
|
8
|
-
target._name = options.name;
|
|
9
|
-
target.prototype._name = options.name;
|
|
10
|
-
target.prototype.mode = target.mode;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=event.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/decorators/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AA+ChD,MAAM,UAAU,SAAS,CAAC,OAAqB;IAC3C,OAAO,CAAC,MAAM,EAAE,EAAE;QACd,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,CAAC,MAAM,CAAA;QAC9C,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;QAC5B,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC9B,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC9B,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;QAC3B,MAAM,CAAC,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;QACrC,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;IACvC,CAAC,CAAA;AACL,CAAC"}
|
package/lib/decorators/map.d.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { TiledMap } from '@rpgjs/tiled';
|
|
2
|
-
export interface MapOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Map identifier. Allows to go to the map (for example with player.changeMap())
|
|
5
|
-
*
|
|
6
|
-
* @prop {string} [id]
|
|
7
|
-
* @memberof MapData
|
|
8
|
-
* */
|
|
9
|
-
id?: string;
|
|
10
|
-
/**
|
|
11
|
-
* the path to the .tmx file (Tiled Map Editor)
|
|
12
|
-
*
|
|
13
|
-
* Remember to use `require()` function
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { MapData, RpgMap } from '@rpgjs/server'
|
|
17
|
-
*
|
|
18
|
-
* @MapData({
|
|
19
|
-
* id: 'town',
|
|
20
|
-
* file: require('./tmx/town.tmx')
|
|
21
|
-
* })
|
|
22
|
-
* class TownMap extends RpgMap { }
|
|
23
|
-
* ```
|
|
24
|
-
* @prop {string} file
|
|
25
|
-
* @memberof MapData
|
|
26
|
-
* */
|
|
27
|
-
file: string | TiledMap;
|
|
28
|
-
/**
|
|
29
|
-
* The name of the map.
|
|
30
|
-
* @prop {string} [name]
|
|
31
|
-
* @memberof MapData
|
|
32
|
-
* */
|
|
33
|
-
name?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Map events. This is an array containing `RpgEvent` classes.
|
|
36
|
-
* You can also give an object that will indicate the positions of the event on the map.
|
|
37
|
-
*
|
|
38
|
-
* ```ts
|
|
39
|
-
* import { MapData, RpgMap, EventData, RpgEvent } from '@rpgjs/server'
|
|
40
|
-
*
|
|
41
|
-
* @EventData({
|
|
42
|
-
* name: 'Ev-1'
|
|
43
|
-
* })
|
|
44
|
-
* class NpcEvent extends RpgEvent { }
|
|
45
|
-
*
|
|
46
|
-
* @MapData({
|
|
47
|
-
* id: 'medieval',
|
|
48
|
-
* file: require('./tmx/town.tmx'),
|
|
49
|
-
* events: [NpcEvent]
|
|
50
|
-
* })
|
|
51
|
-
* class TownMap extends RpgMap {}
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* If the positions are not defined, the event will be placed on a Tiled Map Editor shape ([/guide/create-event.html#position-the-event-on-the-map](Guide)). Otherwise, it will be placed at `{x:0, y:0 }`
|
|
55
|
-
*
|
|
56
|
-
* You can give positions:
|
|
57
|
-
*
|
|
58
|
-
* ```ts
|
|
59
|
-
* events: [{ event: NpcEvent, x: 10, y: 30 }]
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @prop {Class of RpgEvent[] | { event: Class RpgEvent, x: number, y: number }} [events]
|
|
63
|
-
* @memberof MapData
|
|
64
|
-
* */
|
|
65
|
-
events?: {
|
|
66
|
-
event: any;
|
|
67
|
-
x: number;
|
|
68
|
-
y: number;
|
|
69
|
-
}[] | any[];
|
|
70
|
-
/**
|
|
71
|
-
* The sounds that will be played when the map is open. Sounds must be defined on the client side. Then, put the name of the sound identifier
|
|
72
|
-
*
|
|
73
|
-
* So, it is possible to play several sounds (in loop or not) on the card. You can put a background music (BGM) and a background noise (BGS) for example
|
|
74
|
-
*
|
|
75
|
-
* ```ts
|
|
76
|
-
* sounds: ['my-bgm', 'my-bgs']
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* And client side:
|
|
80
|
-
*
|
|
81
|
-
* ```ts
|
|
82
|
-
* import { Sound } from '@rpgjs/client'
|
|
83
|
-
*
|
|
84
|
-
* @Sound({
|
|
85
|
-
* sounds: {
|
|
86
|
-
* 'my-bgm': require('./assets/bgm.ogg'),
|
|
87
|
-
* 'my-bgs': require('./assets/bgs.ogg')
|
|
88
|
-
* },
|
|
89
|
-
* loop: true
|
|
90
|
-
* })
|
|
91
|
-
* export class Sounds {}
|
|
92
|
-
* ```
|
|
93
|
-
*
|
|
94
|
-
* See [https://docs.rpgjs.dev/classes/sound.html#properties](RpgSound Decorator)
|
|
95
|
-
*
|
|
96
|
-
* @prop {Array<string>} [sounds]
|
|
97
|
-
* @memberof MapData
|
|
98
|
-
* */
|
|
99
|
-
sounds?: string[];
|
|
100
|
-
/**
|
|
101
|
-
* Specify which properties will be synchronized with the client. On the client side, you can retrieve the values synchronized with the valueChanges property on the scene
|
|
102
|
-
*
|
|
103
|
-
* You must create the schema:
|
|
104
|
-
*
|
|
105
|
-
* ```ts
|
|
106
|
-
* import { MapData, RpgMap } from '@rpgjs/server'
|
|
107
|
-
*
|
|
108
|
-
* @MapData({
|
|
109
|
-
* id: 'medieval',
|
|
110
|
-
* file: require('./tmx/town.tmx'),
|
|
111
|
-
* syncSchema: {
|
|
112
|
-
* count: Number
|
|
113
|
-
* }
|
|
114
|
-
* })
|
|
115
|
-
* export class TownMap extends RpgMap {
|
|
116
|
-
* count: number = 0
|
|
117
|
-
*
|
|
118
|
-
* onLoad() {}
|
|
119
|
-
*
|
|
120
|
-
* onJoin() {
|
|
121
|
-
* this.count++
|
|
122
|
-
* }
|
|
123
|
-
*
|
|
124
|
-
* onLeave(player) {
|
|
125
|
-
* super.onLeave(player)
|
|
126
|
-
* this.count--
|
|
127
|
-
* }
|
|
128
|
-
* }
|
|
129
|
-
*
|
|
130
|
-
* ```
|
|
131
|
-
*
|
|
132
|
-
* If you want to change the scheme of players and events, consider overwriting the existing scheme
|
|
133
|
-
*
|
|
134
|
-
* ```ts
|
|
135
|
-
* import { MapData, RpgMap, RpgPlayer } from '@rpgjs/server'
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* declare module '@rpgjs/server' {
|
|
139
|
-
* export interface RpgPlayer {
|
|
140
|
-
* customProp: string
|
|
141
|
-
* }
|
|
142
|
-
* }
|
|
143
|
-
*
|
|
144
|
-
* @MapData({
|
|
145
|
-
* id: 'medieval',
|
|
146
|
-
* file: require('./tmx/town.tmx'),
|
|
147
|
-
* syncSchema: {
|
|
148
|
-
* users: [
|
|
149
|
-
* {
|
|
150
|
-
* customProp: String,
|
|
151
|
-
* ...RpgPlayer.schemas
|
|
152
|
-
* }
|
|
153
|
-
* ]
|
|
154
|
-
* }
|
|
155
|
-
* })
|
|
156
|
-
* export class TownMap extends RpgMap {}
|
|
157
|
-
* ```
|
|
158
|
-
*
|
|
159
|
-
* The properties are called `users` and `events`. Their scheme is identical and defined in `RpgPlayer.schemas`. To write schematics, refer to the [documentation of the simple-room](https://github.com/RSamaium/simple-room) module
|
|
160
|
-
*
|
|
161
|
-
* @prop {object} [syncSchema]
|
|
162
|
-
* @memberof MapData
|
|
163
|
-
* */
|
|
164
|
-
syncSchema?: any;
|
|
165
|
-
/**
|
|
166
|
-
* Decreases the RAM of the map. In this case, some instructions will be different.
|
|
167
|
-
*
|
|
168
|
-
* `map.getTileByIndex()` will not return all tiles of an index but only the tile of the highest layer
|
|
169
|
-
*
|
|
170
|
-
* > You can also use the `low-memory` property in Tiled maps
|
|
171
|
-
*
|
|
172
|
-
* @prop {boolean} [lowMemory=false]
|
|
173
|
-
* @since 3.1.0
|
|
174
|
-
* @memberof MapData
|
|
175
|
-
* */
|
|
176
|
-
lowMemory?: boolean;
|
|
177
|
-
}
|
|
178
|
-
export declare function MapData(options: MapOptions): (target: any) => void;
|