rock-mod 0.7.3 → 0.8.1
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/README.md +93 -2
- package/dist/server/RockMod.d.ts +3 -2
- package/dist/server/RockMod.js +5 -1
- package/dist/server/entities/altv/marker/AltVMarker.d.ts +7 -1
- package/dist/server/entities/altv/marker/AltVMarker.js +19 -0
- package/dist/server/entities/altv/player/AltVPlayer.d.ts +1 -0
- package/dist/server/entities/altv/player/AltVPlayer.js +3 -0
- package/dist/server/entities/common/marker/IMarker.d.ts +11 -0
- package/dist/server/entities/common/marker/IMarkersManager.d.ts +4 -4
- package/dist/server/entities/common/player/IPlayer.d.ts +1 -0
- package/dist/server/entities/mock/baseObject/MockBaseObject.d.ts +18 -0
- package/dist/server/entities/mock/baseObject/MockBaseObject.js +24 -0
- package/dist/server/entities/mock/baseObject/MockBaseObjectsIterator.d.ts +7 -0
- package/dist/server/entities/mock/baseObject/MockBaseObjectsIterator.js +13 -0
- package/dist/server/entities/mock/baseObject/MockBaseObjectsManager.d.ts +18 -0
- package/dist/server/entities/mock/baseObject/MockBaseObjectsManager.js +46 -0
- package/dist/server/entities/mock/blip/MockBlip.d.ts +35 -0
- package/dist/server/entities/mock/blip/MockBlip.js +62 -0
- package/dist/server/entities/mock/blip/MockBlipsManager.d.ts +9 -0
- package/dist/server/entities/mock/blip/MockBlipsManager.js +33 -0
- package/dist/server/entities/mock/colshape/MockCircleColshape.d.ts +8 -0
- package/dist/server/entities/mock/colshape/MockCircleColshape.js +10 -0
- package/dist/server/entities/mock/colshape/MockColshape.d.ts +7 -0
- package/dist/server/entities/mock/colshape/MockColshape.js +10 -0
- package/dist/server/entities/mock/colshape/MockColshapesManager.d.ts +27 -0
- package/dist/server/entities/mock/colshape/MockColshapesManager.js +90 -0
- package/dist/server/entities/mock/colshape/MockCuboidColshape.d.ts +10 -0
- package/dist/server/entities/mock/colshape/MockCuboidColshape.js +10 -0
- package/dist/server/entities/mock/colshape/MockCylinderColshape.d.ts +9 -0
- package/dist/server/entities/mock/colshape/MockCylinderColshape.js +10 -0
- package/dist/server/entities/mock/colshape/MockRectangleColshape.d.ts +9 -0
- package/dist/server/entities/mock/colshape/MockRectangleColshape.js +10 -0
- package/dist/server/entities/mock/colshape/MockSphereColshape.d.ts +8 -0
- package/dist/server/entities/mock/colshape/MockSphereColshape.js +10 -0
- package/dist/server/entities/mock/common/IMockEntity.d.ts +18 -0
- package/dist/server/entities/mock/common/IMockEntity.js +2 -0
- package/dist/server/entities/mock/entity/MockEntitiesManager.d.ts +8 -0
- package/dist/server/entities/mock/entity/MockEntitiesManager.js +10 -0
- package/dist/server/entities/mock/entity/MockEntity.d.ts +16 -0
- package/dist/server/entities/mock/entity/MockEntity.js +29 -0
- package/dist/server/entities/mock/marker/MockMarker.d.ts +27 -0
- package/dist/server/entities/mock/marker/MockMarker.js +50 -0
- package/dist/server/entities/mock/marker/MockMarkersManager.d.ts +10 -0
- package/dist/server/entities/mock/marker/MockMarkersManager.js +31 -0
- package/dist/server/entities/mock/object/MockObject.d.ts +11 -0
- package/dist/server/entities/mock/object/MockObject.js +19 -0
- package/dist/server/entities/mock/object/MockObjectsManager.d.ts +10 -0
- package/dist/server/entities/mock/object/MockObjectsManager.js +31 -0
- package/dist/server/entities/mock/ped/MockPed.d.ts +7 -0
- package/dist/server/entities/mock/ped/MockPed.js +10 -0
- package/dist/server/entities/mock/ped/MockPedsManager.d.ts +10 -0
- package/dist/server/entities/mock/ped/MockPedsManager.js +30 -0
- package/dist/server/entities/mock/player/MockPlayer.d.ts +56 -0
- package/dist/server/entities/mock/player/MockPlayer.js +134 -0
- package/dist/server/entities/mock/player/MockPlayersManager.d.ts +26 -0
- package/dist/server/entities/mock/player/MockPlayersManager.js +79 -0
- package/dist/server/entities/mock/vehicle/MockVehicle.d.ts +42 -0
- package/dist/server/entities/mock/vehicle/MockVehicle.js +103 -0
- package/dist/server/entities/mock/vehicle/MockVehiclesManager.d.ts +10 -0
- package/dist/server/entities/mock/vehicle/MockVehiclesManager.js +32 -0
- package/dist/server/entities/mock/worldObject/MockWorldObject.d.ts +12 -0
- package/dist/server/entities/mock/worldObject/MockWorldObject.js +16 -0
- package/dist/server/entities/mock/worldObject/MockWorldObjectsIterator.d.ts +10 -0
- package/dist/server/entities/mock/worldObject/MockWorldObjectsIterator.js +39 -0
- package/dist/server/entities/mock/worldObject/MockWorldObjectsManager.d.ts +11 -0
- package/dist/server/entities/mock/worldObject/MockWorldObjectsManager.js +16 -0
- package/dist/server/entities/ragemp/marker/RageMarker.d.ts +7 -1
- package/dist/server/entities/ragemp/marker/RageMarker.js +19 -0
- package/dist/server/entities/ragemp/player/RagePlayer.d.ts +1 -0
- package/dist/server/entities/ragemp/player/RagePlayer.js +3 -0
- package/dist/server/factories/mock/MockManagersFactory.d.ts +21 -0
- package/dist/server/factories/mock/MockManagersFactory.js +42 -0
- package/dist/server/index.d.ts +4 -1
- package/dist/server/index.js +4 -1
- package/dist/server/net/mock/MockNetManager.d.ts +10 -0
- package/dist/server/net/mock/MockNetManager.js +20 -0
- package/dist/server/net/mock/events/MockEventsManager.d.ts +18 -0
- package/dist/server/net/mock/events/MockEventsManager.js +22 -0
- package/dist/server/net/mock/rpc/MockRPCManager.d.ts +13 -0
- package/dist/server/net/mock/rpc/MockRPCManager.js +26 -0
- package/dist/server/testing.d.ts +8 -0
- package/dist/server/testing.js +19 -0
- package/dist/server/utils/mock/MockUtilsManager.d.ts +4 -0
- package/dist/server/utils/mock/MockUtilsManager.js +16 -0
- package/package.json +21 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Rock-Mod
|
|
2
2
|
|
|
3
|
-
**Rock-Mod** is a versatile and powerful framework designed for cross-platform mod development for Grand Theft Auto (GTA) servers. It supports
|
|
3
|
+
**Rock-Mod** is a versatile and powerful framework designed for cross-platform mod development for Grand Theft Auto (GTA) servers. It supports **RageMP**, **AltV**, and **Mock** multiplayer platforms, allowing you to build and manage mods seamlessly across these environments.
|
|
4
4
|
|
|
5
5
|
### Installation
|
|
6
6
|
|
|
@@ -16,10 +16,101 @@ On the server-side, initialize Rock-Mod with the appropriate multiplayer type:
|
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
const rockMod = await RockMod.create({
|
|
19
|
-
multiplayer: "RageMP", // or "AltV"
|
|
19
|
+
multiplayer: "RageMP", // or "AltV", or "Mock"
|
|
20
20
|
});
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
### Multiplayer Types
|
|
24
|
+
|
|
25
|
+
Rock-Mod supports three multiplayer types:
|
|
26
|
+
|
|
27
|
+
1. **RageMP** - For developing mods for RageMP servers
|
|
28
|
+
2. **AltV** - For developing mods for AltV servers
|
|
29
|
+
3. **Mock** - For testing and development without multiplayer dependencies
|
|
30
|
+
|
|
31
|
+
### Mock Mode
|
|
32
|
+
|
|
33
|
+
Mock mode provides a complete mock environment for testing your mods without requiring a multiplayer server. It includes:
|
|
34
|
+
|
|
35
|
+
- Full entity hierarchy (BaseObject, WorldObject, Entity)
|
|
36
|
+
- All entity types (Blip, Colshape, Marker, Object, Ped, Player, Vehicle)
|
|
37
|
+
- Type-safe events and RPC system
|
|
38
|
+
- In-memory state management
|
|
39
|
+
- Player connection simulation
|
|
40
|
+
|
|
41
|
+
Example using Mock mode for development:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { RockMod } from "rock-mod";
|
|
45
|
+
|
|
46
|
+
// Initialize in Mock mode
|
|
47
|
+
const rockMod = await RockMod.create({
|
|
48
|
+
multiplayer: "Mock",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Subscribe to events
|
|
52
|
+
rockMod.net.events.on({
|
|
53
|
+
"rm::playerConnected": (player) => {
|
|
54
|
+
console.log(`Player ${player.name} connected`);
|
|
55
|
+
},
|
|
56
|
+
"rm::playerDisconnected": (player) => {
|
|
57
|
+
console.log(`Player ${player.name} disconnected`);
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Register RPC handlers
|
|
62
|
+
rockMod.net.rpc.register("getPlayerInfo", (player) => {
|
|
63
|
+
return {
|
|
64
|
+
id: player.id,
|
|
65
|
+
name: player.name,
|
|
66
|
+
position: player.position,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Example using Mock mode for testing:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { TestRockMod } from "rock-mod/testing";
|
|
75
|
+
|
|
76
|
+
// Initialize test environment
|
|
77
|
+
const rockMod = await TestRockMod.create({
|
|
78
|
+
multiplayer: "Mock",
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Simulate player connection
|
|
82
|
+
const player = rockMod.simulatePlayerConnect({
|
|
83
|
+
name: "TestPlayer",
|
|
84
|
+
position: { x: 0, y: 0, z: 0 },
|
|
85
|
+
health: 100,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Test your mod logic here
|
|
89
|
+
// ...
|
|
90
|
+
|
|
91
|
+
// Simulate player disconnection
|
|
92
|
+
rockMod.simulatePlayerDisconnect(player);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Features
|
|
96
|
+
|
|
97
|
+
- **Cross-Platform Support**: Write once, run on any supported platform
|
|
98
|
+
- **Type Safety**: Full TypeScript support with proper type definitions
|
|
99
|
+
- **Entity Management**: Unified API for managing game entities
|
|
100
|
+
- **Networking**: Type-safe events and RPC system
|
|
101
|
+
- **Testing**: Dedicated testing API through `rock-mod/testing`
|
|
102
|
+
- **Modular Design**: Easy to extend and customize
|
|
103
|
+
|
|
104
|
+
### Documentation
|
|
105
|
+
|
|
23
106
|
Please note that client-side implementation is not yet available in this version.
|
|
24
107
|
|
|
25
108
|
Rock-Mod simplifies multiplayer mod development by providing unified tools for managing game entities, networking, and more across different platforms.
|
|
109
|
+
|
|
110
|
+
### Contributing
|
|
111
|
+
|
|
112
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
113
|
+
|
|
114
|
+
### License
|
|
115
|
+
|
|
116
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
package/dist/server/RockMod.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { INetManager } from "./net/common/INetManager";
|
|
2
2
|
import { IBlipsManager, IColshapesManager, IMarkersManager, IObjectsManager, IPedsManager, IPlayersManager, IVehiclesManager } from "./entities";
|
|
3
3
|
import { IUtilsManager } from "./utils";
|
|
4
|
-
|
|
4
|
+
import { IManagersFactory } from "./factories/common/IManagersFactory";
|
|
5
|
+
type MultiplayerType = "RageMP" | "AltV" | "Mock";
|
|
5
6
|
export interface RockModOptions {
|
|
6
7
|
multiplayer: MultiplayerType;
|
|
7
8
|
}
|
|
@@ -28,6 +29,6 @@ export declare class RockMod {
|
|
|
28
29
|
get players(): IPlayersManager;
|
|
29
30
|
get utils(): IUtilsManager;
|
|
30
31
|
get vehicles(): IVehiclesManager;
|
|
31
|
-
|
|
32
|
+
protected constructor(managersFactory: IManagersFactory);
|
|
32
33
|
}
|
|
33
34
|
export {};
|
package/dist/server/RockMod.js
CHANGED
|
@@ -36,7 +36,7 @@ class RockMod {
|
|
|
36
36
|
}
|
|
37
37
|
static get instance() {
|
|
38
38
|
if (!this._instance) {
|
|
39
|
-
throw new Error("RockMod not created");
|
|
39
|
+
throw new Error("RockMod is not created");
|
|
40
40
|
}
|
|
41
41
|
return this._instance;
|
|
42
42
|
}
|
|
@@ -51,6 +51,10 @@ class RockMod {
|
|
|
51
51
|
const { RageManagersFactory } = await Promise.resolve().then(() => __importStar(require("./factories/ragemp/RageManagersFactory")));
|
|
52
52
|
return new RageManagersFactory();
|
|
53
53
|
}
|
|
54
|
+
case "Mock": {
|
|
55
|
+
const { MockManagersFactory } = await Promise.resolve().then(() => __importStar(require("./factories/mock/MockManagersFactory")));
|
|
56
|
+
return new MockManagersFactory();
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
_net;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { AltVWorldObject, IAltVWorldObjectOptions } from "../worldObject/AltVWorldObject";
|
|
2
2
|
import Marker = AltVServer.Marker;
|
|
3
|
-
import { IMarker } from "../../common";
|
|
3
|
+
import { IMarker, IMarkerType } from "../../common";
|
|
4
|
+
import { IRGBA, IVector3D } from "../../../common/utils";
|
|
4
5
|
export interface IAltVMarkerOptions extends IAltVWorldObjectOptions<Marker> {
|
|
5
6
|
}
|
|
6
7
|
export declare class AltVMarker extends AltVWorldObject<Marker> implements IMarker {
|
|
8
|
+
get markerType(): IMarkerType;
|
|
7
9
|
get visible(): boolean;
|
|
8
10
|
get scale(): number;
|
|
11
|
+
get color(): IRGBA;
|
|
12
|
+
get rotation(): IVector3D;
|
|
9
13
|
constructor(options: IAltVMarkerOptions);
|
|
10
14
|
setVisible(value: boolean): void;
|
|
11
15
|
setScale(value: number): void;
|
|
16
|
+
setColor(value: IRGBA): void;
|
|
17
|
+
setRotation(value: IVector3D): void;
|
|
12
18
|
}
|
|
@@ -3,13 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AltVMarker = void 0;
|
|
4
4
|
const AltVWorldObject_1 = require("../worldObject/AltVWorldObject");
|
|
5
5
|
var Vector3 = AltVShared.Vector3;
|
|
6
|
+
const utils_1 = require("../../../common/utils");
|
|
6
7
|
class AltVMarker extends AltVWorldObject_1.AltVWorldObject {
|
|
8
|
+
get markerType() {
|
|
9
|
+
return this.mpEntity.markerType;
|
|
10
|
+
}
|
|
7
11
|
get visible() {
|
|
8
12
|
return this.mpEntity.visible;
|
|
9
13
|
}
|
|
10
14
|
get scale() {
|
|
11
15
|
return this.mpEntity.scale.z;
|
|
12
16
|
}
|
|
17
|
+
get color() {
|
|
18
|
+
const { r, g, b, a } = this.mpEntity.color;
|
|
19
|
+
return new utils_1.RGBA(r, g, b, a);
|
|
20
|
+
}
|
|
21
|
+
get rotation() {
|
|
22
|
+
const { x, y, z } = this.mpEntity.rot;
|
|
23
|
+
return new utils_1.Vector3D(x, y, z);
|
|
24
|
+
}
|
|
13
25
|
constructor(options) {
|
|
14
26
|
super(options);
|
|
15
27
|
}
|
|
@@ -19,5 +31,12 @@ class AltVMarker extends AltVWorldObject_1.AltVWorldObject {
|
|
|
19
31
|
setScale(value) {
|
|
20
32
|
this.mpEntity.scale = new Vector3(0, 0, value);
|
|
21
33
|
}
|
|
34
|
+
setColor(value) {
|
|
35
|
+
const { r, g, b, a } = value;
|
|
36
|
+
this.mpEntity.color = new AltVShared.RGBA(r, g, b, a);
|
|
37
|
+
}
|
|
38
|
+
setRotation(value) {
|
|
39
|
+
this.mpEntity.rot = new Vector3(value);
|
|
40
|
+
}
|
|
22
41
|
}
|
|
23
42
|
exports.AltVMarker = AltVMarker;
|
|
@@ -13,6 +13,7 @@ export declare class AltVPlayer extends AltVEntity<Player> implements IPlayer {
|
|
|
13
13
|
get heading(): number;
|
|
14
14
|
get health(): number;
|
|
15
15
|
get armour(): number;
|
|
16
|
+
get isDead(): boolean;
|
|
16
17
|
get ip(): string;
|
|
17
18
|
get serial(): string;
|
|
18
19
|
get vehicle(): AltVVehicle | null;
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { IWorldObject, IWorldObjectOptions } from "../worldObject";
|
|
2
|
+
import { IMarkerType } from "./IMarkersManager";
|
|
3
|
+
import { IRGBA, IVector3D } from "../../../common/utils";
|
|
2
4
|
export interface IMarkerOptions extends IWorldObjectOptions {
|
|
5
|
+
type: IMarkerType;
|
|
6
|
+
scale: number;
|
|
7
|
+
color: IRGBA;
|
|
8
|
+
rotation: IVector3D;
|
|
3
9
|
}
|
|
4
10
|
export interface IMarker extends IWorldObject {
|
|
11
|
+
get markerType(): IMarkerType;
|
|
5
12
|
get visible(): boolean;
|
|
6
13
|
get scale(): number;
|
|
14
|
+
get color(): IRGBA;
|
|
15
|
+
get rotation(): IVector3D;
|
|
7
16
|
setVisible(value: boolean): void;
|
|
8
17
|
setScale(value: number): void;
|
|
18
|
+
setColor(value: IRGBA): void;
|
|
19
|
+
setRotation(value: IVector3D): void;
|
|
9
20
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { IEntityCreateOptions } from "../entity";
|
|
2
1
|
import { IMarker } from "./IMarker";
|
|
3
|
-
import { IWorldObjectsManager } from "../worldObject";
|
|
4
|
-
import { IRGBA } from "../../../common/utils";
|
|
2
|
+
import { IWorldObjectCreateOptions, IWorldObjectsManager } from "../worldObject";
|
|
3
|
+
import { IRGBA, IVector3D } from "../../../common/utils";
|
|
5
4
|
export declare enum IMarkerType {
|
|
6
5
|
MarkerCone = 0,
|
|
7
6
|
MarkerCylinder = 1,
|
|
@@ -49,10 +48,11 @@ export declare enum IMarkerType {
|
|
|
49
48
|
MarkerBoxes = 43,
|
|
50
49
|
MarkerPitLane = 44
|
|
51
50
|
}
|
|
52
|
-
export interface IMarkerCreateOptions extends
|
|
51
|
+
export interface IMarkerCreateOptions extends IWorldObjectCreateOptions {
|
|
53
52
|
type: IMarkerType;
|
|
54
53
|
scale: number;
|
|
55
54
|
color: IRGBA;
|
|
55
|
+
rotation: IVector3D;
|
|
56
56
|
}
|
|
57
57
|
export interface IMarkersManager extends IWorldObjectsManager<IMarker> {
|
|
58
58
|
create(options: IMarkerCreateOptions): IMarker;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IBaseObject, BaseObjectType } from "../../common/baseObject/IBaseObject";
|
|
2
|
+
import { IVector3D } from "../../../common/utils/math/Vectors";
|
|
3
|
+
export interface IMockBaseObjectOptions {
|
|
4
|
+
id: number;
|
|
5
|
+
type: BaseObjectType;
|
|
6
|
+
position: IVector3D;
|
|
7
|
+
dimension?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class MockBaseObject implements IBaseObject {
|
|
10
|
+
readonly id: number;
|
|
11
|
+
readonly type: BaseObjectType;
|
|
12
|
+
readonly position: IVector3D;
|
|
13
|
+
readonly dimension: number;
|
|
14
|
+
protected _exists: boolean;
|
|
15
|
+
protected constructor(options: IMockBaseObjectOptions);
|
|
16
|
+
get isExists(): boolean;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockBaseObject = void 0;
|
|
4
|
+
class MockBaseObject {
|
|
5
|
+
id;
|
|
6
|
+
type;
|
|
7
|
+
position;
|
|
8
|
+
dimension;
|
|
9
|
+
_exists;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.id = options.id;
|
|
12
|
+
this.type = options.type;
|
|
13
|
+
this.position = options.position;
|
|
14
|
+
this.dimension = options.dimension ?? 0;
|
|
15
|
+
this._exists = true;
|
|
16
|
+
}
|
|
17
|
+
get isExists() {
|
|
18
|
+
return this._exists;
|
|
19
|
+
}
|
|
20
|
+
destroy() {
|
|
21
|
+
this._exists = false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.MockBaseObject = MockBaseObject;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IBaseObjectsIterator } from "../../common/baseObject/IBaseObjectsIterator";
|
|
2
|
+
import { MockBaseObject } from "./MockBaseObject";
|
|
3
|
+
export declare class MockBaseObjectsIterator<T extends MockBaseObject> implements IBaseObjectsIterator<T> {
|
|
4
|
+
protected readonly _baseObjects: ReadonlyMap<number, T>;
|
|
5
|
+
constructor(baseObjects: ReadonlyMap<number, T>);
|
|
6
|
+
all(): IterableIterator<T>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockBaseObjectsIterator = void 0;
|
|
4
|
+
class MockBaseObjectsIterator {
|
|
5
|
+
_baseObjects;
|
|
6
|
+
constructor(baseObjects) {
|
|
7
|
+
this._baseObjects = baseObjects;
|
|
8
|
+
}
|
|
9
|
+
all() {
|
|
10
|
+
return this._baseObjects.values();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.MockBaseObjectsIterator = MockBaseObjectsIterator;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IBaseObjectsManager, IBaseObjectsManagerOptions } from "../../common/baseObject/IBaseObjectsManager";
|
|
2
|
+
import { BaseObjectType } from "../../common/baseObject/IBaseObject";
|
|
3
|
+
import { MockBaseObject } from "./MockBaseObject";
|
|
4
|
+
import { MockBaseObjectsIterator } from "./MockBaseObjectsIterator";
|
|
5
|
+
export interface IMockBaseObjectsManagerOptions extends IBaseObjectsManagerOptions {
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class MockBaseObjectsManager<T extends MockBaseObject> implements IBaseObjectsManager<T> {
|
|
8
|
+
protected readonly _baseObjects: Map<number, T>;
|
|
9
|
+
protected readonly _baseObjectsType: `${BaseObjectType}`;
|
|
10
|
+
protected readonly _iterator: MockBaseObjectsIterator<T>;
|
|
11
|
+
protected get baseObjects(): ReadonlyMap<number, T>;
|
|
12
|
+
get iterator(): MockBaseObjectsIterator<T>;
|
|
13
|
+
protected constructor(options: IMockBaseObjectsManagerOptions);
|
|
14
|
+
getByID(id: number): T;
|
|
15
|
+
findByID(id: number): T | null;
|
|
16
|
+
protected registerBaseObject(baseObject: T): void;
|
|
17
|
+
protected unregisterBaseObject(baseObject: T): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockBaseObjectsManager = void 0;
|
|
4
|
+
const MockBaseObjectsIterator_1 = require("./MockBaseObjectsIterator");
|
|
5
|
+
const RockMod_1 = require("../../../RockMod");
|
|
6
|
+
class MockBaseObjectsManager {
|
|
7
|
+
_baseObjects;
|
|
8
|
+
_baseObjectsType;
|
|
9
|
+
_iterator;
|
|
10
|
+
get baseObjects() {
|
|
11
|
+
return this._baseObjects;
|
|
12
|
+
}
|
|
13
|
+
get iterator() {
|
|
14
|
+
return this._iterator;
|
|
15
|
+
}
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this._baseObjects = new Map();
|
|
18
|
+
this._baseObjectsType = options.baseObjectsType;
|
|
19
|
+
this._iterator = new MockBaseObjectsIterator_1.MockBaseObjectsIterator(this._baseObjects);
|
|
20
|
+
}
|
|
21
|
+
getByID(id) {
|
|
22
|
+
const baseObject = this.findByID(id);
|
|
23
|
+
if (!baseObject) {
|
|
24
|
+
throw new Error(`BaseObject [${this._baseObjectsType}] with id ${id} not found`);
|
|
25
|
+
}
|
|
26
|
+
return baseObject;
|
|
27
|
+
}
|
|
28
|
+
findByID(id) {
|
|
29
|
+
const baseObject = this._baseObjects.get(id);
|
|
30
|
+
return baseObject ?? null;
|
|
31
|
+
}
|
|
32
|
+
registerBaseObject(baseObject) {
|
|
33
|
+
if (this._baseObjects.has(baseObject.id)) {
|
|
34
|
+
throw new Error(`BaseObject [${this._baseObjectsType}] with id ${baseObject.id} already exists`);
|
|
35
|
+
}
|
|
36
|
+
this._baseObjects.set(baseObject.id, baseObject);
|
|
37
|
+
RockMod_1.RockMod.instance.net.events.emit("rm::entityCreated", baseObject);
|
|
38
|
+
}
|
|
39
|
+
unregisterBaseObject(baseObject) {
|
|
40
|
+
if (!this._baseObjects.delete(baseObject.id)) {
|
|
41
|
+
throw new Error(`BaseObject [${this._baseObjectsType}] with id ${baseObject.id} not found`);
|
|
42
|
+
}
|
|
43
|
+
RockMod_1.RockMod.instance.net.events.emit("rm::entityDestroyed", baseObject);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.MockBaseObjectsManager = MockBaseObjectsManager;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IBlip, IBlipColor, IBlipSprite } from "../../common/blip/IBlip";
|
|
2
|
+
import { MockWorldObject, IMockWorldObjectOptions } from "../worldObject/MockWorldObject";
|
|
3
|
+
export interface IMockBlipOptions extends IMockWorldObjectOptions {
|
|
4
|
+
alpha: number;
|
|
5
|
+
color: number;
|
|
6
|
+
drawDistance: number;
|
|
7
|
+
name: string;
|
|
8
|
+
rotation: number;
|
|
9
|
+
scale: number;
|
|
10
|
+
shortRange: boolean;
|
|
11
|
+
sprite: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class MockBlip extends MockWorldObject implements IBlip {
|
|
14
|
+
private _name;
|
|
15
|
+
private _sprite;
|
|
16
|
+
private _color;
|
|
17
|
+
private _alpha;
|
|
18
|
+
private readonly _scale;
|
|
19
|
+
private readonly _drawDistance;
|
|
20
|
+
private readonly _shortRange;
|
|
21
|
+
private readonly _rotation;
|
|
22
|
+
get name(): string;
|
|
23
|
+
get sprite(): IBlipSprite;
|
|
24
|
+
get color(): IBlipColor;
|
|
25
|
+
get alpha(): number;
|
|
26
|
+
get scale(): number;
|
|
27
|
+
get drawDistance(): number;
|
|
28
|
+
get shortRange(): boolean;
|
|
29
|
+
get rotation(): number;
|
|
30
|
+
constructor(options: IMockBlipOptions);
|
|
31
|
+
setName(value: string): void;
|
|
32
|
+
setSprite(value: IBlipSprite): void;
|
|
33
|
+
setColor(value: IBlipColor): void;
|
|
34
|
+
setAlpha(value: number): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockBlip = void 0;
|
|
4
|
+
const MockWorldObject_1 = require("../worldObject/MockWorldObject");
|
|
5
|
+
class MockBlip extends MockWorldObject_1.MockWorldObject {
|
|
6
|
+
_name;
|
|
7
|
+
_sprite;
|
|
8
|
+
_color;
|
|
9
|
+
_alpha;
|
|
10
|
+
_scale;
|
|
11
|
+
_drawDistance;
|
|
12
|
+
_shortRange;
|
|
13
|
+
_rotation;
|
|
14
|
+
get name() {
|
|
15
|
+
return this._name;
|
|
16
|
+
}
|
|
17
|
+
get sprite() {
|
|
18
|
+
return this._sprite;
|
|
19
|
+
}
|
|
20
|
+
get color() {
|
|
21
|
+
return this._color;
|
|
22
|
+
}
|
|
23
|
+
get alpha() {
|
|
24
|
+
return this._alpha;
|
|
25
|
+
}
|
|
26
|
+
get scale() {
|
|
27
|
+
return this._scale;
|
|
28
|
+
}
|
|
29
|
+
get drawDistance() {
|
|
30
|
+
return this._drawDistance;
|
|
31
|
+
}
|
|
32
|
+
get shortRange() {
|
|
33
|
+
return this._shortRange;
|
|
34
|
+
}
|
|
35
|
+
get rotation() {
|
|
36
|
+
return this._rotation;
|
|
37
|
+
}
|
|
38
|
+
constructor(options) {
|
|
39
|
+
super(options);
|
|
40
|
+
this._name = options.name;
|
|
41
|
+
this._sprite = options.sprite;
|
|
42
|
+
this._color = options.color;
|
|
43
|
+
this._alpha = options.alpha;
|
|
44
|
+
this._scale = options.scale;
|
|
45
|
+
this._drawDistance = options.drawDistance;
|
|
46
|
+
this._shortRange = options.shortRange;
|
|
47
|
+
this._rotation = options.rotation;
|
|
48
|
+
}
|
|
49
|
+
setName(value) {
|
|
50
|
+
this._name = value;
|
|
51
|
+
}
|
|
52
|
+
setSprite(value) {
|
|
53
|
+
this._sprite = value;
|
|
54
|
+
}
|
|
55
|
+
setColor(value) {
|
|
56
|
+
this._color = value;
|
|
57
|
+
}
|
|
58
|
+
setAlpha(value) {
|
|
59
|
+
this._alpha = value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.MockBlip = MockBlip;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IBlipCreateOptions, IBlipsManager } from "../../common/blip/IBlipsManager";
|
|
2
|
+
import { MockWorldObjectsManager } from "../worldObject/MockWorldObjectsManager";
|
|
3
|
+
import { MockBlip } from "./MockBlip";
|
|
4
|
+
export interface IMockBlipCreateOptions extends IBlipCreateOptions {
|
|
5
|
+
}
|
|
6
|
+
export declare class MockBlipsManager extends MockWorldObjectsManager<MockBlip> implements IBlipsManager {
|
|
7
|
+
constructor();
|
|
8
|
+
create(options: IMockBlipCreateOptions): MockBlip;
|
|
9
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockBlipsManager = void 0;
|
|
4
|
+
const MockWorldObjectsManager_1 = require("../worldObject/MockWorldObjectsManager");
|
|
5
|
+
const MockBlip_1 = require("./MockBlip");
|
|
6
|
+
const common_1 = require("../../common");
|
|
7
|
+
class MockBlipsManager extends MockWorldObjectsManager_1.MockWorldObjectsManager {
|
|
8
|
+
constructor() {
|
|
9
|
+
super({
|
|
10
|
+
baseObjectsType: "blip",
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
create(options) {
|
|
14
|
+
const { alpha = 255, drawDistance = 30, shortRange = false, sprite, scale = 1, color = 1, name = "Blip", position, dimension, rotation = 0, } = options;
|
|
15
|
+
const blip = new MockBlip_1.MockBlip({
|
|
16
|
+
id: 0,
|
|
17
|
+
type: common_1.BaseObjectType.Blip,
|
|
18
|
+
alpha,
|
|
19
|
+
drawDistance,
|
|
20
|
+
shortRange,
|
|
21
|
+
sprite,
|
|
22
|
+
scale,
|
|
23
|
+
color,
|
|
24
|
+
name,
|
|
25
|
+
position,
|
|
26
|
+
dimension,
|
|
27
|
+
rotation,
|
|
28
|
+
});
|
|
29
|
+
this.registerBaseObject(blip);
|
|
30
|
+
return blip;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.MockBlipsManager = MockBlipsManager;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ICircleColshape } from "../../common";
|
|
2
|
+
import { IMockColshapeOptions, MockColshape } from "./MockColshape";
|
|
3
|
+
export interface IMockCircleColshapeCreateOptions extends IMockColshapeOptions {
|
|
4
|
+
range: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class MockCircleColshape extends MockColshape implements ICircleColshape {
|
|
7
|
+
constructor(options: IMockCircleColshapeCreateOptions);
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockCircleColshape = void 0;
|
|
4
|
+
const MockColshape_1 = require("./MockColshape");
|
|
5
|
+
class MockCircleColshape extends MockColshape_1.MockColshape {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(options);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.MockCircleColshape = MockCircleColshape;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IColshape } from "../../common/colshape/IColshape";
|
|
2
|
+
import { MockWorldObject, IMockWorldObjectOptions } from "../worldObject/MockWorldObject";
|
|
3
|
+
export interface IMockColshapeOptions extends IMockWorldObjectOptions {
|
|
4
|
+
}
|
|
5
|
+
export declare abstract class MockColshape extends MockWorldObject implements IColshape {
|
|
6
|
+
protected constructor(options: IMockColshapeOptions);
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockColshape = void 0;
|
|
4
|
+
const MockWorldObject_1 = require("../worldObject/MockWorldObject");
|
|
5
|
+
class MockColshape extends MockWorldObject_1.MockWorldObject {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(options);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.MockColshape = MockColshape;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ICircleColshapeCreateOptions, IColshapesManager, ICuboidColshapeCreateOptions, ICylinderColshapeCreateOptions, IRectangleColshapeCreateOptions, ISphereColshapeCreateOptions } from "../../common";
|
|
2
|
+
import { MockWorldObjectsManager } from "../worldObject/MockWorldObjectsManager";
|
|
3
|
+
import { MockCircleColshape } from "./MockCircleColshape";
|
|
4
|
+
import { MockCuboidColshape } from "./MockCuboidColshape";
|
|
5
|
+
import { MockCylinderColshape } from "./MockCylinderColshape";
|
|
6
|
+
import { MockRectangleColshape } from "./MockRectangleColshape";
|
|
7
|
+
import { MockSphereColshape } from "./MockSphereColshape";
|
|
8
|
+
import { MockColshape } from "./MockColshape";
|
|
9
|
+
export interface IMockCircleColshapeCreateOptions extends ICircleColshapeCreateOptions {
|
|
10
|
+
}
|
|
11
|
+
export interface IMockCuboidColshapeCreateOptions extends ICuboidColshapeCreateOptions {
|
|
12
|
+
}
|
|
13
|
+
export interface IMockCylinderColshapeCreateOptions extends ICylinderColshapeCreateOptions {
|
|
14
|
+
}
|
|
15
|
+
export interface IMockRectangleColshapeCreateOptions extends IRectangleColshapeCreateOptions {
|
|
16
|
+
}
|
|
17
|
+
export interface IMockSphereColshapeCreateOptions extends ISphereColshapeCreateOptions {
|
|
18
|
+
}
|
|
19
|
+
export declare class MockColshapesManager extends MockWorldObjectsManager<MockColshape> implements IColshapesManager {
|
|
20
|
+
private _nextId;
|
|
21
|
+
constructor();
|
|
22
|
+
createCircle(options: IMockCircleColshapeCreateOptions): MockCircleColshape;
|
|
23
|
+
createCuboid(options: IMockCuboidColshapeCreateOptions): MockCuboidColshape;
|
|
24
|
+
createCylinder(options: IMockCylinderColshapeCreateOptions): MockCylinderColshape;
|
|
25
|
+
createRectangle(options: IMockRectangleColshapeCreateOptions): MockRectangleColshape;
|
|
26
|
+
createSphere(options: IMockSphereColshapeCreateOptions): MockSphereColshape;
|
|
27
|
+
}
|