Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RepairAtSupportStationAction.c
Go to the documentation of this file.
2{
3 [Attribute("#AR-SupportStation_Repair_ActionInvalid_NoDamage", desc: "Text shown on action if undamaged", uiwidget: UIWidgets.LocaleEditBox)]
5
6 [Attribute("#AR-SupportStation_Repair_ActionInvalid_Needs_SupportStation_Field", desc: "Vehicle cannot be repaired any more as max healing is reached", uiwidget: UIWidgets.LocaleEditBox)]
8
9 [Attribute("#AR-SupportStation_Repair_ActionInvalid_Needs_SupportStation_Emergency", desc: "Vehicle cannot be repaired any more as max healing is reached", uiwidget: UIWidgets.LocaleEditBox)]
11
12 [Attribute("#AR-ActionInvalid_OnFire", desc: "Text shown on action if entity is on fire", uiwidget: UIWidgets.LocaleEditBox)]
14
15 [Attribute("#AR-Editor_ContextAction_Extinguish_Name", desc: "Action name when entity is on fire. Only when hitzones are FlammableHitZones", uiwidget: UIWidgets.LocaleEditBox, category: "Heal/Repair Support Station")]
17
18 [Attribute(uiwidget: UIWidgets.SearchComboBox, desc: "Which hitzone groups will be healed, Leave empty if all need to be healed. (VIRTUAL is invalid and will be skipped). The first entry will be used for notifications", enums: ParamEnumArray.FromEnum(EVehicleHitZoneGroup))]
19 protected ref array<EVehicleHitZoneGroup> m_aHitZoneGroups;
20
21 [Attribute(desc: "Used to get the group name of which is going to be repaired")]
23
24 [Attribute(desc: "Any addition Hitzone ID. This is generic and used for example to get the correct fuel tank using it as an ID")]
25 protected ref array<int> m_aHitZoneAdditionalIDs;
26
27 [Attribute("0", desc: "For some repair actions you want the system to know what it will be repairing, eg: Wheels, but the wheels have no hitzones with wheel hitzone group so just get all the hitzones on the entity. But the action and notifications still know they system is repairing the wheels")]
29
30 [Attribute("1", desc: "if true then the action will not be shown if the entity (or root parent entity) is on fire")]
31 protected bool m_bHideIfEntityOnFire;
32
33 protected SCR_DamageManagerComponent m_OnFireCheckDamageManager;
34
35 //------------------------------------------------------------------------------------------------
37 {
38 return ESupportStationType.REPAIR;
39 }
40
41 //------------------------------------------------------------------------------------------------
43 {
44 //~ Entity is undamaged
45 if (reasonInvalid == ESupportStationReasonInvalid.HEAL_ENTITY_UNDAMAGED)
46 return m_sInvalidDamaged;
47 else if (reasonInvalid == ESupportStationReasonInvalid.HEAL_ENTITY_ONFIRE)
48 return m_sInvalidOnFire;
49 else if (reasonInvalid == ESupportStationReasonInvalid.HEAL_MAX_HEALABLE_HEALTH_REACHED_FIELD)
51 else if (reasonInvalid == ESupportStationReasonInvalid.HEAL_MAX_HEALABLE_HEALTH_REACHED_EMERGENCY)
53
54 return super.GetInvalidPerformReasonString(reasonInvalid);
55 }
56
57 //------------------------------------------------------------------------------------------------
58 int GetHitZoneGroups(out notnull array<EVehicleHitZoneGroup> hitZoneGroup)
59 {
60 hitZoneGroup.Copy(m_aHitZoneGroups);
61 return hitZoneGroup.Count();
62 }
63
64 //------------------------------------------------------------------------------------------------
65 protected override bool RequiresGadget()
66 {
67 return true;
68 }
69
70 //------------------------------------------------------------------------------------------------
71 override bool CanBeShownScript(IEntity user)
72 {
74 return false;
75
76 if (!m_DamageManagerComponent.CanBeHealed(false))
77 return false;
78
79 // Only show damaged entries
81 return false;
82
83 return super.CanBeShownScript(user);
84 }
85
86 //------------------------------------------------------------------------------------------------
87 protected override bool CanShowDestroyed()
88 {
89 //~ If HULL is not included then it can always be repaired
90 if (!m_aHitZoneGroups.Contains(EVehicleHitZoneGroup.HULL))
91 return true;
92
93 //~ Don't show if hull is destrpued
94 return super.CanShowDestroyed();
95 }
96
97 //------------------------------------------------------------------------------------------------
98 override bool CanBePerformedScript(IEntity user)
99 {
100 Physics rootPhysics = GetOwner().GetRootParent().GetPhysics(); // Getting root parent to ensure slotted entities get the intended behaviour
101 if (rootPhysics && rootPhysics.GetVelocity().LengthSq() > MAXIMUM_VEHICLE_SPEED_FOR_INTERACTION_SQ)
102 {
104 return false;
105 }
106
107 //~ If hitzones to heal are not on fire but the entity is then hide make the action invalid
109 {
110 SetCanPerform(false, ESupportStationReasonInvalid.HEAL_ENTITY_ONFIRE);
111
112 //~ Resets the support station so override action name is removed
114 return false;
115 }
116
117 if (!m_DamageManagerComponent.CanBeHealed(false))
118 {
119 SetCanPerform(false, ESupportStationReasonInvalid.HEAL_ENTITY_UNDAMAGED);
120
121 //~ Resets the support station so override action name is removed
123 return false;
124 }
125
126 return super.CanBePerformedScript(user);
127 }
128
129 //------------------------------------------------------------------------------------------------
130 protected override void SetHitZonesToHeal()
131 {
132 //~ Virtual gets all hitzones. Or if wheels do the same as wheels have no additional hitzones
134 {
135 super.SetHitZonesToHeal();
136 return;
137 }
138
139 m_aHitZonesToHeal.Clear();
140
141 //~ Get the correct fuel tank to repair
142 if (!m_aHitZoneAdditionalIDs.IsEmpty() && m_aHitZoneGroups.Contains(EVehicleHitZoneGroup.FUEL_TANKS))
143 {
144 SCR_FuelHitZone fuelHitZone;
145 SCR_HitZone scrHitZone;
146
147 array<HitZone> allHitZones = {};
148
149 m_DamageManagerComponent.GetAllHitZonesInHierarchy(allHitZones);
150
151 foreach (HitZone hitZone : allHitZones)
152 {
153 scrHitZone = SCR_HitZone.Cast(hitZone);
154
155 if (scrHitZone.GetHitZoneGroup() != EVehicleHitZoneGroup.FUEL_TANKS)
156 continue;
157
158 //~ Not a fuel hitzone but part of the group
159 fuelHitZone = SCR_FuelHitZone.Cast(hitZone);
160 if (!fuelHitZone)
161 m_aHitZonesToHeal.Insert(hitZone);
162
163 if (!m_aHitZoneAdditionalIDs.Contains(fuelHitZone.GetFuelTankID()))
164 continue;
165
166 //~ Insert Fuel tank
167 m_aHitZonesToHeal.Insert(hitZone);
168 }
169 }
170
171 //~ Get hitzone groups (Fuel tanks are already obtained)
172 foreach (EVehicleHitZoneGroup hitZoneGroup : m_aHitZoneGroups)
173 {
174 if (hitZoneGroup == EVehicleHitZoneGroup.VIRTUAL || (!m_aHitZoneAdditionalIDs.IsEmpty() && hitZoneGroup == EVehicleHitZoneGroup.FUEL_TANKS))
175 continue;
176
177 m_DamageManagerComponent.GetHitZonesOfGroup(hitZoneGroup, m_aHitZonesToHeal, false);
178 }
179 }
180
181 //------------------------------------------------------------------------------------------------
182 protected override string GetActionStringParam()
183 {
184 //~ Don't show damage state when on fire
186 return string.Empty;
187
188 return super.GetActionStringParam();
189 }
190
191 //------------------------------------------------------------------------------------------------
192 override bool GetActionNameScript(out string outName)
193 {
195 return super.GetActionNameScript(outName);
196
197 //~ Set extinguish fire action name
200 //~ Override action name
202 outName = m_SupportStationComponent.GetOverrideUserActionName();
203
204 //~ Default action name
205 if (outName.IsEmpty())
206 {
207 UIInfo uiInfo = GetUIInfo();
208 if (!uiInfo)
209 return super.GetActionNameScript(outName);
210
211 outName = uiInfo.GetName();
212 }
213
214 outName = WidgetManager.Translate(outName, m_HitZoneGroupNames.GetHitZoneGroupName(m_aHitZoneGroups[0]));
215 return super.GetActionNameScript(outName);
216 }
217
218 //------------------------------------------------------------------------------------------------
219 override bool IsStabilizedReason()
220 {
221 return m_eCannotPerformReason == ESupportStationReasonInvalid.HEAL_MAX_HEALABLE_HEALTH_REACHED_FIELD;
222 }
223
224 //------------------------------------------------------------------------------------------------
225 protected override void DelayedInit(IEntity owner)
226 {
227 if (!owner)
228 return;
229
230 super.DelayedInit(owner);
231
232 //~ Make sure to check if the action is hidden if the entity is on fire
234 {
235 IEntity root = owner.GetRootParent();
236
237 //~ If has root and root is vehicle get that damage manager else use defualt damage manager
238 if (root && Vehicle.Cast(root))
239 m_OnFireCheckDamageManager = SCR_DamageManagerComponent.GetDamageManager(root);
240 else
242 }
243 }
244}
ESupportStationType
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SetCannotPerformReason(string reason)
proto external Physics GetPhysics()
proto external IEntity GetRootParent()
SCR_BaseSupportStationComponent m_SupportStationComponent
void SetCanPerform(bool canPerform, ESupportStationReasonInvalid reasonInvalid)
ESupportStationReasonInvalid m_eCannotPerformReason
Holds the name data to show which parts of the vehicle or character the player is healing.
EHitZoneGroup GetHitZoneGroup()
Definition SCR_HitZone.c:12
override LocalizedString GetInvalidPerformReasonString(ESupportStationReasonInvalid reasonInvalid)
ref SCR_HitZoneGroupNameHolder m_HitZoneGroupNames
ref array< EVehicleHitZoneGroup > m_aHitZoneGroups
int GetHitZoneGroups(out notnull array< EVehicleHitZoneGroup > hitZoneGroup)
override bool GetActionNameScript(out string outName)
override ESupportStationType GetSupportStationType()
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
IEntity GetOwner()
Owner entity of the fuel tank.
SCR_FieldOfViewSettings Attribute
EDamageType
Definition EDamageType.c:13