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,149 @@
|
|
|
1
|
+
import { BaseObjectType } from "../../../../shared/entities";
|
|
2
|
+
import { Vector3D } from "../../../../shared/common/utils";
|
|
3
|
+
export class CCMPObject {
|
|
4
|
+
constructor(_ccmpObject, _onDestroy = () => { }) {
|
|
5
|
+
this._ccmpObject = _ccmpObject;
|
|
6
|
+
this._onDestroy = _onDestroy;
|
|
7
|
+
this._destroyed = false;
|
|
8
|
+
}
|
|
9
|
+
get id() {
|
|
10
|
+
return this._ccmpObject.id;
|
|
11
|
+
}
|
|
12
|
+
get remoteId() {
|
|
13
|
+
return this._ccmpObject.remoteId;
|
|
14
|
+
}
|
|
15
|
+
get type() {
|
|
16
|
+
return BaseObjectType.Object;
|
|
17
|
+
}
|
|
18
|
+
get isExists() {
|
|
19
|
+
return !this._destroyed && this._ccmpObject.isExists;
|
|
20
|
+
}
|
|
21
|
+
get handle() {
|
|
22
|
+
return this._normalizeHandle(this._ccmpObject.handle);
|
|
23
|
+
}
|
|
24
|
+
destroy() {
|
|
25
|
+
if (this._destroyed)
|
|
26
|
+
return;
|
|
27
|
+
this._destroyed = true;
|
|
28
|
+
this._ccmpObject.destroy();
|
|
29
|
+
this._onDestroy(this);
|
|
30
|
+
}
|
|
31
|
+
get position() {
|
|
32
|
+
const { x, y, z } = this._ccmpObject.position;
|
|
33
|
+
return new Vector3D(x, y, z);
|
|
34
|
+
}
|
|
35
|
+
get dimension() {
|
|
36
|
+
return this._ccmpObject.dimension;
|
|
37
|
+
}
|
|
38
|
+
setPosition(value) {
|
|
39
|
+
this._ccmpObject.setPosition(value);
|
|
40
|
+
}
|
|
41
|
+
setDimension(value) {
|
|
42
|
+
this._ccmpObject.setDimension(value);
|
|
43
|
+
}
|
|
44
|
+
setCoords(xPos, yPos, zPos, xAxis, yAxis, zAxis, clearArea) {
|
|
45
|
+
this._ccmpObject.setCoords(xPos, yPos, zPos, xAxis, yAxis, zAxis, clearArea);
|
|
46
|
+
}
|
|
47
|
+
get model() {
|
|
48
|
+
return this._ccmpObject.model;
|
|
49
|
+
}
|
|
50
|
+
get heading() {
|
|
51
|
+
return this._ccmpObject.heading;
|
|
52
|
+
}
|
|
53
|
+
setHeading(heading) {
|
|
54
|
+
this._ccmpObject.setHeading(heading);
|
|
55
|
+
}
|
|
56
|
+
setModel(value) {
|
|
57
|
+
this._ccmpObject.setModel(value);
|
|
58
|
+
}
|
|
59
|
+
get rotation() {
|
|
60
|
+
const { x, y, z } = this._ccmpObject.rotation;
|
|
61
|
+
return new Vector3D(x, y, z);
|
|
62
|
+
}
|
|
63
|
+
get forwardVector() {
|
|
64
|
+
const { x, y, z } = this._ccmpObject.forwardVector;
|
|
65
|
+
return new Vector3D(x, y, z);
|
|
66
|
+
}
|
|
67
|
+
setRotation(value) {
|
|
68
|
+
this._ccmpObject.setRotation(value);
|
|
69
|
+
}
|
|
70
|
+
freezePosition(freeze) {
|
|
71
|
+
this._ccmpObject.freezePosition(freeze);
|
|
72
|
+
}
|
|
73
|
+
setCollision(collision, keepPhysics) {
|
|
74
|
+
this._ccmpObject.setCollision(collision, keepPhysics);
|
|
75
|
+
}
|
|
76
|
+
setInvincible(invincible) {
|
|
77
|
+
this._ccmpObject.setInvincible(invincible);
|
|
78
|
+
}
|
|
79
|
+
setVisible(visible) {
|
|
80
|
+
this._ccmpObject.setVisible(visible);
|
|
81
|
+
}
|
|
82
|
+
setAlpha(alpha) {
|
|
83
|
+
this._ccmpObject.setAlpha(alpha);
|
|
84
|
+
}
|
|
85
|
+
get alpha() {
|
|
86
|
+
return this._ccmpObject.alpha;
|
|
87
|
+
}
|
|
88
|
+
resetAlpha() {
|
|
89
|
+
this._ccmpObject.resetAlpha();
|
|
90
|
+
}
|
|
91
|
+
getOffsetFromInWorldCoords(offsetX, offsetY, offsetZ) {
|
|
92
|
+
const { x, y, z } = this._ccmpObject.getOffsetFromInWorldCoords(offsetX, offsetY, offsetZ);
|
|
93
|
+
return new Vector3D(x, y, z);
|
|
94
|
+
}
|
|
95
|
+
getBoneIndexByName(boneName) {
|
|
96
|
+
return this._ccmpObject.getBoneIndexByName(boneName);
|
|
97
|
+
}
|
|
98
|
+
getWorldPositionOfBone(boneIndex) {
|
|
99
|
+
const { x, y, z } = this._ccmpObject.getWorldPositionOfBone(boneIndex);
|
|
100
|
+
return new Vector3D(x, y, z);
|
|
101
|
+
}
|
|
102
|
+
getVariable(name) {
|
|
103
|
+
const remoteId = this.remoteId;
|
|
104
|
+
if (remoteId === null)
|
|
105
|
+
return null;
|
|
106
|
+
const value = ccmp.entities.getStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Object, remoteId, name);
|
|
107
|
+
return value === undefined ? null : value;
|
|
108
|
+
}
|
|
109
|
+
getSyncedMeta(key) {
|
|
110
|
+
const remoteId = this.remoteId;
|
|
111
|
+
if (remoteId === null)
|
|
112
|
+
return undefined;
|
|
113
|
+
return ccmp.entities.getStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Object, remoteId, key);
|
|
114
|
+
}
|
|
115
|
+
hasSyncedMeta(key) {
|
|
116
|
+
const remoteId = this.remoteId;
|
|
117
|
+
if (remoteId === null)
|
|
118
|
+
return false;
|
|
119
|
+
return ccmp.entities.hasStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Object, remoteId, key);
|
|
120
|
+
}
|
|
121
|
+
getSyncedMetaKeys() {
|
|
122
|
+
const remoteId = this.remoteId;
|
|
123
|
+
if (remoteId === null)
|
|
124
|
+
return [];
|
|
125
|
+
return ccmp.entities.getStreamSyncedMetaKeys(ccmp.entities.ENTITY_TYPE.Object, remoteId);
|
|
126
|
+
}
|
|
127
|
+
attachTo(entity, boneIndex, xPos, yPos, zPos, xRot, yRot, zRot, useSoftPinning, collision, isPed, vertexIndex, fixedRot) {
|
|
128
|
+
this._ccmpObject.attachTo(entity, boneIndex, xPos, yPos, zPos, xRot, yRot, zRot, useSoftPinning, collision, isPed, vertexIndex, fixedRot);
|
|
129
|
+
}
|
|
130
|
+
isAttachedTo(entity) {
|
|
131
|
+
return this._ccmpObject.isAttachedTo(entity);
|
|
132
|
+
}
|
|
133
|
+
attachToEntity(target, boneIndex, offset, rotation, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot) {
|
|
134
|
+
this._ccmpObject.attachToEntity(target, boneIndex, offset, rotation, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot);
|
|
135
|
+
}
|
|
136
|
+
detach(useDetachVelocity, collision) {
|
|
137
|
+
this._ccmpObject.detach(useDetachVelocity, collision);
|
|
138
|
+
}
|
|
139
|
+
getSpeed() {
|
|
140
|
+
return this._ccmpObject.getSpeed();
|
|
141
|
+
}
|
|
142
|
+
isPlayingAnim(dictionary, name, taskFlag) {
|
|
143
|
+
return this._ccmpObject.isPlayingAnim(dictionary, name, taskFlag);
|
|
144
|
+
}
|
|
145
|
+
_normalizeHandle(value) {
|
|
146
|
+
const handle = Number(value);
|
|
147
|
+
return Number.isFinite(handle) && handle > 0 ? Math.trunc(handle) : 0;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type CCMPEventsManager } from "../../../net/ccmp/events/CCMPEventsManager";
|
|
2
|
+
import { type IObjectCreateOptions, type IObjectsManager } from "../../common/object/IObjectsManager";
|
|
3
|
+
import { type IWorldObjectsIterator } from "../../common/worldObject/IWorldObjectsIterator";
|
|
4
|
+
import { CCMPObject } from "./CCMPObject";
|
|
5
|
+
export declare class CCMPObjectsManager implements IObjectsManager {
|
|
6
|
+
private readonly _events;
|
|
7
|
+
private readonly _objects;
|
|
8
|
+
private readonly _objectsByRemoteId;
|
|
9
|
+
private readonly _iterator;
|
|
10
|
+
constructor(_events: CCMPEventsManager);
|
|
11
|
+
create(options: IObjectCreateOptions): CCMPObject;
|
|
12
|
+
syncWithMpPool(): void;
|
|
13
|
+
registerById(id: number): CCMPObject;
|
|
14
|
+
unregisterById(id: number): CCMPObject;
|
|
15
|
+
findByID(id: number): CCMPObject | null;
|
|
16
|
+
getByID(id: number): CCMPObject;
|
|
17
|
+
findByRemoteID(remoteId: number): CCMPObject | null;
|
|
18
|
+
getByRemoteID(remoteId: number): CCMPObject;
|
|
19
|
+
deleteById(id: number): CCMPObject;
|
|
20
|
+
get iterator(): IWorldObjectsIterator<CCMPObject>;
|
|
21
|
+
private _register;
|
|
22
|
+
private _unregister;
|
|
23
|
+
private _findRegistered;
|
|
24
|
+
private _registerLifecycleEvents;
|
|
25
|
+
private _filter;
|
|
26
|
+
private _pruneDestroyed;
|
|
27
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { ClientInternalEventName } from "../../../net/common/events/types";
|
|
2
|
+
import { CCMPObject } from "./CCMPObject";
|
|
3
|
+
export class CCMPObjectsManager {
|
|
4
|
+
constructor(_events) {
|
|
5
|
+
this._events = _events;
|
|
6
|
+
this._objects = new Map();
|
|
7
|
+
this._objectsByRemoteId = new Map();
|
|
8
|
+
this._iterator = {
|
|
9
|
+
all: () => this._filter(() => true),
|
|
10
|
+
dimension: (value) => this._filter((object) => object.dimension === value),
|
|
11
|
+
range2D: (center, range) => this._filter((object) => {
|
|
12
|
+
const position = object.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((object) => object.position.isInRange(center, range)),
|
|
17
|
+
};
|
|
18
|
+
this._registerLifecycleEvents();
|
|
19
|
+
this.syncWithMpPool();
|
|
20
|
+
}
|
|
21
|
+
create(options) {
|
|
22
|
+
const ccmpObject = ccmp.objects.create(options.model, options.position, options.rotation, {
|
|
23
|
+
dimension: options.dimension,
|
|
24
|
+
alpha: options.alpha,
|
|
25
|
+
});
|
|
26
|
+
if (!ccmpObject) {
|
|
27
|
+
throw new Error(`CCMPObjectsManager.create: ccmp.objects.create failed for model "${options.model}"`);
|
|
28
|
+
}
|
|
29
|
+
return this._register(ccmpObject);
|
|
30
|
+
}
|
|
31
|
+
syncWithMpPool() {
|
|
32
|
+
this._pruneDestroyed();
|
|
33
|
+
for (const ccmpObject of ccmp.objects.all) {
|
|
34
|
+
this._register(ccmpObject);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
registerById(id) {
|
|
38
|
+
const existingObject = this.findByID(id);
|
|
39
|
+
if (existingObject) {
|
|
40
|
+
return existingObject;
|
|
41
|
+
}
|
|
42
|
+
const ccmpObject = ccmp.objects.getById(id);
|
|
43
|
+
if (!ccmpObject) {
|
|
44
|
+
throw new Error(`CCMPObjectsManager.registerById(${id}): object not found.`);
|
|
45
|
+
}
|
|
46
|
+
return this._register(ccmpObject);
|
|
47
|
+
}
|
|
48
|
+
unregisterById(id) {
|
|
49
|
+
return this.deleteById(id);
|
|
50
|
+
}
|
|
51
|
+
findByID(id) {
|
|
52
|
+
var _a;
|
|
53
|
+
const object = (_a = this._objects.get(id)) !== null && _a !== void 0 ? _a : null;
|
|
54
|
+
if (object && !object.isExists) {
|
|
55
|
+
this._unregister(object);
|
|
56
|
+
}
|
|
57
|
+
else if (object) {
|
|
58
|
+
return object;
|
|
59
|
+
}
|
|
60
|
+
const ccmpObject = ccmp.objects.getById(id);
|
|
61
|
+
if (!ccmpObject) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return this._register(ccmpObject);
|
|
65
|
+
}
|
|
66
|
+
getByID(id) {
|
|
67
|
+
const object = this.findByID(id);
|
|
68
|
+
if (!object) {
|
|
69
|
+
throw new Error(`CCMPObjectsManager.getByID(${id}): object not found.`);
|
|
70
|
+
}
|
|
71
|
+
return object;
|
|
72
|
+
}
|
|
73
|
+
findByRemoteID(remoteId) {
|
|
74
|
+
var _a;
|
|
75
|
+
const object = (_a = this._objectsByRemoteId.get(remoteId)) !== null && _a !== void 0 ? _a : null;
|
|
76
|
+
if (object && !object.isExists) {
|
|
77
|
+
this._unregister(object);
|
|
78
|
+
}
|
|
79
|
+
else if (object) {
|
|
80
|
+
return object;
|
|
81
|
+
}
|
|
82
|
+
const ccmpObject = ccmp.objects.getByRemoteId(remoteId);
|
|
83
|
+
if (!ccmpObject) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return this._register(ccmpObject);
|
|
87
|
+
}
|
|
88
|
+
getByRemoteID(remoteId) {
|
|
89
|
+
const object = this.findByRemoteID(remoteId);
|
|
90
|
+
if (!object) {
|
|
91
|
+
throw new Error(`CCMPObjectsManager.getByRemoteID(${remoteId}): object not found.`);
|
|
92
|
+
}
|
|
93
|
+
return object;
|
|
94
|
+
}
|
|
95
|
+
deleteById(id) {
|
|
96
|
+
const object = this.getByID(id);
|
|
97
|
+
object.destroy();
|
|
98
|
+
return object;
|
|
99
|
+
}
|
|
100
|
+
get iterator() {
|
|
101
|
+
return this._iterator;
|
|
102
|
+
}
|
|
103
|
+
_register(ccmpObject) {
|
|
104
|
+
const existingObject = this._findRegistered(ccmpObject);
|
|
105
|
+
if (existingObject && existingObject.isExists) {
|
|
106
|
+
return existingObject;
|
|
107
|
+
}
|
|
108
|
+
if (existingObject) {
|
|
109
|
+
this._unregister(existingObject);
|
|
110
|
+
}
|
|
111
|
+
const object = new CCMPObject(ccmpObject, (destroyedObject) => {
|
|
112
|
+
this._unregister(destroyedObject);
|
|
113
|
+
});
|
|
114
|
+
this._objects.set(object.id, object);
|
|
115
|
+
if (object.remoteId !== null) {
|
|
116
|
+
this._objectsByRemoteId.set(object.remoteId, object);
|
|
117
|
+
}
|
|
118
|
+
return object;
|
|
119
|
+
}
|
|
120
|
+
_unregister(object) {
|
|
121
|
+
this._objects.delete(object.id);
|
|
122
|
+
if (object.remoteId !== null) {
|
|
123
|
+
this._objectsByRemoteId.delete(object.remoteId);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
_findRegistered(ccmpObject) {
|
|
127
|
+
var _a, _b, _c;
|
|
128
|
+
return ((_c = (_b = (ccmpObject.remoteId === null ? null : ((_a = this._objectsByRemoteId.get(ccmpObject.remoteId)) !== null && _a !== void 0 ? _a : null))) !== null && _b !== void 0 ? _b : this._objects.get(ccmpObject.id)) !== null && _c !== void 0 ? _c : null);
|
|
129
|
+
}
|
|
130
|
+
_registerLifecycleEvents() {
|
|
131
|
+
ccmp.on("objectCreated", (ccmpObject) => {
|
|
132
|
+
if (!ccmpObject)
|
|
133
|
+
return;
|
|
134
|
+
const object = this._register(ccmpObject);
|
|
135
|
+
this._events.emitInternal(ClientInternalEventName.EntityCreated, object);
|
|
136
|
+
});
|
|
137
|
+
ccmp.on("objectDestroyed", (ccmpObject) => {
|
|
138
|
+
var _a;
|
|
139
|
+
if (!ccmpObject)
|
|
140
|
+
return;
|
|
141
|
+
const object = (_a = this._findRegistered(ccmpObject)) !== null && _a !== void 0 ? _a : this._register(ccmpObject);
|
|
142
|
+
this._events.emitInternal(ClientInternalEventName.EntityDestroyed, object);
|
|
143
|
+
this._unregister(object);
|
|
144
|
+
});
|
|
145
|
+
ccmp.on("objectStreamIn", (ccmpObject) => {
|
|
146
|
+
if (!ccmpObject)
|
|
147
|
+
return;
|
|
148
|
+
const object = this._register(ccmpObject);
|
|
149
|
+
this._events.emitInternal(ClientInternalEventName.EntityStreamIn, object);
|
|
150
|
+
});
|
|
151
|
+
ccmp.on("objectStreamOut", (ccmpObject) => {
|
|
152
|
+
var _a;
|
|
153
|
+
if (!ccmpObject)
|
|
154
|
+
return;
|
|
155
|
+
const object = (_a = this._findRegistered(ccmpObject)) !== null && _a !== void 0 ? _a : this._register(ccmpObject);
|
|
156
|
+
this._events.emitInternal(ClientInternalEventName.EntityStreamOut, object);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
*_filter(predicate) {
|
|
160
|
+
for (const object of this._objects.values()) {
|
|
161
|
+
if (!object.isExists) {
|
|
162
|
+
this._unregister(object);
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (predicate(object)) {
|
|
166
|
+
yield object;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
_pruneDestroyed() {
|
|
171
|
+
for (const object of this._objects.values()) {
|
|
172
|
+
if (!object.isExists) {
|
|
173
|
+
this._unregister(object);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -9,7 +9,7 @@ export declare class CCMPPed implements IPed {
|
|
|
9
9
|
private _destroyed;
|
|
10
10
|
constructor(_ccmpPed: CcmpPed, _onDestroy?: (ped: CCMPPed) => void);
|
|
11
11
|
get id(): number;
|
|
12
|
-
get remoteId(): number;
|
|
12
|
+
get remoteId(): number | null;
|
|
13
13
|
get type(): BaseObjectType;
|
|
14
14
|
get isExists(): boolean;
|
|
15
15
|
get handle(): number;
|
|
@@ -101,19 +101,33 @@ export class CCMPPed {
|
|
|
101
101
|
return new Vector3D(x, y, z);
|
|
102
102
|
}
|
|
103
103
|
getVariable(name) {
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const remoteId = this.remoteId;
|
|
105
|
+
if (remoteId === null) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const value = ccmp.entities.getStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Ped, remoteId, name);
|
|
109
|
+
return value === undefined ? null : value;
|
|
106
110
|
}
|
|
107
111
|
getSyncedMeta(key) {
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
const remoteId = this.remoteId;
|
|
113
|
+
if (remoteId === null) {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
return ccmp.entities.getStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Ped, remoteId, key);
|
|
110
117
|
}
|
|
111
118
|
hasSyncedMeta(key) {
|
|
112
|
-
|
|
113
|
-
|
|
119
|
+
const remoteId = this.remoteId;
|
|
120
|
+
if (remoteId === null) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return ccmp.entities.hasStreamSyncedMeta(ccmp.entities.ENTITY_TYPE.Ped, remoteId, key);
|
|
114
124
|
}
|
|
115
125
|
getSyncedMetaKeys() {
|
|
116
|
-
|
|
126
|
+
const remoteId = this.remoteId;
|
|
127
|
+
if (remoteId === null) {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
return ccmp.entities.getStreamSyncedMetaKeys(ccmp.entities.ENTITY_TYPE.Ped, remoteId);
|
|
117
131
|
}
|
|
118
132
|
attachToEntity(target, boneIndex, offset, rotation, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot) {
|
|
119
133
|
this._ccmpPed.attachToEntity(target, boneIndex, offset, rotation, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot);
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { type CCMPEventsManager } from "../../../net/ccmp/events/CCMPEventsManager";
|
|
1
2
|
import { type IPedCreateOptions, type IPedsManager } from "../../common/ped/IPedsManager";
|
|
2
3
|
import { type IWorldObjectsIterator } from "../../common/worldObject/IWorldObjectsIterator";
|
|
3
4
|
import { CCMPPed } from "./CCMPPed";
|
|
4
5
|
export declare class CCMPPedsManager implements IPedsManager {
|
|
6
|
+
private readonly _events;
|
|
5
7
|
private readonly _peds;
|
|
8
|
+
private readonly _pedsByRemoteId;
|
|
6
9
|
private readonly _iterator;
|
|
10
|
+
constructor(_events: CCMPEventsManager);
|
|
7
11
|
create(options: IPedCreateOptions): CCMPPed;
|
|
8
12
|
syncWithMpPool(): void;
|
|
9
13
|
registerById(id: number): CCMPPed;
|
|
@@ -16,5 +20,8 @@ export declare class CCMPPedsManager implements IPedsManager {
|
|
|
16
20
|
get iterator(): IWorldObjectsIterator<CCMPPed>;
|
|
17
21
|
private _filter;
|
|
18
22
|
private _register;
|
|
23
|
+
private _unregister;
|
|
24
|
+
private _findRegistered;
|
|
25
|
+
private _registerStreamEvents;
|
|
19
26
|
private _pruneDestroyed;
|
|
20
27
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { ClientInternalEventName } from "../../../net/common/events/types";
|
|
1
2
|
import { CCMPPed } from "./CCMPPed";
|
|
2
3
|
export class CCMPPedsManager {
|
|
3
|
-
constructor() {
|
|
4
|
+
constructor(_events) {
|
|
5
|
+
this._events = _events;
|
|
4
6
|
this._peds = new Map();
|
|
7
|
+
this._pedsByRemoteId = new Map();
|
|
5
8
|
this._iterator = {
|
|
6
9
|
all: () => this._filter(() => true),
|
|
7
10
|
dimension: (value) => this._filter((ped) => ped.dimension === value),
|
|
@@ -12,6 +15,8 @@ export class CCMPPedsManager {
|
|
|
12
15
|
}),
|
|
13
16
|
range3D: (center, range) => this._filter((ped) => ped.position.isInRange(center, range)),
|
|
14
17
|
};
|
|
18
|
+
this._registerStreamEvents();
|
|
19
|
+
this.syncWithMpPool();
|
|
15
20
|
}
|
|
16
21
|
create(options) {
|
|
17
22
|
const { model, position, rotation, dimension } = options;
|
|
@@ -24,9 +29,7 @@ export class CCMPPedsManager {
|
|
|
24
29
|
syncWithMpPool() {
|
|
25
30
|
this._pruneDestroyed();
|
|
26
31
|
for (const ccmpPed of ccmp.peds.all) {
|
|
27
|
-
|
|
28
|
-
this._register(ccmpPed);
|
|
29
|
-
}
|
|
32
|
+
this._register(ccmpPed);
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
registerById(id) {
|
|
@@ -47,10 +50,16 @@ export class CCMPPedsManager {
|
|
|
47
50
|
var _a;
|
|
48
51
|
const ped = (_a = this._peds.get(id)) !== null && _a !== void 0 ? _a : null;
|
|
49
52
|
if (ped && !ped.isExists) {
|
|
50
|
-
this.
|
|
53
|
+
this._unregister(ped);
|
|
54
|
+
}
|
|
55
|
+
else if (ped) {
|
|
56
|
+
return ped;
|
|
57
|
+
}
|
|
58
|
+
const ccmpPed = ccmp.peds.getById(id);
|
|
59
|
+
if (!ccmpPed) {
|
|
51
60
|
return null;
|
|
52
61
|
}
|
|
53
|
-
return
|
|
62
|
+
return this._register(ccmpPed);
|
|
54
63
|
}
|
|
55
64
|
getByID(id) {
|
|
56
65
|
const ped = this.findByID(id);
|
|
@@ -60,7 +69,19 @@ export class CCMPPedsManager {
|
|
|
60
69
|
return ped;
|
|
61
70
|
}
|
|
62
71
|
findByRemoteID(remoteId) {
|
|
63
|
-
|
|
72
|
+
var _a;
|
|
73
|
+
const ped = (_a = this._pedsByRemoteId.get(remoteId)) !== null && _a !== void 0 ? _a : null;
|
|
74
|
+
if (ped && !ped.isExists) {
|
|
75
|
+
this._unregister(ped);
|
|
76
|
+
}
|
|
77
|
+
else if (ped) {
|
|
78
|
+
return ped;
|
|
79
|
+
}
|
|
80
|
+
const ccmpPed = ccmp.peds.getByRemoteId(remoteId);
|
|
81
|
+
if (!ccmpPed) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return this._register(ccmpPed);
|
|
64
85
|
}
|
|
65
86
|
getByRemoteID(remoteId) {
|
|
66
87
|
const ped = this.findByRemoteID(remoteId);
|
|
@@ -80,7 +101,7 @@ export class CCMPPedsManager {
|
|
|
80
101
|
*_filter(predicate) {
|
|
81
102
|
for (const ped of this._peds.values()) {
|
|
82
103
|
if (!ped.isExists) {
|
|
83
|
-
this.
|
|
104
|
+
this._unregister(ped);
|
|
84
105
|
continue;
|
|
85
106
|
}
|
|
86
107
|
if (predicate(ped)) {
|
|
@@ -89,16 +110,67 @@ export class CCMPPedsManager {
|
|
|
89
110
|
}
|
|
90
111
|
}
|
|
91
112
|
_register(ccmpPed) {
|
|
113
|
+
const existingPed = this._findRegistered(ccmpPed);
|
|
114
|
+
if (existingPed && existingPed.isExists) {
|
|
115
|
+
return existingPed;
|
|
116
|
+
}
|
|
117
|
+
if (existingPed) {
|
|
118
|
+
this._unregister(existingPed);
|
|
119
|
+
}
|
|
92
120
|
const ped = new CCMPPed(ccmpPed, (destroyedPed) => {
|
|
93
|
-
this.
|
|
121
|
+
this._unregister(destroyedPed);
|
|
94
122
|
});
|
|
95
123
|
this._peds.set(ped.id, ped);
|
|
124
|
+
if (ped.remoteId !== null) {
|
|
125
|
+
this._pedsByRemoteId.set(ped.remoteId, ped);
|
|
126
|
+
}
|
|
96
127
|
return ped;
|
|
97
128
|
}
|
|
129
|
+
_unregister(ped) {
|
|
130
|
+
this._peds.delete(ped.id);
|
|
131
|
+
if (ped.remoteId !== null) {
|
|
132
|
+
this._pedsByRemoteId.delete(ped.remoteId);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
_findRegistered(ccmpPed) {
|
|
136
|
+
var _a, _b, _c;
|
|
137
|
+
return ((_c = (_b = (ccmpPed.remoteId === null ? null : ((_a = this._pedsByRemoteId.get(ccmpPed.remoteId)) !== null && _a !== void 0 ? _a : null))) !== null && _b !== void 0 ? _b : this._peds.get(ccmpPed.id)) !== null && _c !== void 0 ? _c : null);
|
|
138
|
+
}
|
|
139
|
+
_registerStreamEvents() {
|
|
140
|
+
ccmp.on("pedCreated", (ccmpPed) => {
|
|
141
|
+
if (ccmpPed) {
|
|
142
|
+
const ped = this._register(ccmpPed);
|
|
143
|
+
this._events.emitInternal(ClientInternalEventName.EntityCreated, ped);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
ccmp.on("pedDestroyed", (ccmpPed) => {
|
|
147
|
+
var _a;
|
|
148
|
+
if (ccmpPed) {
|
|
149
|
+
const ped = (_a = this._findRegistered(ccmpPed)) !== null && _a !== void 0 ? _a : this._register(ccmpPed);
|
|
150
|
+
this._events.emitInternal(ClientInternalEventName.EntityDestroyed, ped);
|
|
151
|
+
this._unregister(ped);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
ccmp.on("pedStreamIn", (ccmpPed) => {
|
|
155
|
+
if (ccmpPed) {
|
|
156
|
+
const ped = this._register(ccmpPed);
|
|
157
|
+
this._events.emitInternal(ClientInternalEventName.EntityStreamIn, ped);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
ccmp.on("pedStreamOut", (ccmpPed) => {
|
|
161
|
+
var _a;
|
|
162
|
+
if (ccmpPed) {
|
|
163
|
+
const ped = (_a = this._findRegistered(ccmpPed)) !== null && _a !== void 0 ? _a : this._register(ccmpPed);
|
|
164
|
+
if (ped) {
|
|
165
|
+
this._events.emitInternal(ClientInternalEventName.EntityStreamOut, ped);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
98
170
|
_pruneDestroyed() {
|
|
99
171
|
for (const ped of this._peds.values()) {
|
|
100
172
|
if (!ped.isExists) {
|
|
101
|
-
this.
|
|
173
|
+
this._unregister(ped);
|
|
102
174
|
}
|
|
103
175
|
}
|
|
104
176
|
}
|
|
@@ -45,7 +45,7 @@ export declare class CCMPPlayer implements IPlayer {
|
|
|
45
45
|
get model(): number;
|
|
46
46
|
get heading(): number;
|
|
47
47
|
setHeading(heading: number): void;
|
|
48
|
-
setModel(
|
|
48
|
+
setModel(value: string): void;
|
|
49
49
|
get rotation(): IVector3D;
|
|
50
50
|
setRotation(value: IVector3D): void;
|
|
51
51
|
get forwardVector(): IVector3D;
|
|
@@ -82,31 +82,29 @@ export declare class CCMPPlayer implements IPlayer {
|
|
|
82
82
|
getAmmoInClip(_weapon: number): number;
|
|
83
83
|
getWeaponAmmo(_weapon: number): number;
|
|
84
84
|
getBoneIndex(boneId: number): number;
|
|
85
|
-
setDecoration(
|
|
86
|
-
removeDecoration(
|
|
85
|
+
setDecoration(collection: string, overlay: string): void;
|
|
86
|
+
removeDecoration(collection: string, overlay: string): void;
|
|
87
87
|
clearDecorations(): void;
|
|
88
|
-
setHeadBlendData(
|
|
89
|
-
setFaceFeature(
|
|
90
|
-
setHeadOverlay(
|
|
91
|
-
setHeadOverlayColor(
|
|
92
|
-
setEyeColor(
|
|
93
|
-
setHairColor(
|
|
94
|
-
setComponentVariation(
|
|
95
|
-
setPropertyVariation(
|
|
96
|
-
clearProp(
|
|
88
|
+
setHeadBlendData(shapeFirstId: number, shapeSecondId: number, shapeThirdId: number, skinFirstId: number, skinSecondId: number, skinThirdId: number, shapeMix: number, skinMix: number, thirdMix: number, isParent: boolean): void;
|
|
89
|
+
setFaceFeature(index: number, value: number): void;
|
|
90
|
+
setHeadOverlay(overlayId: number, index: number, opacity: number, _firstColor: number, _secondColor: number): void;
|
|
91
|
+
setHeadOverlayColor(overlayId: number, colorTypeId: number, firstColor: number, secondColor: number): void;
|
|
92
|
+
setEyeColor(eyeColor: number): void;
|
|
93
|
+
setHairColor(colorId: number, highlightColorId: number): void;
|
|
94
|
+
setComponentVariation(componentId: number, drawableId: number, textureId: number, paletteId: number): void;
|
|
95
|
+
setPropertyVariation(componentId: number, drawableId: number, textureId: number, attach: boolean): void;
|
|
96
|
+
clearProp(componentId: number): void;
|
|
97
97
|
get isLocalPlayer(): boolean;
|
|
98
98
|
taskSwapWeapon(): void;
|
|
99
|
-
taskEnterVehicle(
|
|
99
|
+
taskEnterVehicle(vehicleHandle: number, timeout: number, seat: number, speed: number, flag: number, _p6: number): void;
|
|
100
100
|
clearTasks(): void;
|
|
101
101
|
clearTasksImmediately(): void;
|
|
102
|
-
taskPlayAnim(
|
|
103
|
-
stopAnim(
|
|
102
|
+
taskPlayAnim(dictionary: string, name: string, blendInSpeed: number, blendOutSpeed: number, duration: number, flag: number, playbackRate: number, lockX: boolean, lockY: boolean, lockZ: boolean): void;
|
|
103
|
+
stopAnim(dictionary: string, name: string, blendOutSpeed: number): void;
|
|
104
104
|
setMovementClipset(_clipset: string, _speed: number): void;
|
|
105
105
|
resetMovementClipset(_blendDuration: number): void;
|
|
106
106
|
getBoneCoords(boneId: number, offsetX: number, offsetY: number, offsetZ: number): IVector3D;
|
|
107
107
|
setNoCollision(otherHandle: number, thisFrameOnly: boolean): void;
|
|
108
108
|
private _getNativePlayer;
|
|
109
|
-
private _withHandle;
|
|
110
|
-
private _withHandleVoid;
|
|
111
109
|
private _warnOnce;
|
|
112
110
|
}
|