@rpgjs/server 3.0.0 → 3.2.0
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/Game/Map.d.ts +47 -10
- package/lib/Game/Map.js +75 -14
- package/lib/Game/Map.js.map +1 -1
- package/lib/Player/BattleManager.d.ts +2 -1
- package/lib/Player/BattleManager.js.map +1 -1
- package/lib/Player/MoveManager.d.ts +38 -2
- package/lib/Player/MoveManager.js +18 -0
- package/lib/Player/MoveManager.js.map +1 -1
- package/lib/Player/Player.d.ts +32 -12
- package/lib/Player/Player.js +46 -7
- package/lib/Player/Player.js.map +1 -1
- package/lib/Query.d.ts +20 -3
- package/lib/Query.js +19 -3
- package/lib/Query.js.map +1 -1
- package/lib/Scenes/Map.d.ts +1 -0
- package/lib/Scenes/Map.js +10 -0
- package/lib/Scenes/Map.js.map +1 -1
- package/lib/decorators/map.d.ts +12 -0
- package/lib/decorators/map.js +6 -8
- package/lib/decorators/map.js.map +1 -1
- package/lib/index.d.ts +16 -17
- package/lib/index.js +19 -19
- package/lib/index.js.map +1 -1
- package/lib/server.d.ts +4 -1
- package/lib/server.js +32 -15
- package/lib/server.js.map +1 -1
- package/package.json +7 -6
- package/lib/Enemy.d.ts +0 -7
- package/lib/Enemy.js +0 -26
- package/lib/Enemy.js.map +0 -1
- package/lib/Event.d.ts +0 -10
- package/lib/Event.js +0 -49
- package/lib/Event.js.map +0 -1
- package/lib/Game/Battle/Battle.d.ts +0 -12
- package/lib/Game/Battle/Battle.js +0 -37
- package/lib/Game/Battle/Battle.js.map +0 -1
- package/lib/Gui/BattleGui.d.ts +0 -9
- package/lib/Gui/BattleGui.js +0 -25
- package/lib/Gui/BattleGui.js.map +0 -1
- package/lib/Player/BehaviorManager.d.ts +0 -12
- package/lib/Player/BehaviorManager.js +0 -127
- package/lib/Player/BehaviorManager.js.map +0 -1
- package/lib/Scenes/Battle.d.ts +0 -8
- package/lib/Scenes/Battle.js +0 -34
- package/lib/Scenes/Battle.js.map +0 -1
- package/lib/decorators/strategy-broadcasting.d.ts +0 -7
- package/lib/decorators/strategy-broadcasting.js +0 -13
- package/lib/decorators/strategy-broadcasting.js.map +0 -1
- package/lib/workers/move.d.ts +0 -2
- package/lib/workers/move.js +0 -8
- package/lib/workers/move.js.map +0 -1
- package/lib/yuka.module.d.ts +0 -6379
- package/lib/yuka.module.js +0 -14546
- package/lib/yuka.module.js.map +0 -1
package/lib/Game/Map.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { RpgCommonMap, RpgShape, RpgCommonGame } from '@rpgjs/common';
|
|
1
|
+
import { RpgCommonMap, RpgShape, RpgCommonGame, AbstractObject } from '@rpgjs/common';
|
|
2
2
|
import { EventOptions } from '../decorators/event';
|
|
3
3
|
import { RpgPlayer, EventMode, RpgEvent } from '../Player/Player';
|
|
4
4
|
import { RpgServerEngine } from '../server';
|
|
5
|
+
import { Observable } from 'rxjs';
|
|
6
|
+
import { HitBox, MovingHitbox } from '@rpgjs/types';
|
|
5
7
|
export declare type EventPosOption = {
|
|
6
8
|
x: number;
|
|
7
9
|
y: number;
|
|
@@ -9,6 +11,12 @@ export declare type EventPosOption = {
|
|
|
9
11
|
event: EventOptions;
|
|
10
12
|
};
|
|
11
13
|
export declare type EventOption = EventPosOption | EventOptions;
|
|
14
|
+
export declare type PlayersList = {
|
|
15
|
+
[eventId: string]: RpgEvent;
|
|
16
|
+
};
|
|
17
|
+
export declare type EventsList = {
|
|
18
|
+
[playerId: string]: RpgPlayer;
|
|
19
|
+
};
|
|
12
20
|
export declare class RpgMap extends RpgCommonMap {
|
|
13
21
|
private _server;
|
|
14
22
|
_events: EventOption[];
|
|
@@ -18,15 +26,14 @@ export declare class RpgMap extends RpgCommonMap {
|
|
|
18
26
|
* @prop { { [eventId: string]: RpgEvent } } [events]
|
|
19
27
|
* @memberof Map
|
|
20
28
|
* */
|
|
21
|
-
events:
|
|
22
|
-
[eventId: string]: RpgEvent;
|
|
23
|
-
};
|
|
29
|
+
events: EventsList;
|
|
24
30
|
constructor(_server: RpgServerEngine);
|
|
31
|
+
get players(): PlayersList;
|
|
32
|
+
get nbPlayers(): number;
|
|
25
33
|
load(): Promise<void>;
|
|
26
34
|
private loadProperties;
|
|
27
35
|
get game(): RpgCommonGame;
|
|
28
|
-
|
|
29
|
-
onJoin(player: RpgPlayer): void;
|
|
36
|
+
private removeObject;
|
|
30
37
|
onLeave(player: RpgPlayer): void;
|
|
31
38
|
autoLoadEvent(): void;
|
|
32
39
|
/**
|
|
@@ -106,10 +113,39 @@ export declare class RpgMap extends RpgCommonMap {
|
|
|
106
113
|
* @memberof Map
|
|
107
114
|
*/
|
|
108
115
|
removeEvent(eventId: string): boolean;
|
|
109
|
-
createEvent(obj: EventPosOption, mode: EventMode, shape?:
|
|
110
|
-
createEvents(eventsList: EventOption[], mode: EventMode):
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
createEvent(obj: EventPosOption, mode: EventMode, shape?: RpgShape): RpgEvent | null;
|
|
117
|
+
createEvents(eventsList: EventOption[], mode: EventMode): EventsList;
|
|
118
|
+
/**
|
|
119
|
+
* Allows to create a temporary hitbox on the map that can have a movement
|
|
120
|
+
For example, you can use it to explode a bomb and find all the affected players, or during a sword strike, you can create a moving hitbox and find the affected players again
|
|
121
|
+
* @title Create a temporary and moving hitbox
|
|
122
|
+
* @since 3.2.0
|
|
123
|
+
* @method map.createMovingHitbox(hitboxes,options)
|
|
124
|
+
* @param {Array<{ width: number, height: number, x: number, y: number }>} hitboxes Create several hitboxes that will give an effect of movement
|
|
125
|
+
* @param {object} [options]
|
|
126
|
+
* @param {speed} [options.speed=1] speed of movement (in frames)
|
|
127
|
+
* @returns {Observable<AbstractObject>} You find the methods of position and movement of an event
|
|
128
|
+
* @memberof Map
|
|
129
|
+
* @example
|
|
130
|
+
*
|
|
131
|
+
* ```ts
|
|
132
|
+
* // Two hitboxes that will be done very quickly
|
|
133
|
+
* map.createMovingHitbox(
|
|
134
|
+
* [
|
|
135
|
+
* { x: 0, y: 0, width: 100, height: 100 },
|
|
136
|
+
* { x: 20, y: 0, width: 100, height: 100 }
|
|
137
|
+
* ]
|
|
138
|
+
* ).subscribe({
|
|
139
|
+
* next(hitbox) {
|
|
140
|
+
* console.log(hitbox.otherPlayersCollision)
|
|
141
|
+
* },
|
|
142
|
+
* complete() {
|
|
143
|
+
* console.log('finish')
|
|
144
|
+
* }
|
|
145
|
+
* })
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
createMovingHitbox(hitboxes: Pick<HitBox, 'width' | 'height' | 'x' | 'y'>[], options?: MovingHitbox): Observable<AbstractObject>;
|
|
113
149
|
setSync(schema: any): void;
|
|
114
150
|
}
|
|
115
151
|
export interface RpgMap {
|
|
@@ -118,4 +154,5 @@ export interface RpgMap {
|
|
|
118
154
|
$setSchema: (schema: any) => void;
|
|
119
155
|
$patchSchema: (schema: any) => void;
|
|
120
156
|
$snapshotUser: (userId: string) => any;
|
|
157
|
+
onLoad(): any;
|
|
121
158
|
}
|
package/lib/Game/Map.js
CHANGED
|
@@ -56,6 +56,13 @@ class RpgMap extends common_1.RpgCommonMap {
|
|
|
56
56
|
* */
|
|
57
57
|
this.events = {};
|
|
58
58
|
}
|
|
59
|
+
// alias of users property in simple-room package
|
|
60
|
+
get players() {
|
|
61
|
+
return this['users'];
|
|
62
|
+
}
|
|
63
|
+
get nbPlayers() {
|
|
64
|
+
return Object.keys(this.players).length;
|
|
65
|
+
}
|
|
59
66
|
load() {
|
|
60
67
|
const _super = Object.create(null, {
|
|
61
68
|
load: { get: () => super.load }
|
|
@@ -66,7 +73,9 @@ class RpgMap extends common_1.RpgCommonMap {
|
|
|
66
73
|
return;
|
|
67
74
|
}
|
|
68
75
|
const parser = new tiled_1.TiledParserFile(this.file, this._server.inputOptions.basePath + '/' + this._server.assetsPath);
|
|
69
|
-
const data = yield parser.parseFilePromise(
|
|
76
|
+
const data = yield parser.parseFilePromise({
|
|
77
|
+
getOnlyBasename: true
|
|
78
|
+
});
|
|
70
79
|
_super.load.call(this, data);
|
|
71
80
|
this.getAllObjects().forEach(this.createShape.bind(this));
|
|
72
81
|
this.loadProperties(data.properties);
|
|
@@ -76,7 +85,8 @@ class RpgMap extends common_1.RpgCommonMap {
|
|
|
76
85
|
});
|
|
77
86
|
common_1.RpgCommonMap.buffer.set(this.id, this);
|
|
78
87
|
this.createDynamicEvent(this._events);
|
|
79
|
-
this.onLoad
|
|
88
|
+
if (this.onLoad)
|
|
89
|
+
this.onLoad();
|
|
80
90
|
});
|
|
81
91
|
}
|
|
82
92
|
loadProperties(properties) {
|
|
@@ -87,18 +97,35 @@ class RpgMap extends common_1.RpgCommonMap {
|
|
|
87
97
|
get game() {
|
|
88
98
|
return this._server.gameEngine;
|
|
89
99
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.getShapes().forEach(shape => shape.out(player));
|
|
95
|
-
const events = Object.values(this.game.world.getObjectsOfGroup(this.id, player));
|
|
100
|
+
removeObject(object) {
|
|
101
|
+
var _a;
|
|
102
|
+
this.getShapes().forEach(shape => shape.out(object));
|
|
103
|
+
const events = Object.values(this.game.world.getObjectsOfGroup(this.id, object));
|
|
96
104
|
for (let event of events) {
|
|
97
|
-
|
|
98
|
-
event.getShapes().forEach(shape => shape.out(
|
|
105
|
+
object.getShapes().forEach(shape => shape.out(event));
|
|
106
|
+
event.getShapes().forEach(shape => shape.out(object));
|
|
107
|
+
}
|
|
108
|
+
object.stopMoveTo();
|
|
109
|
+
this.grid.clearObjectInCells(object.id);
|
|
110
|
+
for (let playerId in this.players) {
|
|
111
|
+
if (object.id == playerId)
|
|
112
|
+
continue;
|
|
113
|
+
const otherPlayer = this.players[playerId];
|
|
114
|
+
if (((_a = otherPlayer.following) === null || _a === void 0 ? void 0 : _a.id) == object.id) {
|
|
115
|
+
otherPlayer.cameraFollow(otherPlayer);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// last player before removed of this map
|
|
119
|
+
if (this.nbPlayers === 1) {
|
|
120
|
+
// clear cache for this map
|
|
121
|
+
this._server.sceneMap.removeMap(this.id);
|
|
99
122
|
}
|
|
100
|
-
this.grid.clearObjectInCells(player.id);
|
|
101
123
|
}
|
|
124
|
+
// Hook: called by simple-room package
|
|
125
|
+
onLeave(player) {
|
|
126
|
+
this.removeObject(player);
|
|
127
|
+
}
|
|
128
|
+
// TODO
|
|
102
129
|
autoLoadEvent() {
|
|
103
130
|
this.getShapes().forEach(shape => {
|
|
104
131
|
const { properties } = shape;
|
|
@@ -149,7 +176,6 @@ class RpgMap extends common_1.RpgCommonMap {
|
|
|
149
176
|
}
|
|
150
177
|
return tiles;
|
|
151
178
|
}
|
|
152
|
-
// TODO: return type
|
|
153
179
|
getEventShape(eventName) {
|
|
154
180
|
return this.getShapes().find(shape => shape.name == eventName);
|
|
155
181
|
}
|
|
@@ -192,6 +218,7 @@ class RpgMap extends common_1.RpgCommonMap {
|
|
|
192
218
|
let ret = {};
|
|
193
219
|
for (let key in events) {
|
|
194
220
|
this.events[key] = events[key];
|
|
221
|
+
this.events[key].updateInVirtualGrid();
|
|
195
222
|
this.events[key].execMethod('onInit');
|
|
196
223
|
// force to get Proxy object to sync with client
|
|
197
224
|
ret = Object.assign(Object.assign({}, ret), { [key]: this.events[key] });
|
|
@@ -222,6 +249,7 @@ class RpgMap extends common_1.RpgCommonMap {
|
|
|
222
249
|
removeEvent(eventId) {
|
|
223
250
|
if (!this.events[eventId])
|
|
224
251
|
return false;
|
|
252
|
+
this.removeObject(this.events[eventId]);
|
|
225
253
|
delete this.events[eventId];
|
|
226
254
|
return true;
|
|
227
255
|
}
|
|
@@ -242,15 +270,15 @@ class RpgMap extends common_1.RpgCommonMap {
|
|
|
242
270
|
// Create an instance of RpgEvent and assign its options
|
|
243
271
|
const ev = this.game.addEvent(event);
|
|
244
272
|
const _shape = shape || this.getEventShape(ev.name);
|
|
273
|
+
ev.map = this.id;
|
|
274
|
+
ev.server = this._server;
|
|
245
275
|
ev.width = event.width || this.tileWidth;
|
|
246
276
|
ev.height = event.height || this.tileHeight;
|
|
247
277
|
if (_shape && _shape.properties)
|
|
248
278
|
ev.properties = _shape.properties;
|
|
249
279
|
if (event.hitbox)
|
|
250
280
|
ev.setHitbox(event.hitbox.width, event.hitbox.height);
|
|
251
|
-
ev.map = this.id;
|
|
252
281
|
ev.teleport(position || ev.name);
|
|
253
|
-
ev.server = this._server;
|
|
254
282
|
return ev;
|
|
255
283
|
}
|
|
256
284
|
createEvents(eventsList, mode) {
|
|
@@ -265,6 +293,39 @@ class RpgMap extends common_1.RpgCommonMap {
|
|
|
265
293
|
}
|
|
266
294
|
return events;
|
|
267
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* Allows to create a temporary hitbox on the map that can have a movement
|
|
298
|
+
For example, you can use it to explode a bomb and find all the affected players, or during a sword strike, you can create a moving hitbox and find the affected players again
|
|
299
|
+
* @title Create a temporary and moving hitbox
|
|
300
|
+
* @since 3.2.0
|
|
301
|
+
* @method map.createMovingHitbox(hitboxes,options)
|
|
302
|
+
* @param {Array<{ width: number, height: number, x: number, y: number }>} hitboxes Create several hitboxes that will give an effect of movement
|
|
303
|
+
* @param {object} [options]
|
|
304
|
+
* @param {speed} [options.speed=1] speed of movement (in frames)
|
|
305
|
+
* @returns {Observable<AbstractObject>} You find the methods of position and movement of an event
|
|
306
|
+
* @memberof Map
|
|
307
|
+
* @example
|
|
308
|
+
*
|
|
309
|
+
* ```ts
|
|
310
|
+
* // Two hitboxes that will be done very quickly
|
|
311
|
+
* map.createMovingHitbox(
|
|
312
|
+
* [
|
|
313
|
+
* { x: 0, y: 0, width: 100, height: 100 },
|
|
314
|
+
* { x: 20, y: 0, width: 100, height: 100 }
|
|
315
|
+
* ]
|
|
316
|
+
* ).subscribe({
|
|
317
|
+
* next(hitbox) {
|
|
318
|
+
* console.log(hitbox.otherPlayersCollision)
|
|
319
|
+
* },
|
|
320
|
+
* complete() {
|
|
321
|
+
* console.log('finish')
|
|
322
|
+
* }
|
|
323
|
+
* })
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
createMovingHitbox(hitboxes, options = {}) {
|
|
327
|
+
return this._createMovingHitbox(this.game, this._server.tick, this.id, hitboxes, options);
|
|
328
|
+
}
|
|
268
329
|
setSync(schema) {
|
|
269
330
|
return this.$setSchema(schema);
|
|
270
331
|
}
|
package/lib/Game/Map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Map.js","sourceRoot":"","sources":["../../src/Game/Map.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"Map.js","sourceRoot":"","sources":["../../src/Game/Map.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAA4F;AAC5F,wCAA8C;AAE9C,6CAAiE;AACjE,uDAA4C;AAqB5C,MAAM,SAAU,SAAQ,iBAAQ;IAI5B,MAAM;QACF,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,UAAU,CAAA;QACtE,IAAI,OAAO,EAAE;YACT,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;SAC3B;QACD,IAAI,SAAS,EAAE;YACX,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;SAClC;QACD,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;SACrB;QACD,IAAI,SAAS,EAAE;YACX,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;SAC7B;QACD,IAAI,IAAI,IAAI,QAAQ,EAAE;YAClB,IAAI,CAAC,iBAAiB,CAAC,CAAC,kBAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAA;SAC9C;IACL,CAAC;IAEK,QAAQ,CAAC,MAAiB;;YAC5B,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,UAAU,CAAA;YAChC,IAAI,IA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AwB,EAAE;QAC1B,OAAO,IAAI,CAAC,mBAAmB,CAC3B,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,OAAO,CAAC,IAAW,EACxB,IAAI,CAAC,EAAE,EACP,QAAQ,EACR,OAAO,CAAQ,CAAA;IACvB,CAAC;IAED,OAAO,CAAC,MAAW;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;CACJ;AAzTD,wBAyTC"}
|
|
@@ -2,6 +2,7 @@ import { ParameterManager } from './ParameterManager';
|
|
|
2
2
|
import { RpgPlayer } from './Player';
|
|
3
3
|
import { ElementManager } from './ElementManager';
|
|
4
4
|
import { EffectManager } from './EffectManager';
|
|
5
|
+
import { RpgServerEngine } from '../server';
|
|
5
6
|
export declare class BattleManager {
|
|
6
7
|
/**
|
|
7
8
|
* Apply damage. Player will lose HP. the `otherPlayer` parameter is the other player, the one who attacks.
|
|
@@ -31,5 +32,5 @@ export declare class BattleManager {
|
|
|
31
32
|
}
|
|
32
33
|
export interface BattleManager extends ParameterManager, ElementManager, EffectManager {
|
|
33
34
|
name: string;
|
|
34
|
-
server:
|
|
35
|
+
server: RpgServerEngine;
|
|
35
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BattleManager.js","sourceRoot":"","sources":["../../src/Player/BattleManager.ts"],"names":[],"mappings":";;;AAAA,0CAAsC;AACtC,yDAAqD;AAErD,wCAImB;AACnB,8CAAwC;AACxC,qDAAkD;AAClD,mDAAgD;
|
|
1
|
+
{"version":3,"file":"BattleManager.js","sourceRoot":"","sources":["../../src/Player/BattleManager.ts"],"names":[],"mappings":";;;AAAA,0CAAsC;AACtC,yDAAqD;AAErD,wCAImB;AACnB,8CAAwC;AACxC,qDAAkD;AAClD,mDAAgD;AAGhD,MAAM,EACF,WAAW,EACd,GAAG,cAAK,CAAA;AAET,MAAa,aAAa;IAEtB;;;;;;;;;;;;;;;;SAgBK;IACL,WAAW,CAAC,WAAsB,EA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CAAC,CAAC,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Direction } from '@rpgjs/common';
|
|
2
|
-
import {
|
|
1
|
+
import { Direction, RpgShape, Vector2d } from '@rpgjs/common';
|
|
2
|
+
import { Behavior, ClientMode, MoveMode, MoveTo, PositionXY, SocketEvents } from '@rpgjs/types';
|
|
3
|
+
import { RpgServerEngine } from '../server';
|
|
4
|
+
import { RpgEvent, RpgPlayer } from './Player';
|
|
3
5
|
declare type CallbackTileMove = (player: RpgPlayer, map: any) => Direction[];
|
|
4
6
|
declare type CallbackTurnMove = (player: RpgPlayer, map: any) => string;
|
|
5
7
|
declare type Routes = (string | Promise<any> | Direction | Direction[] | Function)[];
|
|
@@ -286,10 +288,44 @@ export declare class MoveManager {
|
|
|
286
288
|
* ```
|
|
287
289
|
*/
|
|
288
290
|
replayRoutes(): void;
|
|
291
|
+
/**
|
|
292
|
+
* Move the event to another event, a player, a shape or a specific position.
|
|
293
|
+
* The event will avoid obstacles, but you can tell if it is stuck or has completed its path
|
|
294
|
+
*
|
|
295
|
+
* @title Move To
|
|
296
|
+
* @method player.moveTo()
|
|
297
|
+
* @param {RpgPlayer|RpgEvent|RpgShape|Position} target the target
|
|
298
|
+
* @param {object} [options] - animate. Set a boolean to use default parameters
|
|
299
|
+
* @param {boolean} [options.infinite=false] - moves infinitely towards the target, you have to stop its movement manually with the method `stopMoveTo()`
|
|
300
|
+
* @param {() => void} [options.onComplete] - Callback when the event arrives at the destination
|
|
301
|
+
* @param {(duration:number) => void} [options.onStuck] - callback when the event is blocked against a wall. Duration gives you the duration (in frames) of the blocking time
|
|
302
|
+
* @returns {void}
|
|
303
|
+
* @since 3.2.0
|
|
304
|
+
* @memberof MoveManager
|
|
305
|
+
* @example
|
|
306
|
+
*
|
|
307
|
+
* ```ts
|
|
308
|
+
* import { Move } from '@rpgjs/server'
|
|
309
|
+
*
|
|
310
|
+
* player.moveTo(otherPlayer)
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
moveTo(event: RpgEvent, options?: MoveTo): any;
|
|
314
|
+
moveTo(player: RpgPlayer, options?: MoveTo): any;
|
|
315
|
+
moveTo(position: PositionXY, options?: MoveTo): any;
|
|
316
|
+
moveTo(shape: RpgShape, options?: MoveTo): any;
|
|
317
|
+
setMoveMode(mode: MoveMode): void;
|
|
289
318
|
}
|
|
290
319
|
export interface MoveManager {
|
|
291
320
|
moveByDirection: (direction: Direction, deltaTimeInt: number) => boolean;
|
|
292
321
|
changeDirection: (direction: Direction) => boolean;
|
|
293
322
|
getCurrentMap: any;
|
|
323
|
+
checkCollision: boolean;
|
|
324
|
+
clientModeMove: ClientMode;
|
|
325
|
+
behavior: Behavior;
|
|
326
|
+
emit(name: SocketEvents, params: any): any;
|
|
327
|
+
id: string;
|
|
328
|
+
server: RpgServerEngine;
|
|
329
|
+
position: Vector2d;
|
|
294
330
|
}
|
|
295
331
|
export {};
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.MoveManager = exports.Move = exports.Speed = exports.Frequency = void 0;
|
|
13
13
|
const common_1 = require("@rpgjs/common");
|
|
14
14
|
const common_2 = require("@rpgjs/common");
|
|
15
|
+
const types_1 = require("@rpgjs/types");
|
|
15
16
|
const { arrayFlat, random, isFunction, capitalize } = common_2.Utils;
|
|
16
17
|
function wait(sec) {
|
|
17
18
|
return new Promise((resolve) => {
|
|
@@ -421,6 +422,23 @@ class MoveManager {
|
|
|
421
422
|
if (this._infiniteRoutes)
|
|
422
423
|
this.infiniteMoveRoute(this._infiniteRoutes);
|
|
423
424
|
}
|
|
425
|
+
moveTo(position, options) {
|
|
426
|
+
return this['_moveTo'](this.server.tick, position, options);
|
|
427
|
+
}
|
|
428
|
+
// TODO
|
|
429
|
+
setMoveMode(mode) {
|
|
430
|
+
if (mode.checkCollision)
|
|
431
|
+
this.checkCollision = mode.checkCollision;
|
|
432
|
+
if (mode.clientMode)
|
|
433
|
+
this.clientModeMove = mode.clientMode;
|
|
434
|
+
if (mode.behavior)
|
|
435
|
+
this.behavior = mode.behavior;
|
|
436
|
+
this.emit(types_1.SocketEvents.CallMethod, {
|
|
437
|
+
objectId: this.id,
|
|
438
|
+
name: types_1.SocketMethods.ModeMove,
|
|
439
|
+
params: [mode]
|
|
440
|
+
});
|
|
441
|
+
}
|
|
424
442
|
}
|
|
425
443
|
exports.MoveManager = MoveManager;
|
|
426
444
|
//# sourceMappingURL=MoveManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoveManager.js","sourceRoot":"","sources":["../../src/Player/MoveManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"MoveManager.js","sourceRoot":"","sources":["../../src/Player/MoveManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAgG;AAChG,0CAAqC;AACrC,wCAA8H;AAK9H,MAAM,EACF,SAAS,EACT,MAAM,EACN,UAAU,EACV,UAAU,EACb,GAAG,cAAK,CAAA;AAET,SAAS,IAAI,CAAC,GAAW;IACrB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC,CAAA;IACnC,CAAC,CAAC,CAAA;AACN,CAAC;AAMD,IAAY,SAQX;AARD,WAAY,SAAS;IACjB,+CAAY,CAAA;IACZ,6CAAW,CAAA;IACX,yCAAS,CAAA;IACT,2CAAU,CAAA;IACV,8CAAW,CAAA;IACX,gDAAY,CAAA;IACZ,yCAAQ,CAAA;AACZ,CAAC,EARW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAQpB;AAED,IAAY,KAQX;AARD,WAAY,KAAK;IACb,yCAAa,CAAA;IACb,uCAAY,CAAA;IACZ,iCAAQ,CAAA;IACR,qCAAU,CAAA;IACV,iCAAQ,CAAA;IACR,qCAAU,CAAA;IACV,wCAAY,CAAA;AAChB,CAAC,EARW,KAA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N,CAAC;CACJ;AA3UD,kCA2UC"}
|
package/lib/Player/Player.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { GuiManager } from './GuiManager';
|
|
|
12
12
|
import { VariableManager } from './VariableManager';
|
|
13
13
|
import { MoveManager } from './MoveManager';
|
|
14
14
|
import { BattleManager } from './BattleManager';
|
|
15
|
+
import { CameraOptions, PositionXY_OptionalZ } from '@rpgjs/types';
|
|
15
16
|
export interface Position {
|
|
16
17
|
x: number;
|
|
17
18
|
y: number;
|
|
@@ -200,8 +201,12 @@ export declare class RpgPlayer extends RpgCommonPlayer {
|
|
|
200
201
|
session: string | null;
|
|
201
202
|
prevMap: string;
|
|
202
203
|
private touchSide;
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
otherPossessedPlayer: RpgPlayer | RpgEvent | null;
|
|
205
|
+
following: RpgPlayer | RpgEvent | null;
|
|
206
|
+
_lastFramePositions: {
|
|
207
|
+
frame: number;
|
|
208
|
+
position: Position;
|
|
209
|
+
};
|
|
205
210
|
constructor(gameEngine: RpgCommonGame, playerId: string);
|
|
206
211
|
get otherPlayersCollision(): RpgPlayer[];
|
|
207
212
|
teleported: number;
|
|
@@ -330,11 +335,7 @@ export declare class RpgPlayer extends RpgCommonPlayer {
|
|
|
330
335
|
* @returns {Promise<{ {x: number, y: number, z: number} }>}
|
|
331
336
|
* @memberof Player
|
|
332
337
|
*/
|
|
333
|
-
teleport(positions?:
|
|
334
|
-
x: number;
|
|
335
|
-
y: number;
|
|
336
|
-
z?: number;
|
|
337
|
-
} | string): Promise<Position>;
|
|
338
|
+
teleport(positions?: PositionXY_OptionalZ | string): Promise<Position>;
|
|
338
339
|
/**
|
|
339
340
|
* Load the saved data with the method save()
|
|
340
341
|
* If the player was on a map, it repositions the player on the map.
|
|
@@ -381,10 +382,7 @@ export declare class RpgPlayer extends RpgCommonPlayer {
|
|
|
381
382
|
height: any;
|
|
382
383
|
};
|
|
383
384
|
map: string;
|
|
384
|
-
pendingMove:
|
|
385
|
-
input: string;
|
|
386
|
-
frame: number;
|
|
387
|
-
}[];
|
|
385
|
+
pendingMove: import("@rpgjs/types").PendingMove;
|
|
388
386
|
speed: number;
|
|
389
387
|
};
|
|
390
388
|
toJSON(): any;
|
|
@@ -463,6 +461,29 @@ export declare class RpgPlayer extends RpgCommonPlayer {
|
|
|
463
461
|
* @memberof Player
|
|
464
462
|
*/
|
|
465
463
|
showAnimation(graphic: string | string[], animationName: string, replaceGraphic?: boolean): void;
|
|
464
|
+
/**
|
|
465
|
+
* TODO:
|
|
466
|
+
* 1. It is necessary, on the client side, to make the character move even if controlled by someone else (problem: same playerId so, one will not move because of the client side prediction. Solution: create a new Id ? like session Id ?
|
|
467
|
+
* 2. You would need several sockets per character. If the character changes map or changes server, all players controlling the character must be able to see it
|
|
468
|
+
* 3. If the player regains control, what happens, do we return to the previous map?
|
|
469
|
+
* 4. If it's an event, you must be able to get the event by id in GameEngine
|
|
470
|
+
*/
|
|
471
|
+
takePossessionOf(otherPlayer: RpgPlayer | RpgEvent): void;
|
|
472
|
+
/**
|
|
473
|
+
* Sends the client which event or player the camera should follow. You can set options to perform a motion animation
|
|
474
|
+
*
|
|
475
|
+
* @title Camera Follow
|
|
476
|
+
* @method player.cameraFollow(otherPlayer,options)
|
|
477
|
+
* @param {RpgPlayer | RpgEvent} otherPlayer
|
|
478
|
+
* @param {options} options
|
|
479
|
+
* @param {object | boolean} [options.smoothMove] - animate. Set a boolean to use default parameters
|
|
480
|
+
* @param {number} [options.smoothMove.time=1000] - time to animate
|
|
481
|
+
* @param {string} [options.smoothMove.ease=linear] - easing to use. Go to https://easings.net to get function name
|
|
482
|
+
* @returns {void}
|
|
483
|
+
* @since 3.1.0
|
|
484
|
+
* @memberof Player
|
|
485
|
+
*/
|
|
486
|
+
cameraFollow(otherPlayer: RpgPlayer | RpgEvent, options?: CameraOptions): void;
|
|
466
487
|
/**
|
|
467
488
|
* Emit data to clients with socket
|
|
468
489
|
*
|
|
@@ -543,7 +564,6 @@ export declare class RpgPlayer extends RpgCommonPlayer {
|
|
|
543
564
|
* @param {string} soundId Sound identifier, defined on the client side
|
|
544
565
|
* @param {boolean} [allMap] Indicate if the sound is heard by the players on the map
|
|
545
566
|
* @since 3.0.0-alpha.9
|
|
546
|
-
* @stability 1
|
|
547
567
|
* @returns {void}
|
|
548
568
|
* @memberof Player
|
|
549
569
|
*/
|
package/lib/Player/Player.js
CHANGED
|
@@ -30,6 +30,7 @@ const VariableManager_1 = require("./VariableManager");
|
|
|
30
30
|
const MoveManager_1 = require("./MoveManager");
|
|
31
31
|
const BattleManager_1 = require("./BattleManager");
|
|
32
32
|
const presets_1 = require("../presets");
|
|
33
|
+
const types_1 = require("@rpgjs/types");
|
|
33
34
|
const { isPromise, applyMixins, isString } = common_1.Utils;
|
|
34
35
|
const itemSchemas = {
|
|
35
36
|
name: String,
|
|
@@ -105,8 +106,8 @@ class RpgPlayer extends common_1.RpgCommonPlayer {
|
|
|
105
106
|
this.touchSide = false;
|
|
106
107
|
/** @internal */
|
|
107
108
|
this.tmpPositions = null;
|
|
108
|
-
this.
|
|
109
|
-
this.
|
|
109
|
+
this.otherPossessedPlayer = null;
|
|
110
|
+
this.following = null;
|
|
110
111
|
// As soon as a teleport has been made, the value is changed to force the client to change the positions on the map without making a move.
|
|
111
112
|
this.teleported = 0;
|
|
112
113
|
this.initialize();
|
|
@@ -592,10 +593,49 @@ class RpgPlayer extends common_1.RpgCommonPlayer {
|
|
|
592
593
|
showAnimation(graphic, animationName, replaceGraphic = false) {
|
|
593
594
|
this.emitToMap('callMethod', {
|
|
594
595
|
objectId: this.playerId,
|
|
595
|
-
name:
|
|
596
|
+
name: types_1.SocketMethods.ShowAnimation,
|
|
596
597
|
params: [graphic, animationName, replaceGraphic]
|
|
597
598
|
});
|
|
598
599
|
}
|
|
600
|
+
/**
|
|
601
|
+
* TODO:
|
|
602
|
+
* 1. It is necessary, on the client side, to make the character move even if controlled by someone else (problem: same playerId so, one will not move because of the client side prediction. Solution: create a new Id ? like session Id ?
|
|
603
|
+
* 2. You would need several sockets per character. If the character changes map or changes server, all players controlling the character must be able to see it
|
|
604
|
+
* 3. If the player regains control, what happens, do we return to the previous map?
|
|
605
|
+
* 4. If it's an event, you must be able to get the event by id in GameEngine
|
|
606
|
+
*/
|
|
607
|
+
takePossessionOf(otherPlayer) {
|
|
608
|
+
this.otherPossessedPlayer = otherPlayer;
|
|
609
|
+
this._socket.emit('playerJoined', { playerId: otherPlayer.id, session: this.session });
|
|
610
|
+
this.cameraFollow(otherPlayer);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Sends the client which event or player the camera should follow. You can set options to perform a motion animation
|
|
614
|
+
*
|
|
615
|
+
* @title Camera Follow
|
|
616
|
+
* @method player.cameraFollow(otherPlayer,options)
|
|
617
|
+
* @param {RpgPlayer | RpgEvent} otherPlayer
|
|
618
|
+
* @param {options} options
|
|
619
|
+
* @param {object | boolean} [options.smoothMove] - animate. Set a boolean to use default parameters
|
|
620
|
+
* @param {number} [options.smoothMove.time=1000] - time to animate
|
|
621
|
+
* @param {string} [options.smoothMove.ease=linear] - easing to use. Go to https://easings.net to get function name
|
|
622
|
+
* @returns {void}
|
|
623
|
+
* @since 3.1.0
|
|
624
|
+
* @memberof Player
|
|
625
|
+
*/
|
|
626
|
+
cameraFollow(otherPlayer, options = {}) {
|
|
627
|
+
if (otherPlayer.id == this.id) {
|
|
628
|
+
this.following = null;
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
this.following = otherPlayer;
|
|
632
|
+
}
|
|
633
|
+
this.emit(types_1.SocketEvents.CallMethod, {
|
|
634
|
+
objectId: this.playerId,
|
|
635
|
+
name: types_1.SocketMethods.CameraFollow,
|
|
636
|
+
params: [otherPlayer.id, options]
|
|
637
|
+
});
|
|
638
|
+
}
|
|
599
639
|
/**
|
|
600
640
|
* Emit data to clients with socket
|
|
601
641
|
*
|
|
@@ -709,21 +749,20 @@ class RpgPlayer extends common_1.RpgCommonPlayer {
|
|
|
709
749
|
* @param {string} soundId Sound identifier, defined on the client side
|
|
710
750
|
* @param {boolean} [allMap] Indicate if the sound is heard by the players on the map
|
|
711
751
|
* @since 3.0.0-alpha.9
|
|
712
|
-
* @stability 1
|
|
713
752
|
* @returns {void}
|
|
714
753
|
* @memberof Player
|
|
715
754
|
*/
|
|
716
755
|
playSound(soundId, allMap = false) {
|
|
717
756
|
const obj = {
|
|
718
757
|
objectId: this.playerId,
|
|
719
|
-
name:
|
|
758
|
+
name: types_1.SocketMethods.PlaySound,
|
|
720
759
|
params: [soundId]
|
|
721
760
|
};
|
|
722
761
|
if (!allMap) {
|
|
723
|
-
this.emit(
|
|
762
|
+
this.emit(types_1.SocketEvents.CallMethod, obj);
|
|
724
763
|
return;
|
|
725
764
|
}
|
|
726
|
-
this.emitToMap(
|
|
765
|
+
this.emitToMap(types_1.SocketEvents.CallMethod, obj);
|
|
727
766
|
}
|
|
728
767
|
}
|
|
729
768
|
exports.RpgPlayer = RpgPlayer;
|