Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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 //------------------------------------------------------------------------------------------------
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 {
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 m_aHitZones = {hitZone};
73 }
74 else
75 {
76 // Get lowercase hitzone names
77 array<string> hitzoneNames = {};
78 foreach (string name : m_aHitZoneNames)
79 {
80 name.ToLower();
81 hitzoneNames.Insert(name);
82 }
83
84 // Find all matching hitzones
85 m_aHitZones = {};
86 array<HitZone> hitZones = {};
87 damageManager.GetAllHitZonesInHierarchy(hitZones);
88 string name;
89 foreach (HitZone hitZone : hitZones)
90 {
91 name = hitZone.GetName();
92 name.ToLower();
93 if (hitzoneNames.Contains(name))
94 m_aHitZones.Insert(hitZone);
95 }
96 }
97
98 if (m_aHitZones.IsEmpty())
99 m_aHitZones = null;
100
101 // Terminate if there are no hitzones
102 if (!m_aHitZones)
103 return false;
104
105 return super.DisplayStartDrawInit(owner);
106 }
107
108 //------------------------------------------------------------------------------------------------
109 override void DisplayStopDraw(IEntity owner)
110 {
111 m_aHitZones = null;
112 }
113};
EVehicleInfoState
UI indicator state, controlling colors and opacity.
proto external Managed FindComponent(typename typeName)
Base class for all vehicle UI state and damage indicators.
override void DisplayStopDraw(IEntity owner)
ref array< HitZone > m_aHitZones
override bool DisplayStartDrawInit(IEntity owner)
override EVehicleInfoState GetState()
Can be overridden to get state of actual system or linked to an event.
ref array< string > m_aHitZoneNames
SCR_FieldOfViewSettings Attribute
EDamageType
Definition EDamageType.c:13
EDamageState