@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.
- package/Audio.d.ts +2 -2
- package/Audio.js +99 -0
- package/Blip.d.ts +4 -3
- package/Blip.js +113 -0
- package/Camera.d.ts +3 -3
- package/Camera.js +190 -0
- package/Checkpoint.d.ts +2 -2
- package/Checkpoint.js +51 -0
- package/Events.js +80 -0
- package/Game.d.ts +10 -3
- package/Game.js +478 -0
- package/GameplayCamera.d.ts +2 -2
- package/GameplayCamera.js +152 -0
- package/Model.js +210 -0
- package/NetworkedScene.d.ts +2 -1
- package/NetworkedScene.js +50 -0
- package/ParticleEffect.d.ts +4 -3
- package/ParticleEffect.js +128 -0
- package/ParticleEffectAsset.d.ts +2 -2
- package/ParticleEffectAsset.js +133 -0
- package/Pickup.d.ts +1 -1
- package/Pickup.js +27 -0
- package/Raycast.d.ts +5 -3
- package/Raycast.js +132 -0
- package/RelationshipGroup.d.ts +1 -1
- package/RelationshipGroup.js +72 -0
- package/Rope.d.ts +1 -1
- package/Rope.js +149 -0
- package/TaskSequence.js +52 -0
- package/Tasks.d.ts +8 -3
- package/Tasks.js +334 -0
- package/World.d.ts +13 -4
- package/World.js +945 -0
- package/cfx/StateBagChangeHandler.js +0 -0
- package/cfx/index.d.ts +1 -1
- package/cfx/index.js +4 -0
- package/common/Command.js +111 -0
- package/common/Convar.js +58 -0
- package/common/GlobalData.js +16 -0
- package/common/Kvp.js +137 -0
- package/common/Resource.js +54 -0
- package/common/decors/Events.js +170 -0
- package/common/net/NetworkedMap.js +225 -0
- package/common/types.js +0 -0
- package/common/utils/ClassTypes.js +15 -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.js +18 -0
- package/common/utils/Point.d.ts +9 -0
- package/common/utils/Point.js +36 -0
- package/common/utils/PointF.d.ts +1 -1
- package/common/utils/PointF.js +18 -0
- package/common/utils/Quaternion.d.ts +1 -1
- package/common/utils/Quaternion.js +33 -0
- package/common/utils/Vector.js +589 -0
- package/common/utils/cleanPlayerName.js +17 -0
- package/common/utils/enumValues.js +20 -0
- package/common/utils/getStringFromUInt8Array.js +6 -0
- package/common/utils/getUInt32FromUint8Array.js +6 -0
- package/enums/Alignment.js +9 -0
- package/enums/AnimationFlags.js +38 -0
- package/enums/AudioFlag.js +41 -0
- package/enums/BadgeStyle.js +186 -0
- package/enums/Blip.js +229 -0
- package/enums/Bone.js +105 -0
- package/enums/CameraShake.js +17 -0
- package/enums/CameraTypes.js +11 -0
- package/enums/CheckboxStyle.js +8 -0
- package/enums/Checkpoint.js +68 -0
- package/enums/CloudHat.js +27 -0
- package/enums/Control.js +364 -0
- package/enums/CursorSprite.js +18 -0
- package/enums/Driving.js +38 -0
- package/enums/ExplosionType.js +45 -0
- package/enums/FiringPattern.js +23 -0
- package/enums/Font.js +11 -0
- package/enums/ForceType.js +12 -0
- package/enums/Gender.js +8 -0
- package/enums/HelmetType.js +9 -0
- package/enums/HudColor.js +187 -0
- package/enums/HudComponent.js +57 -0
- package/enums/InputMode.js +8 -0
- package/enums/InvertAxis.js +10 -0
- package/enums/Language.js +18 -0
- package/enums/LeaveVehicleFlags.js +14 -0
- package/enums/LoadingSpinnerType.js +11 -0
- package/enums/MarkerType.js +48 -0
- package/enums/MenuAlignment.js +8 -0
- package/enums/NotificationType.js +14 -0
- package/enums/Parachute.js +19 -0
- package/enums/PickupType.js +77 -0
- package/enums/RadioStation.js +28 -0
- package/enums/RagdollType.js +10 -0
- package/enums/RaycastEnums.js +33 -0
- package/enums/Relationship.js +13 -0
- package/enums/RopeType.js +9 -0
- package/enums/ScreenEffect.js +87 -0
- package/enums/SpeechModifier.js +43 -0
- package/enums/Vehicle.js +396 -0
- package/enums/Weather.js +22 -0
- package/enums/ZoneID.js +95 -0
- package/hashes/MaterialHash.js +220 -0
- package/hashes/PedHash.js +728 -0
- package/hashes/VehicleHash.js +526 -0
- package/hashes/WeaponHash.js +155 -0
- package/hashes/WeatherTypeHash.js +22 -0
- package/index.js +166 -18794
- package/interfaces/Dimensions.d.ts +1 -1
- package/interfaces/Dimensions.js +0 -0
- package/models/BaseEntity.d.ts +10 -8
- package/models/BaseEntity.js +576 -0
- package/models/Entity.d.ts +0 -1
- package/models/Entity.js +0 -0
- package/models/EntityBone.d.ts +1 -1
- package/models/EntityBone.js +32 -0
- package/models/EntityBoneCollection.d.ts +1 -1
- package/models/EntityBoneCollection.js +27 -0
- package/models/Ped.d.ts +13 -5
- package/models/Ped.js +711 -0
- package/models/PedBone.d.ts +3 -2
- package/models/PedBone.js +18 -0
- package/models/PedBoneCollection.d.ts +3 -1
- package/models/PedBoneCollection.js +31 -0
- package/models/Player.d.ts +4 -2
- package/models/Player.js +188 -0
- package/models/Prop.d.ts +1 -1
- package/models/Prop.js +34 -0
- package/models/Vehicle.d.ts +9 -4
- package/models/Vehicle.js +582 -0
- package/models/VehicleDoor.d.ts +1 -1
- package/models/VehicleDoor.js +52 -0
- package/models/VehicleDoorCollection.d.ts +1 -1
- package/models/VehicleDoorCollection.js +66 -0
- package/models/VehicleMod.d.ts +1 -1
- package/models/VehicleMod.js +43 -0
- package/models/VehicleModCollection.d.ts +2 -2
- package/models/VehicleModCollection.js +227 -0
- package/models/VehicleToggleMod.d.ts +1 -1
- package/models/VehicleToggleMod.js +37 -0
- package/models/VehicleWheel.js +31 -0
- package/models/VehicleWheelCollection.d.ts +1 -1
- package/models/VehicleWheelCollection.js +61 -0
- package/models/VehicleWindow.d.ts +1 -1
- package/models/VehicleWindow.js +43 -0
- package/models/VehicleWindowCollection.d.ts +1 -1
- package/models/VehicleWindowCollection.js +62 -0
- package/package.json +2 -2
- package/ui/Container.d.ts +4 -2
- package/ui/Container.js +39 -0
- package/ui/Effects.d.ts +1 -1
- package/ui/Effects.js +112 -0
- package/ui/Fading.js +74 -0
- package/ui/Hud.d.ts +3 -2
- package/ui/Hud.js +47 -0
- package/ui/InstructionalButtons.js +42 -0
- package/ui/LoadingPrompt.d.ts +1 -1
- package/ui/LoadingPrompt.js +37 -0
- package/ui/Notification.js +17 -0
- package/ui/Rectangle.d.ts +4 -2
- package/ui/Rectangle.js +46 -0
- package/ui/Scaleform.d.ts +2 -1
- package/ui/Scaleform.js +240 -0
- package/ui/Screen.d.ts +6 -3
- package/ui/Screen.js +83 -0
- package/ui/Sprite.d.ts +3 -1
- package/ui/Sprite.js +70 -0
- package/ui/Text.d.ts +6 -3
- package/ui/Text.js +119 -0
- package/ui/Timerbar.js +241 -0
- package/ui/interfaces/IButton.d.ts +1 -1
- package/ui/interfaces/IButton.js +0 -0
- package/ui/interfaces/IDrawable.d.ts +3 -1
- package/ui/interfaces/IDrawable.js +0 -0
- package/ui/menu/Menu.d.ts +9 -4
- package/ui/menu/Menu.js +830 -0
- package/ui/menu/MenuControl.js +20 -0
- package/ui/menu/MenuControls.js +17 -0
- package/ui/menu/MenuSettings.d.ts +1 -1
- package/ui/menu/MenuSettings.js +57 -0
- package/ui/menu/items/UIMenuCheckboxItem.d.ts +3 -3
- package/ui/menu/items/UIMenuCheckboxItem.js +70 -0
- package/ui/menu/items/UIMenuItem.d.ts +10 -4
- package/ui/menu/items/UIMenuItem.js +1103 -0
- package/ui/menu/items/UIMenuListItem.d.ts +3 -3
- package/ui/menu/items/UIMenuListItem.js +118 -0
- package/ui/menu/items/UIMenuSeparatorItem.d.ts +1 -1
- package/ui/menu/items/UIMenuSeparatorItem.js +37 -0
- package/ui/menu/items/UIMenuSliderItem.d.ts +4 -3
- package/ui/menu/items/UIMenuSliderItem.js +180 -0
- package/ui/menu/items/panels/AbstractUIMenuPanel.d.ts +4 -3
- package/ui/menu/items/panels/AbstractUIMenuPanel.js +49 -0
- package/ui/menu/items/panels/UIMenuColorPanel.d.ts +3 -3
- package/ui/menu/items/panels/UIMenuColorPanel.js +215 -0
- package/ui/menu/items/panels/UIMenuGridPanel.d.ts +3 -3
- package/ui/menu/items/panels/UIMenuGridPanel.js +216 -0
- package/ui/menu/items/panels/UIMenuPercentagePanel.d.ts +2 -2
- package/ui/menu/items/panels/UIMenuPercentagePanel.js +138 -0
- package/ui/menu/items/panels/UIMenuStatisticsPanel.d.ts +3 -2
- package/ui/menu/items/panels/UIMenuStatisticsPanel.js +88 -0
- package/ui/menu/items/panels/UIMenuStatisticsPanelItem.d.ts +2 -1
- package/ui/menu/items/panels/UIMenuStatisticsPanelItem.js +48 -0
- package/ui/menu/modules/ListItem.js +18 -0
- package/utils/Animations.js +43 -0
- package/utils/Crypto.js +33 -0
- package/utils/LiteEvent.js +25 -0
- package/utils/Maths.js +18 -0
- package/utils/Point.js +36 -0
- package/utils/Size.js +16 -0
- package/utils/String.d.ts +1 -1
- package/utils/String.js +35 -0
- package/weapon/DlcWeaponData.d.ts +1 -1
- package/weapon/DlcWeaponData.js +40 -0
- package/weapon/Mk2WeaponHash.js +18 -0
- package/weapon/Weapon.d.ts +7 -7
- package/weapon/Weapon.js +276 -0
- package/weapon/WeaponAsset.d.ts +1 -1
- package/weapon/WeaponAsset.js +87 -0
- package/weapon/WeaponCollection.d.ts +3 -2
- package/weapon/WeaponCollection.js +179 -0
- package/weapon/WeaponDisplayNameByHash.d.ts +1 -1
- package/weapon/WeaponDisplayNameByHash.js +73 -0
- package/weapon/WeaponGroup.js +22 -0
- package/weapon/WeaponHudStats.d.ts +1 -1
- package/weapon/WeaponHudStats.js +33 -0
- package/weapon/WeaponLivery.js +17 -0
- package/weapon/WeaponLiveryColor.js +38 -0
- package/weapon/WeaponTint.js +46 -0
- package/weaponComponent/ComponentAttachmentPoint.js +22 -0
- package/weaponComponent/ComponentAttachmentPointByHash.js +307 -0
- package/weaponComponent/ComponentDisplayNameByHash.js +278 -0
- package/weaponComponent/DlcWeaponComponentData.js +40 -0
- package/weaponComponent/InvalidWeaponComponent.d.ts +1 -1
- package/weaponComponent/InvalidWeaponComponent.js +31 -0
- package/weaponComponent/WeaponComponent.d.ts +4 -4
- package/weaponComponent/WeaponComponent.js +124 -0
- package/weaponComponent/WeaponComponentCollection.d.ts +2 -2
- package/weaponComponent/WeaponComponentCollection.js +187 -0
- package/weaponComponent/WeaponComponentHash.js +670 -0
- package/weaponComponent/WeaponComponentHashesByWeaponHash.d.ts +1 -1
- package/weaponComponent/WeaponComponentHashesByWeaponHash.js +864 -0
- package/weaponComponent/WeaponComponentHudStats.js +33 -0
- package/common/index.d.ts +0 -8
- package/common/utils/Vector2.d.ts +0 -1
- package/common/utils/Vector3.d.ts +0 -1
- package/common/utils/Vector4.d.ts +0 -1
- package/common/utils/index.d.ts +0 -12
- package/enums/index.d.ts +0 -42
- package/hashes/index.d.ts +0 -5
- package/index.d.ts +0 -25
- package/models/index.d.ts +0 -18
- package/ui/index.d.ts +0 -15
- package/ui/interfaces/index.d.ts +0 -2
- package/ui/menu/index.d.ts +0 -6
- package/ui/menu/items/index.d.ts +0 -6
- package/ui/menu/items/panels/index.d.ts +0 -6
- package/ui/menu/modules/index.d.ts +0 -1
- package/utils/PointF.d.ts +0 -7
- package/utils/Quaternion.d.ts +0 -10
- package/utils/enumValues.d.ts +0 -12
- package/utils/getStringFromUInt8Array.d.ts +0 -8
- package/utils/getUInt32FromUint8Array.d.ts +0 -8
- package/utils/index.d.ts +0 -9
- package/weapon/index.d.ts +0 -8
- 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
|
+
};
|