@nativewrappers/common 0.0.125 → 0.0.127

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.
Files changed (103) hide show
  1. package/common-game/CommonGameConstants.d.ts +7 -0
  2. package/common-game/CommonGameConstants.js +24 -0
  3. package/common-game/CommonModel.d.ts +99 -0
  4. package/common-game/CommonModel.js +172 -0
  5. package/common-game/CommonTasks.d.ts +44 -0
  6. package/common-game/CommonTasks.js +233 -0
  7. package/common-game/cfx/StateBagChangeHandler.d.ts +1 -0
  8. package/common-game/cfx/StateBagChangeHandler.js +0 -0
  9. package/common-game/cfx/cfx.d.ts +6 -0
  10. package/common-game/cfx/cfx.js +4 -0
  11. package/common-game/common/Command.d.ts +77 -0
  12. package/common-game/common/Command.js +152 -0
  13. package/common-game/common/Convar.d.ts +13 -0
  14. package/common-game/common/Convar.js +58 -0
  15. package/common-game/common/GlobalData.d.ts +12 -0
  16. package/common-game/common/GlobalData.js +20 -0
  17. package/common-game/common/Kvp.d.ts +69 -0
  18. package/common-game/common/Kvp.js +137 -0
  19. package/common-game/common/Resource.d.ts +14 -0
  20. package/common-game/common/Resource.js +54 -0
  21. package/common-game/common/decors/ConVar.d.ts +14 -0
  22. package/common-game/common/decors/ConVar.js +70 -0
  23. package/common-game/common/decors/Events.d.ts +66 -0
  24. package/common-game/common/decors/Events.js +163 -0
  25. package/common-game/common/decors/Exports.d.ts +1 -0
  26. package/common-game/common/decors/Exports.js +53 -0
  27. package/common-game/common/decors/Permissions.d.ts +3 -0
  28. package/common-game/common/decors/Permissions.js +49 -0
  29. package/common-game/common/decors/Resources.d.ts +8 -0
  30. package/common-game/common/decors/Resources.js +94 -0
  31. package/common-game/common/decors/Ticks.d.ts +9 -0
  32. package/common-game/common/decors/Ticks.js +32 -0
  33. package/common-game/common/net/NetworkedMap.d.ts +28 -0
  34. package/common-game/common/net/NetworkedMap.js +225 -0
  35. package/common-game/common/types.d.ts +5 -0
  36. package/common-game/common/types.js +0 -0
  37. package/common-game/common/utils/ClassTypes.d.ts +11 -0
  38. package/common-game/common/utils/ClassTypes.js +15 -0
  39. package/common-game/common/utils/Color.d.ts +14 -0
  40. package/common-game/common/utils/Color.js +33 -0
  41. package/common-game/common/utils/Delay.d.ts +1 -0
  42. package/common-game/common/utils/Delay.js +6 -0
  43. package/common-game/common/utils/Maths.d.ts +4 -0
  44. package/common-game/common/utils/Maths.js +18 -0
  45. package/common-game/common/utils/Point.d.ts +9 -0
  46. package/common-game/common/utils/Point.js +36 -0
  47. package/common-game/common/utils/PointF.d.ts +7 -0
  48. package/common-game/common/utils/PointF.js +18 -0
  49. package/common-game/common/utils/Quaternion.d.ts +10 -0
  50. package/common-game/common/utils/Quaternion.js +33 -0
  51. package/common-game/common/utils/Vector.d.ts +429 -0
  52. package/common-game/common/utils/Vector.js +589 -0
  53. package/common-game/common/utils/cleanPlayerName.d.ts +6 -0
  54. package/common-game/common/utils/cleanPlayerName.js +17 -0
  55. package/common-game/common/utils/enumValues.d.ts +12 -0
  56. package/common-game/common/utils/enumValues.js +20 -0
  57. package/common-game/common/utils/getStringFromUInt8Array.d.ts +8 -0
  58. package/common-game/common/utils/getStringFromUInt8Array.js +6 -0
  59. package/common-game/common/utils/getUInt32FromUint8Array.d.ts +8 -0
  60. package/common-game/common/utils/getUInt32FromUint8Array.js +6 -0
  61. package/common-game/common/utils/randomInt.d.ts +1 -0
  62. package/common-game/common/utils/randomInt.js +9 -0
  63. package/common-game/definitions/index.d.js +0 -0
  64. package/common-game/definitions/redm.d.js +0 -0
  65. package/common-game/entities/CommonBaseEntity.d.ts +116 -0
  66. package/common-game/entities/CommonBaseEntity.js +266 -0
  67. package/common-game/entities/CommonBaseEntityBone.d.ts +11 -0
  68. package/common-game/entities/CommonBaseEntityBone.js +32 -0
  69. package/common-game/entities/CommonBaseEntityBoneCollection.d.ts +9 -0
  70. package/common-game/entities/CommonBaseEntityBoneCollection.js +17 -0
  71. package/common-game/entities/CommonEntityBone.d.ts +5 -0
  72. package/common-game/entities/CommonEntityBone.js +14 -0
  73. package/common-game/entities/CommonEntityBoneCollection.d.ts +9 -0
  74. package/common-game/entities/CommonEntityBoneCollection.js +24 -0
  75. package/common-game/entities/CommonEntityType.d.ts +4 -0
  76. package/common-game/entities/CommonEntityType.js +0 -0
  77. package/common-game/entities/CommonPed.d.ts +16 -0
  78. package/common-game/entities/CommonPed.js +52 -0
  79. package/common-game/entities/CommonPedBone.d.ts +6 -0
  80. package/common-game/entities/CommonPedBone.js +17 -0
  81. package/common-game/entities/CommonPedBoneCollection.d.ts +10 -0
  82. package/common-game/entities/CommonPedBoneCollection.js +31 -0
  83. package/common-game/entities/CommonPlayer.d.ts +61 -0
  84. package/common-game/entities/CommonPlayer.js +156 -0
  85. package/common-game/entities/CommonProp.d.ts +15 -0
  86. package/common-game/entities/CommonProp.js +43 -0
  87. package/common-game/entities/CommonVehicle.d.ts +11 -0
  88. package/common-game/entities/CommonVehicle.js +36 -0
  89. package/common-game/entities/GetEntityClassIdFromHandle.d.ts +2 -0
  90. package/common-game/entities/GetEntityClassIdFromHandle.js +23 -0
  91. package/common-game/entities/IHandle.d.ts +6 -0
  92. package/common-game/entities/IHandle.js +20 -0
  93. package/common-game/enums/VehicleSeat.d.ts +13 -0
  94. package/common-game/enums/VehicleSeat.js +17 -0
  95. package/common-game/index.d.ts +50 -0
  96. package/common-game/index.js +50 -0
  97. package/common-game/interfaces/Dimension.d.ts +5 -0
  98. package/common-game/interfaces/Dimension.js +0 -0
  99. package/common-game/utils/Animations.d.ts +19 -0
  100. package/common-game/utils/Animations.js +43 -0
  101. package/index.d.ts +52 -1
  102. package/index.js +52 -1
  103. package/package.json +1 -1
@@ -0,0 +1,116 @@
1
+ import type { ClassTypes } from "../common/utils/ClassTypes";
2
+ import type { Quaternion } from "../common/utils/Quaternion";
3
+ import { Vector3 } from "../common/utils/Vector";
4
+ import type { CommonBaseEntityBoneCollection } from "./CommonBaseEntityBoneCollection";
5
+ import type { StateBagChangeHandler } from "../cfx/StateBagChangeHandler";
6
+ import { CommonModel } from "../CommonModel";
7
+ import type { CommonBaseEntityBone } from "./CommonBaseEntityBone";
8
+ import { IHandle } from "./IHandle";
9
+ export declare abstract class CommonBaseEntity extends IHandle {
10
+ protected stateBagCookies: number[];
11
+ protected netId: number | null;
12
+ protected abstract type: ClassTypes;
13
+ protected abstract bones?: CommonBaseEntityBoneCollection;
14
+ constructor(handle: number);
15
+ /**
16
+ * Replaces the current handle for the entity used on, this should be used sparringly, mainly
17
+ * in situations where you're going to reuse an entity over and over and don't want to make a
18
+ * new entity every time.
19
+ *
20
+ * **WARNING**: This does no checks, if you provide it an invalid entity it will use it
21
+ *
22
+ * ```ts
23
+ * const REUSABLE_ENTITY = new Entity(entityHandle);
24
+ *
25
+ * onNet("entityHandler", (entNetId: number) => {
26
+ * // if no net entity we should ignore
27
+ * if (!NetworkDoesEntityExistWithNetworkId(entNetId)) return;
28
+ *
29
+ * // Reuse our entity so we don't have to initialize a new one
30
+ * REUSABLE_ENTITY.replaceHandle(NetworkGetEntityFromNetworkId(entNetId));
31
+ * // Do something with REUSABLE_ENTITY entity
32
+ * })
33
+ ```
34
+ */
35
+ replaceHandle(newHandle: number): void;
36
+ get Exists(): boolean;
37
+ get Handle(): number;
38
+ /**
39
+ * This will return a warning if the the entity is not networked, you should always use {@link IsNetworked} prior to calling thisl
40
+ * @returns the network for the specified entity
41
+ */
42
+ get NetworkId(): number;
43
+ /**
44
+ * @returns `true` if the current entity is networked, false otherwise
45
+ */
46
+ get IsNetworked(): boolean;
47
+ set IsNetworked(networked: boolean);
48
+ get State(): StateBagInterface;
49
+ AddStateBagChangeHandler(keyFilter: string | null, handler: StateBagChangeHandler<unknown>): number;
50
+ /**
51
+ * A short hand function for AddStateBagChangeHandler, this gets automatically cleaned up on entity deletion.
52
+ * @param keyFilter the key to filter for or null
53
+ * @param handler the function to handle the change
54
+ * @returns a cookie to be used in RemoveStateBagChangeHandler
55
+ */
56
+ listenForStateChange(keyFilter: string | null, handler: StateBagChangeHandler<unknown>): number;
57
+ removeStateListener(tgtCookie: number): void;
58
+ get Owner(): number;
59
+ get Speed(): number;
60
+ getSpeedVector(isRelative?: boolean): Vector3;
61
+ get ForwardVector(): Vector3;
62
+ get Matrix(): Vector3[];
63
+ get MaxHealth(): number;
64
+ set MaxHealth(amount: number);
65
+ set IsDead(value: boolean);
66
+ /**
67
+ * @returns Returns true if the entity is dead
68
+ */
69
+ get IsDead(): boolean;
70
+ get IsAlive(): boolean;
71
+ get Model(): CommonModel;
72
+ /**
73
+ * Returns if the entity is set as a mission entity and will not be cleaned up by the engine
74
+ */
75
+ get IsMissionEntity(): boolean;
76
+ /**
77
+ * Sets if the entity is a mission entity and will not be cleaned up by the engine
78
+ */
79
+ set IsMissionEntity(value: boolean);
80
+ set PositionNoOffset(position: Vector3);
81
+ get Rotation(): Vector3;
82
+ set Rotation(rotation: Vector3);
83
+ set Quaternion(quaternion: Quaternion);
84
+ get IsPositionFrozen(): boolean;
85
+ set IsPositionFrozen(value: boolean);
86
+ get Velocity(): Vector3;
87
+ set Velocity(velocity: Vector3);
88
+ get IsVisible(): boolean;
89
+ /**
90
+ * @param amount the health to set the health to, setting to `0` will kill the entity, if using on a {@link Ped} you should check the MaxHealth before setting.
91
+ */
92
+ set Health(amount: number);
93
+ /**
94
+ * @returns the amount of health the current {@link BaseEntity} has
95
+ */
96
+ get Health(): number;
97
+ /**
98
+ * @returns the heading of the current {@link BaseEntity}
99
+ */
100
+ get Heading(): number;
101
+ /**
102
+ * @param heading sets the entitys heading to the specified heading, this can be in the range of 0..360
103
+ */
104
+ set Heading(heading: number);
105
+ /**
106
+ * @returns the position of the current Entity
107
+ */
108
+ get Position(): Vector3;
109
+ /**
110
+ * You should always try to load the collisions before setting the entitys position if going a long distance.
111
+ * @param pos sets the position for the current ped
112
+ */
113
+ set Position(pos: Vector3);
114
+ delete(): void;
115
+ attachToBone(entityBone: CommonBaseEntityBone, position: Vector3, rotation: Vector3, collisions?: boolean, unk9?: boolean, useSoftPinning?: boolean, rotationOrder?: number): void;
116
+ }
@@ -0,0 +1,266 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Vector3 } from "../common/utils/Vector";
4
+ import cfx from "../cfx/cfx";
5
+ import { CommonModel } from "../CommonModel";
6
+ import { GlobalData } from "../common/GlobalData";
7
+ import { IHandle } from "./IHandle";
8
+ class CommonBaseEntity extends IHandle {
9
+ static {
10
+ __name(this, "CommonBaseEntity");
11
+ }
12
+ stateBagCookies = [];
13
+ netId = null;
14
+ constructor(handle) {
15
+ super(handle);
16
+ }
17
+ /**
18
+ * Replaces the current handle for the entity used on, this should be used sparringly, mainly
19
+ * in situations where you're going to reuse an entity over and over and don't want to make a
20
+ * new entity every time.
21
+ *
22
+ * **WARNING**: This does no checks, if you provide it an invalid entity it will use it
23
+ *
24
+ * ```ts
25
+ * const REUSABLE_ENTITY = new Entity(entityHandle);
26
+ *
27
+ * onNet("entityHandler", (entNetId: number) => {
28
+ * // if no net entity we should ignore
29
+ * if (!NetworkDoesEntityExistWithNetworkId(entNetId)) return;
30
+ *
31
+ * // Reuse our entity so we don't have to initialize a new one
32
+ * REUSABLE_ENTITY.replaceHandle(NetworkGetEntityFromNetworkId(entNetId));
33
+ * // Do something with REUSABLE_ENTITY entity
34
+ * })
35
+ ```
36
+ */
37
+ replaceHandle(newHandle) {
38
+ this.handle = newHandle;
39
+ }
40
+ /*
41
+ * @returns `true` if the entity exists, `false` otherwise.
42
+ */
43
+ get Exists() {
44
+ return DoesEntityExist(this.handle);
45
+ }
46
+ /*
47
+ * @returns the handle of the specified entity
48
+ */
49
+ get Handle() {
50
+ return this.handle;
51
+ }
52
+ /**
53
+ * This will return a warning if the the entity is not networked, you should always use {@link IsNetworked} prior to calling thisl
54
+ * @returns the network for the specified entity
55
+ */
56
+ get NetworkId() {
57
+ return NetworkGetNetworkIdFromEntity(this.handle);
58
+ }
59
+ /**
60
+ * @returns `true` if the current entity is networked, false otherwise
61
+ */
62
+ get IsNetworked() {
63
+ return NetworkGetEntityIsNetworked(this.handle);
64
+ }
65
+ set IsNetworked(networked) {
66
+ if (networked) {
67
+ NetworkRegisterEntityAsNetworked(this.handle);
68
+ } else {
69
+ if (GlobalData.IS_REDM) {
70
+ Citizen.invokeNative("0xE31A04513237DC89", this.handle);
71
+ } else {
72
+ NetworkUnregisterNetworkedEntity(this.handle);
73
+ }
74
+ }
75
+ }
76
+ get State() {
77
+ return cfx.Entity(this.handle).state;
78
+ }
79
+ AddStateBagChangeHandler(keyFilter, handler) {
80
+ const stateBagName = this.IsNetworked ? `entity:${this.NetworkId}` : `localEntity:${this.handle}`;
81
+ const cookie = AddStateBagChangeHandler(keyFilter, stateBagName, handler);
82
+ this.stateBagCookies.push(cookie);
83
+ return cookie;
84
+ }
85
+ /**
86
+ * A short hand function for AddStateBagChangeHandler, this gets automatically cleaned up on entity deletion.
87
+ * @param keyFilter the key to filter for or null
88
+ * @param handler the function to handle the change
89
+ * @returns a cookie to be used in RemoveStateBagChangeHandler
90
+ */
91
+ listenForStateChange(keyFilter, handler) {
92
+ return this.AddStateBagChangeHandler(keyFilter, handler);
93
+ }
94
+ removeStateListener(tgtCookie) {
95
+ this.stateBagCookies = this.stateBagCookies.filter((cookie) => {
96
+ const isCookie = cookie === tgtCookie;
97
+ if (isCookie) RemoveStateBagChangeHandler(cookie);
98
+ return isCookie;
99
+ });
100
+ }
101
+ get Owner() {
102
+ return NetworkGetEntityOwner(this.handle);
103
+ }
104
+ get Speed() {
105
+ return GetEntitySpeed(this.handle);
106
+ }
107
+ getSpeedVector(isRelative = false) {
108
+ return Vector3.fromArray(GetEntitySpeedVector(this.handle, isRelative));
109
+ }
110
+ get ForwardVector() {
111
+ return Vector3.fromArray(GetEntityForwardVector(this.handle));
112
+ }
113
+ get Matrix() {
114
+ return Vector3.fromArrays(GetEntityMatrix(this.handle));
115
+ }
116
+ get MaxHealth() {
117
+ return GetEntityMaxHealth(this.handle);
118
+ }
119
+ set MaxHealth(amount) {
120
+ SetEntityMaxHealth(this.handle, amount);
121
+ }
122
+ set IsDead(value) {
123
+ if (value) {
124
+ SetEntityHealth(this.handle, 0);
125
+ } else {
126
+ SetEntityHealth(this.handle, 200);
127
+ }
128
+ }
129
+ /**
130
+ * @returns Returns true if the entity is dead
131
+ */
132
+ get IsDead() {
133
+ return IsEntityDead(this.handle);
134
+ }
135
+ get IsAlive() {
136
+ return !IsEntityDead(this.handle);
137
+ }
138
+ get Model() {
139
+ return new CommonModel(GetEntityModel(this.handle));
140
+ }
141
+ /**
142
+ * Returns if the entity is set as a mission entity and will not be cleaned up by the engine
143
+ */
144
+ get IsMissionEntity() {
145
+ return IsEntityAMissionEntity(this.handle);
146
+ }
147
+ /**
148
+ * Sets if the entity is a mission entity and will not be cleaned up by the engine
149
+ */
150
+ set IsMissionEntity(value) {
151
+ if (value) {
152
+ SetEntityAsMissionEntity(this.handle, false, false);
153
+ } else {
154
+ SetEntityAsNoLongerNeeded(this.handle);
155
+ }
156
+ }
157
+ set PositionNoOffset(position) {
158
+ SetEntityCoordsNoOffset(this.handle, position.x, position.y, position.z, true, true, true);
159
+ }
160
+ get Rotation() {
161
+ return Vector3.fromArray(GetEntityRotation(this.handle, 2));
162
+ }
163
+ set Rotation(rotation) {
164
+ SetEntityRotation(this.handle, rotation.x, rotation.y, rotation.z, 2, true);
165
+ }
166
+ set Quaternion(quaternion) {
167
+ SetEntityQuaternion(this.handle, quaternion.x, quaternion.y, quaternion.z, quaternion.w);
168
+ }
169
+ get IsPositionFrozen() {
170
+ return IsEntityPositionFrozen(this.handle);
171
+ }
172
+ set IsPositionFrozen(value) {
173
+ FreezeEntityPosition(this.handle, value);
174
+ }
175
+ get Velocity() {
176
+ return Vector3.fromArray(GetEntityVelocity(this.handle));
177
+ }
178
+ set Velocity(velocity) {
179
+ SetEntityVelocity(this.handle, velocity.x, velocity.y, velocity.z);
180
+ }
181
+ get IsVisible() {
182
+ return IsEntityVisible(this.handle);
183
+ }
184
+ /**
185
+ * @param amount the health to set the health to, setting to `0` will kill the entity, if using on a {@link Ped} you should check the MaxHealth before setting.
186
+ */
187
+ set Health(amount) {
188
+ SetEntityHealth(this.handle, amount, 0);
189
+ }
190
+ /**
191
+ * @returns the amount of health the current {@link BaseEntity} has
192
+ */
193
+ get Health() {
194
+ return GetEntityHealth(this.handle);
195
+ }
196
+ /**
197
+ * @returns the heading of the current {@link BaseEntity}
198
+ */
199
+ get Heading() {
200
+ return GetEntityHeading(this.handle);
201
+ }
202
+ /**
203
+ * @param heading sets the entitys heading to the specified heading, this can be in the range of 0..360
204
+ */
205
+ set Heading(heading) {
206
+ SetEntityHeading(this.handle, heading);
207
+ }
208
+ /**
209
+ * @returns the position of the current Entity
210
+ */
211
+ get Position() {
212
+ return Vector3.fromArray(GetEntityCoords(this.handle, true, true));
213
+ }
214
+ /**
215
+ * You should always try to load the collisions before setting the entitys position if going a long distance.
216
+ * @param pos sets the position for the current ped
217
+ */
218
+ set Position(pos) {
219
+ SetEntityCoords(this.handle, pos.x, pos.y, pos.z, false, false, false, false);
220
+ }
221
+ delete() {
222
+ this.IsMissionEntity = true;
223
+ DeleteEntity(this.handle);
224
+ for (const cookie of this.stateBagCookies) {
225
+ RemoveStateBagChangeHandler(cookie);
226
+ }
227
+ }
228
+ /*
229
+ * Attaches an entity to another entity via a bone
230
+ * @example
231
+ * ```typescript
232
+ * const ply = Game.PlayerPed;
233
+ * const bag = await World.createProp(new Model('ba_prop_battle_bag_01b'), ply.Position, true, true, true);
234
+ * bag.attachToBone(
235
+ * ply.Bones.getBone(64113),
236
+ * new Vector3(0.12, -0.25, 0.0),
237
+ * new Vector3(105.0, 50.0, 190.0)
238
+ * )
239
+ * ```
240
+ */
241
+ attachToBone(entityBone, position, rotation, collisions = false, unk9 = true, useSoftPinning = true, rotationOrder = 1) {
242
+ if (this.handle === entityBone.Owner.Handle) {
243
+ throw new Error("You cannot attach an entity to the same entity this will result in a crash!");
244
+ }
245
+ AttachEntityToEntity(
246
+ this.handle,
247
+ entityBone.Owner.Handle,
248
+ entityBone.Index,
249
+ position.x,
250
+ position.y,
251
+ position.z,
252
+ rotation.x,
253
+ rotation.y,
254
+ rotation.z,
255
+ unk9,
256
+ useSoftPinning,
257
+ collisions,
258
+ IsEntityAPed(entityBone.Owner.Handle),
259
+ rotationOrder,
260
+ true
261
+ );
262
+ }
263
+ }
264
+ export {
265
+ CommonBaseEntity
266
+ };
@@ -0,0 +1,11 @@
1
+ import { Vector3 } from "../common/utils/Vector";
2
+ import type { IHandle } from "./IHandle";
3
+ export declare abstract class CommonBaseEntityBone {
4
+ protected readonly owner: IHandle;
5
+ protected readonly index: number;
6
+ constructor(owner: IHandle, boneIndex?: number, boneName?: string);
7
+ get Index(): number;
8
+ get Owner(): IHandle;
9
+ get Position(): Vector3;
10
+ get IsValid(): boolean;
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
+ owner;
9
+ index;
10
+ constructor(owner, boneIndex, boneName) {
11
+ this.owner = owner;
12
+ this.index = boneIndex ? boneIndex : GetEntityBoneIndexByName(this.owner.Handle, boneName ?? "");
13
+ }
14
+ get Index() {
15
+ return this.index;
16
+ }
17
+ get Owner() {
18
+ return this.owner;
19
+ }
20
+ get Position() {
21
+ return Vector3.fromArray(GetWorldPositionOfEntityBone(this.owner.Handle, this.index));
22
+ }
23
+ // public get Rotation(): Vector3 {
24
+ // return Vector3.fromArray(GetEntityBoneRotation(this.owner.Handle, this.index));
25
+ // }
26
+ get IsValid() {
27
+ return this.owner.exists() && this.index !== -1;
28
+ }
29
+ }
30
+ export {
31
+ CommonBaseEntityBone
32
+ };
@@ -0,0 +1,9 @@
1
+ import type { CommonBaseEntityBone } from "./CommonBaseEntityBone";
2
+ import type { IHandle } from "./IHandle";
3
+ export declare abstract class CommonBaseEntityBoneCollection {
4
+ protected readonly owner: IHandle;
5
+ constructor(owner: IHandle);
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 { CommonBaseEntityBone } from "./CommonBaseEntityBone";
2
+ import type { IHandle } from "./IHandle";
3
+ export declare class CommonEntityBone extends CommonBaseEntityBone {
4
+ constructor(owner: IHandle, 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 { CommonBaseEntityBoneCollection } from "./CommonBaseEntityBoneCollection";
2
+ import { CommonEntityBone } from "./CommonEntityBone";
3
+ import type { IHandle } from "./IHandle";
4
+ export declare class CommonEntityBoneCollection extends CommonBaseEntityBoneCollection {
5
+ constructor(owner: IHandle);
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,4 @@
1
+ import type { CommonPed } from "./CommonPed";
2
+ import type { CommonProp } from "./CommonProp";
3
+ import type { CommonVehicle } from "./CommonVehicle";
4
+ export type CommonEntity = CommonProp | CommonPed | CommonVehicle | null;
File without changes
@@ -0,0 +1,16 @@
1
+ import { CommonBaseEntity } from "./CommonBaseEntity";
2
+ import { CommonPlayer } from "./CommonPlayer";
3
+ import { ClassTypes } from "../common/utils/ClassTypes";
4
+ import { CommonPedBoneCollection } from "./CommonPedBoneCollection";
5
+ import { CommonTasks } from "../CommonTasks";
6
+ export declare class CommonPed extends CommonBaseEntity {
7
+ private tasks;
8
+ protected type: ClassTypes;
9
+ protected bones?: CommonPedBoneCollection;
10
+ static fromHandle(handle: number): CommonPed | null;
11
+ static fromNetworkId(networkId: number): CommonPed | null;
12
+ constructor(handle: number);
13
+ get Player(): CommonPlayer | null;
14
+ get Task(): CommonTasks;
15
+ get Bones(): CommonPedBoneCollection;
16
+ }
@@ -0,0 +1,52 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { CommonBaseEntity } from "./CommonBaseEntity";
4
+ import { CommonPlayer } from "./CommonPlayer";
5
+ import { ClassTypes } from "../common/utils/ClassTypes";
6
+ import { CommonPedBoneCollection } from "./CommonPedBoneCollection";
7
+ import { CommonTasks } from "../CommonTasks";
8
+ class CommonPed extends CommonBaseEntity {
9
+ static {
10
+ __name(this, "CommonPed");
11
+ }
12
+ tasks;
13
+ type = ClassTypes.Ped;
14
+ bones;
15
+ static fromHandle(handle) {
16
+ if (handle === 0 || !DoesEntityExist(handle)) {
17
+ return null;
18
+ }
19
+ return new this(handle);
20
+ }
21
+ static fromNetworkId(networkId) {
22
+ if (!NetworkDoesEntityExistWithNetworkId(networkId)) {
23
+ return null;
24
+ }
25
+ return new this(NetworkGetEntityFromNetworkId(networkId));
26
+ }
27
+ constructor(handle) {
28
+ super(handle);
29
+ }
30
+ get Player() {
31
+ const playerIndex = NetworkGetPlayerIndexFromPed(this.handle);
32
+ if (playerIndex === -1) {
33
+ return null;
34
+ }
35
+ return new CommonPlayer(playerIndex);
36
+ }
37
+ get Task() {
38
+ if (!this.tasks) {
39
+ this.tasks = new CommonTasks(this);
40
+ }
41
+ return this.tasks;
42
+ }
43
+ get Bones() {
44
+ if (!this.bones) {
45
+ this.bones = new CommonPedBoneCollection(this);
46
+ }
47
+ return this.bones;
48
+ }
49
+ }
50
+ export {
51
+ CommonPed
52
+ };
@@ -0,0 +1,6 @@
1
+ import { CommonBaseEntityBone } from "./CommonBaseEntityBone";
2
+ import type { IHandle } from "./IHandle";
3
+ export declare class CommonPedBone extends CommonBaseEntityBone {
4
+ constructor(owner: IHandle, boneId: number);
5
+ get IsValid(): boolean;
6
+ }
@@ -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 { CommonPedBone } from "./CommonPedBone";
3
+ import type { IHandle } from "./IHandle";
4
+ export declare class CommonPedBoneCollection extends CommonBaseEntityBoneCollection {
5
+ constructor(owner: IHandle);
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
+ };