Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_FieldManualUI_WeaponStatsHelper.c
Go to the documentation of this file.
2{
3 protected string m_sDisplayName;
4 protected string m_sDescription;
5 protected ResourceName m_sInventoryIcon; // not set atm
6
8 protected ref array<string> m_aFireModes;
10 protected int m_iRateOfFire;
11 protected float m_fMass;
12 protected ref array<int> m_aSightDistanceSettings;
13
14 //------------------------------------------------------------------------------------------------
17 {
18 return m_sDisplayName;
19 }
20
21 //------------------------------------------------------------------------------------------------
27
28 //------------------------------------------------------------------------------------------------
31 {
32 return m_sDescription;
33 }
34
35 //------------------------------------------------------------------------------------------------
37 array<string> GetFireModes()
38 {
39 return m_aFireModes;
40 }
41
42 //------------------------------------------------------------------------------------------------
45 {
46 return m_iRateOfFire;
47 }
48
49 //------------------------------------------------------------------------------------------------
51 float GetMass()
52 {
53 return m_fMass;
54 }
55
56 //------------------------------------------------------------------------------------------------
59 {
61 }
62
63 //------------------------------------------------------------------------------------------------
69
70 //------------------------------------------------------------------------------------------------
71 // constructor
74 {
75 if (!weaponResource)
76 return;
77
78 Resource resource = Resource.Load(weaponResource);
79 if (!resource.IsValid())
80 return;
81
82 IEntity entity = GetGame().SpawnEntityPrefabLocal(resource, null, null);
83 if (!entity)
84 return;
85
86 WeaponComponent weaponComponent = WeaponComponent.Cast(entity.FindComponent(WeaponComponent));
87 if (!weaponComponent)
88 {
89 delete entity;
90 return;
91 }
92
93 m_iDefaultSightDistanceSetting = Math.Round(weaponComponent.GetCurrentSightsZeroing()); // NOT zeroing, dammit
94 m_iMuzzleVelocity = weaponComponent.GetInitialProjectileSpeed();
95 UIInfo weaponComponentUIInfo = weaponComponent.GetUIInfo();
96 if (weaponComponentUIInfo)
97 {
98 m_sDisplayName = weaponComponentUIInfo.GetName();
99 m_sDescription = weaponComponentUIInfo.GetDescription();
100 }
101
102 m_aFireModes = {};
104
105// WeaponAttachmentsStorageComponent weaponAttachmentsStorageComponent = WeaponAttachmentsStorageComponent.Cast(entity.FindComponent(WeaponAttachmentsStorageComponent));
106// if (weaponAttachmentsStorageComponent)
107// {
108// ItemAttributeCollection collection = weaponAttachmentsStorageComponent.GetAttributes();
109// UIInfo uiInfo = collection.GetUIInfo();
110// WeaponUIInfo weaponUIInfo = WeaponUIInfo.Cast(uiInfo);
111// if (weaponUIInfo)
112// {
113 //Warka: Hotfix, as the GetWeaponIconPath() was removed from the WeaponUIInfo class
114 //m_sInventoryIcon = weaponUIInfo.GetWeaponIconPath();
115// }
116// }
117
118 MuzzleComponent muzzleComponent = MuzzleComponent.Cast(weaponComponent.FindComponent(MuzzleComponent));
119 if (muzzleComponent)
120 {
121 array<BaseFireMode> fireModes = {};
122 muzzleComponent.GetFireModesList(fireModes);
123
124 foreach (BaseFireMode fireMode : fireModes)
125 {
126 if (fireMode.GetBurstSize() == 0)
127 continue;
128
129 m_aFireModes.Insert(fireMode.GetUIName());
130 float shotSpan = fireMode.GetShotSpan();
131 if (shotSpan > 0)
132 {
133 int rateOfFire = Math.Round(60 / shotSpan);
134 if (rateOfFire > m_iRateOfFire)
135 m_iRateOfFire = rateOfFire;
136 }
137 }
138 }
139
140 WeaponAttachmentsStorageComponent storageComponent = WeaponAttachmentsStorageComponent.Cast(entity.FindComponent(WeaponAttachmentsStorageComponent));
141 if (storageComponent)
142 {
143 m_fMass = storageComponent.GetTotalWeight();
144 }
145
146 BaseSightsComponent sightsComponent = weaponComponent.GetSights();
147 if (sightsComponent)
148 {
149 // TODO when API is available
150 }
151
152 delete entity;
153 }
154};
ArmaReforgerScripted GetGame()
Definition game.c:1398
proto external GenericComponent FindComponent(typename typeName)
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
void SCR_FieldManualUI_WeaponStatsHelper(ResourceName weaponResource)
UIInfo - allows to define UI elements.
Definition UIInfo.c:14