@nativewrappers/common-game 0.0.114
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/CommonGameConstants.d.ts +7 -0
- package/CommonGameConstants.js +24 -0
- package/CommonModel.d.ts +99 -0
- package/CommonModel.js +172 -0
- package/CommonTasks.d.ts +43 -0
- package/CommonTasks.js +232 -0
- package/README.md +45 -0
- package/cfx/StateBagChangeHandler.d.ts +1 -0
- package/cfx/StateBagChangeHandler.js +0 -0
- package/cfx/cfx.d.ts +6 -0
- package/cfx/cfx.js +4 -0
- package/common/Command.d.ts +77 -0
- package/common/Command.js +152 -0
- package/common/Convar.d.ts +13 -0
- package/common/Convar.js +58 -0
- package/common/GlobalData.d.ts +10 -0
- package/common/GlobalData.js +18 -0
- package/common/Kvp.d.ts +69 -0
- package/common/Kvp.js +137 -0
- package/common/Resource.d.ts +14 -0
- package/common/Resource.js +54 -0
- package/common/decors/Events.d.ts +65 -0
- package/common/decors/Events.js +208 -0
- package/common/net/NetworkedMap.d.ts +28 -0
- package/common/net/NetworkedMap.js +225 -0
- package/common/types.d.ts +5 -0
- package/common/types.js +0 -0
- package/common/utils/ClassTypes.d.ts +11 -0
- package/common/utils/ClassTypes.js +15 -0
- package/common/utils/Color.d.ts +14 -0
- package/common/utils/Color.js +33 -0
- package/common/utils/Delay.d.ts +1 -0
- package/common/utils/Delay.js +6 -0
- package/common/utils/Maths.d.ts +4 -0
- package/common/utils/Maths.js +18 -0
- package/common/utils/Point.d.ts +9 -0
- package/common/utils/Point.js +36 -0
- package/common/utils/PointF.d.ts +7 -0
- package/common/utils/PointF.js +18 -0
- package/common/utils/Quaternion.d.ts +10 -0
- package/common/utils/Quaternion.js +33 -0
- package/common/utils/Vector.d.ts +429 -0
- package/common/utils/Vector.js +589 -0
- package/common/utils/cleanPlayerName.d.ts +6 -0
- package/common/utils/cleanPlayerName.js +17 -0
- package/common/utils/enumValues.d.ts +12 -0
- package/common/utils/enumValues.js +20 -0
- package/common/utils/getStringFromUInt8Array.d.ts +8 -0
- package/common/utils/getStringFromUInt8Array.js +6 -0
- package/common/utils/getUInt32FromUint8Array.d.ts +8 -0
- package/common/utils/getUInt32FromUint8Array.js +6 -0
- package/common/utils/randomInt.d.ts +1 -0
- package/common/utils/randomInt.js +9 -0
- package/definitions/index.d.js +0 -0
- package/definitions/redm.d.js +0 -0
- package/entities/CommonBaseEntity.d.ts +66 -0
- package/entities/CommonBaseEntity.js +180 -0
- package/entities/CommonBaseEntityBone.d.ts +11 -0
- package/entities/CommonBaseEntityBone.js +32 -0
- package/entities/CommonBaseEntityBoneCollection.d.ts +9 -0
- package/entities/CommonBaseEntityBoneCollection.js +17 -0
- package/entities/CommonEntityBone.d.ts +5 -0
- package/entities/CommonEntityBone.js +14 -0
- package/entities/CommonEntityBoneCollection.d.ts +9 -0
- package/entities/CommonEntityBoneCollection.js +24 -0
- package/entities/CommonEntityType.d.ts +4 -0
- package/entities/CommonEntityType.js +3 -0
- package/entities/CommonPed.d.ts +17 -0
- package/entities/CommonPed.js +55 -0
- package/entities/CommonPedBone.d.ts +6 -0
- package/entities/CommonPedBone.js +17 -0
- package/entities/CommonPedBoneCollection.d.ts +10 -0
- package/entities/CommonPedBoneCollection.js +31 -0
- package/entities/CommonPlayer.d.ts +61 -0
- package/entities/CommonPlayer.js +156 -0
- package/entities/CommonProp.d.ts +16 -0
- package/entities/CommonProp.js +46 -0
- package/entities/CommonVehicle.d.ts +12 -0
- package/entities/CommonVehicle.js +39 -0
- package/entities/GetEntityClassIdFromHandle.d.ts +2 -0
- package/entities/GetEntityClassIdFromHandle.js +23 -0
- package/enums/VehicleSeat.d.ts +13 -0
- package/enums/VehicleSeat.js +17 -0
- package/index.d.ts +44 -0
- package/index.js +44 -0
- package/interfaces/Dimension.d.ts +5 -0
- package/interfaces/Dimension.js +0 -0
- package/package.json +36 -0
- package/utils/Animations.d.ts +19 -0
- package/utils/Animations.js +43 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ClassTypes } from "../common/utils/ClassTypes";
|
|
2
|
+
import { Quaternion } from "../common/utils/Quaternion";
|
|
3
|
+
import { Vector3 } from "../common/utils/Vector";
|
|
4
|
+
import type { CommonBaseEntityBoneCollection } from "./CommonBaseEntityBoneCollection";
|
|
5
|
+
import type { StateBagChangeHandler } from "common-game/cfx/StateBagChangeHandler";
|
|
6
|
+
import { CommonModel } from "common-game/CommonModel";
|
|
7
|
+
export declare abstract class CommonBaseEntity {
|
|
8
|
+
protected handle: number;
|
|
9
|
+
protected stateBagCookies: number[];
|
|
10
|
+
protected netId: number | null;
|
|
11
|
+
protected abstract type: ClassTypes;
|
|
12
|
+
protected abstract bones?: CommonBaseEntityBoneCollection;
|
|
13
|
+
constructor(handle: number);
|
|
14
|
+
get Handle(): number;
|
|
15
|
+
/**
|
|
16
|
+
* @returns if the entity is a networked entity or local entity
|
|
17
|
+
*/
|
|
18
|
+
get IsNetworked(): boolean;
|
|
19
|
+
set IsNetworked(networked: boolean);
|
|
20
|
+
get NetworkId(): number;
|
|
21
|
+
get State(): StateBagInterface;
|
|
22
|
+
AddStateBagChangeHandler(keyFilter: string | null, handler: StateBagChangeHandler<unknown>): number;
|
|
23
|
+
/**
|
|
24
|
+
* A short hand function for AddStateBagChangeHandler, this gets automatically cleaned up on entity deletion.
|
|
25
|
+
* @param keyFilter the key to filter for or null
|
|
26
|
+
* @param handler the function to handle the change
|
|
27
|
+
* @returns a cookie to be used in RemoveStateBagChangeHandler
|
|
28
|
+
*/
|
|
29
|
+
listenForStateChange(keyFilter: string | null, handler: StateBagChangeHandler<unknown>): number;
|
|
30
|
+
removeStateListener(tgtCookie: number): void;
|
|
31
|
+
get Owner(): number;
|
|
32
|
+
get Speed(): number;
|
|
33
|
+
getSpeedVector(isRelative?: boolean): Vector3;
|
|
34
|
+
get ForwardVector(): Vector3;
|
|
35
|
+
get Matrix(): Vector3[];
|
|
36
|
+
get Health(): number;
|
|
37
|
+
set Health(amount: number);
|
|
38
|
+
get MaxHealth(): number;
|
|
39
|
+
set MaxHealth(amount: number);
|
|
40
|
+
set IsDead(value: boolean);
|
|
41
|
+
get IsDead(): boolean;
|
|
42
|
+
get IsAlive(): boolean;
|
|
43
|
+
get Model(): CommonModel;
|
|
44
|
+
/**
|
|
45
|
+
* Returns if the entity is set as a mission entity and will not be cleaned up by the engine
|
|
46
|
+
*/
|
|
47
|
+
get IsMissionEntity(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Sets if the entity is a mission entity and will not be cleaned up by the engine
|
|
50
|
+
*/
|
|
51
|
+
set IsMissionEntity(value: boolean);
|
|
52
|
+
get Position(): Vector3;
|
|
53
|
+
set Position(position: Vector3);
|
|
54
|
+
set PositionNoOffset(position: Vector3);
|
|
55
|
+
get Rotation(): Vector3;
|
|
56
|
+
set Rotation(rotation: Vector3);
|
|
57
|
+
set Quaternion(quaternion: Quaternion);
|
|
58
|
+
get Heading(): number;
|
|
59
|
+
set Heading(heading: number);
|
|
60
|
+
get IsPositionFrozen(): boolean;
|
|
61
|
+
set IsPositionFrozen(value: boolean);
|
|
62
|
+
get Velocity(): Vector3;
|
|
63
|
+
set Velocity(velocity: Vector3);
|
|
64
|
+
exists(): boolean;
|
|
65
|
+
delete(): void;
|
|
66
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { Quaternion } from "../common/utils/Quaternion";
|
|
4
|
+
import { Vector3 } from "../common/utils/Vector";
|
|
5
|
+
import cfx from "common-game/cfx/cfx";
|
|
6
|
+
import { CommonModel } from "common-game/CommonModel";
|
|
7
|
+
import { GlobalData } from "../common/GlobalData";
|
|
8
|
+
class CommonBaseEntity {
|
|
9
|
+
static {
|
|
10
|
+
__name(this, "CommonBaseEntity");
|
|
11
|
+
}
|
|
12
|
+
handle;
|
|
13
|
+
stateBagCookies = [];
|
|
14
|
+
netId = null;
|
|
15
|
+
constructor(handle) {
|
|
16
|
+
this.handle = handle;
|
|
17
|
+
if (this.IsNetworked) {
|
|
18
|
+
this.netId = this.NetworkId;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
get Handle() {
|
|
22
|
+
return this.handle;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @returns if the entity is a networked entity or local entity
|
|
26
|
+
*/
|
|
27
|
+
get IsNetworked() {
|
|
28
|
+
return NetworkGetEntityIsNetworked(this.handle);
|
|
29
|
+
}
|
|
30
|
+
set IsNetworked(networked) {
|
|
31
|
+
if (networked) {
|
|
32
|
+
NetworkRegisterEntityAsNetworked(this.handle);
|
|
33
|
+
} else {
|
|
34
|
+
if (GlobalData.GameName === "redm") {
|
|
35
|
+
Citizen.invokeNative("0xE31A04513237DC89", this.handle);
|
|
36
|
+
} else {
|
|
37
|
+
NetworkUnregisterNetworkedEntity(this.handle);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
get NetworkId() {
|
|
42
|
+
if (this.netId) {
|
|
43
|
+
return this.netId;
|
|
44
|
+
}
|
|
45
|
+
return NetworkGetNetworkIdFromEntity(this.handle);
|
|
46
|
+
}
|
|
47
|
+
get State() {
|
|
48
|
+
return cfx.Entity(this.handle).state;
|
|
49
|
+
}
|
|
50
|
+
AddStateBagChangeHandler(keyFilter, handler) {
|
|
51
|
+
const stateBagName = this.IsNetworked ? `entity:${this.NetworkId}` : `localEntity:${this.handle}`;
|
|
52
|
+
const cookie = AddStateBagChangeHandler(keyFilter, stateBagName, handler);
|
|
53
|
+
this.stateBagCookies.push(cookie);
|
|
54
|
+
return cookie;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A short hand function for AddStateBagChangeHandler, this gets automatically cleaned up on entity deletion.
|
|
58
|
+
* @param keyFilter the key to filter for or null
|
|
59
|
+
* @param handler the function to handle the change
|
|
60
|
+
* @returns a cookie to be used in RemoveStateBagChangeHandler
|
|
61
|
+
*/
|
|
62
|
+
listenForStateChange(keyFilter, handler) {
|
|
63
|
+
return this.AddStateBagChangeHandler(keyFilter, handler);
|
|
64
|
+
}
|
|
65
|
+
removeStateListener(tgtCookie) {
|
|
66
|
+
this.stateBagCookies = this.stateBagCookies.filter((cookie) => {
|
|
67
|
+
const isCookie = cookie === tgtCookie;
|
|
68
|
+
if (isCookie) RemoveStateBagChangeHandler(cookie);
|
|
69
|
+
return isCookie;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
get Owner() {
|
|
73
|
+
return NetworkGetEntityOwner(this.handle);
|
|
74
|
+
}
|
|
75
|
+
get Speed() {
|
|
76
|
+
return GetEntitySpeed(this.handle);
|
|
77
|
+
}
|
|
78
|
+
getSpeedVector(isRelative = false) {
|
|
79
|
+
return Vector3.fromArray(GetEntitySpeedVector(this.handle, isRelative));
|
|
80
|
+
}
|
|
81
|
+
get ForwardVector() {
|
|
82
|
+
return Vector3.fromArray(GetEntityForwardVector(this.handle));
|
|
83
|
+
}
|
|
84
|
+
get Matrix() {
|
|
85
|
+
return Vector3.fromArrays(GetEntityMatrix(this.handle));
|
|
86
|
+
}
|
|
87
|
+
get Health() {
|
|
88
|
+
return GetEntityHealth(this.handle);
|
|
89
|
+
}
|
|
90
|
+
set Health(amount) {
|
|
91
|
+
SetEntityHealth(this.handle, amount);
|
|
92
|
+
}
|
|
93
|
+
get MaxHealth() {
|
|
94
|
+
return GetEntityMaxHealth(this.handle);
|
|
95
|
+
}
|
|
96
|
+
set MaxHealth(amount) {
|
|
97
|
+
SetEntityMaxHealth(this.handle, amount);
|
|
98
|
+
}
|
|
99
|
+
set IsDead(value) {
|
|
100
|
+
if (value) {
|
|
101
|
+
SetEntityHealth(this.handle, 0);
|
|
102
|
+
} else {
|
|
103
|
+
SetEntityHealth(this.handle, 200);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
get IsDead() {
|
|
107
|
+
return IsEntityDead(this.handle);
|
|
108
|
+
}
|
|
109
|
+
get IsAlive() {
|
|
110
|
+
return !IsEntityDead(this.handle);
|
|
111
|
+
}
|
|
112
|
+
get Model() {
|
|
113
|
+
return new CommonModel(GetEntityModel(this.handle));
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Returns if the entity is set as a mission entity and will not be cleaned up by the engine
|
|
117
|
+
*/
|
|
118
|
+
get IsMissionEntity() {
|
|
119
|
+
return IsEntityAMissionEntity(this.handle);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Sets if the entity is a mission entity and will not be cleaned up by the engine
|
|
123
|
+
*/
|
|
124
|
+
set IsMissionEntity(value) {
|
|
125
|
+
if (value) {
|
|
126
|
+
SetEntityAsMissionEntity(this.handle, false, false);
|
|
127
|
+
} else {
|
|
128
|
+
SetEntityAsNoLongerNeeded(this.handle);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
get Position() {
|
|
132
|
+
return Vector3.fromArray(GetEntityCoords(this.handle, false));
|
|
133
|
+
}
|
|
134
|
+
set Position(position) {
|
|
135
|
+
SetEntityCoords(this.handle, position.x, position.y, position.z, false, false, false, true);
|
|
136
|
+
}
|
|
137
|
+
set PositionNoOffset(position) {
|
|
138
|
+
SetEntityCoordsNoOffset(this.handle, position.x, position.y, position.z, true, true, true);
|
|
139
|
+
}
|
|
140
|
+
get Rotation() {
|
|
141
|
+
return Vector3.fromArray(GetEntityRotation(this.handle, 2));
|
|
142
|
+
}
|
|
143
|
+
set Rotation(rotation) {
|
|
144
|
+
SetEntityRotation(this.handle, rotation.x, rotation.y, rotation.z, 2, true);
|
|
145
|
+
}
|
|
146
|
+
set Quaternion(quaternion) {
|
|
147
|
+
SetEntityQuaternion(this.handle, quaternion.x, quaternion.y, quaternion.z, quaternion.w);
|
|
148
|
+
}
|
|
149
|
+
get Heading() {
|
|
150
|
+
return GetEntityHeading(this.handle);
|
|
151
|
+
}
|
|
152
|
+
set Heading(heading) {
|
|
153
|
+
SetEntityHeading(this.handle, heading);
|
|
154
|
+
}
|
|
155
|
+
get IsPositionFrozen() {
|
|
156
|
+
return IsEntityPositionFrozen(this.handle);
|
|
157
|
+
}
|
|
158
|
+
set IsPositionFrozen(value) {
|
|
159
|
+
FreezeEntityPosition(this.handle, value);
|
|
160
|
+
}
|
|
161
|
+
get Velocity() {
|
|
162
|
+
return Vector3.fromArray(GetEntityVelocity(this.handle));
|
|
163
|
+
}
|
|
164
|
+
set Velocity(velocity) {
|
|
165
|
+
SetEntityVelocity(this.handle, velocity.x, velocity.y, velocity.z);
|
|
166
|
+
}
|
|
167
|
+
exists() {
|
|
168
|
+
return DoesEntityExist(this.handle);
|
|
169
|
+
}
|
|
170
|
+
delete() {
|
|
171
|
+
this.IsMissionEntity = true;
|
|
172
|
+
DeleteEntity(this.handle);
|
|
173
|
+
for (const cookie of this.stateBagCookies) {
|
|
174
|
+
RemoveStateBagChangeHandler(cookie);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export {
|
|
179
|
+
CommonBaseEntity
|
|
180
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Vector3 } from "../common/utils/Vector";
|
|
2
|
+
import type { CommonBaseEntity } from "./CommonBaseEntity";
|
|
3
|
+
export declare abstract class CommonBaseEntityBone {
|
|
4
|
+
get Index(): number;
|
|
5
|
+
get Owner(): CommonBaseEntity;
|
|
6
|
+
get Position(): Vector3;
|
|
7
|
+
get IsValid(): boolean;
|
|
8
|
+
protected readonly owner: CommonBaseEntity;
|
|
9
|
+
protected readonly index: number;
|
|
10
|
+
constructor(owner: CommonBaseEntity, boneIndex?: number, boneName?: string);
|
|
11
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { Vector3 } from "../common/utils/Vector";
|
|
4
|
+
class CommonBaseEntityBone {
|
|
5
|
+
static {
|
|
6
|
+
__name(this, "CommonBaseEntityBone");
|
|
7
|
+
}
|
|
8
|
+
get Index() {
|
|
9
|
+
return this.index;
|
|
10
|
+
}
|
|
11
|
+
get Owner() {
|
|
12
|
+
return this.owner;
|
|
13
|
+
}
|
|
14
|
+
get Position() {
|
|
15
|
+
return Vector3.fromArray(GetWorldPositionOfEntityBone(this.owner.Handle, this.index));
|
|
16
|
+
}
|
|
17
|
+
// public get Rotation(): Vector3 {
|
|
18
|
+
// return Vector3.fromArray(GetEntityBoneRotation(this.owner.Handle, this.index));
|
|
19
|
+
// }
|
|
20
|
+
get IsValid() {
|
|
21
|
+
return this.owner.exists() && this.index !== -1;
|
|
22
|
+
}
|
|
23
|
+
owner;
|
|
24
|
+
index;
|
|
25
|
+
constructor(owner, boneIndex, boneName) {
|
|
26
|
+
this.owner = owner;
|
|
27
|
+
this.index = boneIndex ? boneIndex : GetEntityBoneIndexByName(this.owner.Handle, boneName ?? "");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
CommonBaseEntityBone
|
|
32
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommonBaseEntity } from "./CommonBaseEntity";
|
|
2
|
+
import type { CommonBaseEntityBone } from "./CommonBaseEntityBone";
|
|
3
|
+
export declare abstract class CommonBaseEntityBoneCollection {
|
|
4
|
+
protected readonly owner: CommonBaseEntity;
|
|
5
|
+
constructor(owner: CommonBaseEntity);
|
|
6
|
+
hasBone(name: string): boolean;
|
|
7
|
+
abstract getBone(boneIndex?: number, boneName?: string): CommonBaseEntityBone;
|
|
8
|
+
abstract get Core(): CommonBaseEntityBone;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
class CommonBaseEntityBoneCollection {
|
|
4
|
+
static {
|
|
5
|
+
__name(this, "CommonBaseEntityBoneCollection");
|
|
6
|
+
}
|
|
7
|
+
owner;
|
|
8
|
+
constructor(owner) {
|
|
9
|
+
this.owner = owner;
|
|
10
|
+
}
|
|
11
|
+
hasBone(name) {
|
|
12
|
+
return GetEntityBoneIndexByName(this.owner.Handle, name) !== -1;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
CommonBaseEntityBoneCollection
|
|
17
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CommonBaseEntity } from "./CommonBaseEntity";
|
|
2
|
+
import { CommonBaseEntityBone } from "./CommonBaseEntityBone";
|
|
3
|
+
export declare class CommonEntityBone extends CommonBaseEntityBone {
|
|
4
|
+
constructor(owner: CommonBaseEntity, boneIndex?: number, boneName?: string);
|
|
5
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { CommonBaseEntityBone } from "./CommonBaseEntityBone";
|
|
4
|
+
class CommonEntityBone extends CommonBaseEntityBone {
|
|
5
|
+
static {
|
|
6
|
+
__name(this, "CommonEntityBone");
|
|
7
|
+
}
|
|
8
|
+
constructor(owner, boneIndex, boneName) {
|
|
9
|
+
super(owner, boneIndex, boneName);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
CommonEntityBone
|
|
14
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommonBaseEntity } from "./CommonBaseEntity";
|
|
2
|
+
import { CommonBaseEntityBoneCollection } from "./CommonBaseEntityBoneCollection";
|
|
3
|
+
import { CommonEntityBone } from "./CommonEntityBone";
|
|
4
|
+
export declare class CommonEntityBoneCollection extends CommonBaseEntityBoneCollection {
|
|
5
|
+
constructor(owner: CommonBaseEntity);
|
|
6
|
+
getBone(boneIndex: number): CommonEntityBone;
|
|
7
|
+
getBone(boneName: string): CommonEntityBone;
|
|
8
|
+
get Core(): CommonEntityBone;
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { CommonBaseEntityBoneCollection } from "./CommonBaseEntityBoneCollection";
|
|
4
|
+
import { CommonEntityBone } from "./CommonEntityBone";
|
|
5
|
+
class CommonEntityBoneCollection extends CommonBaseEntityBoneCollection {
|
|
6
|
+
static {
|
|
7
|
+
__name(this, "CommonEntityBoneCollection");
|
|
8
|
+
}
|
|
9
|
+
constructor(owner) {
|
|
10
|
+
super(owner);
|
|
11
|
+
}
|
|
12
|
+
getBone(bone) {
|
|
13
|
+
return new CommonEntityBone(
|
|
14
|
+
this.owner,
|
|
15
|
+
typeof bone === "number" ? bone : GetEntityBoneIndexByName(this.owner.Handle, bone ?? "")
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
get Core() {
|
|
19
|
+
return new CommonEntityBone(this.owner, -1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
CommonEntityBoneCollection
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CommonTasks } from "common-game/CommonTasks";
|
|
2
|
+
import { CommonBaseEntity } from "./CommonBaseEntity";
|
|
3
|
+
import { CommonPlayer } from "./CommonPlayer";
|
|
4
|
+
import { ClassTypes } from "../common/utils/ClassTypes";
|
|
5
|
+
import { CommonPedBoneCollection } from "./CommonPedBoneCollection";
|
|
6
|
+
export declare class CommonPed extends CommonBaseEntity {
|
|
7
|
+
private tasks;
|
|
8
|
+
protected type: ClassTypes;
|
|
9
|
+
protected bones?: CommonPedBoneCollection;
|
|
10
|
+
static exists(ped: CommonPed): boolean;
|
|
11
|
+
static fromHandle(handle: number): CommonPed | null;
|
|
12
|
+
static fromNetworkId(networkId: number): CommonPed | null;
|
|
13
|
+
constructor(handle: number);
|
|
14
|
+
get Player(): CommonPlayer | null;
|
|
15
|
+
get Task(): CommonTasks;
|
|
16
|
+
get Bones(): CommonPedBoneCollection;
|
|
17
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { CommonTasks } from "common-game/CommonTasks";
|
|
4
|
+
import { CommonBaseEntity } from "./CommonBaseEntity";
|
|
5
|
+
import { CommonPlayer } from "./CommonPlayer";
|
|
6
|
+
import { ClassTypes } from "../common/utils/ClassTypes";
|
|
7
|
+
import { CommonPedBoneCollection } from "./CommonPedBoneCollection";
|
|
8
|
+
class CommonPed extends CommonBaseEntity {
|
|
9
|
+
static {
|
|
10
|
+
__name(this, "CommonPed");
|
|
11
|
+
}
|
|
12
|
+
tasks;
|
|
13
|
+
type = ClassTypes.Ped;
|
|
14
|
+
bones;
|
|
15
|
+
static exists(ped) {
|
|
16
|
+
return typeof ped !== "undefined" && ped.exists();
|
|
17
|
+
}
|
|
18
|
+
static fromHandle(handle) {
|
|
19
|
+
if (handle === 0 || !DoesEntityExist(handle)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return new this(handle);
|
|
23
|
+
}
|
|
24
|
+
static fromNetworkId(networkId) {
|
|
25
|
+
if (!NetworkDoesEntityExistWithNetworkId(networkId)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return new this(NetworkGetEntityFromNetworkId(networkId));
|
|
29
|
+
}
|
|
30
|
+
constructor(handle) {
|
|
31
|
+
super(handle);
|
|
32
|
+
}
|
|
33
|
+
get Player() {
|
|
34
|
+
const playerIndex = NetworkGetPlayerIndexFromPed(this.handle);
|
|
35
|
+
if (playerIndex === -1) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return new CommonPlayer(playerIndex);
|
|
39
|
+
}
|
|
40
|
+
get Task() {
|
|
41
|
+
if (!this.tasks) {
|
|
42
|
+
this.tasks = new CommonTasks(this);
|
|
43
|
+
}
|
|
44
|
+
return this.tasks;
|
|
45
|
+
}
|
|
46
|
+
get Bones() {
|
|
47
|
+
if (!this.bones) {
|
|
48
|
+
this.bones = new CommonPedBoneCollection(this);
|
|
49
|
+
}
|
|
50
|
+
return this.bones;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
CommonPed
|
|
55
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { CommonBaseEntityBone } from "./CommonBaseEntityBone";
|
|
4
|
+
class CommonPedBone extends CommonBaseEntityBone {
|
|
5
|
+
static {
|
|
6
|
+
__name(this, "CommonPedBone");
|
|
7
|
+
}
|
|
8
|
+
constructor(owner, boneId) {
|
|
9
|
+
super(owner, GetPedBoneIndex(owner.Handle, Number(boneId)));
|
|
10
|
+
}
|
|
11
|
+
get IsValid() {
|
|
12
|
+
return this.Owner.exists() && this.Index !== -1;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
CommonPedBone
|
|
17
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommonBaseEntityBoneCollection } from "./CommonBaseEntityBoneCollection";
|
|
2
|
+
import type { CommonPed } from "./CommonPed";
|
|
3
|
+
import { CommonPedBone } from "./CommonPedBone";
|
|
4
|
+
export declare class CommonPedBoneCollection extends CommonBaseEntityBoneCollection {
|
|
5
|
+
constructor(owner: CommonPed);
|
|
6
|
+
get Core(): CommonPedBone;
|
|
7
|
+
get LastDamaged(): CommonPedBone;
|
|
8
|
+
clearLastDamaged(): void;
|
|
9
|
+
getBone(boneIndex?: number, boneName?: string): CommonPedBone;
|
|
10
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { CommonBaseEntityBoneCollection } from "./CommonBaseEntityBoneCollection";
|
|
4
|
+
import { CommonPedBone } from "./CommonPedBone";
|
|
5
|
+
class CommonPedBoneCollection extends CommonBaseEntityBoneCollection {
|
|
6
|
+
static {
|
|
7
|
+
__name(this, "CommonPedBoneCollection");
|
|
8
|
+
}
|
|
9
|
+
constructor(owner) {
|
|
10
|
+
super(owner);
|
|
11
|
+
}
|
|
12
|
+
get Core() {
|
|
13
|
+
return new CommonPedBone(this.owner, -1);
|
|
14
|
+
}
|
|
15
|
+
get LastDamaged() {
|
|
16
|
+
const [, outBone] = GetPedLastDamageBone(this.owner.Handle, 0);
|
|
17
|
+
return CommonPedBone[outBone];
|
|
18
|
+
}
|
|
19
|
+
clearLastDamaged() {
|
|
20
|
+
ClearPedLastDamageBone(this.owner.Handle);
|
|
21
|
+
}
|
|
22
|
+
getBone(boneIndex, boneName) {
|
|
23
|
+
return new CommonPedBone(
|
|
24
|
+
this.owner,
|
|
25
|
+
boneIndex ? boneIndex : GetEntityBoneIndexByName(this.owner.Handle, boneName ?? "")
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
CommonPedBoneCollection
|
|
31
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { StateBagChangeHandler } from "common-game/cfx/StateBagChangeHandler";
|
|
2
|
+
import { CommonPed } from "./CommonPed";
|
|
3
|
+
import type { CommonEntity } from "./CommonEntityType";
|
|
4
|
+
export declare class CommonPlayer {
|
|
5
|
+
private handle;
|
|
6
|
+
private ped?;
|
|
7
|
+
private pvp;
|
|
8
|
+
private stateBagCookies;
|
|
9
|
+
private source;
|
|
10
|
+
private type;
|
|
11
|
+
static AllPlayers(excludeLocalPlayer?: boolean): IterableIterator<CommonPlayer>;
|
|
12
|
+
/**
|
|
13
|
+
* @param handle the handoe of the ped to get the player of
|
|
14
|
+
* @returns the player, or null if the player doesn't exist
|
|
15
|
+
*/
|
|
16
|
+
static fromPedHandle(handle: number): CommonPlayer | null;
|
|
17
|
+
/**
|
|
18
|
+
* @param serverId the server id to get the player of
|
|
19
|
+
* @returns the player, or null if the player doesn't exist
|
|
20
|
+
*/
|
|
21
|
+
static fromServerId(serverId: number): CommonPlayer | null;
|
|
22
|
+
/**
|
|
23
|
+
* @param [minimumDistance=Number.MAX_VALUE] the minimum distance this should check
|
|
24
|
+
* @param [fromPlayer=GameConstants.Player] the player to get the distance from
|
|
25
|
+
* @returns the closest player from {@param fromPlayer} and the distance the player was
|
|
26
|
+
*/
|
|
27
|
+
static getClosestPlayerPedWithDistance(minimumDistance?: number, fromPlayer?: CommonPlayer): [CommonPed | null, number];
|
|
28
|
+
/**
|
|
29
|
+
* @param [minimumDistance=Number.MAX_VALUE] the minimum distance this should check
|
|
30
|
+
* @param [fromPlayer=GameConstants.Player] the player to get the distance from
|
|
31
|
+
* @returns the closest player from {@param fromPlayer} and the distance the player was
|
|
32
|
+
*/
|
|
33
|
+
static getClosestPlayerPed(minimumDistance?: number, fromPlayer?: CommonPlayer): CommonPed | null;
|
|
34
|
+
/**
|
|
35
|
+
* @param handle the player handle, or if on the server, their source.
|
|
36
|
+
*/
|
|
37
|
+
constructor(handle?: number);
|
|
38
|
+
get Handle(): number;
|
|
39
|
+
/**
|
|
40
|
+
* This is here for compatibility with older versions.
|
|
41
|
+
*/
|
|
42
|
+
get Character(): CommonPed;
|
|
43
|
+
get Ped(): CommonPed;
|
|
44
|
+
get ServerId(): number;
|
|
45
|
+
get State(): StateBagInterface;
|
|
46
|
+
AddStateBagChangeHandler(keyFilter: string | null, handler: StateBagChangeHandler<unknown>): number;
|
|
47
|
+
/**
|
|
48
|
+
* A short hand function for AddStateBagChangeHandler, this gets automatically cleaned up on entity deletion.
|
|
49
|
+
* @param keyFilter the key to filter for or null
|
|
50
|
+
* @param handler the function to handle the change
|
|
51
|
+
* @returns a cookie to be used in RemoveStateBagChangeHandler
|
|
52
|
+
*/
|
|
53
|
+
listenForStateChange(keyFilter: string | null, handler: StateBagChangeHandler<unknown>): number;
|
|
54
|
+
removeStateListener(tgtCookie: number): void;
|
|
55
|
+
removeAllStateListeners(): void;
|
|
56
|
+
get Name(): string;
|
|
57
|
+
get IsDead(): boolean;
|
|
58
|
+
set DisableFiring(value: boolean);
|
|
59
|
+
get EntityPlayerIsAimingAt(): CommonEntity | null;
|
|
60
|
+
get StealthNoise(): number;
|
|
61
|
+
}
|