@rpgjs/server 3.0.0-beta.6 → 3.0.0-beta.9

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.
@@ -1,21 +1,81 @@
1
+ import { TiledMap } from '@rpgjs/tiled';
1
2
  import { MapOptions } from '../decorators/map';
2
3
  import { RpgMap } from '../Game/Map';
4
+ import { RpgWorldMaps, WorldMap } from '../Game/WorldMaps';
3
5
  import { RpgPlayer } from '../Player/Player';
6
+ import { RpgServerEngine } from '../server';
7
+ export interface RpgClassMap<T> {
8
+ id?: string;
9
+ new (server: any): T;
10
+ }
4
11
  export declare class SceneMap {
5
12
  private maps;
6
13
  private server;
7
14
  static readonly id: string;
8
15
  private mapsById;
9
- constructor(maps: any[], server: any);
10
- getMapBydId(id: any): any;
11
- loadMap(id: string): Promise<RpgMap>;
16
+ private worldMaps;
17
+ constructor(maps: any[], worldMaps: WorldMap[], server: RpgServerEngine);
18
+ getMapBydId(id: string): RpgClassMap<RpgMap> | null;
19
+ loadMap(id: string): Promise<RpgMap | undefined>;
20
+ /**
21
+ * Loads the content of a `.world` file from Tiled Map Editor into the map scene
22
+ *
23
+ * > 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
24
+ *
25
+ * @title Create worlds dynamically
26
+ * @method sceneMap.createDynamicWorldMaps(world)
27
+ * @param {object} world
28
+ * object is
29
+ * ```ts
30
+ * {
31
+ * id?: string
32
+ * maps: {
33
+ * id?: string
34
+ * properties?: object
35
+ * fileName: string;
36
+ height: number;
37
+ width: number;
38
+ x: number;
39
+ y: number;
40
+ * }[],
41
+ onlyShowAdjacentMaps: boolean, // only for Tiled Map Editor
42
+ type: 'world' // only for Tiled Map Editor
43
+ * }
44
+ * ```
45
+ * @since 3.0.0-beta.8
46
+ * @memberof SceneMap
47
+ */
48
+ createDynamicWorldMaps(world: WorldMap): RpgWorldMaps;
49
+ /**
50
+ * Recover a world
51
+ *
52
+ * @title Recover a world
53
+ * @method sceneMap.getWorldMaps(id)
54
+ * @param {string} id world id
55
+ * @return { RpgWorldMaps | undefined }
56
+ * @since 3.0.0-beta.8
57
+ * @memberof SceneMap
58
+ */
59
+ getWorldMaps(id: string): RpgWorldMaps | undefined;
60
+ /**
61
+ * Delete a world
62
+ *
63
+ * @title Delete a world
64
+ * @method sceneMap.deleteWorldMaps(id)
65
+ * @param {string} id world id
66
+ * @since 3.0.0-beta.8
67
+ * @memberof SceneMap
68
+ */
69
+ deleteWorldMaps(id: string): void;
12
70
  /**
13
71
  * Create a dynamic map
14
72
  *
73
+ * 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
74
+ *
15
75
  * @method sceneMap.createDynamicMap(mapData)
16
76
  * @title Create a dynamic map
17
- * @param {object | RpgMap} mapData The same property as [@MapData decorator](https://docs.rpgjs.dev/classes/map.html#mapdata-decorator)
18
- * @returns {void}
77
+ * @param {object | RpgMap | string} mapData The same property as [@MapData decorator](https://docs.rpgjs.dev/classes/map.html#mapdata-decorator)
78
+ * @returns {RpgMap}
19
79
  * @since 3.0.0-beta.4
20
80
  * @memberof SceneMap
21
81
  * @example
@@ -31,11 +91,19 @@ export declare class SceneMap {
31
91
  * ```ts
32
92
  * player.changeMap('myid')
33
93
  * ```
94
+ *
95
+ * ---
96
+ *
97
+ * since beta.8
98
+ *
99
+ * ```ts
100
+ * sceneMap.createDynamicMap(require('./tmx/mymap.tmx')) // id is "mymap"
101
+ * ```
34
102
  */
35
- createDynamicMap(mapData: MapOptions): void;
103
+ createDynamicMap(mapData: MapOptions | string | RpgClassMap<RpgMap> | TiledMap): RpgClassMap<RpgMap> | never;
36
104
  changeMap(mapId: string, player: RpgPlayer, positions?: {
37
105
  x: number;
38
106
  y: number;
39
- z: number;
40
- } | string): Promise<RpgMap>;
107
+ z?: number;
108
+ } | string): Promise<RpgMap | null | boolean>;
41
109
  }
package/lib/Scenes/Map.js CHANGED
@@ -18,25 +18,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.SceneMap = void 0;
19
19
  const common_1 = require("@rpgjs/common");
20
20
  const sync_server_1 = require("@rpgjs/sync-server");
21
+ const tiled_1 = require("@rpgjs/tiled");
21
22
  const map_1 = require("../decorators/map");
22
23
  const Map_1 = require("../Game/Map");
24
+ const WorldMaps_1 = require("../Game/WorldMaps");
25
+ const Player_1 = require("../Player/Player");
23
26
  class SceneMap {
24
- constructor(maps, server) {
27
+ constructor(maps, worldMaps, server) {
25
28
  this.maps = maps;
26
29
  this.server = server;
27
30
  this.mapsById = {};
31
+ this.worldMaps = new Map();
28
32
  this.mapsById = {};
33
+ common_1.RpgCommonMap.buffer.clear();
29
34
  if (this.maps) {
30
35
  for (let map of this.maps) {
31
36
  this.createDynamicMap(map);
32
37
  }
33
38
  }
39
+ if (this.worldMaps) {
40
+ for (let worldMap of worldMaps) {
41
+ this.createDynamicWorldMaps(worldMap);
42
+ }
43
+ }
34
44
  }
35
45
  getMapBydId(id) {
36
46
  let mapClass = this.mapsById[id];
37
47
  if (!mapClass) {
38
- console.log(`Map ${id} not exists`);
39
- return false;
48
+ return null;
40
49
  }
41
50
  if (!common_1.Utils.isClass(mapClass))
42
51
  mapClass = common_1.Utils.createConstructor(mapClass);
@@ -45,27 +54,96 @@ class SceneMap {
45
54
  loadMap(id) {
46
55
  return __awaiter(this, void 0, void 0, function* () {
47
56
  const mapClass = this.getMapBydId(id);
57
+ if (!mapClass) {
58
+ console.log(`Map ${id} not exists`);
59
+ return;
60
+ }
48
61
  let mapInstance;
49
- if (mapClass.buffer.has(id)) {
50
- return mapClass.buffer.get(id);
62
+ if (mapClass['buffer'].has(id)) {
63
+ return mapClass['buffer'].get(id);
51
64
  }
52
65
  if (common_1.RpgCommonMap.buffer.has(id)) {
53
66
  mapInstance = common_1.RpgCommonMap.buffer.get(id);
54
67
  }
55
68
  else {
56
- mapInstance = sync_server_1.World.addRoom(id, new mapClass(this.server));
69
+ const room = new mapClass(this.server);
70
+ room.$schema.users = [
71
+ Object.assign(Object.assign({}, Player_1.RpgPlayer.schemas), this.server['playerProps'])
72
+ ];
73
+ mapInstance = sync_server_1.World.addRoom(id, room);
57
74
  yield mapInstance.load();
58
75
  }
59
76
  return mapInstance;
60
77
  });
61
78
  }
79
+ /**
80
+ * Loads the content of a `.world` file from Tiled Map Editor into the map scene
81
+ *
82
+ * > 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
83
+ *
84
+ * @title Create worlds dynamically
85
+ * @method sceneMap.createDynamicWorldMaps(world)
86
+ * @param {object} world
87
+ * object is
88
+ * ```ts
89
+ * {
90
+ * id?: string
91
+ * maps: {
92
+ * id?: string
93
+ * properties?: object
94
+ * fileName: string;
95
+ height: number;
96
+ width: number;
97
+ x: number;
98
+ y: number;
99
+ * }[],
100
+ onlyShowAdjacentMaps: boolean, // only for Tiled Map Editor
101
+ type: 'world' // only for Tiled Map Editor
102
+ * }
103
+ * ```
104
+ * @since 3.0.0-beta.8
105
+ * @memberof SceneMap
106
+ */
107
+ createDynamicWorldMaps(world) {
108
+ world.id = world.id || common_1.Utils.generateUID();
109
+ const worldMap = new WorldMaps_1.RpgWorldMaps(world.id).load(world, this);
110
+ this.worldMaps.set(world.id, worldMap);
111
+ return worldMap;
112
+ }
113
+ /**
114
+ * Recover a world
115
+ *
116
+ * @title Recover a world
117
+ * @method sceneMap.getWorldMaps(id)
118
+ * @param {string} id world id
119
+ * @return { RpgWorldMaps | undefined }
120
+ * @since 3.0.0-beta.8
121
+ * @memberof SceneMap
122
+ */
123
+ getWorldMaps(id) {
124
+ return this.worldMaps.get(id);
125
+ }
126
+ /**
127
+ * Delete a world
128
+ *
129
+ * @title Delete a world
130
+ * @method sceneMap.deleteWorldMaps(id)
131
+ * @param {string} id world id
132
+ * @since 3.0.0-beta.8
133
+ * @memberof SceneMap
134
+ */
135
+ deleteWorldMaps(id) {
136
+ this.worldMaps.delete(id);
137
+ }
62
138
  /**
63
139
  * Create a dynamic map
64
140
  *
141
+ * 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
142
+ *
65
143
  * @method sceneMap.createDynamicMap(mapData)
66
144
  * @title Create a dynamic map
67
- * @param {object | RpgMap} mapData The same property as [@MapData decorator](https://docs.rpgjs.dev/classes/map.html#mapdata-decorator)
68
- * @returns {void}
145
+ * @param {object | RpgMap | string} mapData The same property as [@MapData decorator](https://docs.rpgjs.dev/classes/map.html#mapdata-decorator)
146
+ * @returns {RpgMap}
69
147
  * @since 3.0.0-beta.4
70
148
  * @memberof SceneMap
71
149
  * @example
@@ -81,8 +159,34 @@ class SceneMap {
81
159
  * ```ts
82
160
  * player.changeMap('myid')
83
161
  * ```
162
+ *
163
+ * ---
164
+ *
165
+ * since beta.8
166
+ *
167
+ * ```ts
168
+ * sceneMap.createDynamicMap(require('./tmx/mymap.tmx')) // id is "mymap"
169
+ * ```
84
170
  */
85
171
  createDynamicMap(mapData) {
172
+ if (common_1.Utils.isString(mapData)) {
173
+ const id = common_1.Utils.extractId(mapData);
174
+ if (!id) {
175
+ throw new Error('Unable to extract the file identifier. Check that the file has only the following characters: [a-zA-Z0-9-_$!]+');
176
+ }
177
+ mapData = {
178
+ id: id[1],
179
+ file: mapData
180
+ };
181
+ }
182
+ if (tiled_1.isTiledFormat(mapData)) {
183
+ const tiledData = mapData;
184
+ mapData = {
185
+ file: Object.assign({}, tiledData)
186
+ };
187
+ }
188
+ if (!mapData.id)
189
+ mapData.id = common_1.Utils.generateUID();
86
190
  if (!common_1.Utils.isClass(mapData)) {
87
191
  let DynamicMap = class DynamicMap extends Map_1.RpgMap {
88
192
  };
@@ -91,19 +195,33 @@ class SceneMap {
91
195
  ], DynamicMap);
92
196
  mapData = DynamicMap;
93
197
  }
94
- mapData.id = mapData.id || common_1.Utils.generateUID();
95
- this.mapsById[mapData.id] = mapData;
198
+ const map = mapData;
199
+ this.mapsById[map.id] = map;
200
+ return map;
96
201
  }
97
202
  changeMap(mapId, player, positions) {
98
203
  return __awaiter(this, void 0, void 0, function* () {
204
+ const boolArray = yield common_1.RpgPlugin.emit(common_1.HookServer.PlayerCanChangeMap, [player, this.getMapBydId(mapId)], true);
205
+ if (boolArray.some(el => el === false)) {
206
+ return null;
207
+ }
208
+ player.emit('preLoadScene', mapId);
99
209
  player.prevMap = player.map;
100
210
  if (player.prevMap) {
101
- player.execMethod('onLeaveMap', [player.getCurrentMap()]);
211
+ yield player.execMethod('onLeaveMap', [player.getCurrentMap()]);
102
212
  sync_server_1.World.leaveRoom(player.prevMap, player.id);
103
213
  }
104
214
  player.map = mapId;
105
215
  player.events = {};
216
+ player.tmpPositions = positions;
217
+ const scalabilityArray = yield common_1.RpgPlugin.emit(common_1.HookServer.ScalabilityChangeServer, player);
218
+ if (scalabilityArray.some(el => el === true)) {
219
+ return true;
220
+ }
221
+ player.tmpPositions = null;
106
222
  const mapInstance = yield this.loadMap(mapId);
223
+ if (!mapInstance)
224
+ return null;
107
225
  if (!player.height)
108
226
  player.height = mapInstance.tileHeight;
109
227
  if (!player.width)
@@ -120,11 +238,10 @@ class SceneMap {
120
238
  delete layer.map;
121
239
  }
122
240
  player.loadScene('map', Object.assign({ id: mapId, sounds: mapInstance.sounds }, serializeMap));
241
+ player.teleport(positions || 'start');
123
242
  sync_server_1.World.joinRoom(mapId, player.id);
124
243
  player = sync_server_1.World.getUser(player.id);
125
244
  if (player) {
126
- player.teleport(positions || 'start');
127
- player.events = {};
128
245
  player.createDynamicEvent(mapInstance._events, false);
129
246
  player.execMethod('onJoinMap', [mapInstance]);
130
247
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Map.js","sourceRoot":"","sources":["../../src/Scenes/Map.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,0CAAmD;AACnD,oDAA0C;AAC1C,2CAAuD;AACvD,qCAAoC;AAGpC,MAAa,QAAQ;IAMjB,YAAoB,IAAW,EAAU,MAAW;QAAhC,SAAI,GAAJ,IAAI,CAAO;QAAU,WAAM,GAAN,MAAM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} from '../Event';
1
+ import { EventMode } from '../Player/Player';
2
2
  export interface EventOptions {
3
3
  /**
4
4
  * The mode of the event, shared evening or scenario
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EventData = void 0;
4
- const Event_1 = require("../Event");
4
+ const Player_1 = require("../Player/Player");
5
5
  function EventData(options) {
6
6
  return (target) => {
7
- target.mode = options.mode || Event_1.EventMode.Shared;
7
+ target.mode = options.mode || Player_1.EventMode.Shared;
8
8
  target.width = options.width;
9
9
  target.height = options.height;
10
10
  target.hitbox = options.hitbox;
@@ -1 +1 @@
1
- {"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/decorators/event.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AA+CpC,SAAgB,SAAS,CAAC,OAAqB;IAC3C,OAAO,CAAC,MAAM,EAAE,EAAE;QACd,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,iBAAS,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,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;IACzC,CAAC,CAAA;AACL,CAAC;AARD,8BAQC"}
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/decorators/event.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AA+C5C,SAAgB,SAAS,CAAC,OAAqB;IAC3C,OAAO,CAAC,MAAM,EAAE,EAAE;QACd,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,kBAAS,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,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;IACzC,CAAC,CAAA;AACL,CAAC;AARD,8BAQC"}
@@ -1,3 +1,4 @@
1
+ import { TiledMap } from '@rpgjs/tiled';
1
2
  export interface MapOptions {
2
3
  /**
3
4
  * Map identifier. Allows to go to the map (for example with player.changeMap())
@@ -23,7 +24,7 @@ export interface MapOptions {
23
24
  * @prop {string} file
24
25
  * @memberof MapData
25
26
  * */
26
- file: string;
27
+ file: string | TiledMap;
27
28
  /**
28
29
  * The name of the map.
29
30
  * @prop {string} [name]
@@ -131,8 +132,10 @@ export interface MapOptions {
131
132
  * import { MapData, RpgMap, RpgPlayer } from '@rpgjs/server'
132
133
  *
133
134
  *
134
- * export class Player extends RpgPlayer {
135
- * customProp: string = 'test'
135
+ * declare module '@rpgjs/server' {
136
+ * export interface RpgPlayer {
137
+ * customProp: string
138
+ * }
136
139
  * }
137
140
  *
138
141
  * @MapData({
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","sourceRoot":"","sources":["../../src/decorators/map.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAmK5C,SAAgB,OAAO,CAAC,OAAmB;IACvC,OAAO,CAAC,MAAM,EAAE,EAAE;QACd,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QAC1B,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAA;QACtB,MAAM,CAAC,IAAI,GAAG,KAAK,CAAA;QACnB,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACpC,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACpC,MAAM,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAA;QAChC,MAAM,CAAC,SAAS,CAAC,MAA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SAAS,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,kBAAS,CAAC,OAAO,CAAC,CAAA;SACxD;QAED,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAA;IAC7C,CAAC,CAAA;AACL,CAAC;AA5CD,0BA4CC"}
@@ -29,5 +29,5 @@ interface RpgServerEntryPointOptions {
29
29
  globalConfig?: any;
30
30
  workers?: any;
31
31
  }
32
- export default function (modules: ModuleType[], options: RpgServerEntryPointOptions): RpgServerEngine;
32
+ export default function (modules: ModuleType[], options: RpgServerEntryPointOptions): Promise<RpgServerEngine>;
33
33
  export {};
@@ -1,36 +1,70 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  const common_1 = require("@rpgjs/common");
4
13
  const server_1 = require("./server");
14
+ const MatchMaker_1 = require("./MatchMaker");
5
15
  function default_1(modules, options) {
6
- const gameEngine = new common_1.RpgCommonGame('server');
7
- if (!options.globalConfig)
8
- options.globalConfig = {};
9
- const relations = {
10
- onConnected: common_1.HookServer.PlayerConnected,
11
- onInput: common_1.HookServer.PlayerInput,
12
- onJoinMap: common_1.HookServer.PlayerJoinMap,
13
- onLeaveMap: common_1.HookServer.PlayerLeaveMap,
14
- onLevelUp: common_1.HookServer.PlayerLevelUp,
15
- onDead: common_1.HookServer.PlayerDead,
16
- onDisconnected: common_1.HookServer.PlayerDisconnected,
17
- onInShape: common_1.HookServer.PlayerInShape,
18
- onOutShape: common_1.HookServer.PlayerOutShape,
19
- onMove: common_1.HookServer.PlayerMove
20
- };
21
- const relationsEngine = {
22
- onStart: common_1.HookServer.Start,
23
- onStep: common_1.HookServer.Step
24
- };
25
- common_1.loadModules(modules, {
26
- side: 'server',
27
- relations: {
28
- player: relations,
29
- engine: relationsEngine
30
- }
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const gameEngine = new common_1.RpgCommonGame(common_1.GameSide.Server);
18
+ if (!options.globalConfig)
19
+ options.globalConfig = {};
20
+ const relations = {
21
+ onConnected: common_1.HookServer.PlayerConnected,
22
+ onInput: common_1.HookServer.PlayerInput,
23
+ onJoinMap: common_1.HookServer.PlayerJoinMap,
24
+ onLeaveMap: common_1.HookServer.PlayerLeaveMap,
25
+ onLevelUp: common_1.HookServer.PlayerLevelUp,
26
+ onDead: common_1.HookServer.PlayerDead,
27
+ onDisconnected: common_1.HookServer.PlayerDisconnected,
28
+ onInShape: common_1.HookServer.PlayerInShape,
29
+ onOutShape: common_1.HookServer.PlayerOutShape,
30
+ onMove: common_1.HookServer.PlayerMove,
31
+ canChangeMap: common_1.HookServer.PlayerCanChangeMap
32
+ };
33
+ const relationsEngine = {
34
+ onStart: common_1.HookServer.Start,
35
+ onStep: common_1.HookServer.Step
36
+ };
37
+ const { playerProps } = yield common_1.loadModules(modules, {
38
+ side: 'server',
39
+ relations: {
40
+ player: relations,
41
+ engine: relationsEngine,
42
+ scalability: {
43
+ onConnected: common_1.HookServer.ScalabilityPlayerConnected,
44
+ doChangeServer: common_1.HookServer.ScalabilityChangeServer
45
+ }
46
+ }
47
+ }, (mod) => {
48
+ const { scalability } = mod;
49
+ if (scalability) {
50
+ const { hooks, stateStore, matchMaker } = scalability;
51
+ const matchMakerInstance = new MatchMaker_1.RpgMatchMaker(matchMaker);
52
+ common_1.RpgPlugin.on(common_1.HookServer.Start, () => {
53
+ return stateStore.connect();
54
+ });
55
+ mod.scalability._hooks = {};
56
+ for (let hookName in hooks) {
57
+ let originalHook = mod.scalability.hooks[hookName];
58
+ mod.scalability._hooks[hookName] = function (player) {
59
+ return originalHook(stateStore, matchMakerInstance, player);
60
+ };
61
+ }
62
+ }
63
+ return mod;
64
+ });
65
+ const serverEngine = new server_1.RpgServerEngine(options.io, gameEngine, Object.assign({ debug: {}, updateRate: 10, stepRate: 60, timeoutInterval: 0, countConnections: false, playerProps }, options));
66
+ return serverEngine;
31
67
  });
32
- const serverEngine = new server_1.RpgServerEngine(options.io, gameEngine, Object.assign({ debug: {}, updateRate: 10, stepRate: 60, timeoutInterval: 0, countConnections: false }, options));
33
- return serverEngine;
34
68
  }
35
69
  exports.default = default_1;
36
70
  //# sourceMappingURL=entry-point.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entry-point.js","sourceRoot":"","sources":["../src/entry-point.ts"],"names":[],"mappings":";;AAAA,0CAAkF;AAClF,qCAA0C;AAmC1C,mBAAwB,OAAqB,EAAE,OAAmC;IAC9E,MAAM,UAAU,GAAG,IAAI,sBAAa,CAAC,QAAQ,CAAC,CAAA;IAE9C,IAAI,CAAC,OAAO,CAAC,YAAY;QAAE,OAAO,CAAC,YAAY,GAAG,EAAE,CAAA;IAEpD,MAAM,SAAS,GAAG;QACd,WAAW,EAAE,mBAAU,CAAC,eAAe;QACvC,OAAO,EAAE,mBAAU,CAAC,WAAW;QAC/B,SAAS,EAAE,mBAAU,CAAC,aAAa;QACnC,UAAU,EAAE,mBAAU,CAAC,cAAc;QACrC,SAAS,EAAE,mBAAU,CAAC,aAAa;QACnC,MAAM,EAAE,mBAAU,CAAC,UAAU;QAC7B,cAAc,EAAE,mBAAU,CAAC,kBAAkB;QAC7C,SAAS,EAAE,mBAAU,CAAC,aAAa;QACnC,UAAU,EAAE,mBAAU,CAAC,cAAc;QACrC,MAAM,EAAE,mBAAU,CAAC,UAAU;KAChC,CAAA;IAED,MAAM,eAAe,GAAG;QACpB,OAAO,EAAE,mBAAU,CAAC,KAAK;QACzB,MAAM,E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,EAAE,UAAU,kBAC3D,KAAK,EAAE,EAAE,EACT,UAAU,EAAE,EAAE,EACd,QAAQ,EAAE,EAAE,EACZ,eAAe,EAAE,CAAC,EAClB,gBAAgB,EAAE,KAAK,EACvB,WAAW,IACR,OAAO,EACZ,CAAA;QACF,OAAO,YAAY,CAAA;IACvB,CAAC;CAAA;AA/DD,4BA+DC"}
package/lib/index.d.ts CHANGED
@@ -3,13 +3,15 @@ import { Direction, Input, Control, RpgPlugin, HookServer, HookClient, RpgModule
3
3
  import { RpgServer, RpgPlayerHooks, RpgServerEngineHooks } from './RpgServer';
4
4
  import { EventData } from './decorators/event';
5
5
  import { MapData } from './decorators/map';
6
+ import { RpgPlayer, RpgEvent, EventMode } from './Player/Player';
6
7
  import { RpgMap } from './Game/Map';
7
- import { RpgEvent, EventMode } from './Event';
8
- import { RpgPlayer } from './Player/Player';
9
- import RpgEnemy from './Enemy';
8
+ import { RpgWorldMaps } from './Game/WorldMaps';
10
9
  import { Query } from './Query';
11
10
  import Monitor from './Monitor';
12
11
  import * as Presets from './presets';
13
- import { Move } from './Player/MoveManager';
12
+ import { Move, Frequency, Speed } from './Player/MoveManager';
14
13
  import { RpgServerEngine } from './server';
15
- export { RpgServer, RpgEvent, RpgPlayer, RpgPlugin, RpgMap, RpgEnemy, MapData, EventData, Query as RpgWorld, Query, entryPoint, Presets, Monitor, Move, EventMode, Direction, Input, Control, HookServer, HookClient, RpgModule, RpgPlayerHooks, RpgServerEngineHooks, RpgServerEngine, RpgShape, ShapePositioning };
14
+ import { SceneMap as RpgSceneMap, RpgClassMap } from './Scenes/Map';
15
+ import { RpgMatchMaker } from './MatchMaker';
16
+ import { IStoreState } from './Interfaces/StateStore';
17
+ export { RpgServer, RpgEvent, RpgPlayer, RpgPlugin, RpgMap, RpgSceneMap, MapData, EventData, Query as RpgWorld, Query, entryPoint, Presets, Monitor, Move, EventMode, Direction, Input, Control, HookServer, HookClient, RpgModule, RpgPlayerHooks, RpgServerEngineHooks, RpgServerEngine, RpgShape, ShapePositioning, Frequency, Speed, RpgWorldMaps, RpgClassMap, IStoreState, RpgMatchMaker };
package/lib/index.js CHANGED
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.ShapePositioning = exports.RpgShape = exports.RpgServerEngine = exports.RpgModule = exports.HookClient = exports.HookServer = exports.Control = exports.Input = exports.Direction = exports.EventMode = exports.Move = exports.Monitor = exports.Presets = exports.entryPoint = exports.Query = exports.RpgWorld = exports.EventData = exports.MapData = exports.RpgEnemy = exports.RpgMap = exports.RpgPlugin = exports.RpgPlayer = exports.RpgEvent = void 0;
25
+ exports.RpgMatchMaker = exports.RpgWorldMaps = exports.Speed = exports.Frequency = exports.ShapePositioning = exports.RpgShape = exports.RpgServerEngine = exports.RpgModule = exports.HookClient = exports.HookServer = exports.Control = exports.Input = exports.Direction = exports.EventMode = exports.Move = exports.Monitor = exports.Presets = exports.entryPoint = exports.Query = exports.RpgWorld = exports.EventData = exports.MapData = exports.RpgSceneMap = exports.RpgMap = exports.RpgPlugin = exports.RpgPlayer = exports.RpgEvent = void 0;
26
26
  const entry_point_1 = __importDefault(require("./entry-point"));
27
27
  exports.entryPoint = entry_point_1.default;
28
28
  const common_1 = require("@rpgjs/common");
@@ -39,15 +39,14 @@ const event_1 = require("./decorators/event");
39
39
  Object.defineProperty(exports, "EventData", { enumerable: true, get: function () { return event_1.EventData; } });
40
40
  const map_1 = require("./decorators/map");
41
41
  Object.defineProperty(exports, "MapData", { enumerable: true, get: function () { return map_1.MapData; } });
42
- const Map_1 = require("./Game/Map");
43
- Object.defineProperty(exports, "RpgMap", { enumerable: true, get: function () { return Map_1.RpgMap; } });
44
- const Event_1 = require("./Event");
45
- Object.defineProperty(exports, "RpgEvent", { enumerable: true, get: function () { return Event_1.RpgEvent; } });
46
- Object.defineProperty(exports, "EventMode", { enumerable: true, get: function () { return Event_1.EventMode; } });
47
42
  const Player_1 = require("./Player/Player");
48
43
  Object.defineProperty(exports, "RpgPlayer", { enumerable: true, get: function () { return Player_1.RpgPlayer; } });
49
- const Enemy_1 = __importDefault(require("./Enemy"));
50
- exports.RpgEnemy = Enemy_1.default;
44
+ Object.defineProperty(exports, "RpgEvent", { enumerable: true, get: function () { return Player_1.RpgEvent; } });
45
+ Object.defineProperty(exports, "EventMode", { enumerable: true, get: function () { return Player_1.EventMode; } });
46
+ const Map_1 = require("./Game/Map");
47
+ Object.defineProperty(exports, "RpgMap", { enumerable: true, get: function () { return Map_1.RpgMap; } });
48
+ const WorldMaps_1 = require("./Game/WorldMaps");
49
+ Object.defineProperty(exports, "RpgWorldMaps", { enumerable: true, get: function () { return WorldMaps_1.RpgWorldMaps; } });
51
50
  const Query_1 = require("./Query");
52
51
  Object.defineProperty(exports, "RpgWorld", { enumerable: true, get: function () { return Query_1.Query; } });
53
52
  Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return Query_1.Query; } });
@@ -57,6 +56,12 @@ const Presets = __importStar(require("./presets"));
57
56
  exports.Presets = Presets;
58
57
  const MoveManager_1 = require("./Player/MoveManager");
59
58
  Object.defineProperty(exports, "Move", { enumerable: true, get: function () { return MoveManager_1.Move; } });
59
+ Object.defineProperty(exports, "Frequency", { enumerable: true, get: function () { return MoveManager_1.Frequency; } });
60
+ Object.defineProperty(exports, "Speed", { enumerable: true, get: function () { return MoveManager_1.Speed; } });
60
61
  const server_1 = require("./server");
61
62
  Object.defineProperty(exports, "RpgServerEngine", { enumerable: true, get: function () { return server_1.RpgServerEngine; } });
63
+ const Map_2 = require("./Scenes/Map");
64
+ Object.defineProperty(exports, "RpgSceneMap", { enumerable: true, get: function () { return Map_2.SceneMap; } });
65
+ const MatchMaker_1 = require("./MatchMaker");
66
+ Object.defineProperty(exports, "RpgMatchMaker", { enumerable: true, get: function () { return MatchMaker_1.RpgMatchMaker; } });
62
67
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAsC;AAoClC,qBApCG,qBAAU,CAoCH;AAnCd,0CAUsB;AA8BlB,0FAvCA,kBAAS,OAuCA;AACT,sFAvCA,cAAK,OAuCA;AACL,wFAvCA,gBAAO,OAuCA;AAdP,0FAxBA,kBAAS,OAwBA;AAeT,2FAtCA,mBAAU,OAsCA;AACV,2FAtCA,mBAAU,OAsCA;AACV,0FAtCA,kBAAS,OAsCA;AAIT,yFAzCA,iBAAQ,OAyCA;AACR,iGAzCA,yBAAgB,OAyCA;AAtCpB,8CAA8C;AAoB1C,0FApBK,iBAAS,OAoBL;AAnBb,0CAA0C;AAkBtC,wFAlBK,aAAO,OAkBL;AAjBX,oCAAmC;AAe/B,uFAfK,YAAM,OAeL;AAdV,mCAA6C;AAWzC,yFAXK,gBAAQ,OAWL;AAaR,0FAxBe,iBAAS,OAwBf;AAvBb,4CAA2C;AAWvC,0FAXK,kBAAS,OAWL;AAVb,oDAA8B;AAa1B,mBAbG,eAAQ,CAaH;AAZZ,mCAA+B;AAelB,yFAfJ,aAAK,OAeO;AACjB,sFAhBK,aAAK,OAgBL;AAfT,wDAA+B;AAkB3B,kBAlBG,iBAAO,CAkBH;AAjBX,mDAAoC;AAgBhC,0BAAO;AAfX,sDAA2C;AAiBvC,qFAjBK,kBAAI,OAiBL;AAhBR,qCAA0C;AA0BtC,gGA1BK,wBAAe,OA0BL"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAsC;AAsClC,qBAtCG,qBAAU,CAsCH;AArCd,0CAUsB;AAgClB,0FAzCA,kBAAS,OAyCA;AACT,sFAzCA,cAAK,OAyCA;AACL,wFAzCA,gBAAO,OAyCA;AAdP,0FA1BA,kBAAS,OA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