@nativewrappers/fivem 0.0.64 → 0.0.72

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 (241) hide show
  1. package/Audio.d.ts +2 -2
  2. package/Blip.d.ts +2 -2
  3. package/Camera.d.ts +1 -1
  4. package/Game.d.ts +1 -1
  5. package/GameplayCamera.d.ts +1 -1
  6. package/Model.d.ts +1 -1
  7. package/ParticleEffect.d.ts +2 -2
  8. package/ParticleEffectAsset.d.ts +1 -1
  9. package/README.md +45 -0
  10. package/Raycast.d.ts +2 -2
  11. package/RelationshipGroup.d.ts +1 -1
  12. package/Tasks.d.ts +3 -3
  13. package/World.d.ts +2 -2
  14. package/cfx/StateBagChangeHandler.d.ts +1 -3
  15. package/common/Command.d.ts +30 -0
  16. package/common/Convar.d.ts +13 -0
  17. package/common/GlobalData.d.ts +8 -0
  18. package/common/Kvp.d.ts +69 -0
  19. package/common/Resource.d.ts +14 -0
  20. package/common/decors/Events.d.ts +54 -0
  21. package/common/index.d.ts +8 -0
  22. package/common/net/NetworkedMap.d.ts +28 -0
  23. package/common/types.d.ts +5 -0
  24. package/common/utils/ClassTypes.d.ts +11 -0
  25. package/common/utils/Color.d.ts +14 -0
  26. package/common/utils/Maths.d.ts +4 -0
  27. package/common/utils/PointF.d.ts +12 -0
  28. package/common/utils/Quaternion.d.ts +10 -0
  29. package/common/utils/Vector.d.ts +429 -0
  30. package/common/utils/Vector2.d.ts +1 -0
  31. package/common/utils/Vector3.d.ts +1 -0
  32. package/common/utils/Vector4.d.ts +1 -0
  33. package/common/utils/cleanPlayerName.d.ts +6 -0
  34. package/common/utils/enumValues.d.ts +12 -0
  35. package/{utils/getStringFromUInt8Array.js → common/utils/getStringFromUInt8Array.d.ts} +1 -3
  36. package/{utils/getUInt32FromUint8Array.js → common/utils/getUInt32FromUint8Array.d.ts} +1 -1
  37. package/common/utils/index.d.ts +12 -0
  38. package/index.d.ts +1 -1
  39. package/index.js +20136 -26
  40. package/interfaces/Dimensions.d.ts +1 -1
  41. package/models/BaseEntity.d.ts +3 -3
  42. package/models/Ped.d.ts +2 -2
  43. package/models/PedBone.d.ts +1 -1
  44. package/models/PedBoneCollection.d.ts +1 -1
  45. package/models/Player.d.ts +1 -1
  46. package/models/Vehicle.d.ts +2 -2
  47. package/models/VehicleDoor.d.ts +2 -2
  48. package/models/VehicleDoorCollection.d.ts +1 -1
  49. package/models/VehicleMod.d.ts +2 -2
  50. package/models/VehicleModCollection.d.ts +2 -2
  51. package/models/VehicleToggleMod.d.ts +2 -2
  52. package/models/VehicleWheel.d.ts +1 -1
  53. package/models/VehicleWheelCollection.d.ts +1 -1
  54. package/models/VehicleWindow.d.ts +2 -2
  55. package/models/VehicleWindowCollection.d.ts +1 -1
  56. package/package.json +6 -4
  57. package/ui/Container.d.ts +2 -2
  58. package/ui/Effects.d.ts +1 -1
  59. package/ui/Hud.d.ts +2 -2
  60. package/ui/InstructionalButtons.d.ts +1 -1
  61. package/ui/Rectangle.d.ts +2 -2
  62. package/ui/Scaleform.d.ts +1 -1
  63. package/ui/Screen.d.ts +1 -1
  64. package/ui/Text.d.ts +1 -1
  65. package/ui/interfaces/IButton.d.ts +1 -1
  66. package/ui/interfaces/IDrawable.d.ts +1 -1
  67. package/ui/menu/items/UIMenuItem.d.ts +1 -1
  68. package/ui/menu/items/UIMenuListItem.d.ts +1 -1
  69. package/ui/menu/items/panels/AbstractUIMenuPanel.d.ts +2 -2
  70. package/ui/menu/items/panels/UIMenuStatisticsPanel.d.ts +1 -1
  71. package/utils/LiteEvent.d.ts +2 -6
  72. package/utils/index.d.ts +1 -1
  73. package/weapon/DlcWeaponData.d.ts +1 -1
  74. package/weapon/Weapon.d.ts +7 -7
  75. package/weapon/WeaponAsset.d.ts +1 -1
  76. package/weapon/WeaponCollection.d.ts +2 -2
  77. package/weaponComponent/DlcWeaponComponentData.d.ts +1 -1
  78. package/weaponComponent/InvalidWeaponComponent.d.ts +1 -1
  79. package/weaponComponent/WeaponComponent.d.ts +3 -3
  80. package/weaponComponent/WeaponComponentCollection.d.ts +3 -3
  81. package/Audio.js +0 -93
  82. package/Blip.js +0 -105
  83. package/Camera.js +0 -162
  84. package/Checkpoint.js +0 -43
  85. package/Events.js +0 -74
  86. package/Game.js +0 -474
  87. package/GameplayCamera.js +0 -141
  88. package/Model.js +0 -213
  89. package/NetworkedScene.js +0 -18
  90. package/ParticleEffect.js +0 -123
  91. package/ParticleEffectAsset.js +0 -105
  92. package/Pickup.js +0 -19
  93. package/Raycast.js +0 -123
  94. package/RelationshipGroup.js +0 -67
  95. package/Rope.js +0 -129
  96. package/TaskSequence.js +0 -48
  97. package/Tasks.js +0 -241
  98. package/World.js +0 -765
  99. package/cfx/StateBagChangeHandler.js +0 -1
  100. package/cfx/index.js +0 -1
  101. package/enums/Alignment.js +0 -6
  102. package/enums/AnimationFlags.js +0 -35
  103. package/enums/AudioFlag.js +0 -38
  104. package/enums/BadgeStyle.js +0 -183
  105. package/enums/Blip.js +0 -225
  106. package/enums/Bone.js +0 -103
  107. package/enums/CameraShake.js +0 -14
  108. package/enums/CameraTypes.js +0 -8
  109. package/enums/CheckboxStyle.js +0 -5
  110. package/enums/Checkpoint.js +0 -67
  111. package/enums/CloudHat.js +0 -27
  112. package/enums/Control.js +0 -361
  113. package/enums/CursorSprite.js +0 -15
  114. package/enums/Driving.js +0 -34
  115. package/enums/ExplosionType.js +0 -45
  116. package/enums/FiringPattern.js +0 -20
  117. package/enums/Font.js +0 -8
  118. package/enums/ForceType.js +0 -9
  119. package/enums/Gender.js +0 -5
  120. package/enums/HelmetType.js +0 -6
  121. package/enums/HudColor.js +0 -184
  122. package/enums/HudComponent.js +0 -54
  123. package/enums/InputMode.js +0 -5
  124. package/enums/InvertAxis.js +0 -7
  125. package/enums/Language.js +0 -15
  126. package/enums/LeaveVehicleFlags.js +0 -11
  127. package/enums/LoadingSpinnerType.js +0 -8
  128. package/enums/MarkerType.js +0 -50
  129. package/enums/MenuAlignment.js +0 -5
  130. package/enums/NotificationType.js +0 -11
  131. package/enums/Parachute.js +0 -15
  132. package/enums/PickupType.js +0 -74
  133. package/enums/RadioStation.js +0 -25
  134. package/enums/RagdollType.js +0 -7
  135. package/enums/RaycastEnums.js +0 -32
  136. package/enums/Relationship.js +0 -10
  137. package/enums/RopeType.js +0 -6
  138. package/enums/ScreenEffect.js +0 -84
  139. package/enums/SpeechModifier.js +0 -40
  140. package/enums/Vehicle.js +0 -376
  141. package/enums/Weather.js +0 -22
  142. package/enums/ZoneID.js +0 -95
  143. package/enums/index.js +0 -42
  144. package/hashes/MaterialHash.js +0 -217
  145. package/hashes/PedHash.js +0 -725
  146. package/hashes/VehicleHash.js +0 -523
  147. package/hashes/WeaponHash.js +0 -161
  148. package/hashes/WeatherTypeHash.js +0 -22
  149. package/hashes/index.js +0 -5
  150. package/interfaces/Dimensions.js +0 -1
  151. package/models/BaseEntity.js +0 -477
  152. package/models/Entity.js +0 -25
  153. package/models/EntityBone.js +0 -26
  154. package/models/EntityBoneCollection.js +0 -18
  155. package/models/Ped.js +0 -692
  156. package/models/PedBone.js +0 -9
  157. package/models/PedBoneCollection.js +0 -21
  158. package/models/Player.js +0 -186
  159. package/models/Prop.js +0 -26
  160. package/models/Vehicle.js +0 -576
  161. package/models/VehicleDoor.js +0 -44
  162. package/models/VehicleDoorCollection.js +0 -62
  163. package/models/VehicleMod.js +0 -35
  164. package/models/VehicleModCollection.js +0 -227
  165. package/models/VehicleToggleMod.js +0 -29
  166. package/models/VehicleWheel.js +0 -23
  167. package/models/VehicleWheelCollection.js +0 -57
  168. package/models/VehicleWindow.js +0 -35
  169. package/models/VehicleWindowCollection.js +0 -57
  170. package/models/index.js +0 -19
  171. package/ui/Container.js +0 -31
  172. package/ui/Effects.js +0 -106
  173. package/ui/Fading.js +0 -69
  174. package/ui/Hud.js +0 -39
  175. package/ui/InstructionalButtons.js +0 -54
  176. package/ui/LoadingPrompt.js +0 -45
  177. package/ui/Notification.js +0 -9
  178. package/ui/Rectangle.js +0 -40
  179. package/ui/Scaleform.js +0 -236
  180. package/ui/Screen.js +0 -72
  181. package/ui/Sprite.js +0 -60
  182. package/ui/Text.js +0 -115
  183. package/ui/Timerbar.js +0 -248
  184. package/ui/index.js +0 -15
  185. package/ui/interfaces/IButton.js +0 -1
  186. package/ui/interfaces/IDrawable.js +0 -1
  187. package/ui/interfaces/index.js +0 -1
  188. package/ui/menu/Menu.js +0 -831
  189. package/ui/menu/MenuControl.js +0 -12
  190. package/ui/menu/MenuControls.js +0 -9
  191. package/ui/menu/MenuSettings.js +0 -54
  192. package/ui/menu/index.js +0 -6
  193. package/ui/menu/items/UIMenuCheckboxItem.js +0 -59
  194. package/ui/menu/items/UIMenuItem.js +0 -1111
  195. package/ui/menu/items/UIMenuListItem.js +0 -119
  196. package/ui/menu/items/UIMenuSeparatorItem.js +0 -29
  197. package/ui/menu/items/UIMenuSliderItem.js +0 -191
  198. package/ui/menu/items/index.js +0 -6
  199. package/ui/menu/items/panels/AbstractUIMenuPanel.js +0 -44
  200. package/ui/menu/items/panels/UIMenuColorPanel.js +0 -217
  201. package/ui/menu/items/panels/UIMenuGridPanel.js +0 -261
  202. package/ui/menu/items/panels/UIMenuPercentagePanel.js +0 -124
  203. package/ui/menu/items/panels/UIMenuStatisticsPanel.js +0 -79
  204. package/ui/menu/items/panels/UIMenuStatisticsPanelItem.js +0 -35
  205. package/ui/menu/items/panels/index.js +0 -6
  206. package/ui/menu/modules/ListItem.js +0 -10
  207. package/ui/menu/modules/index.js +0 -1
  208. package/utils/Animations.js +0 -55
  209. package/utils/Crypto.js +0 -25
  210. package/utils/LiteEvent.js +0 -19
  211. package/utils/Maths.js +0 -10
  212. package/utils/Point.js +0 -30
  213. package/utils/PointF.js +0 -14
  214. package/utils/Quaternion.js +0 -27
  215. package/utils/Size.js +0 -8
  216. package/utils/String.js +0 -25
  217. package/utils/enumValues.js +0 -14
  218. package/utils/index.js +0 -9
  219. package/weapon/DlcWeaponData.js +0 -44
  220. package/weapon/Mk2WeaponHash.js +0 -25
  221. package/weapon/Weapon.js +0 -270
  222. package/weapon/WeaponAsset.js +0 -84
  223. package/weapon/WeaponCollection.js +0 -187
  224. package/weapon/WeaponDisplayNameByHash.js +0 -75
  225. package/weapon/WeaponGroup.js +0 -19
  226. package/weapon/WeaponHudStats.js +0 -38
  227. package/weapon/WeaponLivery.js +0 -14
  228. package/weapon/WeaponLiveryColor.js +0 -35
  229. package/weapon/WeaponTint.js +0 -43
  230. package/weapon/index.js +0 -8
  231. package/weaponComponent/ComponentAttachmentPoint.js +0 -19
  232. package/weaponComponent/ComponentAttachmentPointByHash.js +0 -573
  233. package/weaponComponent/ComponentDisplayNameByHash.js +0 -280
  234. package/weaponComponent/DlcWeaponComponentData.js +0 -44
  235. package/weaponComponent/InvalidWeaponComponent.js +0 -28
  236. package/weaponComponent/WeaponComponent.js +0 -123
  237. package/weaponComponent/WeaponComponentCollection.js +0 -174
  238. package/weaponComponent/WeaponComponentHash.js +0 -887
  239. package/weaponComponent/WeaponComponentHashesByWeaponHash.js +0 -829
  240. package/weaponComponent/WeaponComponentHudStats.js +0 -34
  241. package/weaponComponent/index.js +0 -5
package/Model.js DELETED
@@ -1,213 +0,0 @@
1
- import { Game } from "./Game";
2
- import { VehicleHash } from "./hashes";
3
- import { Vector3, Wait } from "./utils";
4
- /**
5
- * Class to create and manage entity models.
6
- */
7
- export class Model {
8
- /**
9
- * Hash of this model.
10
- */
11
- hash;
12
- requestedModel = false;
13
- /**
14
- * Creates a model object based on the hash key or model string.
15
- *
16
- * @param hash A number or string of the model's hash. Example: "mp_m_freemode_01"
17
- */
18
- constructor(hash) {
19
- if (typeof hash === "string") {
20
- this.hash = Game.generateHash(hash);
21
- }
22
- else {
23
- this.hash = hash;
24
- }
25
- }
26
- [Symbol.dispose]() {
27
- if (this.requestedModel) {
28
- this.markAsNoLongerNeeded();
29
- }
30
- }
31
- /**
32
- * Gets the hash of the model.
33
- *
34
- * @returns The hash key.
35
- */
36
- get Hash() {
37
- return this.hash;
38
- }
39
- /**
40
- * Gets if the model is valid or not.
41
- *
42
- * @returns Whether this model is valid.
43
- */
44
- get IsValid() {
45
- return IsModelValid(this.hash);
46
- }
47
- /**
48
- * Gets if the model is in cd image or not.
49
- *
50
- * @returns Whether this model is in cd image.
51
- */
52
- get IsInCdImage() {
53
- return IsModelInCdimage(this.hash);
54
- }
55
- /**
56
- * Gets if the model is loaded or not.
57
- *
58
- * @returns Whether this model is loaded.
59
- */
60
- get IsLoaded() {
61
- return HasModelLoaded(this.hash);
62
- }
63
- /**
64
- * Gets if the model collision is loaded or not.
65
- *
66
- * @returns Whether this model collision is loaded.
67
- */
68
- get IsCollisionLoaded() {
69
- return HasCollisionForModelLoaded(this.hash);
70
- }
71
- /**
72
- * Gets if the model is a bicycle or not.
73
- *
74
- * @returns Whether this model is a bicycle.
75
- */
76
- get IsBicycle() {
77
- return IsThisModelABicycle(this.hash);
78
- }
79
- /**
80
- * Gets if the model is a motorbike or not.
81
- *
82
- * @returns Whether this model is a motorbike.
83
- */
84
- get IsBike() {
85
- return IsThisModelABike(this.hash);
86
- }
87
- /**
88
- * Gets if the model is a boat or not.
89
- *
90
- * @returns Whether this model is a boat.
91
- */
92
- get IsBoat() {
93
- return IsThisModelABoat(this.hash);
94
- }
95
- /**
96
- * Gets if the model is a car or not.
97
- *
98
- * @returns Whether this model is a car.
99
- */
100
- get IsCar() {
101
- return IsThisModelACar(this.hash);
102
- }
103
- /**
104
- * Gets if the model is a cargobob or not.
105
- *
106
- * @returns Whether this model is a cargobob.
107
- */
108
- get IsCargobob() {
109
- return (this.hash === VehicleHash.Cargobob ||
110
- this.hash === VehicleHash.Cargobob2 ||
111
- this.hash === VehicleHash.Cargobob3 ||
112
- this.hash === VehicleHash.Cargobob4);
113
- }
114
- /**
115
- * Gets if the model is a helicopter or not.
116
- *
117
- * @returns Whether this model is a helicopter.
118
- */
119
- get IsHelicopter() {
120
- return IsThisModelAHeli(this.hash);
121
- }
122
- /**
123
- * Gets if the model is a Ped or not.
124
- *
125
- * @returns Whether this model is a Ped.
126
- */
127
- get IsPed() {
128
- return IsModelAPed(this.hash);
129
- }
130
- /**
131
- * Gets if the model is a plane or not.
132
- *
133
- * @returns Whether this model is a plane.
134
- */
135
- get IsPlane() {
136
- return IsThisModelAPlane(this.hash);
137
- }
138
- /**
139
- * Gets if the model is a prop or not.
140
- *
141
- * @returns Whether this model is a prop.
142
- */
143
- get IsProp() {
144
- return (this.IsValid &&
145
- !this.IsPed &&
146
- !this.IsVehicle &&
147
- !IsWeaponValid(this.hash));
148
- }
149
- /**
150
- * Gets if the model is a quadbike or not.
151
- *
152
- * @returns Whether this model is a quadbike.
153
- */
154
- get IsQuadbike() {
155
- return IsThisModelAQuadbike(this.hash);
156
- }
157
- /**
158
- * Gets if the model is a train or not.
159
- *
160
- * @returns Whether this model is a train.
161
- */
162
- get IsTrain() {
163
- return IsThisModelATrain(this.hash);
164
- }
165
- /**
166
- * Gets if the model is a Vehicle or not.
167
- *
168
- * @returns Whether this model is a Vehicle.
169
- */
170
- get IsVehicle() {
171
- return IsModelAVehicle(this.hash);
172
- }
173
- /**
174
- * Gets the model dimensions.
175
- *
176
- * @returns This model min & max dimensions.
177
- */
178
- get Dimensions() {
179
- const [minArray, maxArray] = GetModelDimensions(this.hash);
180
- const min = Vector3.fromArray(minArray);
181
- const max = Vector3.fromArray(maxArray);
182
- return { min, max };
183
- }
184
- /**
185
- * Request and load the model with a specified timeout. Default timeout is 1000 (recommended).
186
- * This function will not automatically set the model as no longer needed when
187
- * done.
188
- *
189
- * @param timeoutMs Maximum allowed time for model to load.
190
- */
191
- async request(timeoutMs = 1000) {
192
- if (!this.IsInCdImage && !this.IsValid && !IsWeaponValid(this.hash)) {
193
- return false;
194
- }
195
- // pre-check so if its already loaded we don't add another ref
196
- if (this.IsLoaded) {
197
- return true;
198
- }
199
- RequestModel(this.hash);
200
- const timeout = GetGameTimer() + timeoutMs;
201
- while (!this.IsLoaded && GetGameTimer() < timeout) {
202
- await Wait(0);
203
- }
204
- this.requestedModel = true;
205
- return this.IsLoaded;
206
- }
207
- /**
208
- * Sets the model as no longer needed allowing the game engine to free memory.
209
- */
210
- markAsNoLongerNeeded() {
211
- SetModelAsNoLongerNeeded(this.hash);
212
- }
213
- }
package/NetworkedScene.js DELETED
@@ -1,18 +0,0 @@
1
- export class NetworkedScene {
2
- scene;
3
- constructor(pos, rot, rotationOrder, holdLastFrame, looped, sceneHash, animTime, animSpeed) {
4
- this.scene = NetworkCreateSynchronisedScene(pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, rotationOrder, holdLastFrame, looped, sceneHash, animTime + 0.0, animSpeed + 0.0);
5
- }
6
- addPed(ped, animDict, animName, blendInSpeed, blendOutSpeed, duration, flag, playbackRate, p9) {
7
- NetworkAddPedToSynchronisedScene(ped.Handle, this.scene, animDict, animName, blendInSpeed, blendOutSpeed, duration, flag, playbackRate, p9);
8
- }
9
- addEntity(entity, animDict, animName, speed, speedMultiplier, flag) {
10
- NetworkAddEntityToSynchronisedScene(entity.Handle, this.scene, animDict, animName, speed, speedMultiplier, flag);
11
- }
12
- start() {
13
- NetworkStartSynchronisedScene(this.scene);
14
- }
15
- stop() {
16
- NetworkStopSynchronisedScene(this.scene);
17
- }
18
- }
package/ParticleEffect.js DELETED
@@ -1,123 +0,0 @@
1
- import { InvertAxisFlags } from "./enums";
2
- import { Color, Vector3 } from "./utils";
3
- // TODO: Lots of Matrix stuff through memory access
4
- /**
5
- * UNFINISHED! Class to manage particle effects.
6
- */
7
- export class ParticleEffect {
8
- asset;
9
- effectName;
10
- offset = new Vector3(0, 0, 0);
11
- rotation = new Vector3(0, 0, 0);
12
- color = Color.Transparent;
13
- scale = 1.0;
14
- range = 1.0;
15
- invertAxis = { flags: InvertAxisFlags.None };
16
- handle;
17
- /**
18
- * Creates a particle effect.
19
- *
20
- * @param asset Particle effect asset.
21
- * @param effectName Name of effect.
22
- */
23
- constructor(asset, effectName) {
24
- this.handle = -1;
25
- this.asset = asset;
26
- this.effectName = effectName;
27
- }
28
- /**
29
- * Get the particle effect handle.
30
- */
31
- get Handle() {
32
- return this.handle;
33
- }
34
- /**
35
- * Get whether particle effect is currently active.
36
- */
37
- get IsActive() {
38
- return this.Handle !== -1 && DoesParticleFxLoopedExist(this.Handle);
39
- }
40
- /**
41
- * Stop a particle effect.
42
- */
43
- stop() {
44
- if (this.IsActive) {
45
- RemoveParticleFx(this.Handle, false);
46
- }
47
- this.handle = -1;
48
- }
49
- /**
50
- * Get the rotation of the particle effect.
51
- */
52
- get Rotation() {
53
- return this.rotation;
54
- }
55
- /**
56
- * Set the rotation of the particle effect.
57
- */
58
- set Rotation(rotation) {
59
- this.rotation = rotation;
60
- if (this.IsActive) {
61
- const off = this.offset; // TODO Matrix stuff to access from memory
62
- SetParticleFxLoopedOffsets(this.Handle, off.x, off.y, off.z, rotation.x, rotation.y, rotation.z);
63
- }
64
- }
65
- /**
66
- * Get the range of the particle effect.
67
- */
68
- get Range() {
69
- return this.range;
70
- }
71
- /**
72
- * Set the range of the particle effect.
73
- */
74
- set Range(range) {
75
- this.range = range;
76
- SetParticleFxLoopedRange(this.Handle, range);
77
- }
78
- /**
79
- * Get the invert axis flag of the particle effect.
80
- */
81
- get InvertAxis() {
82
- return this.invertAxis;
83
- }
84
- /**
85
- * Set the inverted axis of the particle effect.
86
- */
87
- set InvertAxis(invertAxis) {
88
- this.invertAxis = invertAxis;
89
- if (this.IsActive) {
90
- this.stop();
91
- this.start();
92
- }
93
- }
94
- /**
95
- * Set a paramaeter of a particle effect.
96
- *
97
- * @param parameterName Name of parameter.
98
- * @param value Value of parameter.
99
- */
100
- setParameter(parameterName, value) {
101
- if (this.IsActive) {
102
- SetParticleFxLoopedEvolution(this.Handle, parameterName, value, false);
103
- }
104
- }
105
- /**
106
- * Get the name of the particle effect asset. Same as ParticleEffect.AssetName.
107
- */
108
- get AssetName() {
109
- return this.asset.AssetName;
110
- }
111
- /**
112
- * Get the name of the particle effect.
113
- */
114
- get EffectName() {
115
- return this.effectName;
116
- }
117
- /**
118
- * Return the particle effect as string. `AssetName`\\`EffectName`.
119
- */
120
- toString() {
121
- return `${this.AssetName}\\${this.EffectName}`;
122
- }
123
- }
@@ -1,105 +0,0 @@
1
- import { InvertAxisFlags } from "./enums";
2
- import { Vector3 } from "./utils";
3
- /**
4
- * UNFINISHED! Class that represents a particle effect asset.
5
- */
6
- export class ParticleEffectAsset {
7
- /**
8
- * Returns the name of the asset. Same as AssetName.
9
- */
10
- get Asset() {
11
- return this.assetName;
12
- }
13
- assetName;
14
- constructor(assetName) {
15
- this.assetName = assetName;
16
- }
17
- /**
18
- * Get the name of the particle effect.
19
- */
20
- get AssetName() {
21
- return this.assetName;
22
- }
23
- /**
24
- * Get whether the particle effect has loaded into game memory.
25
- */
26
- get IsLoaded() {
27
- return HasNamedPtfxAssetLoaded(this.assetName);
28
- }
29
- /**
30
- * Start a particle effect at a world position.
31
- *
32
- * @param effectName Name of effect.
33
- * @param rot Rotation from entity position.
34
- * @param scale Size of the effect.
35
- * @param invertAxis Which axis to invert (default none).
36
- */
37
- startNonLoopedAtCoord(effectName, pos, rot = new Vector3(0, 0, 0), scale = 1.0, invertAxis = { flags: InvertAxisFlags.None }) {
38
- if (!this.setNextCall()) {
39
- return false;
40
- }
41
- const invertAxisFlags = invertAxis.flags;
42
- SetPtfxAssetNextCall(this.assetName);
43
- return (StartParticleFxLoopedAtCoord(effectName, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, !!(invertAxisFlags & InvertAxisFlags.X), !!(invertAxisFlags & InvertAxisFlags.Y), !!(invertAxisFlags & InvertAxisFlags.Z), false) > 0);
44
- }
45
- /**
46
- * Start a particle effect on an entity
47
- *
48
- * @param effectName Name of effect.
49
- * @param entity Entity to use effect on.
50
- * @param off Offset from entity position.
51
- * @param rot Rotation from entity position.
52
- * @param scale Size of the effect.
53
- * @param invertAxis Which axis to invert (default none).
54
- */
55
- startNonLoopedOnEntity(effectName, entity, off = new Vector3(0, 0, 0), rot = new Vector3(0, 0, 0), scale = 1.0, invertAxis = { flags: InvertAxisFlags.None }) {
56
- if (!this.setNextCall()) {
57
- return false;
58
- }
59
- const invertAxisFlags = invertAxis.flags;
60
- SetPtfxAssetNextCall(this.assetName);
61
- // This still returns
62
- return !!StartParticleFxLoopedOnEntity(effectName, entity.Handle, off.x, off.y, off.z, rot.x, rot.y, rot.z, scale, !!(invertAxisFlags & InvertAxisFlags.X), !!(invertAxisFlags & InvertAxisFlags.Y), !!(invertAxisFlags & InvertAxisFlags.Z));
63
- }
64
- /**
65
- * Load a particle effect into the game memory.
66
- *
67
- * @param timeout Max time to load Particle Effect
68
- */
69
- request(timeout) {
70
- return new Promise((resolve) => {
71
- if (!this.IsLoaded) {
72
- RequestNamedPtfxAsset(this.assetName);
73
- const start = GetGameTimer();
74
- const interval = setInterval(() => {
75
- if (this.IsLoaded || GetGameTimer() - start >= timeout) {
76
- clearInterval(interval);
77
- resolve(this.IsLoaded);
78
- }
79
- }, 0);
80
- }
81
- else {
82
- resolve(this.IsLoaded);
83
- }
84
- });
85
- }
86
- /**
87
- * Allow game engine to safely unload particle effect model from memory.
88
- */
89
- markAsNoLongerNeeded() {
90
- RemoveNamedPtfxAsset(this.assetName);
91
- }
92
- toString() {
93
- return this.assetName;
94
- }
95
- setNextCall() {
96
- if (!this.IsLoaded) {
97
- RequestNamedPtfxAsset(this.assetName);
98
- }
99
- else {
100
- SetPtfxAssetNextCall(this.assetName);
101
- return true;
102
- }
103
- return false;
104
- }
105
- }
package/Pickup.js DELETED
@@ -1,19 +0,0 @@
1
- import { Vector3 } from "./utils";
2
- export class Pickup {
3
- handle;
4
- constructor(handle) {
5
- this.handle = handle;
6
- }
7
- get Position() {
8
- return Vector3.fromArray(GetPickupCoords(this.handle));
9
- }
10
- get IsCollected() {
11
- return HasPickupBeenCollected(this.handle);
12
- }
13
- delete() {
14
- RemovePickup(this.handle);
15
- }
16
- exists() {
17
- return DoesPickupExist(this.handle);
18
- }
19
- }
package/Raycast.js DELETED
@@ -1,123 +0,0 @@
1
- import { ShapeTestStatus } from "./enums/RaycastEnums";
2
- import { Game } from "./Game";
3
- import { Delay, Vector3 } from "./utils";
4
- /**
5
- * Class that represents the result of a raycast.
6
- */
7
- class RaycastResult {
8
- /**
9
- * Return the entity that was hit.
10
- */
11
- get HitEntity() {
12
- return this.entityHandleArg;
13
- }
14
- /**
15
- * Get the position of the entity that was hit.
16
- */
17
- get HitPosition() {
18
- return this.hitPositionArg;
19
- }
20
- /**
21
- * Return the vector perpendicular to the tangent plane.
22
- */
23
- get SurfaceNormal() {
24
- return this.surfaceNormalArg;
25
- }
26
- /**
27
- * Whether we hit anything.
28
- */
29
- get DidHit() {
30
- return this.hitSomethingArg;
31
- }
32
- /**
33
- * Whether the entity hit exists.
34
- */
35
- get DidHitEntity() {
36
- return this.entityHandleArg !== null && this.entityHandleArg.Handle !== 0;
37
- }
38
- /**
39
- * Material type that was hit.
40
- */
41
- get Material() {
42
- return this.materialArg;
43
- }
44
- /**
45
- * Raycast result's handle.
46
- */
47
- get Result() {
48
- return this.result;
49
- }
50
- /**
51
- * @returns if the shape test handle was already discarded
52
- */
53
- get WasDiscarded() {
54
- return this.result === ShapeTestStatus.Discarded;
55
- }
56
- /**
57
- * NOTE: These will not be updated unless polled by `resolve` or the shape
58
- * test is synchronous
59
- * @returns if the raycast has been marked as ready by the engine
60
- */
61
- get HasResolved() {
62
- return this.result === ShapeTestStatus.Ready;
63
- }
64
- applyShapeTestResults() {
65
- const [result, hit, endCoords, surfaceNormal, materialHash, entityHit] = GetShapeTestResultIncludingMaterial(this.handle);
66
- this.result = result;
67
- if (!this.HasResolved || this.WasDiscarded)
68
- return;
69
- this.hitSomethingArg = hit;
70
- this.hitPositionArg = Vector3.fromArray(endCoords);
71
- this.surfaceNormalArg = Vector3.fromArray(surfaceNormal);
72
- this.materialArg = materialHash;
73
- if (entityHit !== 0) {
74
- this.entityHandleArg = Game.entityFromHandle(entityHit);
75
- }
76
- }
77
- handle;
78
- hitPositionArg;
79
- hitSomethingArg;
80
- entityHandleArg;
81
- surfaceNormalArg;
82
- materialArg;
83
- result;
84
- /**
85
- * Create a RaycastResult object that gets the results from a StartShapeTestRay()
86
- *
87
- * @param handle The handle returned from StartShapeTestRay()
88
- */
89
- constructor(handle) {
90
- this.handle = handle;
91
- this.hitPositionArg = new Vector3(0, 0, 0);
92
- this.hitSomethingArg = false;
93
- this.entityHandleArg = null;
94
- this.surfaceNormalArg = new Vector3(0, 0, 0);
95
- this.materialArg = 0;
96
- this.result = ShapeTestStatus.NotReady;
97
- }
98
- }
99
- export class SynchronousRaycastResult extends RaycastResult {
100
- constructor(handle) {
101
- super(handle);
102
- // if we're using a synchronous call then we want to instantly update our
103
- // data, if its invalid then the caller can deal with it.
104
- this.applyShapeTestResults();
105
- }
106
- }
107
- export class AsynchronousRaycastResult extends RaycastResult {
108
- /**
109
- * waits until the shape test handle is valid and then sets the expected
110
- * values on the RaycastResult
111
- */
112
- async resolve(timeoutInMs = 1000) {
113
- const timeout = GetGameTimer() + timeoutInMs;
114
- // this has to be polled every frame or the engien will mark the field shape
115
- // test handle as discarded
116
- while (!this.HasResolved && !this.WasDiscarded) {
117
- this.applyShapeTestResults();
118
- if (timeout < GetGameTimer())
119
- break;
120
- await Delay(0);
121
- }
122
- }
123
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * Class to create and manage a relationship group. Useful to manage behavior between Peds.
3
- */
4
- export class RelationshipGroup {
5
- /**
6
- * The hash of the relationship group
7
- */
8
- hash;
9
- /**
10
- * Create a relationship group. Optionally pass a group hash.
11
- *
12
- * @param name Name of the relationship group.
13
- */
14
- constructor(name) {
15
- const [, groupHash] = AddRelationshipGroup(name);
16
- this.hash = groupHash;
17
- }
18
- /**
19
- * Gets the hash of the relationship group.
20
- *
21
- * @returns The hash of this object.
22
- */
23
- get Hash() {
24
- return this.hash;
25
- }
26
- /**
27
- * Get the relationship between two relationship groups.
28
- *
29
- * @param targetGroup The other relationship group.
30
- * @returns The relationship
31
- */
32
- getRelationshipBetweenGroups(targetGroup) {
33
- return GetRelationshipBetweenGroups(this.Hash, targetGroup.Hash);
34
- }
35
- /**
36
- * Set the relationship group between this relationship group and another one.
37
- *
38
- * @param targetGroup The other relationship group.
39
- * @param relationship The desired relationship.
40
- * @param biDirectionally If target group should have same relationship towards this.
41
- */
42
- setRelationshipBetweenGroups(targetGroup, relationship, biDirectionally = false) {
43
- SetRelationshipBetweenGroups(Number(relationship), this.Hash, targetGroup.Hash);
44
- if (biDirectionally) {
45
- SetRelationshipBetweenGroups(Number(relationship), targetGroup.Hash, this.Hash);
46
- }
47
- }
48
- /**
49
- * Clear the relationship between this relationship group and another.
50
- *
51
- * @param targetGroup The other relationship group.
52
- * @param relationship The desired relationship to clear.
53
- * @param biDirectionally Whether the target group should also clear the relationship.
54
- */
55
- clearRelationshipBetweenGroups(targetGroup, relationship, biDirectionally = false) {
56
- ClearRelationshipBetweenGroups(Number(relationship), this.Hash, targetGroup.Hash);
57
- if (biDirectionally) {
58
- ClearRelationshipBetweenGroups(Number(relationship), targetGroup.Hash, this.Hash);
59
- }
60
- }
61
- /**
62
- * Remove this relationship group from the game. This will not delete this object.
63
- */
64
- remove() {
65
- RemoveRelationshipGroup(this.Hash);
66
- }
67
- }