Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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 
7  protected int m_iDefaultSightDistanceSetting;
8  protected ref array<string> m_aFireModes;
9  int m_iMuzzleVelocity;
10  protected int m_iRateOfFire;
11  protected float m_fMass;
12  protected ref array<int> m_aSightDistanceSettings;
13 
14  //------------------------------------------------------------------------------------------------
16  string GetDisplayName()
17  {
18  return m_sDisplayName;
19  }
20 
21  //------------------------------------------------------------------------------------------------
23  ResourceName GetInventoryIcon()
24  {
25  return m_sInventoryIcon;
26  }
27 
28  //------------------------------------------------------------------------------------------------
30  string GetDescription()
31  {
32  return m_sDescription;
33  }
34 
35  //------------------------------------------------------------------------------------------------
37  array<string> GetFireModes()
38  {
39  return m_aFireModes;
40  }
41 
42  //------------------------------------------------------------------------------------------------
44  int GetRateOfFire()
45  {
46  return m_iRateOfFire;
47  }
48 
49  //------------------------------------------------------------------------------------------------
51  float GetMass()
52  {
53  return m_fMass;
54  }
55 
56  //------------------------------------------------------------------------------------------------
58  array<int> GetSightDistanceSettings()
59  {
60  return m_aSightDistanceSettings;
61  }
62 
63  //------------------------------------------------------------------------------------------------
65  int GetDefaultSightDistanceSetting()
66  {
67  return m_iDefaultSightDistanceSetting;
68  }
69 
70  //------------------------------------------------------------------------------------------------
71  // constructor
73  void SCR_FieldManualUI_WeaponStatsHelper(ResourceName weaponResource)
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 = {};
103  m_aSightDistanceSettings = {};
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 };
m_sDisplayName
protected string m_sDisplayName
Definition: SCR_KeybindDialogs.c:39
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
UIInfo
UIInfo - declare object, allows to define UI elements.
Definition: UIInfo.c:13
BaseFireMode
Definition: BaseFireMode.c:12
m_sDescription
string m_sDescription
Definition: SCR_FlashlightComponent.c:3
m_fMass
SCR_HybridPhysicsComponentClass m_fMass
Class for storing physics setup info for SCR_HybridPhysicsComponent.
SCR_FieldManualUI_WeaponStatsHelper
Definition: SCR_FieldManualUI_WeaponStatsHelper.c:1