rock-mod 0.5.1 → 0.6.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 +21 -21
- package/dist/client/entities/common/baseObject/IBaseObject.d.ts +12 -0
- package/dist/client/entities/common/baseObject/IBaseObject.js +7 -0
- package/dist/client/entities/common/baseObject/IBaseObjectsIterator.d.ts +4 -0
- package/dist/client/entities/common/baseObject/IBaseObjectsIterator.js +2 -0
- package/dist/client/entities/common/baseObject/IBaseObjectsManager.d.ts +12 -0
- package/dist/client/entities/common/baseObject/IBaseObjectsManager.js +2 -0
- package/dist/client/entities/common/baseObject/index.d.ts +3 -0
- package/dist/client/entities/common/baseObject/index.js +19 -0
- package/dist/client/entities/common/index.d.ts +1 -0
- package/dist/client/entities/common/index.js +17 -0
- package/dist/server/entities/altv/baseObject/AltVBaseObject.js +1 -1
- package/dist/server/entities/altv/baseObject/AltVBaseObjectsManager.js +7 -1
- package/dist/server/entities/ragemp/baseObject/RageBaseObject.js +6 -1
- package/dist/server/entities/ragemp/baseObject/RageBaseObjectsManager.js +6 -0
- package/package.json +62 -62
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Carter
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Carter
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BaseObject = AltVClient.BaseObject;
|
|
2
|
+
export declare enum BaseObjectType {
|
|
3
|
+
Player = "player"
|
|
4
|
+
}
|
|
5
|
+
export interface IBaseObjectOptions {
|
|
6
|
+
mpEntity: EntityMp | BaseObject;
|
|
7
|
+
}
|
|
8
|
+
export interface IBaseObject {
|
|
9
|
+
get id(): number;
|
|
10
|
+
get type(): BaseObjectType;
|
|
11
|
+
get isExists(): boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseObjectType = void 0;
|
|
4
|
+
var BaseObjectType;
|
|
5
|
+
(function (BaseObjectType) {
|
|
6
|
+
BaseObjectType["Player"] = "player";
|
|
7
|
+
})(BaseObjectType || (exports.BaseObjectType = BaseObjectType = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseObjectType, IBaseObject } from "./IBaseObject";
|
|
2
|
+
import { IBaseObjectsIterator } from "./IBaseObjectsIterator";
|
|
3
|
+
export interface IBaseObjectsManagerOptions {
|
|
4
|
+
baseObjectsType: `${BaseObjectType}`;
|
|
5
|
+
}
|
|
6
|
+
export interface IBaseObjectCreateOptions {
|
|
7
|
+
}
|
|
8
|
+
export interface IBaseObjectsManager<T extends IBaseObject> {
|
|
9
|
+
get iterator(): IBaseObjectsIterator<T>;
|
|
10
|
+
getByID(id: number): T;
|
|
11
|
+
findByID(id: number): T | null;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./IBaseObject"), exports);
|
|
18
|
+
__exportStar(require("./IBaseObjectsIterator"), exports);
|
|
19
|
+
__exportStar(require("./IBaseObjectsManager"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./baseObject";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./baseObject"), exports);
|
|
@@ -17,6 +17,12 @@ class AltVBaseObjectsManager {
|
|
|
17
17
|
this._baseObjects = new Map();
|
|
18
18
|
this._baseObjectsType = options.baseObjectsType;
|
|
19
19
|
this._iterator = new AltVBaseObjectsIterator_1.AltVBaseObjectsIterator(this._baseObjects);
|
|
20
|
+
AltVServer.on("removeEntity", (mpEntity) => {
|
|
21
|
+
if (mpEntity.type === this._baseObjectsType) {
|
|
22
|
+
const baseObject = this.getByID(mpEntity.id);
|
|
23
|
+
this.unregisterBaseObject(baseObject);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
20
26
|
}
|
|
21
27
|
getByID(id) {
|
|
22
28
|
const baseObject = this.findByID(id);
|
|
@@ -40,7 +46,7 @@ class AltVBaseObjectsManager {
|
|
|
40
46
|
if (!this._baseObjects.delete(baseObject.id)) {
|
|
41
47
|
throw new Error(`BaseObject [${this._baseObjectsType}] with id ${baseObject.id} not found`);
|
|
42
48
|
}
|
|
43
|
-
RockMod_1.RockMod.instance.net.events.emit("rm::
|
|
49
|
+
RockMod_1.RockMod.instance.net.events.emit("rm::entityDestroyed", baseObject);
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
exports.AltVBaseObjectsManager = AltVBaseObjectsManager;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RageBaseObject = void 0;
|
|
4
|
+
// RAGEMP BUG: event 'entityDestroyed' is not callable
|
|
5
|
+
const unsupportedRageEntityTypes = new Set(["blip", "colshape"]);
|
|
4
6
|
class RageBaseObject {
|
|
5
7
|
_mpEntity;
|
|
6
8
|
get id() {
|
|
@@ -19,7 +21,10 @@ class RageBaseObject {
|
|
|
19
21
|
this._mpEntity = options.mpEntity;
|
|
20
22
|
}
|
|
21
23
|
destroy() {
|
|
22
|
-
|
|
24
|
+
this._mpEntity.destroy();
|
|
25
|
+
if (unsupportedRageEntityTypes.has(this.type)) {
|
|
26
|
+
mp.events.call("entityDestroyed", this._mpEntity);
|
|
27
|
+
}
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
exports.RageBaseObject = RageBaseObject;
|
|
@@ -17,6 +17,12 @@ class RageBaseObjectsManager {
|
|
|
17
17
|
this._baseObjects = new Map();
|
|
18
18
|
this._baseObjectsType = options.baseObjectsType;
|
|
19
19
|
this._iterator = new RageBaseObjectsIterator_1.RageBaseObjectsIterator(this._baseObjects);
|
|
20
|
+
mp.events.add("entityDestroyed", (mpEntity) => {
|
|
21
|
+
if (mpEntity.type === this._baseObjectsType) {
|
|
22
|
+
const baseObject = this.getByID(mpEntity.id);
|
|
23
|
+
this.unregisterBaseObject(baseObject);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
20
26
|
}
|
|
21
27
|
getByID(id) {
|
|
22
28
|
const baseObject = this.findByID(id);
|
package/package.json
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "rock-mod",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Rock-Mod is a powerful framework designed for creating and managing mods for Grand Theft Auto (GTA) games.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "npx tsx src/server/index.ts",
|
|
9
|
-
"build": "npm run build:server && npm run build:client",
|
|
10
|
-
"build:server": "tsc --project src/server/tsconfig.json",
|
|
11
|
-
"build:client": "tsc --project src/client/tsconfig.json",
|
|
12
|
-
"lint:server:check": "cd src/server && eslint . --ext .ts",
|
|
13
|
-
"lint:server:fix": "cd src/server && eslint . --ext .ts --fix",
|
|
14
|
-
"lint:client:check": "cd src/client && eslint . --ext .ts",
|
|
15
|
-
"lint:client:fix": "cd src/client && eslint . --ext .ts --fix",
|
|
16
|
-
"lint:check": "npm run lint:server:check && npm run lint:client:check",
|
|
17
|
-
"lint:fix": "npm run lint:server:fix && npm run lint:client:fix",
|
|
18
|
-
"format:check": "prettier --check .",
|
|
19
|
-
"format:fix": "prettier --write .",
|
|
20
|
-
"type:server:check": "tsc --noEmit --project src/server/tsconfig.json",
|
|
21
|
-
"type:client:check": "tsc --noEmit --project src/client/tsconfig.json",
|
|
22
|
-
"type:check": "npm run type:server:check && npm run type:client:check",
|
|
23
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
24
|
-
"prepare": "husky"
|
|
25
|
-
},
|
|
26
|
-
"husky": {
|
|
27
|
-
"hooks": {
|
|
28
|
-
"pre-commit": "lint-staged"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"lint-staged": {
|
|
32
|
-
"*.{ts,json,md}": [
|
|
33
|
-
"npm run lint:fix",
|
|
34
|
-
"npm run format:fix"
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
"files": [
|
|
38
|
-
"dist"
|
|
39
|
-
],
|
|
40
|
-
"keywords": [
|
|
41
|
-
"gta",
|
|
42
|
-
"multiplayer",
|
|
43
|
-
"altv",
|
|
44
|
-
"ragemp"
|
|
45
|
-
],
|
|
46
|
-
"author": "xvetal",
|
|
47
|
-
"license": "MIT",
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
50
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
51
|
-
"eslint": "^8.57.1",
|
|
52
|
-
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
53
|
-
"eslint-config-prettier": "^9.1.0",
|
|
54
|
-
"eslint-import-resolver-typescript": "^3.6.3",
|
|
55
|
-
"eslint-plugin-import": "^2.30.0",
|
|
56
|
-
"eslint-plugin-prettier": "^5.2.1",
|
|
57
|
-
"husky": "^9.1.6",
|
|
58
|
-
"lint-staged": "^15.2.10",
|
|
59
|
-
"prettier": "^3.3.3",
|
|
60
|
-
"typescript": "^5.6.2"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "rock-mod",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Rock-Mod is a powerful framework designed for creating and managing mods for Grand Theft Auto (GTA) games.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "npx tsx src/server/index.ts",
|
|
9
|
+
"build": "npm run build:server && npm run build:client",
|
|
10
|
+
"build:server": "tsc --project src/server/tsconfig.json",
|
|
11
|
+
"build:client": "tsc --project src/client/tsconfig.json",
|
|
12
|
+
"lint:server:check": "cd src/server && eslint . --ext .ts",
|
|
13
|
+
"lint:server:fix": "cd src/server && eslint . --ext .ts --fix",
|
|
14
|
+
"lint:client:check": "cd src/client && eslint . --ext .ts",
|
|
15
|
+
"lint:client:fix": "cd src/client && eslint . --ext .ts --fix",
|
|
16
|
+
"lint:check": "npm run lint:server:check && npm run lint:client:check",
|
|
17
|
+
"lint:fix": "npm run lint:server:fix && npm run lint:client:fix",
|
|
18
|
+
"format:check": "prettier --check .",
|
|
19
|
+
"format:fix": "prettier --write .",
|
|
20
|
+
"type:server:check": "tsc --noEmit --project src/server/tsconfig.json",
|
|
21
|
+
"type:client:check": "tsc --noEmit --project src/client/tsconfig.json",
|
|
22
|
+
"type:check": "npm run type:server:check && npm run type:client:check",
|
|
23
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
24
|
+
"prepare": "husky"
|
|
25
|
+
},
|
|
26
|
+
"husky": {
|
|
27
|
+
"hooks": {
|
|
28
|
+
"pre-commit": "lint-staged"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"lint-staged": {
|
|
32
|
+
"*.{ts,json,md}": [
|
|
33
|
+
"npm run lint:fix",
|
|
34
|
+
"npm run format:fix"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"keywords": [
|
|
41
|
+
"gta",
|
|
42
|
+
"multiplayer",
|
|
43
|
+
"altv",
|
|
44
|
+
"ragemp"
|
|
45
|
+
],
|
|
46
|
+
"author": "xvetal",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
50
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
51
|
+
"eslint": "^8.57.1",
|
|
52
|
+
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
53
|
+
"eslint-config-prettier": "^9.1.0",
|
|
54
|
+
"eslint-import-resolver-typescript": "^3.6.3",
|
|
55
|
+
"eslint-plugin-import": "^2.30.0",
|
|
56
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
57
|
+
"husky": "^9.1.6",
|
|
58
|
+
"lint-staged": "^15.2.10",
|
|
59
|
+
"prettier": "^3.3.3",
|
|
60
|
+
"typescript": "^5.6.2"
|
|
61
|
+
}
|
|
62
|
+
}
|