Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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)]
4  protected LocalizedString m_sInvalidDamaged;
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)]
7  protected LocalizedString m_sInvalidMaxHealingReached_Field;
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)]
10  protected LocalizedString m_sInvalidMaxHealingReached_Emergency;
11 
12  [Attribute("#AR-ActionInvalid_OnFire", desc: "Text shown on action if entity is on fire", uiwidget: UIWidgets.LocaleEditBox)]
13  protected LocalizedString m_sInvalidOnFire;
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")]
16  protected LocalizedString m_sOnFireOverrideActionName;
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")]
22  protected ref SCR_HitZoneGroupNameHolder m_HitZoneGroupNames;
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")]
28  protected bool m_bAlwaysRepairAllHitZones;
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  //------------------------------------------------------------------------------------------------
36  protected override ESupportStationType GetSupportStationType()
37  {
38  return ESupportStationType.REPAIR;
39  }
40 
41  //------------------------------------------------------------------------------------------------
42  protected override LocalizedString GetInvalidPerformReasonString(ESupportStationReasonInvalid reasonInvalid)
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)
50  return m_sInvalidMaxHealingReached_Field;
51  else if (reasonInvalid == ESupportStationReasonInvalid.HEAL_MAX_HEALABLE_HEALTH_REACHED_EMERGENCY)
52  return m_sInvalidMaxHealingReached_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  {
73  if (!m_DamageManagerComponent || m_aHitZonesToHeal.IsEmpty())
74  return false;
75 
76  return super.CanBeShownScript(user);
77  }
78 
79  //------------------------------------------------------------------------------------------------
80  protected override bool CanShowDestroyed()
81  {
82  //~ If HULL is not included then it can always be repaired
83  if (!m_aHitZoneGroups.Contains(EVehicleHitZoneGroup.HULL))
84  return true;
85 
86  //~ Don't show if hull is destrpued
87  return super.CanShowDestroyed();
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  override bool CanBePerformedScript(IEntity user)
92  {
93  //~ If hitzones to heal are not on fire but the entity is then hide make the action invalid
94  if (m_OnFireCheckDamageManager && !IsHitZoneOnFire() && m_OnFireCheckDamageManager.IsDamagedOverTime(EDamageType.FIRE))
95  {
96  SetCanPerform(false, ESupportStationReasonInvalid.HEAL_ENTITY_ONFIRE);
97 
98  //~ Resets the support station so override action name is removed
100  return false;
101  }
102 
103  if (!m_DamageManagerComponent.CanBeHealed())
104  {
105  SetCanPerform(false, ESupportStationReasonInvalid.HEAL_ENTITY_UNDAMAGED);
106 
107  //~ Resets the support station so override action name is removed
109  return false;
110  }
111 
112  return super.CanBePerformedScript(user);
113  }
114 
115  //------------------------------------------------------------------------------------------------
116  protected override void SetHitZonesToHeal()
117  {
118  //~ Virtual gets all hitzones. Or if wheels do the same as wheels have no additional hitzones
119  if (m_aHitZoneGroups.IsEmpty() || m_bAlwaysRepairAllHitZones)
120  {
121  super.SetHitZonesToHeal();
122  return;
123  }
124 
125  m_aHitZonesToHeal.Clear();
126 
127  //~ Get the correct fuel tank to repair
128  if (!m_aHitZoneAdditionalIDs.IsEmpty() && m_aHitZoneGroups.Contains(EVehicleHitZoneGroup.FUEL_TANKS))
129  {
130  SCR_FuelHitZone fuelHitZone;
131  SCR_HitZone scrHitZone;
132 
133  array<HitZone> allHitZones = {};
134 
135  m_DamageManagerComponent.GetAllHitZones(allHitZones);
136 
137  foreach (HitZone hitZone : allHitZones)
138  {
139  scrHitZone = SCR_HitZone.Cast(hitZone);
140 
141  if (scrHitZone.GetHitZoneGroup() != EVehicleHitZoneGroup.FUEL_TANKS)
142  continue;
143 
144  //~ Not a fuel hitzone but part of the group
145  fuelHitZone = SCR_FuelHitZone.Cast(hitZone);
146  if (!fuelHitZone)
147  m_aHitZonesToHeal.Insert(hitZone);
148 
149  if (!m_aHitZoneAdditionalIDs.Contains(fuelHitZone.GetFuelTankID()))
150  continue;
151 
152  //~ Insert Fuel tank
153  m_aHitZonesToHeal.Insert(hitZone);
154  }
155  }
156 
157  //~ Get hitzone groups (Fuel tanks are already obtained)
158  foreach (EVehicleHitZoneGroup hitZoneGroup : m_aHitZoneGroups)
159  {
160  if (hitZoneGroup == EVehicleHitZoneGroup.VIRTUAL || (!m_aHitZoneAdditionalIDs.IsEmpty() && hitZoneGroup == EVehicleHitZoneGroup.FUEL_TANKS))
161  continue;
162 
163  m_DamageManagerComponent.GetHitZonesOfGroup(hitZoneGroup, m_aHitZonesToHeal, false);
164  }
165  }
166 
167  //------------------------------------------------------------------------------------------------
169  protected bool IsHitZoneOnFire()
170  {
171  SCR_FlammableHitZone flammableHitZone;
172  array<HitZone> hitZones = {};
173  GetHitZonesToHeal(hitZones);
174 
175  foreach (HitZone hitZone : hitZones)
176  {
177  flammableHitZone = SCR_FlammableHitZone.Cast(hitZone);
178  if (!flammableHitZone)
179  continue;
180 
181  if (flammableHitZone.GetFireState() == EFireState.BURNING)// || flammableHitZone.GetFireState() == EFireState.SMOKING_IGNITING)
182  return true;
183  }
184 
185  return false;
186  }
187 
188  //------------------------------------------------------------------------------------------------
189  protected override string GetActionStringParam()
190  {
191  //~ Don't show damage state when on fire
192  if (IsHitZoneOnFire())
193  return string.Empty;
194 
195  return super.GetActionStringParam();
196  }
197 
198  //------------------------------------------------------------------------------------------------
199  override bool GetActionNameScript(out string outName)
200  {
201  if (!m_HitZoneGroupNames)
202  return super.GetActionNameScript(outName);
203 
204  //~ Set extinguish fire action name
205  if (IsHitZoneOnFire())
206  outName = m_sOnFireOverrideActionName;
207  //~ Override action name
208  else if (m_SupportStationComponent)
209  outName = m_SupportStationComponent.GetOverrideUserActionName();
210 
211  //~ Default action name
212  if (outName.IsEmpty())
213  {
214  UIInfo uiInfo = GetUIInfo();
215  if (!uiInfo)
216  return super.GetActionNameScript(outName);
217 
218  outName = uiInfo.GetName();
219  }
220 
221  outName = WidgetManager.Translate(outName, m_HitZoneGroupNames.GetHitZoneGroupName(m_aHitZoneGroups[0]));
222  return super.GetActionNameScript(outName);
223  }
224 
225  //------------------------------------------------------------------------------------------------
226  protected override void DelayedInit(IEntity owner)
227  {
228  if (!owner)
229  return;
230 
231  super.DelayedInit(owner);
232 
233  //~ Make sure to check if the action is hidden if the entity is on fire
234  if (m_bHideIfEntityOnFire)
235  {
236  IEntity root = owner.GetRootParent();
237 
238  //~ If has root and root is vehicle get that damage manager else use defualt damage manager
239  if (root && Vehicle.Cast(root))
240  m_OnFireCheckDamageManager = SCR_DamageManagerComponent.GetDamageManager(root);
241  else
242  m_OnFireCheckDamageManager = m_DamageManagerComponent;
243  }
244  }
245 }
HitZone
Definition: HitZone.c:12
UIInfo
UIInfo - declare object, allows to define UI elements.
Definition: UIInfo.c:13
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
ESupportStationReasonInvalid
ESupportStationReasonInvalid
Definition: ESupportStationReasonInvalid.c:3
GetUIInfo
SCR_UIInfo GetUIInfo()
Definition: SCR_EditableEntityCampaignBuildingModeLabelSetting.c:27
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_DamageManagerComponent
private DamageManagerComponent m_DamageManagerComponent
Definition: SpectateTargetComponent.c:11
ESupportStationType
ESupportStationType
Definition: ESupportStationType.c:2
SCR_HitZoneGroupNameHolder
Holds the name data to show which parts of the vehicle or character the player is healing.
Definition: SCR_HitZoneGroupNameHolder.c:3
SCR_FuelHitZone
Definition: SCR_FuelHitZone.c:1
SCR_HitZone
Definition: SCR_HitZone.c:1
EFireState
EFireState
Definition: SCR_FlammableHitZone.c:1
SCR_BaseDamageHealSupportStationAction
Allows healing of action owner (not user)
Definition: SCR_BaseDamageHealSupportStationAction.c:2
EDamageType
EDamageType
Definition: EDamageType.c:12
m_SupportStationComponent
protected SCR_BaseSupportStationComponent m_SupportStationComponent
Definition: SCR_SupportStationAreaMeshComponent.c:18
EVehicleHitZoneGroup
EVehicleHitZoneGroup
Definition: SCR_VehicleDamageManagerComponent.c:1
LocalizedString
Definition: LocalizedString.c:21
SCR_RepairAtSupportStationAction
Definition: SCR_RepairAtSupportStationAction.c:1
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180