@rpgjs/common 3.0.0-beta.7 → 3.0.0-rc
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.d.ts +3 -0
- package/lib/Game.js +10 -1
- package/lib/Game.js.map +1 -1
- package/lib/Hit.d.ts +5 -3
- package/lib/Hit.js +11 -6
- package/lib/Hit.js.map +1 -1
- package/lib/Map.d.ts +55 -150
- package/lib/Map.js +86 -240
- package/lib/Map.js.map +1 -1
- package/lib/Module.d.ts +3 -1
- package/lib/Module.js +89 -60
- package/lib/Module.js.map +1 -1
- package/lib/Player.d.ts +8 -4
- package/lib/Player.js +39 -12
- package/lib/Player.js.map +1 -1
- package/lib/Plugin.d.ts +5 -1
- package/lib/Plugin.js +4 -0
- package/lib/Plugin.js.map +1 -1
- package/lib/Scheduler.js +1 -1
- package/lib/Scheduler.js.map +1 -1
- package/lib/Shape.d.ts +24 -6
- package/lib/Shape.js +90 -20
- package/lib/Shape.js.map +1 -1
- package/lib/Utils.d.ts +5 -3
- package/lib/Utils.js +16 -3
- package/lib/Utils.js.map +1 -1
- package/lib/WorldMaps.d.ts +103 -0
- package/lib/WorldMaps.js +170 -0
- package/lib/WorldMaps.js.map +1 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +5 -3
- package/lib/index.js.map +1 -1
- package/lib/transports/io.d.ts +4 -2
- package/lib/transports/io.js +12 -5
- package/lib/transports/io.js.map +1 -1
- package/lib/workers/move.js +3 -3
- package/lib/workers/move.js.map +1 -1
- package/package.json +4 -2
package/lib/Game.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { EventEmitter } from './EventEmitter';
|
|
2
2
|
import { RpgCommonPlayer } from './Player';
|
|
3
3
|
import { GameWorker } from './Worker';
|
|
4
|
+
import { HitObject } from './Hit';
|
|
5
|
+
import { RpgShape } from './Shape';
|
|
4
6
|
export declare enum GameSide {
|
|
5
7
|
Server = "server",
|
|
6
8
|
Client = "client",
|
|
@@ -17,5 +19,6 @@ export declare class RpgCommonGame extends EventEmitter {
|
|
|
17
19
|
addObject(_class: any, playerId?: string): any;
|
|
18
20
|
addPlayer(playerClass: any, playerId?: string): any;
|
|
19
21
|
addEvent(eventClass: any, eventId?: string): any;
|
|
22
|
+
addShape(obj: HitObject): RpgShape;
|
|
20
23
|
processInput<RpgPlayer extends RpgCommonPlayer>(playerId: string): Promise<RpgPlayer>;
|
|
21
24
|
}
|
package/lib/Game.js
CHANGED
|
@@ -16,6 +16,7 @@ const Player_1 = require("./Player");
|
|
|
16
16
|
const Input_1 = require("./Input");
|
|
17
17
|
const Plugin_1 = require("./Plugin");
|
|
18
18
|
const Worker_1 = require("./Worker");
|
|
19
|
+
const Shape_1 = require("./Shape");
|
|
19
20
|
var GameSide;
|
|
20
21
|
(function (GameSide) {
|
|
21
22
|
GameSide["Server"] = "server";
|
|
@@ -57,13 +58,21 @@ class RpgCommonGame extends EventEmitter_1.EventEmitter {
|
|
|
57
58
|
const event = this.addObject(eventClass, eventId);
|
|
58
59
|
return event;
|
|
59
60
|
}
|
|
61
|
+
addShape(obj) {
|
|
62
|
+
const id = obj.name = (obj.name || Utils_1.generateUID());
|
|
63
|
+
const shape = new Shape_1.RpgShape(obj);
|
|
64
|
+
shape.name = id;
|
|
65
|
+
return shape;
|
|
66
|
+
}
|
|
60
67
|
processInput(playerId) {
|
|
61
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
69
|
const player = this.world.getObject(playerId);
|
|
63
70
|
if (!player)
|
|
64
71
|
return player;
|
|
65
|
-
if (!player.canMove)
|
|
72
|
+
if (!player.canMove) {
|
|
73
|
+
player.pendingMove = [];
|
|
66
74
|
return player;
|
|
75
|
+
}
|
|
67
76
|
const routesMove = [];
|
|
68
77
|
while (player.pendingMove.length > 0) {
|
|
69
78
|
const inputData = player.pendingMove.shift();
|
package/lib/Game.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Game.js","sour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MAAM,GAAG,KAAK,CAAA;gBAClB,IAAI,KAAK,IAAI,eAAO,CAAC,MAAM,EAAE;oBACzB,MAAM,CAAC,oBAAoB,CAAC,wBAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;iBAC9D;qBACI,IACD,KAAK,IAAI,kBAAS,CAAC,IAAI;oBACvB,KAAK,IAAI,kBAAS,CAAC,KAAK;oBACxB,KAAK,IAAI,kBAAS,CAAC,EAAE;oBACrB,KAAK,IAAI,kBAAS,CAAC,IAAI,EACzB;oBACE,MAAM,GAAG,IAAI,CAAA;oBACb,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC,KAAK,EAAE,YAAY,IAAI,CAAC,CAAC,CAAA;oBACtE,IAAI,MAAM,EAAE;wBACR,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;qBAC7B;iBACJ;gBACD,kBAAkB;gBAClB,kBAAS,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,MAAM,kCACjC,SAAS,KACZ,MAAM,IACR,EAAE,IAAI,CAAC,CAAA;aAEZ;YACD,OAAO,MAAM,CAAA;QACjB,CAAC;KAAA;CACJ;AA1FD,sCA0FC"}
|
package/lib/Hit.d.ts
CHANGED
|
@@ -19,15 +19,17 @@ export interface HitObject {
|
|
|
19
19
|
type?: string;
|
|
20
20
|
name?: string;
|
|
21
21
|
}
|
|
22
|
+
export declare enum HitType {
|
|
23
|
+
Box = "box",
|
|
24
|
+
Circle = "circle",
|
|
25
|
+
Polygon = "polygon"
|
|
26
|
+
}
|
|
22
27
|
declare class HitClass {
|
|
23
28
|
createObjectHitbox(x: number, y: number, z: number, w: number, h: number): SAT.Box;
|
|
24
29
|
getHitbox(obj: HitObject, offset?: {
|
|
25
30
|
x: number;
|
|
26
31
|
y: number;
|
|
27
32
|
}): {
|
|
28
|
-
properties: {
|
|
29
|
-
[key: string]: any;
|
|
30
|
-
} | undefined;
|
|
31
33
|
hitbox: SAT;
|
|
32
34
|
type: string;
|
|
33
35
|
name: string | undefined;
|
package/lib/Hit.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Hit = void 0;
|
|
6
|
+
exports.Hit = exports.HitType = void 0;
|
|
7
7
|
const sat_1 = __importDefault(require("sat"));
|
|
8
8
|
const Utils_1 = require("./Utils");
|
|
9
9
|
var HitType;
|
|
@@ -11,7 +11,7 @@ var HitType;
|
|
|
11
11
|
HitType["Box"] = "box";
|
|
12
12
|
HitType["Circle"] = "circle";
|
|
13
13
|
HitType["Polygon"] = "polygon";
|
|
14
|
-
})(HitType || (HitType = {}));
|
|
14
|
+
})(HitType = exports.HitType || (exports.HitType = {}));
|
|
15
15
|
class HitClass {
|
|
16
16
|
createObjectHitbox(x, y, z, w, h) {
|
|
17
17
|
return new sat_1.default.Box(new sat_1.default.Vector(x, y - z), w, h);
|
|
@@ -40,7 +40,6 @@ class HitClass {
|
|
|
40
40
|
type = obj.type;
|
|
41
41
|
}
|
|
42
42
|
return {
|
|
43
|
-
properties: obj.properties,
|
|
44
43
|
hitbox,
|
|
45
44
|
type,
|
|
46
45
|
name: obj.name
|
|
@@ -48,14 +47,20 @@ class HitClass {
|
|
|
48
47
|
}
|
|
49
48
|
testPolyCollision(type, hit1, hit2) {
|
|
50
49
|
let collided = false;
|
|
50
|
+
if (type == HitType.Box) {
|
|
51
|
+
if (hit1.pos.x <= hit2.pos.x + hit2.w &&
|
|
52
|
+
hit1.pos.x + hit1.w >= hit2.pos.x &&
|
|
53
|
+
hit1.pos.y <= hit2.pos.y + hit2.h &&
|
|
54
|
+
hit1.h + hit1.pos.y >= hit2.pos.y) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
51
59
|
if (Utils_1.isInstanceOf(hit1, sat_1.default.Box))
|
|
52
60
|
hit1 = hit1.toPolygon();
|
|
53
61
|
if (Utils_1.isInstanceOf(hit2, sat_1.default.Box))
|
|
54
62
|
hit2 = hit2.toPolygon();
|
|
55
63
|
switch (type) {
|
|
56
|
-
case HitType.Box:
|
|
57
|
-
collided = sat_1.default.testPolygonPolygon(hit1, hit2);
|
|
58
|
-
break;
|
|
59
64
|
case HitType.Circle:
|
|
60
65
|
collided = sat_1.default.testPolygonCircle(hit1, hit2);
|
|
61
66
|
break;
|
package/lib/Hit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hit.js","sourceRoot":"","sources":["../src/Hit.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"Hit.js","sourceRoot":"","sources":["../src/Hit.ts"],"names":[],"mappings":";;;;;;AACA,8CAAqB;AACrB,mCAAsC;AAoBtC,IAAY,OAIX;AAJD,WAAY,OAAO;IACf,sBAAW,CAAA;IACX,4BAAiB,CAAA;IACjB,8BAAmB,CAAA;AACvB,CAAC,EAJW,OAAO,GAAP,eAAO,KAAP,eAAO,QAIlB;AAED,MAAM,QAAQ;IAEV,kBAAkB,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;QACpE,OAAO,IAAI,aAAG,CAAC,GAAG,CAAC,IAAI,aAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACtD,CAAC;IAED,SAAS,CAAC,GAAc,EAAE,MAAiC;QAKvD,IAAI,MAAM,EAAE,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM;YAAE,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;QACpC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAA;QAC1B,MAAM,CAAC,GAAG,GA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@@
|
|
|
1
1
|
import { HitObject } from './Hit';
|
|
2
2
|
import { RpgShape } from './Shape';
|
|
3
3
|
import { VirtualGrid } from './VirtualGrid';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
terrain: any[];
|
|
7
|
-
probability: any;
|
|
8
|
-
properties: any;
|
|
9
|
-
animations: any[];
|
|
10
|
-
objectGroups: any[];
|
|
11
|
-
image: any;
|
|
12
|
-
gid: number;
|
|
13
|
-
}
|
|
4
|
+
import { RpgCommonWorldMaps } from './WorldMaps';
|
|
5
|
+
import { TiledMap, Tile, TiledObjectClass, MapClass } from '@rpgjs/tiled';
|
|
14
6
|
export interface TileInfo {
|
|
15
7
|
tiles: Tile[];
|
|
16
|
-
hasCollision: boolean;
|
|
17
|
-
isClimbable?: boolean;
|
|
18
|
-
isOverlay: boolean;
|
|
19
|
-
objectGroups:
|
|
8
|
+
hasCollision: boolean | undefined;
|
|
9
|
+
isClimbable?: boolean | undefined;
|
|
10
|
+
isOverlay: boolean | undefined;
|
|
11
|
+
objectGroups: TiledObjectClass[];
|
|
20
12
|
tileIndex: number;
|
|
21
13
|
}
|
|
22
14
|
export interface LayerInfo {
|
|
@@ -28,43 +20,39 @@ export interface LayerInfo {
|
|
|
28
20
|
objects: HitObject[];
|
|
29
21
|
tiles: Tile[];
|
|
30
22
|
}
|
|
31
|
-
export
|
|
32
|
-
grid: VirtualGrid;
|
|
23
|
+
export declare class RpgCommonMap extends MapClass {
|
|
33
24
|
/**
|
|
34
|
-
* @title
|
|
35
|
-
* @prop {object} [data]
|
|
25
|
+
* @title map id
|
|
36
26
|
* @readonly
|
|
27
|
+
* @prop {string} [id]
|
|
37
28
|
* @memberof Map
|
|
38
|
-
* @memberof RpgSceneMap
|
|
39
29
|
* */
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
readonly id: string;
|
|
31
|
+
grid: VirtualGrid;
|
|
32
|
+
gridShapes: VirtualGrid;
|
|
33
|
+
get tileWidth(): number;
|
|
34
|
+
get tileHeight(): number;
|
|
35
|
+
private worldMapParent;
|
|
43
36
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
37
|
+
* Retrieves the X position of the map in the world (0 if no world assigned)
|
|
38
|
+
*
|
|
39
|
+
* @title World X Position
|
|
40
|
+
* @prop {number} [worldX]
|
|
46
41
|
* @readonly
|
|
42
|
+
* @since 3.0.0-beta.8
|
|
47
43
|
* @memberof Map
|
|
48
|
-
* @memberof RpgSceneMap
|
|
49
44
|
* */
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @title Height of a tile
|
|
53
|
-
* @prop {number} [tileHeight]
|
|
54
|
-
* @readonly
|
|
55
|
-
* @memberof Map
|
|
56
|
-
* @memberof RpgSceneMap
|
|
57
|
-
* */
|
|
58
|
-
tileHeight: number;
|
|
45
|
+
get worldX(): number;
|
|
59
46
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
47
|
+
* Retrieves the Y position of the map in the world (0 if no world assigned)
|
|
48
|
+
*
|
|
49
|
+
* @title World Y Position
|
|
50
|
+
* @prop {number} [worldY]
|
|
62
51
|
* @readonly
|
|
52
|
+
* @since 3.0.0-beta.8
|
|
63
53
|
* @memberof Map
|
|
64
|
-
* @memberof RpgSceneMap
|
|
65
54
|
* */
|
|
66
|
-
|
|
67
|
-
private shapes;
|
|
55
|
+
get worldY(): number;
|
|
68
56
|
/**
|
|
69
57
|
* Memorize the maps so you don't have to make a new request or open a file each time you load a map
|
|
70
58
|
*/
|
|
@@ -73,47 +61,7 @@ export default class RpgCommonMap {
|
|
|
73
61
|
* In RPG mode, to avoid confusion with buffer, we have a new variable to memorize the maps
|
|
74
62
|
*/
|
|
75
63
|
static get bufferClient(): Map<any, any>;
|
|
76
|
-
load(data:
|
|
77
|
-
/**
|
|
78
|
-
* @title Width of the map in pixels
|
|
79
|
-
* @prop {number} [widthPx]
|
|
80
|
-
* @readonly
|
|
81
|
-
* @memberof Map
|
|
82
|
-
* @memberof RpgSceneMap
|
|
83
|
-
* */
|
|
84
|
-
get widthPx(): number;
|
|
85
|
-
/**
|
|
86
|
-
* @title Height of the map in pixels
|
|
87
|
-
* @prop {number} [heightPx]
|
|
88
|
-
* @readonly
|
|
89
|
-
* @memberof Map
|
|
90
|
-
* @memberof RpgSceneMap
|
|
91
|
-
* */
|
|
92
|
-
get heightPx(): number;
|
|
93
|
-
/**
|
|
94
|
-
* @title The depth of the map in pixels (this is the height of a tile ;))
|
|
95
|
-
* @prop {number} map.zTileHeight
|
|
96
|
-
* @readonly
|
|
97
|
-
* @memberof Map
|
|
98
|
-
* @memberof RpgSceneMap
|
|
99
|
-
* */
|
|
100
|
-
get zTileHeight(): number;
|
|
101
|
-
_extractShapes(): void;
|
|
102
|
-
/**
|
|
103
|
-
* Find a layer by name. Returns `undefined` is the layer is not found
|
|
104
|
-
|
|
105
|
-
* @title Get Layer by name
|
|
106
|
-
* @method map.getLayerByName(name)
|
|
107
|
-
* @param {string} name layer name
|
|
108
|
-
* @returns {LayerInfo | undefined}
|
|
109
|
-
* @example
|
|
110
|
-
* ```ts
|
|
111
|
-
* const tiles = map.getLayerByName(0, 0)
|
|
112
|
-
* ```
|
|
113
|
-
* @memberof Map
|
|
114
|
-
* @memberof RpgSceneMap
|
|
115
|
-
*/
|
|
116
|
-
getLayerByName(name: string): LayerInfo | undefined;
|
|
64
|
+
load(data: TiledMap): void;
|
|
117
65
|
/**
|
|
118
66
|
* Create a shape dynamically on the map
|
|
119
67
|
*
|
|
@@ -172,85 +120,42 @@ export default class RpgCommonMap {
|
|
|
172
120
|
y: number;
|
|
173
121
|
z: number;
|
|
174
122
|
} | null;
|
|
175
|
-
setTile(x: number, y: number, layerFilter: string | ((layer: any) => boolean), tileInfo: any): {
|
|
176
|
-
x: number;
|
|
177
|
-
y: number;
|
|
178
|
-
tiles: {
|
|
179
|
-
[tileIndex: number]: object;
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
123
|
/**
|
|
183
|
-
* Get
|
|
184
|
-
*
|
|
185
|
-
* @
|
|
186
|
-
* @
|
|
187
|
-
* @param
|
|
188
|
-
* @
|
|
189
|
-
* @returns {number}
|
|
190
|
-
* @memberof Map
|
|
191
|
-
* @memberof RpgSceneMap
|
|
124
|
+
* Get tile and verify collision with hitbox
|
|
125
|
+
* @param hitbox
|
|
126
|
+
* @param x
|
|
127
|
+
* @param y
|
|
128
|
+
* @param z
|
|
129
|
+
* @returns TileInfo
|
|
192
130
|
*/
|
|
193
|
-
|
|
131
|
+
getTile(hitbox: any, x: number, y: number, z?: [number, number]): TileInfo;
|
|
194
132
|
/**
|
|
195
|
-
*
|
|
133
|
+
* Assign the map to a world
|
|
196
134
|
|
|
197
|
-
* @title
|
|
198
|
-
* @method map.
|
|
199
|
-
* @param {
|
|
200
|
-
* @
|
|
201
|
-
* @example
|
|
202
|
-
* ```ts
|
|
203
|
-
* const index = map.getTileIndex(0, 0)
|
|
204
|
-
* const tiles = map.getTileByIndex(index)
|
|
205
|
-
* ```
|
|
135
|
+
* @title Assign the map to a world
|
|
136
|
+
* @method map.setInWorldMaps(name)
|
|
137
|
+
* @param {RpgWorldMaps} worldMap world maps
|
|
138
|
+
* @since 3.0.0-beta.8
|
|
206
139
|
* @memberof Map
|
|
207
|
-
* @memberof RpgSceneMap
|
|
208
140
|
*/
|
|
209
|
-
|
|
141
|
+
setInWorldMaps(worldMap: RpgCommonWorldMaps): void;
|
|
210
142
|
/**
|
|
211
|
-
*
|
|
212
|
-
|
|
213
|
-
* @
|
|
214
|
-
* @
|
|
215
|
-
* @
|
|
216
|
-
* @param {number} x Position Y
|
|
217
|
-
* @returns { {x: number, y: number }}
|
|
218
|
-
* @example
|
|
219
|
-
* ```ts
|
|
220
|
-
* // If the size of a tile is 32x32px
|
|
221
|
-
* const position = map.getTileOriginPosition(35, 12)
|
|
222
|
-
* console.log(position) // { x: 32, y: 0 }
|
|
223
|
-
* ```
|
|
143
|
+
* Remove this map from the world
|
|
144
|
+
* @title Remove this map from the world
|
|
145
|
+
* @method map.removeFromWorldMaps()
|
|
146
|
+
* @returns {boolean | undefined}
|
|
147
|
+
* @since 3.0.0-beta.8
|
|
224
148
|
* @memberof Map
|
|
225
|
-
* @memberof RpgSceneMap
|
|
226
149
|
*/
|
|
227
|
-
|
|
228
|
-
x: number;
|
|
229
|
-
y: number;
|
|
230
|
-
};
|
|
150
|
+
removeFromWorldMaps(): boolean | undefined;
|
|
231
151
|
/**
|
|
232
|
-
|
|
152
|
+
* Recover the world attached to this map (`undefined` if no world attached)
|
|
233
153
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
* const tiles = map.getTileByPosition(0, 0)
|
|
242
|
-
* ```
|
|
243
|
-
* @memberof Map
|
|
244
|
-
* @memberof RpgSceneMap
|
|
245
|
-
*/
|
|
246
|
-
getTileByPosition(x: number, y: number, z?: [number, number]): TileInfo;
|
|
247
|
-
/**
|
|
248
|
-
* Get tile and verify collision with hitbox
|
|
249
|
-
* @param hitbox
|
|
250
|
-
* @param x
|
|
251
|
-
* @param y
|
|
252
|
-
* @param z
|
|
253
|
-
* @returns TileInfo
|
|
254
|
-
*/
|
|
255
|
-
getTile(hitbox: any, x: number, y: number, z?: [number, number]): TileInfo;
|
|
154
|
+
* @title Get attached World
|
|
155
|
+
* @method map.getInWorldMaps()
|
|
156
|
+
* @return {RpgCommonWorldMaps | undefined}
|
|
157
|
+
* @since 3.0.0-beta.8
|
|
158
|
+
* @memberof Map
|
|
159
|
+
*/
|
|
160
|
+
getInWorldMaps(): RpgCommonWorldMaps | undefined;
|
|
256
161
|
}
|