@nativewrappers/fivem 0.0.80 → 0.0.82

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 (265) hide show
  1. package/Audio.d.ts +2 -2
  2. package/Audio.js +99 -0
  3. package/Blip.d.ts +4 -3
  4. package/Blip.js +113 -0
  5. package/Camera.d.ts +3 -3
  6. package/Camera.js +190 -0
  7. package/Checkpoint.d.ts +2 -2
  8. package/Checkpoint.js +51 -0
  9. package/Events.js +80 -0
  10. package/Game.d.ts +10 -3
  11. package/Game.js +478 -0
  12. package/GameplayCamera.d.ts +2 -2
  13. package/GameplayCamera.js +152 -0
  14. package/Model.js +210 -0
  15. package/NetworkedScene.d.ts +2 -1
  16. package/NetworkedScene.js +50 -0
  17. package/ParticleEffect.d.ts +4 -3
  18. package/ParticleEffect.js +128 -0
  19. package/ParticleEffectAsset.d.ts +2 -2
  20. package/ParticleEffectAsset.js +133 -0
  21. package/Pickup.d.ts +1 -1
  22. package/Pickup.js +27 -0
  23. package/Raycast.d.ts +5 -3
  24. package/Raycast.js +132 -0
  25. package/RelationshipGroup.d.ts +1 -1
  26. package/RelationshipGroup.js +72 -0
  27. package/Rope.d.ts +1 -1
  28. package/Rope.js +149 -0
  29. package/TaskSequence.js +52 -0
  30. package/Tasks.d.ts +8 -3
  31. package/Tasks.js +334 -0
  32. package/World.d.ts +13 -4
  33. package/World.js +945 -0
  34. package/cfx/StateBagChangeHandler.js +0 -0
  35. package/cfx/index.d.ts +1 -1
  36. package/cfx/index.js +4 -0
  37. package/common/Command.js +111 -0
  38. package/common/Convar.js +58 -0
  39. package/common/GlobalData.js +16 -0
  40. package/common/Kvp.js +137 -0
  41. package/common/Resource.js +54 -0
  42. package/common/decors/Events.js +170 -0
  43. package/common/net/NetworkedMap.js +225 -0
  44. package/common/types.js +0 -0
  45. package/common/utils/ClassTypes.js +15 -0
  46. package/common/utils/Color.js +33 -0
  47. package/common/utils/Delay.d.ts +1 -0
  48. package/common/utils/Delay.js +6 -0
  49. package/common/utils/Maths.js +18 -0
  50. package/common/utils/Point.d.ts +9 -0
  51. package/common/utils/Point.js +36 -0
  52. package/common/utils/PointF.d.ts +1 -1
  53. package/common/utils/PointF.js +18 -0
  54. package/common/utils/Quaternion.d.ts +1 -1
  55. package/common/utils/Quaternion.js +33 -0
  56. package/common/utils/Vector.js +589 -0
  57. package/common/utils/cleanPlayerName.js +17 -0
  58. package/common/utils/enumValues.js +20 -0
  59. package/common/utils/getStringFromUInt8Array.js +6 -0
  60. package/common/utils/getUInt32FromUint8Array.js +6 -0
  61. package/enums/Alignment.js +9 -0
  62. package/enums/AnimationFlags.js +38 -0
  63. package/enums/AudioFlag.js +41 -0
  64. package/enums/BadgeStyle.js +186 -0
  65. package/enums/Blip.js +229 -0
  66. package/enums/Bone.js +105 -0
  67. package/enums/CameraShake.js +17 -0
  68. package/enums/CameraTypes.js +11 -0
  69. package/enums/CheckboxStyle.js +8 -0
  70. package/enums/Checkpoint.js +68 -0
  71. package/enums/CloudHat.js +27 -0
  72. package/enums/Control.js +364 -0
  73. package/enums/CursorSprite.js +18 -0
  74. package/enums/Driving.js +38 -0
  75. package/enums/ExplosionType.js +45 -0
  76. package/enums/FiringPattern.js +23 -0
  77. package/enums/Font.js +11 -0
  78. package/enums/ForceType.js +12 -0
  79. package/enums/Gender.js +8 -0
  80. package/enums/HelmetType.js +9 -0
  81. package/enums/HudColor.js +187 -0
  82. package/enums/HudComponent.js +57 -0
  83. package/enums/InputMode.js +8 -0
  84. package/enums/InvertAxis.js +10 -0
  85. package/enums/Language.js +18 -0
  86. package/enums/LeaveVehicleFlags.js +14 -0
  87. package/enums/LoadingSpinnerType.js +11 -0
  88. package/enums/MarkerType.js +48 -0
  89. package/enums/MenuAlignment.js +8 -0
  90. package/enums/NotificationType.js +14 -0
  91. package/enums/Parachute.js +19 -0
  92. package/enums/PickupType.js +77 -0
  93. package/enums/RadioStation.js +28 -0
  94. package/enums/RagdollType.js +10 -0
  95. package/enums/RaycastEnums.js +33 -0
  96. package/enums/Relationship.js +13 -0
  97. package/enums/RopeType.js +9 -0
  98. package/enums/ScreenEffect.js +87 -0
  99. package/enums/SpeechModifier.js +43 -0
  100. package/enums/Vehicle.js +396 -0
  101. package/enums/Weather.js +22 -0
  102. package/enums/ZoneID.js +95 -0
  103. package/hashes/MaterialHash.js +220 -0
  104. package/hashes/PedHash.js +728 -0
  105. package/hashes/VehicleHash.js +526 -0
  106. package/hashes/WeaponHash.js +155 -0
  107. package/hashes/WeatherTypeHash.js +22 -0
  108. package/index.js +166 -18794
  109. package/interfaces/Dimensions.d.ts +1 -1
  110. package/interfaces/Dimensions.js +0 -0
  111. package/models/BaseEntity.d.ts +10 -8
  112. package/models/BaseEntity.js +576 -0
  113. package/models/Entity.d.ts +0 -1
  114. package/models/Entity.js +0 -0
  115. package/models/EntityBone.d.ts +1 -1
  116. package/models/EntityBone.js +32 -0
  117. package/models/EntityBoneCollection.d.ts +1 -1
  118. package/models/EntityBoneCollection.js +27 -0
  119. package/models/Ped.d.ts +13 -5
  120. package/models/Ped.js +711 -0
  121. package/models/PedBone.d.ts +3 -2
  122. package/models/PedBone.js +18 -0
  123. package/models/PedBoneCollection.d.ts +3 -1
  124. package/models/PedBoneCollection.js +31 -0
  125. package/models/Player.d.ts +4 -2
  126. package/models/Player.js +188 -0
  127. package/models/Prop.d.ts +1 -1
  128. package/models/Prop.js +34 -0
  129. package/models/Vehicle.d.ts +9 -4
  130. package/models/Vehicle.js +582 -0
  131. package/models/VehicleDoor.d.ts +1 -1
  132. package/models/VehicleDoor.js +52 -0
  133. package/models/VehicleDoorCollection.d.ts +1 -1
  134. package/models/VehicleDoorCollection.js +66 -0
  135. package/models/VehicleMod.d.ts +1 -1
  136. package/models/VehicleMod.js +43 -0
  137. package/models/VehicleModCollection.d.ts +2 -2
  138. package/models/VehicleModCollection.js +227 -0
  139. package/models/VehicleToggleMod.d.ts +1 -1
  140. package/models/VehicleToggleMod.js +37 -0
  141. package/models/VehicleWheel.js +31 -0
  142. package/models/VehicleWheelCollection.d.ts +1 -1
  143. package/models/VehicleWheelCollection.js +61 -0
  144. package/models/VehicleWindow.d.ts +1 -1
  145. package/models/VehicleWindow.js +43 -0
  146. package/models/VehicleWindowCollection.d.ts +1 -1
  147. package/models/VehicleWindowCollection.js +62 -0
  148. package/package.json +2 -2
  149. package/ui/Container.d.ts +4 -2
  150. package/ui/Container.js +39 -0
  151. package/ui/Effects.d.ts +1 -1
  152. package/ui/Effects.js +112 -0
  153. package/ui/Fading.js +74 -0
  154. package/ui/Hud.d.ts +3 -2
  155. package/ui/Hud.js +47 -0
  156. package/ui/InstructionalButtons.js +42 -0
  157. package/ui/LoadingPrompt.d.ts +1 -1
  158. package/ui/LoadingPrompt.js +37 -0
  159. package/ui/Notification.js +17 -0
  160. package/ui/Rectangle.d.ts +4 -2
  161. package/ui/Rectangle.js +46 -0
  162. package/ui/Scaleform.d.ts +2 -1
  163. package/ui/Scaleform.js +240 -0
  164. package/ui/Screen.d.ts +6 -3
  165. package/ui/Screen.js +83 -0
  166. package/ui/Sprite.d.ts +3 -1
  167. package/ui/Sprite.js +70 -0
  168. package/ui/Text.d.ts +6 -3
  169. package/ui/Text.js +119 -0
  170. package/ui/Timerbar.js +241 -0
  171. package/ui/interfaces/IButton.d.ts +1 -1
  172. package/ui/interfaces/IButton.js +0 -0
  173. package/ui/interfaces/IDrawable.d.ts +3 -1
  174. package/ui/interfaces/IDrawable.js +0 -0
  175. package/ui/menu/Menu.d.ts +9 -4
  176. package/ui/menu/Menu.js +830 -0
  177. package/ui/menu/MenuControl.js +20 -0
  178. package/ui/menu/MenuControls.js +17 -0
  179. package/ui/menu/MenuSettings.d.ts +1 -1
  180. package/ui/menu/MenuSettings.js +57 -0
  181. package/ui/menu/items/UIMenuCheckboxItem.d.ts +3 -3
  182. package/ui/menu/items/UIMenuCheckboxItem.js +70 -0
  183. package/ui/menu/items/UIMenuItem.d.ts +10 -4
  184. package/ui/menu/items/UIMenuItem.js +1103 -0
  185. package/ui/menu/items/UIMenuListItem.d.ts +3 -3
  186. package/ui/menu/items/UIMenuListItem.js +118 -0
  187. package/ui/menu/items/UIMenuSeparatorItem.d.ts +1 -1
  188. package/ui/menu/items/UIMenuSeparatorItem.js +37 -0
  189. package/ui/menu/items/UIMenuSliderItem.d.ts +4 -3
  190. package/ui/menu/items/UIMenuSliderItem.js +180 -0
  191. package/ui/menu/items/panels/AbstractUIMenuPanel.d.ts +4 -3
  192. package/ui/menu/items/panels/AbstractUIMenuPanel.js +49 -0
  193. package/ui/menu/items/panels/UIMenuColorPanel.d.ts +3 -3
  194. package/ui/menu/items/panels/UIMenuColorPanel.js +215 -0
  195. package/ui/menu/items/panels/UIMenuGridPanel.d.ts +3 -3
  196. package/ui/menu/items/panels/UIMenuGridPanel.js +216 -0
  197. package/ui/menu/items/panels/UIMenuPercentagePanel.d.ts +2 -2
  198. package/ui/menu/items/panels/UIMenuPercentagePanel.js +138 -0
  199. package/ui/menu/items/panels/UIMenuStatisticsPanel.d.ts +3 -2
  200. package/ui/menu/items/panels/UIMenuStatisticsPanel.js +88 -0
  201. package/ui/menu/items/panels/UIMenuStatisticsPanelItem.d.ts +2 -1
  202. package/ui/menu/items/panels/UIMenuStatisticsPanelItem.js +48 -0
  203. package/ui/menu/modules/ListItem.js +18 -0
  204. package/utils/Animations.js +43 -0
  205. package/utils/Crypto.js +33 -0
  206. package/utils/LiteEvent.js +25 -0
  207. package/utils/Maths.js +18 -0
  208. package/utils/Point.js +36 -0
  209. package/utils/Size.js +16 -0
  210. package/utils/String.d.ts +1 -1
  211. package/utils/String.js +35 -0
  212. package/weapon/DlcWeaponData.d.ts +1 -1
  213. package/weapon/DlcWeaponData.js +40 -0
  214. package/weapon/Mk2WeaponHash.js +18 -0
  215. package/weapon/Weapon.d.ts +7 -7
  216. package/weapon/Weapon.js +276 -0
  217. package/weapon/WeaponAsset.d.ts +1 -1
  218. package/weapon/WeaponAsset.js +87 -0
  219. package/weapon/WeaponCollection.d.ts +3 -2
  220. package/weapon/WeaponCollection.js +179 -0
  221. package/weapon/WeaponDisplayNameByHash.d.ts +1 -1
  222. package/weapon/WeaponDisplayNameByHash.js +73 -0
  223. package/weapon/WeaponGroup.js +22 -0
  224. package/weapon/WeaponHudStats.d.ts +1 -1
  225. package/weapon/WeaponHudStats.js +33 -0
  226. package/weapon/WeaponLivery.js +17 -0
  227. package/weapon/WeaponLiveryColor.js +38 -0
  228. package/weapon/WeaponTint.js +46 -0
  229. package/weaponComponent/ComponentAttachmentPoint.js +22 -0
  230. package/weaponComponent/ComponentAttachmentPointByHash.js +307 -0
  231. package/weaponComponent/ComponentDisplayNameByHash.js +278 -0
  232. package/weaponComponent/DlcWeaponComponentData.js +40 -0
  233. package/weaponComponent/InvalidWeaponComponent.d.ts +1 -1
  234. package/weaponComponent/InvalidWeaponComponent.js +31 -0
  235. package/weaponComponent/WeaponComponent.d.ts +4 -4
  236. package/weaponComponent/WeaponComponent.js +124 -0
  237. package/weaponComponent/WeaponComponentCollection.d.ts +2 -2
  238. package/weaponComponent/WeaponComponentCollection.js +187 -0
  239. package/weaponComponent/WeaponComponentHash.js +670 -0
  240. package/weaponComponent/WeaponComponentHashesByWeaponHash.d.ts +1 -1
  241. package/weaponComponent/WeaponComponentHashesByWeaponHash.js +864 -0
  242. package/weaponComponent/WeaponComponentHudStats.js +33 -0
  243. package/common/index.d.ts +0 -8
  244. package/common/utils/Vector2.d.ts +0 -1
  245. package/common/utils/Vector3.d.ts +0 -1
  246. package/common/utils/Vector4.d.ts +0 -1
  247. package/common/utils/index.d.ts +0 -12
  248. package/enums/index.d.ts +0 -42
  249. package/hashes/index.d.ts +0 -5
  250. package/index.d.ts +0 -25
  251. package/models/index.d.ts +0 -18
  252. package/ui/index.d.ts +0 -15
  253. package/ui/interfaces/index.d.ts +0 -2
  254. package/ui/menu/index.d.ts +0 -6
  255. package/ui/menu/items/index.d.ts +0 -6
  256. package/ui/menu/items/panels/index.d.ts +0 -6
  257. package/ui/menu/modules/index.d.ts +0 -1
  258. package/utils/PointF.d.ts +0 -7
  259. package/utils/Quaternion.d.ts +0 -10
  260. package/utils/enumValues.d.ts +0 -12
  261. package/utils/getStringFromUInt8Array.d.ts +0 -8
  262. package/utils/getUInt32FromUint8Array.d.ts +0 -8
  263. package/utils/index.d.ts +0 -9
  264. package/weapon/index.d.ts +0 -8
  265. package/weaponComponent/index.d.ts +0 -5
@@ -0,0 +1,31 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { WeaponComponent } from "./WeaponComponent";
4
+ import { WeaponComponentHash } from "./WeaponComponentHash";
5
+ import { ComponentAttachmentPoint } from "./ComponentAttachmentPoint";
6
+ import { Game } from "../Game";
7
+ class InvalidWeaponComponent extends WeaponComponent {
8
+ static {
9
+ __name(this, "InvalidWeaponComponent");
10
+ }
11
+ constructor() {
12
+ super(null, null, WeaponComponentHash.Invalid);
13
+ }
14
+ get Active() {
15
+ return false;
16
+ }
17
+ set Active(value) {
18
+ }
19
+ get DisplayName() {
20
+ return "WCT_INVALID";
21
+ }
22
+ get LocalizedName() {
23
+ return Game.getGXTEntry(this.DisplayName);
24
+ }
25
+ static getAttachmentPoint(hash, componentHash) {
26
+ return ComponentAttachmentPoint.Invalid;
27
+ }
28
+ }
29
+ export {
30
+ InvalidWeaponComponent
31
+ };
@@ -1,9 +1,9 @@
1
- import type { Ped } from "../models";
2
- import type { Weapon } from "../weapon";
3
- import { WeaponComponentHash } from "./WeaponComponentHash";
4
- import type { WeaponHash } from "../hashes";
5
1
  import { ComponentAttachmentPoint } from "./ComponentAttachmentPoint";
6
2
  import { WeaponComponentHudStats } from "./WeaponComponentHudStats";
3
+ import type { WeaponHash } from "fivem/hashes/WeaponHash";
4
+ import type { Ped } from "fivem/models/Ped";
5
+ import type { Weapon } from "fivem/weapon/Weapon";
6
+ import { WeaponComponentHash } from "./WeaponComponentHash";
7
7
  /**
8
8
  * ped weapon component on weapon
9
9
  *
@@ -0,0 +1,124 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { ComponentAttachmentPoint } from "./ComponentAttachmentPoint";
4
+ import { Game } from "../Game";
5
+ import { ComponentDisplayNameByHash } from "./ComponentDisplayNameByHash";
6
+ import { WeaponComponentHashesByWeaponHash } from "./WeaponComponentHashesByWeaponHash";
7
+ import { ComponentAttachmentPointByHash } from "./ComponentAttachmentPointByHash";
8
+ import { WeaponComponentHudStats } from "./WeaponComponentHudStats";
9
+ import { WeaponComponentHash } from "./WeaponComponentHash";
10
+ class WeaponComponent {
11
+ static {
12
+ __name(this, "WeaponComponent");
13
+ }
14
+ owner;
15
+ weapon;
16
+ componentHash;
17
+ constructor(owner, weapon, componentHash) {
18
+ this.owner = owner;
19
+ this.weapon = weapon;
20
+ this.componentHash = componentHash;
21
+ }
22
+ /**
23
+ * Check WeaponComponent is invalid or not
24
+ *
25
+ * @constructor
26
+ */
27
+ get IsInvalid() {
28
+ return this.componentHash === WeaponComponentHash.Invalid;
29
+ }
30
+ /**
31
+ * get component hash
32
+ *
33
+ * @constructor
34
+ */
35
+ get ComponentHash() {
36
+ return this.componentHash;
37
+ }
38
+ /**
39
+ * check ped has weapon component
40
+ *
41
+ * @constructor
42
+ */
43
+ get Active() {
44
+ return HasPedGotWeaponComponent(this.owner.Handle, this.weapon.Hash, this.componentHash);
45
+ }
46
+ /**
47
+ * give weapon component to ped
48
+ *
49
+ * @param value
50
+ * @constructor
51
+ */
52
+ set Active(value) {
53
+ if (value) {
54
+ GiveWeaponComponentToPed(this.owner.Handle, this.weapon.Hash, this.componentHash);
55
+ } else {
56
+ RemoveWeaponComponentFromPed(this.owner.Handle, this.weapon.Hash, this.componentHash);
57
+ }
58
+ }
59
+ /**
60
+ * get component display name / label
61
+ *
62
+ * @constructor
63
+ */
64
+ get DisplayName() {
65
+ return WeaponComponent.getComponentDisplayNameFromHash(this.weapon.Hash, this.componentHash);
66
+ }
67
+ /**
68
+ * get component localized name
69
+ *
70
+ * @constructor
71
+ */
72
+ get LocalizedName() {
73
+ return Game.getGXTEntry(this.DisplayName);
74
+ }
75
+ /**
76
+ * get component attachment point
77
+ *
78
+ * @constructor
79
+ */
80
+ get AttachmentPoint() {
81
+ return WeaponComponent.getAttachmentPoint(this.weapon.Hash, this.componentHash);
82
+ }
83
+ /**
84
+ * get component hud stats
85
+ *
86
+ * @constructor
87
+ */
88
+ get HudStats() {
89
+ return WeaponComponentHudStats.get(this.componentHash);
90
+ }
91
+ /**
92
+ * get component display name / label by hash
93
+ *
94
+ * @param hash
95
+ * @param componentHash
96
+ * @constructor
97
+ */
98
+ static getComponentDisplayNameFromHash(hash, componentHash) {
99
+ if (!hash) {
100
+ return "WCT_INVALID";
101
+ }
102
+ return ComponentDisplayNameByHash.get(componentHash) ?? "WCT_INVALID";
103
+ }
104
+ /**
105
+ * get component attachment point by WeaponHash and WeaponComponentHash
106
+ *
107
+ * @param weaponHash
108
+ * @param componentHash
109
+ * @constructor
110
+ */
111
+ static getAttachmentPoint(weaponHash, componentHash) {
112
+ const componentHashes = WeaponComponentHashesByWeaponHash.get(weaponHash);
113
+ if (!componentHashes) {
114
+ return ComponentAttachmentPoint.Invalid;
115
+ }
116
+ if (componentHashes.every((x) => x !== componentHash)) {
117
+ return ComponentAttachmentPoint.Invalid;
118
+ }
119
+ return ComponentAttachmentPointByHash.get(componentHash) ?? ComponentAttachmentPoint.Invalid;
120
+ }
121
+ }
122
+ export {
123
+ WeaponComponent
124
+ };
@@ -1,7 +1,7 @@
1
- import type { Ped } from "../models";
2
- import type { Weapon } from "../weapon";
3
1
  import type { WeaponComponentHash } from "./WeaponComponentHash";
4
2
  import { WeaponComponent } from "./WeaponComponent";
3
+ import type { Ped } from "fivem/models/Ped";
4
+ import type { Weapon } from "fivem/weapon/Weapon";
5
5
  /**
6
6
  * ped weapon components on weapon
7
7
  *
@@ -0,0 +1,187 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { WeaponComponent } from "./WeaponComponent";
4
+ import { InvalidWeaponComponent } from "./InvalidWeaponComponent";
5
+ import { WeaponComponentHashesByWeaponHash } from "./WeaponComponentHashesByWeaponHash";
6
+ import { ComponentAttachmentPoint } from "./ComponentAttachmentPoint";
7
+ import { ComponentAttachmentPointByHash } from "./ComponentAttachmentPointByHash";
8
+ class WeaponComponentCollection {
9
+ static {
10
+ __name(this, "WeaponComponentCollection");
11
+ }
12
+ owner;
13
+ weapon;
14
+ components = /* @__PURE__ */ new Map();
15
+ invalidComponent = new InvalidWeaponComponent();
16
+ constructor(owner, weapon) {
17
+ this.owner = owner;
18
+ this.weapon = weapon;
19
+ }
20
+ [Symbol.iterator]() {
21
+ let pointer = 0;
22
+ const components = Array.from(this.components.values());
23
+ return {
24
+ next() {
25
+ if (pointer < components.length) {
26
+ return { done: false, value: components[pointer++] };
27
+ }
28
+ return { done: true, value: null };
29
+ }
30
+ };
31
+ }
32
+ /**
33
+ * get component
34
+ *
35
+ * @param componentHash
36
+ */
37
+ get(componentHash) {
38
+ if (this.AllWeaponComponentHashes.some((x) => x === componentHash)) {
39
+ let component = this.components.get(componentHash);
40
+ if (!component) {
41
+ component = this.createAndAddComponent(componentHash);
42
+ }
43
+ return component;
44
+ }
45
+ return this.invalidComponent;
46
+ }
47
+ /**
48
+ * get current weapon component count
49
+ *
50
+ * @constructor
51
+ */
52
+ get Count() {
53
+ return this.components.size;
54
+ }
55
+ /**
56
+ * get clip component
57
+ *
58
+ * @param index - index of component
59
+ */
60
+ getClipComponent(index) {
61
+ return this.getAnyComponentByAttachmentPoints(index, ComponentAttachmentPoint.Clip, ComponentAttachmentPoint.Clip2);
62
+ }
63
+ /**
64
+ * get clip variation count
65
+ *
66
+ * @constructor
67
+ */
68
+ get ClipVariationsCount() {
69
+ return this.getComponentHashesByAttachmentPoints(ComponentAttachmentPoint.Clip, ComponentAttachmentPoint.Clip2).length;
70
+ }
71
+ /**
72
+ * get scope component
73
+ *
74
+ * @param index - index of component
75
+ */
76
+ getScopeComponent(index) {
77
+ return this.getAnyComponentByAttachmentPoints(
78
+ index,
79
+ ComponentAttachmentPoint.Scope,
80
+ ComponentAttachmentPoint.Scope2
81
+ );
82
+ }
83
+ /**
84
+ * get scope variation count
85
+ *
86
+ * @constructor
87
+ */
88
+ get ScopeVariationsCount() {
89
+ return this.getComponentHashesByAttachmentPoints(ComponentAttachmentPoint.Scope, ComponentAttachmentPoint.Scope2).length;
90
+ }
91
+ /**
92
+ * get suppressor component
93
+ *
94
+ */
95
+ getSuppressorComponent() {
96
+ return this.getAnyComponentByAttachmentPoints(
97
+ void 0,
98
+ ComponentAttachmentPoint.Supp,
99
+ ComponentAttachmentPoint.Supp2
100
+ );
101
+ }
102
+ /**
103
+ * get flash light component
104
+ *
105
+ */
106
+ getFlashLightComponent() {
107
+ return this.getAnyComponentByAttachmentPoints(
108
+ void 0,
109
+ ComponentAttachmentPoint.FlashLaser,
110
+ ComponentAttachmentPoint.FlashLaser2
111
+ );
112
+ }
113
+ /**
114
+ * get luxury finish component
115
+ *
116
+ */
117
+ getLuxuryFinishComponent() {
118
+ return this.getAnyComponentByAttachmentPoints(void 0, ComponentAttachmentPoint.GunRoot);
119
+ }
120
+ /**
121
+ * get Mk2 camo component
122
+ *
123
+ * @param index - index of component
124
+ */
125
+ getMk2CamoComponent(index) {
126
+ return this.getAnyComponentByAttachmentPoints(index, ComponentAttachmentPoint.GunRoot);
127
+ }
128
+ /**
129
+ * get Mk2 barrel component
130
+ *
131
+ * @param index - index of component
132
+ */
133
+ getMk2BarrelComponent(index) {
134
+ return this.getAnyComponentByAttachmentPoints(index, ComponentAttachmentPoint.Barrel);
135
+ }
136
+ /**
137
+ * Create component object and add to collection
138
+ *
139
+ * @param hash
140
+ * @private
141
+ */
142
+ createAndAddComponent(hash) {
143
+ const uintHash = hash >>> 0;
144
+ console.log("createAndAdd", hash, uintHash);
145
+ console.log("about to create", this.owner, this.weapon, uintHash);
146
+ const component = new WeaponComponent(this.owner, this.weapon, uintHash);
147
+ this.components.set(uintHash, component);
148
+ return component;
149
+ }
150
+ /**
151
+ * get all WeaponComponentHash belongs to weapon
152
+ *
153
+ * @constructor
154
+ * @private
155
+ */
156
+ get AllWeaponComponentHashes() {
157
+ return WeaponComponentHashesByWeaponHash.get(this.weapon.Hash);
158
+ }
159
+ /**
160
+ * get components belongs to attachmentPoints
161
+ *
162
+ * @param attachmentPoints
163
+ * @private
164
+ */
165
+ getComponentHashesByAttachmentPoints(...attachmentPoints) {
166
+ return this.AllWeaponComponentHashes.filter(
167
+ (hash) => attachmentPoints.some((attachmentPoint) => ComponentAttachmentPointByHash.get(hash) === attachmentPoint)
168
+ );
169
+ }
170
+ /**
171
+ * get component by index and attachmentPoints
172
+ *
173
+ * @param index - component index
174
+ * @param attachmentPoints - attachmentPoints to search
175
+ * @private
176
+ */
177
+ getAnyComponentByAttachmentPoints(index, ...attachmentPoints) {
178
+ const hashes = this.getComponentHashesByAttachmentPoints(...attachmentPoints);
179
+ if (index === void 0) {
180
+ return this.get(hashes[0]) ?? this.invalidComponent;
181
+ }
182
+ return 0 <= index && index <= hashes.length - 1 ? this.get(hashes[index]) : this.invalidComponent;
183
+ }
184
+ }
185
+ export {
186
+ WeaponComponentCollection
187
+ };