@rpgjs/server 5.0.0-alpha.25 → 5.0.0-alpha.26
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/dist/Player/Player.d.ts +31 -22
- package/dist/index.js +412 -196
- package/dist/index.js.map +1 -1
- package/dist/rooms/BaseRoom.d.ts +95 -0
- package/dist/rooms/lobby.d.ts +4 -1
- package/dist/rooms/map.d.ts +17 -75
- package/package.json +8 -8
- package/src/Player/ItemManager.ts +50 -15
- package/src/Player/Player.ts +161 -135
- package/src/module.ts +13 -0
- package/src/rooms/BaseRoom.ts +120 -0
- package/src/rooms/lobby.ts +11 -1
- package/src/rooms/map.ts +68 -144
- package/tests/item.spec.ts +455 -441
- package/tests/world-maps.spec.ts +43 -81
package/dist/Player/Player.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Hooks, RpgCommonPlayer, Constructor, Direction, AttachShapeOptions, RpgShape } from '../../../common/src';
|
|
2
|
+
import { Vector2 } from '../../../physic/src';
|
|
2
3
|
import { IComponentManager } from './ComponentManager';
|
|
3
4
|
import { RpgMap } from '../rooms/map';
|
|
4
5
|
import { Context } from '@signe/di';
|
|
@@ -40,6 +41,34 @@ export declare class RpgPlayer extends RpgPlayer_base {
|
|
|
40
41
|
context?: Context;
|
|
41
42
|
conn: MockConnection | null;
|
|
42
43
|
touchSide: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Computed signal for world X position
|
|
46
|
+
*
|
|
47
|
+
* Calculates the absolute world X position from the map's world position
|
|
48
|
+
* plus the player's local X position. Returns 0 if no map is assigned.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const worldX = player.worldX();
|
|
53
|
+
* console.log(`Player is at world X: ${worldX}`);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
get worldPositionX(): any;
|
|
57
|
+
/**
|
|
58
|
+
* Computed signal for world Y position
|
|
59
|
+
*
|
|
60
|
+
* Calculates the absolute world Y position from the map's world position
|
|
61
|
+
* plus the player's local Y position. Returns 0 if no map is assigned.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const worldY = player.worldY();
|
|
66
|
+
* console.log(`Player is at world Y: ${worldY}`);
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
get worldPositionY(): any;
|
|
70
|
+
private _worldPositionSignals;
|
|
71
|
+
private _getComputedWorldPosition;
|
|
43
72
|
/** Internal: Shapes attached to this player */
|
|
44
73
|
private _attachedShapes;
|
|
45
74
|
/** Internal: Shapes where this player is currently located */
|
|
@@ -66,6 +95,7 @@ export declare class RpgPlayer extends RpgPlayer_base {
|
|
|
66
95
|
_onInit(): void;
|
|
67
96
|
get hooks(): Hooks;
|
|
68
97
|
get server(): RpgMap | null;
|
|
98
|
+
setMap(map: RpgMap): void;
|
|
69
99
|
applyFrames(): void;
|
|
70
100
|
execMethod(method: string, methodData?: any[], target?: any): Promise<any>;
|
|
71
101
|
/**
|
|
@@ -89,28 +119,7 @@ export declare class RpgPlayer extends RpgPlayer_base {
|
|
|
89
119
|
y: number;
|
|
90
120
|
z?: number;
|
|
91
121
|
} | string): Promise<any | null | boolean>;
|
|
92
|
-
|
|
93
|
-
* Auto change map when player touches map borders
|
|
94
|
-
*
|
|
95
|
-
* This method checks if the player touches the current map borders
|
|
96
|
-
* and automatically performs a change to the adjacent map if it exists.
|
|
97
|
-
*
|
|
98
|
-
* @param nextPosition - The next position of the player
|
|
99
|
-
* @returns Promise<boolean> - true if a map change occurred
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```ts
|
|
103
|
-
* // Called automatically by the movement system
|
|
104
|
-
* const changed = await player.autoChangeMap({ x: newX, y: newY });
|
|
105
|
-
* if (changed) {
|
|
106
|
-
* console.log('Player changed map automatically');
|
|
107
|
-
* }
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
autoChangeMap(nextPosition: {
|
|
111
|
-
x: number;
|
|
112
|
-
y: number;
|
|
113
|
-
}, forcedDirection?: any): Promise<boolean>;
|
|
122
|
+
autoChangeMap(nextPosition: Vector2): Promise<boolean>;
|
|
114
123
|
teleport(positions: {
|
|
115
124
|
x: number;
|
|
116
125
|
y: number;
|