@rpgjs/common 3.0.1 → 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/LICENSE +19 -0
- package/lib/AbstractObject.d.ts +318 -0
- package/lib/AbstractObject.js +828 -0
- package/lib/AbstractObject.js.map +1 -0
- package/lib/Game.d.ts +6 -2
- package/lib/Game.js +42 -13
- package/lib/Game.js.map +1 -1
- package/lib/Hit.d.ts +4 -28
- package/lib/Hit.js +12 -15
- package/lib/Hit.js.map +1 -1
- package/lib/Hitbox.d.ts +6 -0
- package/lib/Hitbox.js +10 -0
- package/lib/Hitbox.js.map +1 -0
- package/lib/HitboxEffect.d.ts +6 -0
- package/lib/HitboxEffect.js +10 -0
- package/lib/HitboxEffect.js.map +1 -0
- package/lib/Map.d.ts +12 -0
- package/lib/Map.js +77 -4
- package/lib/Map.js.map +1 -1
- package/lib/Player.d.ts +9 -296
- package/lib/Player.js +7 -639
- package/lib/Player.js.map +1 -1
- package/lib/Scheduler.d.ts +16 -38
- package/lib/Scheduler.js +69 -76
- package/lib/Scheduler.js.map +1 -1
- package/lib/Shape.d.ts +8 -7
- package/lib/Shape.js +11 -15
- package/lib/Shape.js.map +1 -1
- package/lib/SocketEvents.d.ts +8 -0
- package/lib/SocketEvents.js +14 -0
- package/lib/SocketEvents.js.map +1 -0
- package/lib/Utils.d.ts +12 -11
- package/lib/Utils.js.map +1 -1
- package/lib/Vector2d.d.ts +19 -0
- package/lib/Vector2d.js +63 -0
- package/lib/Vector2d.js.map +1 -0
- package/lib/VirtualGrid.d.ts +2 -3
- package/lib/VirtualGrid.js.map +1 -1
- package/lib/WorldMaps.d.ts +1 -1
- package/lib/WorldMaps.js +5 -5
- package/lib/WorldMaps.js.map +1 -1
- package/lib/index.d.ts +21 -19
- package/lib/index.js +27 -30
- package/lib/index.js.map +1 -1
- package/lib/types/Hitbox.d.ts +24 -0
- package/lib/types/Hitbox.js +3 -0
- package/lib/types/Hitbox.js.map +1 -0
- package/lib/types/Player.d.ts +8 -0
- package/lib/types/Player.js +3 -0
- package/lib/types/Player.js.map +1 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +3 -0
- package/lib/types/index.js.map +1 -0
- package/lib/workers/move.js +1 -1
- package/lib/workers/move.js.map +1 -1
- package/package.json +5 -3
package/lib/Player.d.ts
CHANGED
|
@@ -1,52 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { TileInfo } from './Map';
|
|
4
|
-
import { RpgCommonGame } from './Game';
|
|
5
|
-
export declare type Position = {
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
z: number;
|
|
9
|
-
};
|
|
10
|
-
export declare enum Direction {
|
|
11
|
-
Up = 1,
|
|
12
|
-
Down = 3,
|
|
13
|
-
Left = 4,
|
|
14
|
-
Right = 2,
|
|
15
|
-
UpRight = 1.5,
|
|
16
|
-
DownRight = 2.5,
|
|
17
|
-
DownLeft = 3.5,
|
|
18
|
-
UpLeft = 2.5
|
|
19
|
-
}
|
|
1
|
+
import { PendingMove } from '@rpgjs/types';
|
|
2
|
+
import { AbstractObject } from './AbstractObject';
|
|
20
3
|
export declare const LiteralDirection: {
|
|
21
4
|
1: string;
|
|
22
5
|
2: string;
|
|
23
6
|
3: string;
|
|
24
7
|
4: string;
|
|
25
8
|
};
|
|
26
|
-
export declare
|
|
27
|
-
|
|
28
|
-
Event = "event",
|
|
29
|
-
Shape = "shape"
|
|
30
|
-
}
|
|
31
|
-
export declare class RpgCommonPlayer {
|
|
32
|
-
private gameEngine;
|
|
33
|
-
playerId: string;
|
|
34
|
-
map: string;
|
|
9
|
+
export declare class RpgCommonPlayer extends AbstractObject {
|
|
10
|
+
events: any[];
|
|
35
11
|
layerName: string;
|
|
36
12
|
components: any[];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
direction: number;
|
|
43
|
-
private collisionWith;
|
|
44
|
-
private _collisionWithTiles;
|
|
45
|
-
hitbox: SAT.Box;
|
|
46
|
-
pendingMove: {
|
|
47
|
-
input: string;
|
|
48
|
-
frame: number;
|
|
49
|
-
}[];
|
|
13
|
+
data: any;
|
|
14
|
+
pendingMove: PendingMove;
|
|
15
|
+
inputsTimestamp: {
|
|
16
|
+
[inputName: string]: number;
|
|
17
|
+
};
|
|
50
18
|
/**
|
|
51
19
|
* Display/Hide the GUI attached to this sprite
|
|
52
20
|
*
|
|
@@ -55,259 +23,4 @@ export declare class RpgCommonPlayer {
|
|
|
55
23
|
* @memberof RpgSprite
|
|
56
24
|
* */
|
|
57
25
|
guiDisplay: boolean;
|
|
58
|
-
inShapes: {
|
|
59
|
-
[shapeId: string]: RpgShape;
|
|
60
|
-
};
|
|
61
|
-
private shapes;
|
|
62
|
-
private _position;
|
|
63
|
-
private _hitboxPos;
|
|
64
|
-
static get ACTIONS(): {
|
|
65
|
-
IDLE: number;
|
|
66
|
-
RUN: number;
|
|
67
|
-
ACTION: number;
|
|
68
|
-
};
|
|
69
|
-
constructor(gameEngine: RpgCommonGame, playerId: string);
|
|
70
|
-
get id(): string;
|
|
71
|
-
set id(str: string);
|
|
72
|
-
updateInVirtualGrid(): void;
|
|
73
|
-
/**
|
|
74
|
-
* Get/Set position x, y and z of player
|
|
75
|
-
*
|
|
76
|
-
* z is the depth layer. By default, its value is 0. Collisions and overlays will be performed with other objects on the same z-position.
|
|
77
|
-
*
|
|
78
|
-
* @title Get/Set position
|
|
79
|
-
* @prop { { x: number, y: number, z: number } } position
|
|
80
|
-
* @memberof Player
|
|
81
|
-
*/
|
|
82
|
-
set position(val: Position);
|
|
83
|
-
get position(): Position;
|
|
84
|
-
get worldPositionX(): number;
|
|
85
|
-
get worldPositionY(): number;
|
|
86
|
-
set posX(val: any);
|
|
87
|
-
set posY(val: any);
|
|
88
|
-
set posZ(val: any);
|
|
89
|
-
/**
|
|
90
|
-
*
|
|
91
|
-
* Recovers all the colliding tiles of the current player
|
|
92
|
-
*
|
|
93
|
-
* @title Get Collision of tiles
|
|
94
|
-
* @since 3.0.0-beta.4
|
|
95
|
-
* @readonly
|
|
96
|
-
* @prop { TileInfo[] } tiles
|
|
97
|
-
* @memberof Player
|
|
98
|
-
* @memberof RpgSpriteLogic
|
|
99
|
-
*/
|
|
100
|
-
get tilesCollision(): TileInfo[];
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
* Recovers all other players and events colliding with the current player's hitbox
|
|
104
|
-
*
|
|
105
|
-
* @title Get Collision of other players/events
|
|
106
|
-
* @since 3.0.0-beta.4
|
|
107
|
-
* @readonly
|
|
108
|
-
* @prop { (RpgPlayer | RpgEvent)[] } otherPlayersCollision
|
|
109
|
-
* @memberof Player
|
|
110
|
-
* @memberof RpgSpriteLogic
|
|
111
|
-
*/
|
|
112
|
-
get otherPlayersCollision(): RpgCommonPlayer[];
|
|
113
|
-
/**
|
|
114
|
-
* Define the size of the player. You can set the hitbox for collisions
|
|
115
|
-
*
|
|
116
|
-
* ```ts
|
|
117
|
-
* player.setSizes({
|
|
118
|
-
* width: 32,
|
|
119
|
-
* height: 32
|
|
120
|
-
* })
|
|
121
|
-
* ```
|
|
122
|
-
*
|
|
123
|
-
* and with hitbox:
|
|
124
|
-
*
|
|
125
|
-
* ```ts
|
|
126
|
-
* player.setSizes({
|
|
127
|
-
* width: 32,
|
|
128
|
-
* height: 32,
|
|
129
|
-
* hitbox: {
|
|
130
|
-
* width: 20,
|
|
131
|
-
* height: 20
|
|
132
|
-
* }
|
|
133
|
-
* })
|
|
134
|
-
* ```
|
|
135
|
-
*
|
|
136
|
-
* @title Set Sizes
|
|
137
|
-
* @method player.setSizes(key,value)
|
|
138
|
-
* @param { { width: number, height: number, hitbox?: { width: number, height: number } } } obj
|
|
139
|
-
* @deprecated
|
|
140
|
-
* @returns {void}
|
|
141
|
-
* @memberof Player
|
|
142
|
-
*/
|
|
143
|
-
setSizes(obj: {
|
|
144
|
-
width: number;
|
|
145
|
-
height: number;
|
|
146
|
-
hitbox?: {
|
|
147
|
-
width: number;
|
|
148
|
-
height: number;
|
|
149
|
-
};
|
|
150
|
-
}): void;
|
|
151
|
-
/**
|
|
152
|
-
* Define the hitbox of the player.
|
|
153
|
-
*
|
|
154
|
-
* ```ts
|
|
155
|
-
* player.setHitbox(20, 20)
|
|
156
|
-
* ```
|
|
157
|
-
*
|
|
158
|
-
* @title Set Hitbox
|
|
159
|
-
* @method player.setHitbox(width,height)
|
|
160
|
-
* @param {number} width
|
|
161
|
-
* @param {number} height
|
|
162
|
-
* @returns {void}
|
|
163
|
-
* @memberof Player
|
|
164
|
-
*/
|
|
165
|
-
setHitbox(width: number, height: number): void;
|
|
166
|
-
set wHitbox(val: any);
|
|
167
|
-
set hHitbox(val: any);
|
|
168
|
-
get wHitbox(): any;
|
|
169
|
-
get hHitbox(): any;
|
|
170
|
-
private directionToAngle;
|
|
171
|
-
/**
|
|
172
|
-
* Retrieves a tile and checks if the player has a collision
|
|
173
|
-
*
|
|
174
|
-
* ```ts
|
|
175
|
-
* const tileInfo = player.getTile(20, 30)
|
|
176
|
-
* console.log(tileInfo)
|
|
177
|
-
* ```
|
|
178
|
-
*
|
|
179
|
-
* Example of returns:
|
|
180
|
-
*
|
|
181
|
-
```ts
|
|
182
|
-
{
|
|
183
|
-
tiles: [
|
|
184
|
-
{
|
|
185
|
-
id: 0,
|
|
186
|
-
terrain: [],
|
|
187
|
-
probability: null,
|
|
188
|
-
properties: [Object],
|
|
189
|
-
animations: [],
|
|
190
|
-
objectGroups: [],
|
|
191
|
-
image: null,
|
|
192
|
-
gid: 1
|
|
193
|
-
}
|
|
194
|
-
],
|
|
195
|
-
hasCollision: false,
|
|
196
|
-
isOverlay: undefined,
|
|
197
|
-
objectGroups: [],
|
|
198
|
-
isClimbable: undefined,
|
|
199
|
-
tileIndex: 93
|
|
200
|
-
}
|
|
201
|
-
```
|
|
202
|
-
*
|
|
203
|
-
* @title Get Tile
|
|
204
|
-
* @since 3.0.0-beta.4
|
|
205
|
-
* @method player.getTile(x,y,z?)
|
|
206
|
-
* @param {number} x
|
|
207
|
-
* @param {number} y
|
|
208
|
-
* @param {number} [z]
|
|
209
|
-
* @returns {object}
|
|
210
|
-
* @memberof Player
|
|
211
|
-
* @memberof RpgSpriteLogic
|
|
212
|
-
*/
|
|
213
|
-
getTile(x: number, y: number, z?: number, hitbox?: SAT.Box): TileInfo;
|
|
214
|
-
isCollided(nextPosition: Position): Promise<boolean>;
|
|
215
|
-
/**
|
|
216
|
-
* Attach a shape to the player (and allow interaction with it)
|
|
217
|
-
*
|
|
218
|
-
* ```ts
|
|
219
|
-
* import { ShapePositioning } from '@rpgjs/server'
|
|
220
|
-
*
|
|
221
|
-
* player.attachShape({
|
|
222
|
-
* width: 100,
|
|
223
|
-
* height: 100,
|
|
224
|
-
* positioning: ShapePositioning.Center
|
|
225
|
-
* })
|
|
226
|
-
* ```
|
|
227
|
-
*
|
|
228
|
-
* @title Attach Shape
|
|
229
|
-
* @method player.attachShape(parameters)
|
|
230
|
-
* @param { { width: number, height: number, positioning?, name?, properties?: object } } obj
|
|
231
|
-
* - positioning: Indicate where the shape is placed.
|
|
232
|
-
* - properties: An object in order to retrieve information when interacting with the shape
|
|
233
|
-
* - name: The name of the shape
|
|
234
|
-
* @since 3.0.0-beta.3
|
|
235
|
-
* @returns {RpgShape}
|
|
236
|
-
* @memberof Player
|
|
237
|
-
*/
|
|
238
|
-
attachShape(obj: {
|
|
239
|
-
width: number;
|
|
240
|
-
height: number;
|
|
241
|
-
positioning?: string;
|
|
242
|
-
name?: string;
|
|
243
|
-
properties?: object;
|
|
244
|
-
}): RpgShape;
|
|
245
|
-
/**
|
|
246
|
-
* Returns all shapes assigned to this player
|
|
247
|
-
*
|
|
248
|
-
* @title Get Shapes
|
|
249
|
-
* @method player.getShapes()
|
|
250
|
-
* @returns {RpgShape[]}
|
|
251
|
-
* @since 3.0.0-beta.3
|
|
252
|
-
* @memberof Player
|
|
253
|
-
* @memberof RpgSpriteLogic
|
|
254
|
-
*/
|
|
255
|
-
getShapes(): RpgShape[];
|
|
256
|
-
/**
|
|
257
|
-
* Retrieves all shapes where the player is located
|
|
258
|
-
*
|
|
259
|
-
* @title Get In-Shapes
|
|
260
|
-
* @method player.getInShapes()
|
|
261
|
-
* @returns {RpgShape[]}
|
|
262
|
-
* @since 3.0.0-beta.3
|
|
263
|
-
* @memberof Player
|
|
264
|
-
*/
|
|
265
|
-
getInShapes(): RpgShape[];
|
|
266
|
-
/**
|
|
267
|
-
* Get the current direction.
|
|
268
|
-
*
|
|
269
|
-
* ```ts
|
|
270
|
-
* player.getDirection()
|
|
271
|
-
* ```
|
|
272
|
-
*
|
|
273
|
-
* @title Get Direction
|
|
274
|
-
* @method player.getDirection()
|
|
275
|
-
* @returns {Direction | number} direction
|
|
276
|
-
* @memberof Player
|
|
277
|
-
*/
|
|
278
|
-
getDirection(direction?: Direction | number): string | number;
|
|
279
|
-
/**
|
|
280
|
-
* Changes the player's direction
|
|
281
|
-
*
|
|
282
|
-
* ```ts
|
|
283
|
-
* import { Direction } from '@rpgjs/server'
|
|
284
|
-
*
|
|
285
|
-
* player.changeDirection(Direction.Left)
|
|
286
|
-
* ```
|
|
287
|
-
*
|
|
288
|
-
* @title Change direction
|
|
289
|
-
* @method player.changeDirection(direction)
|
|
290
|
-
* @param {Direction} direction
|
|
291
|
-
* @enum {string}
|
|
292
|
-
*
|
|
293
|
-
* Direction.Left | left
|
|
294
|
-
* Direction.Right | right
|
|
295
|
-
* Direction.Up | up
|
|
296
|
-
* Direction.Down | down
|
|
297
|
-
* @returns {boolean} the direction has changed
|
|
298
|
-
* @memberof Player
|
|
299
|
-
*/
|
|
300
|
-
changeDirection(direction: Direction): boolean;
|
|
301
|
-
/**
|
|
302
|
-
* Gets the necessary number of pixels to allow the player to cross a tile.
|
|
303
|
-
* This is the ratio between the height or width of the tile and the speed of the player.
|
|
304
|
-
*/
|
|
305
|
-
get nbPixelInTile(): any;
|
|
306
|
-
}
|
|
307
|
-
export interface RpgCommonPlayer {
|
|
308
|
-
readonly type: string;
|
|
309
|
-
through: boolean;
|
|
310
|
-
throughOtherPlayer: boolean;
|
|
311
|
-
autoChangeMap?(nextPosition: Position): Promise<boolean>;
|
|
312
|
-
execMethod(methodName: string, methodData?: any, instance?: any): any;
|
|
313
26
|
}
|