rock-mod 0.21.0 → 0.23.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/dist/client/entities/ccmp/blip/CCMPBlip.d.ts +38 -0
- package/dist/client/entities/ccmp/blip/CCMPBlip.js +118 -0
- package/dist/client/entities/ccmp/blip/CCMPBlipsManager.d.ts +27 -0
- package/dist/client/entities/ccmp/blip/CCMPBlipsManager.js +191 -0
- package/dist/client/entities/ccmp/camera/CCMPCamera.d.ts +1 -1
- package/dist/client/entities/ccmp/camera/CCMPCamera.js +1 -1
- package/dist/client/entities/ccmp/camera/CCMPCameraManager.js +2 -1
- package/dist/client/entities/ccmp/colshape/CCMPColshape.d.ts +26 -0
- package/dist/client/entities/ccmp/colshape/CCMPColshape.js +83 -0
- package/dist/client/entities/ccmp/colshape/CCMPColshapesManager.d.ts +31 -0
- package/dist/client/entities/ccmp/colshape/CCMPColshapesManager.js +193 -0
- package/dist/client/entities/ccmp/marker/CCMPMarker.d.ts +34 -0
- package/dist/client/entities/ccmp/marker/CCMPMarker.js +109 -0
- package/dist/client/entities/ccmp/marker/CCMPMarkersManager.d.ts +27 -0
- package/dist/client/entities/ccmp/marker/CCMPMarkersManager.js +180 -0
- package/dist/client/entities/ccmp/object/CCMPObject.d.ts +50 -0
- package/dist/client/entities/ccmp/object/CCMPObject.js +149 -0
- package/dist/client/entities/ccmp/object/CCMPObjectsManager.d.ts +27 -0
- package/dist/client/entities/ccmp/object/CCMPObjectsManager.js +177 -0
- package/dist/client/entities/ccmp/ped/CCMPPed.d.ts +1 -1
- package/dist/client/entities/ccmp/ped/CCMPPed.js +21 -7
- package/dist/client/entities/ccmp/ped/CCMPPedsManager.d.ts +7 -0
- package/dist/client/entities/ccmp/ped/CCMPPedsManager.js +82 -10
- package/dist/client/entities/ccmp/player/CCMPPlayer.d.ts +15 -17
- package/dist/client/entities/ccmp/player/CCMPPlayer.js +86 -87
- package/dist/client/entities/ccmp/player/CCMPPlayersManager.d.ts +4 -3
- package/dist/client/entities/ccmp/player/CCMPPlayersManager.js +20 -7
- package/dist/client/entities/ccmp/vehicle/CCMPVehicle.d.ts +102 -0
- package/dist/client/entities/ccmp/vehicle/CCMPVehicle.js +311 -0
- package/dist/client/entities/ccmp/vehicle/CCMPVehiclesManager.d.ts +11 -48
- package/dist/client/entities/ccmp/vehicle/CCMPVehiclesManager.js +154 -75
- package/dist/client/entities/common/baseObject/IBaseObject.d.ts +2 -1
- package/dist/client/entities/ragemp/entity/RageEntity.d.ts +4 -0
- package/dist/client/entities/ragemp/entity/RageEntity.js +34 -2
- package/dist/client/factories/ccmp/CCMPManagersFactory.d.ts +9 -7
- package/dist/client/factories/ccmp/CCMPManagersFactory.js +62 -22
- package/dist/client/game/ccmp/chat/CCMPChatManager.d.ts +2 -22
- package/dist/client/game/ccmp/chat/CCMPChatManager.js +6 -34
- package/dist/client/game/ccmp/storage/CCMPStorageManager.d.ts +0 -18
- package/dist/client/game/ccmp/storage/CCMPStorageManager.js +4 -36
- package/dist/client/game/ccmp/ui/CCMPUiManager.d.ts +0 -29
- package/dist/client/game/ccmp/ui/CCMPUiManager.js +5 -41
- package/dist/client/net/ccmp/CCMPNetManager.d.ts +0 -7
- package/dist/client/net/ccmp/CCMPNetManager.js +0 -26
- package/dist/client/net/ccmp/dataHandler/CCMPDataHandler.d.ts +2 -2
- package/dist/client/net/ccmp/dataHandler/CCMPDataHandler.js +2 -2
- package/dist/client/net/ccmp/events/CCMPEventsBridge.d.ts +3 -1
- package/dist/client/net/ccmp/events/CCMPEventsBridge.js +33 -3
- package/dist/client/net/ccmp/events/CCMPSyncedMetaBridge.d.ts +21 -16
- package/dist/client/net/ccmp/events/CCMPSyncedMetaBridge.js +32 -22
- package/dist/client/net/common/dataHandler/IDataHandler.d.ts +2 -2
- package/dist/client/net/common/events/types.d.ts +4 -4
- package/dist/client/net/ragemp/dataHandler/RageDataHandler.d.ts +2 -2
- package/dist/server/entities/altv/colshape/AltVColshape.d.ts +2 -0
- package/dist/server/entities/altv/colshape/AltVColshape.js +6 -0
- package/dist/server/entities/ccmp/baseObject/CCMPBaseObjectsManager.js +4 -4
- package/dist/server/entities/ccmp/blip/CCMPBlip.d.ts +2 -0
- package/dist/server/entities/ccmp/blip/CCMPBlip.js +6 -0
- package/dist/server/entities/ccmp/colshape/CCMPColshape.d.ts +2 -0
- package/dist/server/entities/ccmp/colshape/CCMPColshape.js +6 -0
- package/dist/server/entities/ccmp/marker/CCMPMarker.d.ts +2 -0
- package/dist/server/entities/ccmp/marker/CCMPMarker.js +6 -0
- package/dist/server/entities/ccmp/object/CCMPObject.d.ts +1 -1
- package/dist/server/entities/ccmp/object/CCMPObject.js +3 -5
- package/dist/server/entities/ccmp/object/CCMPObjectsManager.js +1 -2
- package/dist/server/entities/ccmp/player/CCMPPlayersManager.js +15 -0
- package/dist/server/entities/ccmp/vehicle/CCMPVehicle.d.ts +29 -15
- package/dist/server/entities/ccmp/vehicle/CCMPVehicle.js +87 -44
- package/dist/server/entities/common/colshape/IColshape.d.ts +2 -0
- package/dist/server/entities/mock/colshape/MockColshape.d.ts +3 -0
- package/dist/server/entities/mock/colshape/MockColshape.js +8 -0
- package/dist/server/entities/ragemp/colshape/RageColshape.d.ts +2 -0
- package/dist/server/entities/ragemp/colshape/RageColshape.js +6 -0
- package/dist/server/entities/ragemp/entity/RageEntity.d.ts +5 -1
- package/dist/server/entities/ragemp/entity/RageEntity.js +17 -1
- package/dist/server/entities/ragemp/object/RageObjectsManager.js +1 -1
- package/dist/server/entities/ragemp/ped/RagePedsManager.js +1 -1
- package/dist/server/entities/ragemp/vehicle/RageVehiclesManager.js +1 -1
- package/dist/server/net/ccmp/CCMPNetManager.js +0 -5
- package/dist/server/net/ccmp/events/CCMPEventsManager.d.ts +6 -2
- package/package.json +2 -2
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { ClientInternalEventName } from "../../../net/common/events/types";
|
|
2
|
+
import { CCMPColshape } from "./CCMPColshape";
|
|
3
|
+
export class CCMPColshapesManager {
|
|
4
|
+
constructor(_events) {
|
|
5
|
+
this._events = _events;
|
|
6
|
+
this._colshapes = new Map();
|
|
7
|
+
this._colshapesByRemoteId = new Map();
|
|
8
|
+
this._iterator = {
|
|
9
|
+
all: () => this._filter(() => true),
|
|
10
|
+
dimension: (value) => this._filter((colshape) => colshape.dimension === value),
|
|
11
|
+
range2D: (center, range) => this._filter((colshape) => {
|
|
12
|
+
const position = colshape.position;
|
|
13
|
+
const squaredDistance = (position.x - center.x) ** 2 + (position.y - center.y) ** 2;
|
|
14
|
+
return squaredDistance <= range * range;
|
|
15
|
+
}),
|
|
16
|
+
range3D: (center, range) => this._filter((colshape) => colshape.position.isInRange(center, range)),
|
|
17
|
+
};
|
|
18
|
+
this._registerLifecycleEvents();
|
|
19
|
+
this.syncWithMpPool();
|
|
20
|
+
}
|
|
21
|
+
createCircle(options) {
|
|
22
|
+
const ccmpColshape = ccmp.colshapes.createCircle(options.position, options.range, {
|
|
23
|
+
dimension: options.dimension,
|
|
24
|
+
});
|
|
25
|
+
return this._register(ccmpColshape);
|
|
26
|
+
}
|
|
27
|
+
createCuboid(options) {
|
|
28
|
+
const ccmpColshape = ccmp.colshapes.createCuboid(options.position, { x: options.width, y: options.depth, z: options.height }, { dimension: options.dimension });
|
|
29
|
+
return this._register(ccmpColshape);
|
|
30
|
+
}
|
|
31
|
+
createCylinder(options) {
|
|
32
|
+
const ccmpColshape = ccmp.colshapes.createCylinder(options.position, options.range, options.height, {
|
|
33
|
+
dimension: options.dimension,
|
|
34
|
+
});
|
|
35
|
+
return this._register(ccmpColshape);
|
|
36
|
+
}
|
|
37
|
+
createRectangle(options) {
|
|
38
|
+
void options;
|
|
39
|
+
throw new Error("CCMPColshapesManager.createRectangle: not supported by CCMP");
|
|
40
|
+
}
|
|
41
|
+
createSphere(options) {
|
|
42
|
+
const ccmpColshape = ccmp.colshapes.createSphere(options.position, options.range, {
|
|
43
|
+
dimension: options.dimension,
|
|
44
|
+
});
|
|
45
|
+
return this._register(ccmpColshape);
|
|
46
|
+
}
|
|
47
|
+
syncWithMpPool() {
|
|
48
|
+
this._pruneDestroyed();
|
|
49
|
+
for (const ccmpColshape of ccmp.colshapes.all) {
|
|
50
|
+
this._register(ccmpColshape);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
registerById(id) {
|
|
54
|
+
const existingColshape = this.findByID(id);
|
|
55
|
+
if (existingColshape) {
|
|
56
|
+
return existingColshape;
|
|
57
|
+
}
|
|
58
|
+
const ccmpColshape = ccmp.colshapes.getById(id);
|
|
59
|
+
if (!ccmpColshape) {
|
|
60
|
+
throw new Error(`CCMPColshapesManager.registerById(${id}): colshape not found.`);
|
|
61
|
+
}
|
|
62
|
+
return this._register(ccmpColshape);
|
|
63
|
+
}
|
|
64
|
+
unregisterById(id) {
|
|
65
|
+
return this.deleteById(id);
|
|
66
|
+
}
|
|
67
|
+
findByID(id) {
|
|
68
|
+
var _a;
|
|
69
|
+
const colshape = (_a = this._colshapes.get(id)) !== null && _a !== void 0 ? _a : null;
|
|
70
|
+
if (colshape && !colshape.isExists) {
|
|
71
|
+
this._unregister(colshape);
|
|
72
|
+
}
|
|
73
|
+
else if (colshape) {
|
|
74
|
+
return colshape;
|
|
75
|
+
}
|
|
76
|
+
const ccmpColshape = ccmp.colshapes.getById(id);
|
|
77
|
+
if (!ccmpColshape) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return this._register(ccmpColshape);
|
|
81
|
+
}
|
|
82
|
+
getByID(id) {
|
|
83
|
+
const colshape = this.findByID(id);
|
|
84
|
+
if (!colshape) {
|
|
85
|
+
throw new Error(`CCMPColshapesManager.getByID(${id}): colshape not found.`);
|
|
86
|
+
}
|
|
87
|
+
return colshape;
|
|
88
|
+
}
|
|
89
|
+
findByRemoteID(remoteId) {
|
|
90
|
+
var _a;
|
|
91
|
+
const colshape = (_a = this._colshapesByRemoteId.get(remoteId)) !== null && _a !== void 0 ? _a : null;
|
|
92
|
+
if (colshape && !colshape.isExists) {
|
|
93
|
+
this._unregister(colshape);
|
|
94
|
+
}
|
|
95
|
+
else if (colshape) {
|
|
96
|
+
return colshape;
|
|
97
|
+
}
|
|
98
|
+
const ccmpColshape = ccmp.colshapes.getByRemoteId(remoteId);
|
|
99
|
+
if (!ccmpColshape) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return this._register(ccmpColshape);
|
|
103
|
+
}
|
|
104
|
+
getByRemoteID(remoteId) {
|
|
105
|
+
const colshape = this.findByRemoteID(remoteId);
|
|
106
|
+
if (!colshape) {
|
|
107
|
+
throw new Error(`CCMPColshapesManager.getByRemoteID(${remoteId}): colshape not found.`);
|
|
108
|
+
}
|
|
109
|
+
return colshape;
|
|
110
|
+
}
|
|
111
|
+
deleteById(id) {
|
|
112
|
+
const colshape = this.getByID(id);
|
|
113
|
+
colshape.destroy();
|
|
114
|
+
return colshape;
|
|
115
|
+
}
|
|
116
|
+
get iterator() {
|
|
117
|
+
return this._iterator;
|
|
118
|
+
}
|
|
119
|
+
_register(ccmpColshape) {
|
|
120
|
+
const existingColshape = this._findRegistered(ccmpColshape);
|
|
121
|
+
if (existingColshape && existingColshape.isExists) {
|
|
122
|
+
return existingColshape;
|
|
123
|
+
}
|
|
124
|
+
if (existingColshape) {
|
|
125
|
+
this._unregister(existingColshape);
|
|
126
|
+
}
|
|
127
|
+
const colshape = new CCMPColshape(ccmpColshape, (destroyedColshape) => {
|
|
128
|
+
this._unregister(destroyedColshape);
|
|
129
|
+
});
|
|
130
|
+
this._colshapes.set(colshape.id, colshape);
|
|
131
|
+
if (colshape.remoteId !== null) {
|
|
132
|
+
this._colshapesByRemoteId.set(colshape.remoteId, colshape);
|
|
133
|
+
}
|
|
134
|
+
return colshape;
|
|
135
|
+
}
|
|
136
|
+
_unregister(colshape) {
|
|
137
|
+
this._colshapes.delete(colshape.id);
|
|
138
|
+
if (colshape.remoteId !== null) {
|
|
139
|
+
this._colshapesByRemoteId.delete(colshape.remoteId);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
_findRegistered(ccmpColshape) {
|
|
143
|
+
var _a, _b, _c;
|
|
144
|
+
return ((_c = (_b = (ccmpColshape.remoteId === null ? null : ((_a = this._colshapesByRemoteId.get(ccmpColshape.remoteId)) !== null && _a !== void 0 ? _a : null))) !== null && _b !== void 0 ? _b : this._colshapes.get(ccmpColshape.id)) !== null && _c !== void 0 ? _c : null);
|
|
145
|
+
}
|
|
146
|
+
_registerLifecycleEvents() {
|
|
147
|
+
ccmp.on("colshapeCreated", (ccmpColshape) => {
|
|
148
|
+
if (!ccmpColshape)
|
|
149
|
+
return;
|
|
150
|
+
const colshape = this._register(ccmpColshape);
|
|
151
|
+
this._events.emitInternal(ClientInternalEventName.EntityCreated, colshape);
|
|
152
|
+
});
|
|
153
|
+
ccmp.on("colshapeDestroyed", (ccmpColshape) => {
|
|
154
|
+
var _a;
|
|
155
|
+
if (!ccmpColshape)
|
|
156
|
+
return;
|
|
157
|
+
const colshape = (_a = this._findRegistered(ccmpColshape)) !== null && _a !== void 0 ? _a : this._register(ccmpColshape);
|
|
158
|
+
this._events.emitInternal(ClientInternalEventName.EntityDestroyed, colshape);
|
|
159
|
+
this._unregister(colshape);
|
|
160
|
+
});
|
|
161
|
+
ccmp.on("colshapeStreamIn", (ccmpColshape) => {
|
|
162
|
+
if (!ccmpColshape)
|
|
163
|
+
return;
|
|
164
|
+
const colshape = this._register(ccmpColshape);
|
|
165
|
+
this._events.emitInternal(ClientInternalEventName.EntityStreamIn, colshape);
|
|
166
|
+
});
|
|
167
|
+
ccmp.on("colshapeStreamOut", (ccmpColshape) => {
|
|
168
|
+
var _a;
|
|
169
|
+
if (!ccmpColshape)
|
|
170
|
+
return;
|
|
171
|
+
const colshape = (_a = this._findRegistered(ccmpColshape)) !== null && _a !== void 0 ? _a : this._register(ccmpColshape);
|
|
172
|
+
this._events.emitInternal(ClientInternalEventName.EntityStreamOut, colshape);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
*_filter(predicate) {
|
|
176
|
+
for (const colshape of this._colshapes.values()) {
|
|
177
|
+
if (!colshape.isExists) {
|
|
178
|
+
this._unregister(colshape);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (predicate(colshape)) {
|
|
182
|
+
yield colshape;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
_pruneDestroyed() {
|
|
187
|
+
for (const colshape of this._colshapes.values()) {
|
|
188
|
+
if (!colshape.isExists) {
|
|
189
|
+
this._unregister(colshape);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseObjectType, type IMarkerType } from "../../../../shared/entities";
|
|
2
|
+
import { type IRGBA, type IVector3D, Vector3D } from "../../../../shared/common/utils";
|
|
3
|
+
import { type Marker as CcmpMarker } from "@classic-mp/types/client";
|
|
4
|
+
import { type IMarker } from "../../common/marker/IMarker";
|
|
5
|
+
export declare class CCMPMarker implements IMarker {
|
|
6
|
+
private readonly _ccmpMarker;
|
|
7
|
+
private readonly _onDestroy;
|
|
8
|
+
private _destroyed;
|
|
9
|
+
constructor(_ccmpMarker: CcmpMarker, _onDestroy?: (marker: CCMPMarker) => void);
|
|
10
|
+
get id(): number;
|
|
11
|
+
get remoteId(): number | null;
|
|
12
|
+
get type(): BaseObjectType;
|
|
13
|
+
get isExists(): boolean;
|
|
14
|
+
get handle(): number;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
get position(): Vector3D;
|
|
17
|
+
get dimension(): number;
|
|
18
|
+
setPosition(_value: IVector3D): void;
|
|
19
|
+
setDimension(_value: number): void;
|
|
20
|
+
setCoords(_xPos: number, _yPos: number, _zPos: number, _xAxis: boolean, _yAxis: boolean, _zAxis: boolean, _clearArea: boolean): void;
|
|
21
|
+
get markerType(): IMarkerType;
|
|
22
|
+
get visible(): boolean;
|
|
23
|
+
get rotation(): Vector3D;
|
|
24
|
+
getVariable(name: string): unknown | null;
|
|
25
|
+
getSyncedMeta(key: string): unknown | undefined;
|
|
26
|
+
hasSyncedMeta(key: string): boolean;
|
|
27
|
+
getSyncedMetaKeys(): readonly string[];
|
|
28
|
+
setVisible(_value: boolean): void;
|
|
29
|
+
setRotation(_value: IVector3D): void;
|
|
30
|
+
get scale(): number;
|
|
31
|
+
setScale(_value: number): void;
|
|
32
|
+
get color(): IRGBA;
|
|
33
|
+
setColor(_value: IRGBA): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { BaseObjectType } from "../../../../shared/entities";
|
|
3
|
+
import { RGBA, Vector3D } from "../../../../shared/common/utils";
|
|
4
|
+
const notImplemented = (memberName) => {
|
|
5
|
+
throw new Error(`CCMPMarker.${memberName}: not implemented`);
|
|
6
|
+
};
|
|
7
|
+
export class CCMPMarker {
|
|
8
|
+
constructor(_ccmpMarker, _onDestroy = () => { }) {
|
|
9
|
+
this._ccmpMarker = _ccmpMarker;
|
|
10
|
+
this._onDestroy = _onDestroy;
|
|
11
|
+
this._destroyed = false;
|
|
12
|
+
}
|
|
13
|
+
get id() {
|
|
14
|
+
return this._ccmpMarker.id;
|
|
15
|
+
}
|
|
16
|
+
get remoteId() {
|
|
17
|
+
return this._ccmpMarker.remoteId;
|
|
18
|
+
}
|
|
19
|
+
get type() {
|
|
20
|
+
return BaseObjectType.Marker;
|
|
21
|
+
}
|
|
22
|
+
get isExists() {
|
|
23
|
+
return !this._destroyed && this._ccmpMarker.isExists;
|
|
24
|
+
}
|
|
25
|
+
get handle() {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
destroy() {
|
|
29
|
+
if (this._destroyed)
|
|
30
|
+
return;
|
|
31
|
+
this._destroyed = true;
|
|
32
|
+
this._ccmpMarker.destroy();
|
|
33
|
+
this._onDestroy(this);
|
|
34
|
+
}
|
|
35
|
+
get position() {
|
|
36
|
+
const { x, y, z } = this._ccmpMarker.position;
|
|
37
|
+
return new Vector3D(x, y, z);
|
|
38
|
+
}
|
|
39
|
+
get dimension() {
|
|
40
|
+
return this._ccmpMarker.dimension;
|
|
41
|
+
}
|
|
42
|
+
setPosition(_value) {
|
|
43
|
+
notImplemented("setPosition");
|
|
44
|
+
}
|
|
45
|
+
setDimension(_value) {
|
|
46
|
+
notImplemented("setDimension");
|
|
47
|
+
}
|
|
48
|
+
setCoords(_xPos, _yPos, _zPos, _xAxis, _yAxis, _zAxis, _clearArea) {
|
|
49
|
+
notImplemented("setCoords");
|
|
50
|
+
}
|
|
51
|
+
get markerType() {
|
|
52
|
+
return this._ccmpMarker.markerType;
|
|
53
|
+
}
|
|
54
|
+
get visible() {
|
|
55
|
+
return this._ccmpMarker.visible;
|
|
56
|
+
}
|
|
57
|
+
get rotation() {
|
|
58
|
+
const { x, y, z } = this._ccmpMarker.rotation;
|
|
59
|
+
return new Vector3D(x, y, z);
|
|
60
|
+
}
|
|
61
|
+
getVariable(name) {
|
|
62
|
+
const remoteId = this.remoteId;
|
|
63
|
+
if (remoteId === null) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const value = ccmp.entities.getStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Marker, remoteId, name);
|
|
67
|
+
return value === undefined ? null : value;
|
|
68
|
+
}
|
|
69
|
+
getSyncedMeta(key) {
|
|
70
|
+
const remoteId = this.remoteId;
|
|
71
|
+
if (remoteId === null) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
return ccmp.entities.getStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Marker, remoteId, key);
|
|
75
|
+
}
|
|
76
|
+
hasSyncedMeta(key) {
|
|
77
|
+
const remoteId = this.remoteId;
|
|
78
|
+
if (remoteId === null) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return ccmp.entities.hasStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Marker, remoteId, key);
|
|
82
|
+
}
|
|
83
|
+
getSyncedMetaKeys() {
|
|
84
|
+
const remoteId = this.remoteId;
|
|
85
|
+
if (remoteId === null) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
return ccmp.entities.getStreamSyncedMetaKeys(ccmp.entities.ENTITY_TYPE.Marker, remoteId);
|
|
89
|
+
}
|
|
90
|
+
setVisible(_value) {
|
|
91
|
+
notImplemented("setVisible");
|
|
92
|
+
}
|
|
93
|
+
setRotation(_value) {
|
|
94
|
+
notImplemented("setRotation");
|
|
95
|
+
}
|
|
96
|
+
get scale() {
|
|
97
|
+
return this._ccmpMarker.scale;
|
|
98
|
+
}
|
|
99
|
+
setScale(_value) {
|
|
100
|
+
notImplemented("setScale");
|
|
101
|
+
}
|
|
102
|
+
get color() {
|
|
103
|
+
const { r, g, b, a } = this._ccmpMarker.color;
|
|
104
|
+
return new RGBA(r, g, b, a);
|
|
105
|
+
}
|
|
106
|
+
setColor(_value) {
|
|
107
|
+
notImplemented("setColor");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type CCMPEventsManager } from "../../../net/ccmp/events/CCMPEventsManager";
|
|
2
|
+
import { type IMarkerCreateOptions, type IMarkersManager } from "../../common/marker/IMarkersManager";
|
|
3
|
+
import { type IWorldObjectsIterator } from "../../common/worldObject/IWorldObjectsIterator";
|
|
4
|
+
import { CCMPMarker } from "./CCMPMarker";
|
|
5
|
+
export declare class CCMPMarkersManager implements IMarkersManager {
|
|
6
|
+
private readonly _events;
|
|
7
|
+
private readonly _markers;
|
|
8
|
+
private readonly _markersByRemoteId;
|
|
9
|
+
private readonly _iterator;
|
|
10
|
+
constructor(_events: CCMPEventsManager);
|
|
11
|
+
create(options: IMarkerCreateOptions): CCMPMarker;
|
|
12
|
+
syncWithMpPool(): void;
|
|
13
|
+
registerById(id: number): CCMPMarker;
|
|
14
|
+
unregisterById(id: number): CCMPMarker;
|
|
15
|
+
findByID(id: number): CCMPMarker | null;
|
|
16
|
+
getByID(id: number): CCMPMarker;
|
|
17
|
+
findByRemoteID(remoteId: number): CCMPMarker | null;
|
|
18
|
+
getByRemoteID(remoteId: number): CCMPMarker;
|
|
19
|
+
deleteById(id: number): CCMPMarker;
|
|
20
|
+
get iterator(): IWorldObjectsIterator<CCMPMarker>;
|
|
21
|
+
private _register;
|
|
22
|
+
private _unregister;
|
|
23
|
+
private _findRegistered;
|
|
24
|
+
private _registerLifecycleEvents;
|
|
25
|
+
private _filter;
|
|
26
|
+
private _pruneDestroyed;
|
|
27
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { ClientInternalEventName } from "../../../net/common/events/types";
|
|
2
|
+
import { CCMPMarker } from "./CCMPMarker";
|
|
3
|
+
export class CCMPMarkersManager {
|
|
4
|
+
constructor(_events) {
|
|
5
|
+
this._events = _events;
|
|
6
|
+
this._markers = new Map();
|
|
7
|
+
this._markersByRemoteId = new Map();
|
|
8
|
+
this._iterator = {
|
|
9
|
+
all: () => this._filter(() => true),
|
|
10
|
+
dimension: (value) => this._filter((marker) => marker.dimension === value),
|
|
11
|
+
range2D: (center, range) => this._filter((marker) => {
|
|
12
|
+
const position = marker.position;
|
|
13
|
+
const squaredDistance = (position.x - center.x) ** 2 + (position.y - center.y) ** 2;
|
|
14
|
+
return squaredDistance <= range * range;
|
|
15
|
+
}),
|
|
16
|
+
range3D: (center, range) => this._filter((marker) => marker.position.isInRange(center, range)),
|
|
17
|
+
};
|
|
18
|
+
this._registerLifecycleEvents();
|
|
19
|
+
this.syncWithMpPool();
|
|
20
|
+
}
|
|
21
|
+
create(options) {
|
|
22
|
+
const { r, g, b, a } = options.color;
|
|
23
|
+
const ccmpMarker = ccmp.markers.create(options.type, options.position, {
|
|
24
|
+
dimension: options.dimension,
|
|
25
|
+
rotation: options.rotation,
|
|
26
|
+
scale: options.scale,
|
|
27
|
+
color: { r, g, b, a: a !== null && a !== void 0 ? a : 255 },
|
|
28
|
+
});
|
|
29
|
+
if (!ccmpMarker) {
|
|
30
|
+
throw new Error(`CCMPMarkersManager.create: ccmp.markers.create failed for marker type "${options.type}"`);
|
|
31
|
+
}
|
|
32
|
+
return this._register(ccmpMarker);
|
|
33
|
+
}
|
|
34
|
+
syncWithMpPool() {
|
|
35
|
+
this._pruneDestroyed();
|
|
36
|
+
for (const ccmpMarker of ccmp.markers.all) {
|
|
37
|
+
this._register(ccmpMarker);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
registerById(id) {
|
|
41
|
+
const existingMarker = this.findByID(id);
|
|
42
|
+
if (existingMarker) {
|
|
43
|
+
return existingMarker;
|
|
44
|
+
}
|
|
45
|
+
const ccmpMarker = ccmp.markers.getById(id);
|
|
46
|
+
if (!ccmpMarker) {
|
|
47
|
+
throw new Error(`CCMPMarkersManager.registerById(${id}): marker not found.`);
|
|
48
|
+
}
|
|
49
|
+
return this._register(ccmpMarker);
|
|
50
|
+
}
|
|
51
|
+
unregisterById(id) {
|
|
52
|
+
return this.deleteById(id);
|
|
53
|
+
}
|
|
54
|
+
findByID(id) {
|
|
55
|
+
var _a;
|
|
56
|
+
const marker = (_a = this._markers.get(id)) !== null && _a !== void 0 ? _a : null;
|
|
57
|
+
if (marker && !marker.isExists) {
|
|
58
|
+
this._unregister(marker);
|
|
59
|
+
}
|
|
60
|
+
else if (marker) {
|
|
61
|
+
return marker;
|
|
62
|
+
}
|
|
63
|
+
const ccmpMarker = ccmp.markers.getById(id);
|
|
64
|
+
if (!ccmpMarker) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return this._register(ccmpMarker);
|
|
68
|
+
}
|
|
69
|
+
getByID(id) {
|
|
70
|
+
const marker = this.findByID(id);
|
|
71
|
+
if (!marker) {
|
|
72
|
+
throw new Error(`CCMPMarkersManager.getByID(${id}): marker not found.`);
|
|
73
|
+
}
|
|
74
|
+
return marker;
|
|
75
|
+
}
|
|
76
|
+
findByRemoteID(remoteId) {
|
|
77
|
+
var _a;
|
|
78
|
+
const marker = (_a = this._markersByRemoteId.get(remoteId)) !== null && _a !== void 0 ? _a : null;
|
|
79
|
+
if (marker && !marker.isExists) {
|
|
80
|
+
this._unregister(marker);
|
|
81
|
+
}
|
|
82
|
+
else if (marker) {
|
|
83
|
+
return marker;
|
|
84
|
+
}
|
|
85
|
+
const ccmpMarker = ccmp.markers.getByRemoteId(remoteId);
|
|
86
|
+
if (!ccmpMarker) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return this._register(ccmpMarker);
|
|
90
|
+
}
|
|
91
|
+
getByRemoteID(remoteId) {
|
|
92
|
+
const marker = this.findByRemoteID(remoteId);
|
|
93
|
+
if (!marker) {
|
|
94
|
+
throw new Error(`CCMPMarkersManager.getByRemoteID(${remoteId}): marker not found.`);
|
|
95
|
+
}
|
|
96
|
+
return marker;
|
|
97
|
+
}
|
|
98
|
+
deleteById(id) {
|
|
99
|
+
const marker = this.getByID(id);
|
|
100
|
+
marker.destroy();
|
|
101
|
+
return marker;
|
|
102
|
+
}
|
|
103
|
+
get iterator() {
|
|
104
|
+
return this._iterator;
|
|
105
|
+
}
|
|
106
|
+
_register(ccmpMarker) {
|
|
107
|
+
const existingMarker = this._findRegistered(ccmpMarker);
|
|
108
|
+
if (existingMarker && existingMarker.isExists) {
|
|
109
|
+
return existingMarker;
|
|
110
|
+
}
|
|
111
|
+
if (existingMarker) {
|
|
112
|
+
this._unregister(existingMarker);
|
|
113
|
+
}
|
|
114
|
+
const marker = new CCMPMarker(ccmpMarker, (destroyedMarker) => {
|
|
115
|
+
this._unregister(destroyedMarker);
|
|
116
|
+
});
|
|
117
|
+
this._markers.set(marker.id, marker);
|
|
118
|
+
if (marker.remoteId !== null) {
|
|
119
|
+
this._markersByRemoteId.set(marker.remoteId, marker);
|
|
120
|
+
}
|
|
121
|
+
return marker;
|
|
122
|
+
}
|
|
123
|
+
_unregister(marker) {
|
|
124
|
+
this._markers.delete(marker.id);
|
|
125
|
+
if (marker.remoteId !== null) {
|
|
126
|
+
this._markersByRemoteId.delete(marker.remoteId);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
_findRegistered(ccmpMarker) {
|
|
130
|
+
var _a, _b, _c;
|
|
131
|
+
return ((_c = (_b = (ccmpMarker.remoteId === null ? null : ((_a = this._markersByRemoteId.get(ccmpMarker.remoteId)) !== null && _a !== void 0 ? _a : null))) !== null && _b !== void 0 ? _b : this._markers.get(ccmpMarker.id)) !== null && _c !== void 0 ? _c : null);
|
|
132
|
+
}
|
|
133
|
+
_registerLifecycleEvents() {
|
|
134
|
+
ccmp.on("markerCreated", (ccmpMarker) => {
|
|
135
|
+
if (!ccmpMarker)
|
|
136
|
+
return;
|
|
137
|
+
const marker = this._register(ccmpMarker);
|
|
138
|
+
this._events.emitInternal(ClientInternalEventName.EntityCreated, marker);
|
|
139
|
+
});
|
|
140
|
+
ccmp.on("markerDestroyed", (ccmpMarker) => {
|
|
141
|
+
var _a;
|
|
142
|
+
if (!ccmpMarker)
|
|
143
|
+
return;
|
|
144
|
+
const marker = (_a = this._findRegistered(ccmpMarker)) !== null && _a !== void 0 ? _a : this._register(ccmpMarker);
|
|
145
|
+
this._events.emitInternal(ClientInternalEventName.EntityDestroyed, marker);
|
|
146
|
+
this._unregister(marker);
|
|
147
|
+
});
|
|
148
|
+
ccmp.on("markerStreamIn", (ccmpMarker) => {
|
|
149
|
+
if (!ccmpMarker)
|
|
150
|
+
return;
|
|
151
|
+
const marker = this._register(ccmpMarker);
|
|
152
|
+
this._events.emitInternal(ClientInternalEventName.EntityStreamIn, marker);
|
|
153
|
+
});
|
|
154
|
+
ccmp.on("markerStreamOut", (ccmpMarker) => {
|
|
155
|
+
var _a;
|
|
156
|
+
if (!ccmpMarker)
|
|
157
|
+
return;
|
|
158
|
+
const marker = (_a = this._findRegistered(ccmpMarker)) !== null && _a !== void 0 ? _a : this._register(ccmpMarker);
|
|
159
|
+
this._events.emitInternal(ClientInternalEventName.EntityStreamOut, marker);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
*_filter(predicate) {
|
|
163
|
+
for (const marker of this._markers.values()) {
|
|
164
|
+
if (!marker.isExists) {
|
|
165
|
+
this._unregister(marker);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (predicate(marker)) {
|
|
169
|
+
yield marker;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
_pruneDestroyed() {
|
|
174
|
+
for (const marker of this._markers.values()) {
|
|
175
|
+
if (!marker.isExists) {
|
|
176
|
+
this._unregister(marker);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Object as CcmpObject } from "@classic-mp/types/client";
|
|
2
|
+
import { BaseObjectType } from "../../../../shared/entities";
|
|
3
|
+
import { type IVector3D, Vector3D } from "../../../../shared/common/utils";
|
|
4
|
+
import { type IBaseObject } from "../../common/baseObject/IBaseObject";
|
|
5
|
+
import { type IObject } from "../../common/object/IObject";
|
|
6
|
+
export declare class CCMPObject implements IObject {
|
|
7
|
+
private readonly _ccmpObject;
|
|
8
|
+
private readonly _onDestroy;
|
|
9
|
+
private _destroyed;
|
|
10
|
+
constructor(_ccmpObject: CcmpObject, _onDestroy?: (object: CCMPObject) => void);
|
|
11
|
+
get id(): number;
|
|
12
|
+
get remoteId(): number | null;
|
|
13
|
+
get type(): BaseObjectType;
|
|
14
|
+
get isExists(): boolean;
|
|
15
|
+
get handle(): number;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
get position(): Vector3D;
|
|
18
|
+
get dimension(): number;
|
|
19
|
+
setPosition(value: IVector3D): void;
|
|
20
|
+
setDimension(value: number): void;
|
|
21
|
+
setCoords(xPos: number, yPos: number, zPos: number, xAxis: boolean, yAxis: boolean, zAxis: boolean, clearArea: boolean): void;
|
|
22
|
+
get model(): number;
|
|
23
|
+
get heading(): number;
|
|
24
|
+
setHeading(heading: number): void;
|
|
25
|
+
setModel(value: string): void;
|
|
26
|
+
get rotation(): Vector3D;
|
|
27
|
+
get forwardVector(): Vector3D;
|
|
28
|
+
setRotation(value: IVector3D): void;
|
|
29
|
+
freezePosition(freeze: boolean): void;
|
|
30
|
+
setCollision(collision: boolean, keepPhysics: boolean): void;
|
|
31
|
+
setInvincible(invincible: boolean): void;
|
|
32
|
+
setVisible(visible: boolean): void;
|
|
33
|
+
setAlpha(alpha: number): void;
|
|
34
|
+
get alpha(): number;
|
|
35
|
+
resetAlpha(): void;
|
|
36
|
+
getOffsetFromInWorldCoords(offsetX: number, offsetY: number, offsetZ: number): IVector3D;
|
|
37
|
+
getBoneIndexByName(boneName: string): number;
|
|
38
|
+
getWorldPositionOfBone(boneIndex: number): IVector3D;
|
|
39
|
+
getVariable(name: string): unknown | null;
|
|
40
|
+
getSyncedMeta(key: string): unknown | undefined;
|
|
41
|
+
hasSyncedMeta(key: string): boolean;
|
|
42
|
+
getSyncedMetaKeys(): readonly string[];
|
|
43
|
+
attachTo(entity: Handle, boneIndex: number, xPos: number, yPos: number, zPos: number, xRot: number, yRot: number, zRot: number, useSoftPinning: boolean, collision: boolean, isPed: boolean, vertexIndex: number, fixedRot: boolean): void;
|
|
44
|
+
isAttachedTo(entity: number): boolean;
|
|
45
|
+
attachToEntity(target: IBaseObject, boneIndex: number, offset: IVector3D, rotation: IVector3D, p9: boolean, useSoftPinning: boolean, collision: boolean, isPed: boolean, vertexIndex: number, fixedRot: boolean): void;
|
|
46
|
+
detach(useDetachVelocity: boolean, collision: boolean): void;
|
|
47
|
+
getSpeed(): number;
|
|
48
|
+
isPlayingAnim(dictionary: string, name: string, taskFlag: number): boolean;
|
|
49
|
+
private _normalizeHandle;
|
|
50
|
+
}
|