Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_HitZoneInfo.c
Go to the documentation of this file.
1 //#define SHOW_DMG_INDICATORS_WARNING
2 //#define SHOW_DMG_INDICATORS_ERROR
3 
5 {
6  [Attribute("", uiwidget: UIWidgets.Auto)]
7  protected ref array<string> m_aHitZoneNames;
8 
9  protected ref array<HitZone> m_aHitZones;
10 
11  //------------------------------------------------------------------------------------------------
13  override EVehicleInfoState GetState()
14  {
15  #ifdef SHOW_DMG_INDICATORS_ERROR
16  return EVehicleInfoState.ERROR;
17  #endif
18 
19  #ifdef SHOW_DMG_INDICATORS_WARNING
20  return EVehicleInfoState.WARNING;
21  #endif
22 
23  if (!m_aHitZones)
24  return EVehicleInfoState.DISABLED;
25 
26  m_bIsBlinking = false;
27 
28  EDamageState damageState;
29  EVehicleInfoState state = EVehicleInfoState.DISABLED;
30  SCR_WheelHitZone wheelHitZone;
31  foreach (HitZone hitZone : m_aHitZones)
32  {
33  if (!hitZone)
34  continue;
35 
36  // Ignore spare wheels
37  wheelHitZone = SCR_WheelHitZone.Cast(hitZone);
38  if (wheelHitZone && wheelHitZone.GetWheelIndex() < 0)
39  continue;
40 
41  // On fire
42  if (hitZone.GetDamageOverTime(EDamageType.FIRE) > 0)
43  {
44  m_bIsBlinking = true;
45  return EVehicleInfoState.ERROR;
46  }
47 
48  // Destroyed or damaged
49  damageState = hitZone.GetDamageState();
50  if (damageState > EDamageState.DESTROYED)
51  state = EVehicleInfoState.WARNING;
52  else if (damageState == EDamageState.DESTROYED)
53  return EVehicleInfoState.ERROR;
54  }
55 
56  return state;
57  }
58 
59  //------------------------------------------------------------------------------------------------
60  override bool DisplayStartDrawInit(IEntity owner)
61  {
62  DamageManagerComponent damageManager = DamageManagerComponent.Cast(owner.FindComponent(DamageManagerComponent));
63  if (!damageManager)
64  return false;
65 
66  m_aHitZones = {};
67 
68  // Just get default hitzone if none are provided
69  if (m_aHitZoneNames.IsEmpty())
70  {
71  HitZone hitZone = damageManager.GetDefaultHitZone();
72  if (hitZone)
73  m_aHitZones = {hitZone};
74  }
75  else
76  {
77  // Get lowercase hitzone names
78  array<string> hitzoneNames = {};
79  foreach (string name : m_aHitZoneNames)
80  {
81  name.ToLower();
82  hitzoneNames.Insert(name);
83  }
84 
85  // Find all matching hitzones
86  m_aHitZones = {};
87  array<HitZone> hitZones = {};
88  damageManager.GetAllHitZones(hitZones);
89  string name;
90  foreach (HitZone hitZone : hitZones)
91  {
92  name = hitZone.GetName();
93  name.ToLower();
94  if (hitzoneNames.Contains(name))
95  m_aHitZones.Insert(hitZone);
96  }
97  }
98 
99  if (m_aHitZones.IsEmpty())
100  m_aHitZones = null;
101 
102  // Terminate if there are no hitzones
103  if (!m_aHitZones)
104  return false;
105 
106  return super.DisplayStartDrawInit(owner);
107  }
108 
109  //------------------------------------------------------------------------------------------------
110  override void DisplayStopDraw(IEntity owner)
111  {
112  m_aHitZones = null;
113  }
114 };
SCR_HitZoneInfo
Definition: SCR_HitZoneInfo.c:4
HitZone
Definition: HitZone.c:12
SCR_BaseVehicleInfo
Base class for all vehicle UI state and damage indicators.
Definition: SCR_BaseVehicleInfo.c:28
EDamageState
EDamageState
Definition: EDamageState.c:12
Attribute
typedef Attribute
Post-process effect of scripted camera.
EDamageType
EDamageType
Definition: EDamageType.c:12
EVehicleInfoState
EVehicleInfoState
UI indicator state, controlling colors and opacity.
Definition: SCR_BaseVehicleInfo.c:5
DamageManagerComponent
Definition: DamageManagerComponent.c:12