1 [
ComponentEditorProps(
category:
"GameScripted/GameMode/Components", description:
"Manager that holds a reference to all Support Stations.")]
13 protected ref map<ESupportStationType, ref array<SCR_BaseSupportStationComponent>> m_mSupportStations =
new map<ESupportStationType, ref array<SCR_BaseSupportStationComponent>>();
18 protected ref ScriptInvokerBase<SupportStation_OnSupportStationExecuted> m_OnSupportStationExecutedSuccessfully =
new ScriptInvokerBase<SupportStation_OnSupportStationExecuted>();
41 instance.GetOnSupportStationExecutedSuccessfully().Invoke(supportStation, supportStationType, actionOwner, actionUser, action);
48 ScriptInvokerBase<SupportStation_OnSupportStationExecuted> GetOnSupportStationExecutedSuccessfully()
50 return m_OnSupportStationExecutedSuccessfully;
55 protected int GetArrayOfSupportStationType(
ESupportStationType type, notnull out array<SCR_BaseSupportStationComponent> supportStations)
57 supportStations.Clear();
66 return supportStations.Count();
81 array<SCR_BaseSupportStationComponent> supportStations = {};
83 GetArrayOfSupportStationType(
type, supportStations);
88 SCR_BaseSupportStationComponent closestSupportStation =
null;
90 float closestDistance =
float.MAX;
91 int minSuppliesRequired =
int.MAX;
92 int suppliesRequired, validSupplyCost;
94 foreach (SCR_BaseSupportStationComponent station : supportStations)
100 if (closestSupportStation !=
null && station.GetSupportStationPriority() < validPriority)
104 if (station.IsValid(actionOwner, actionUser, action, actionPosition, newReasonInvalid, suppliesRequired))
107 if (validPriority < 0)
108 validPriority = station.GetSupportStationPriority();
111 float distancesq = vector.DistanceSq(actionPosition, station.GetPosition());
114 if (distancesq < closestDistance)
116 closestDistance = distancesq;
117 closestSupportStation = station;
118 validSupplyCost = suppliesRequired;
122 else if (newReasonInvalid > reasonInvalid)
124 reasonInvalid = newReasonInvalid;
129 minSuppliesRequired = suppliesRequired;
133 if (closestSupportStation)
134 supplyCost = validSupplyCost;
137 supplyCost = minSuppliesRequired;
142 return closestSupportStation;
148 void AddSupportStation(notnull SCR_BaseSupportStationComponent supportStation)
152 Print(
"Cannot add SupportStation of type NONE! Make sure to overwrite GetSupportStationType() in inherited class.", LogLevel.ERROR);
156 array<SCR_BaseSupportStationComponent> supportStations = {};
157 GetArrayOfSupportStationType(supportStation.GetSupportStationType(), supportStations);
160 if (supportStations.Contains(supportStation))
163 for (
int i = 0, count = supportStations.Count(); i < count; i++)
166 if (supportStation.GetSupportStationPriority() >= supportStations[i].GetSupportStationPriority())
169 m_mSupportStations[supportStation.GetSupportStationType()].InsertAt(supportStation, i);
181 void RemoveSupportStation(notnull SCR_BaseSupportStationComponent supportStation)
186 array<SCR_BaseSupportStationComponent> supportStations = {};
187 GetArrayOfSupportStationType(supportStation.GetSupportStationType(), supportStations);
189 int index = supportStations.Find(supportStation);
207 static void GetCombinedHitZonesStateForDamageSupportStation(notnull SCR_DamageManagerComponent damageManagerComponent, notnull array<HitZone> hitZones,
float maxHealPercentage, out
float roughHealPercentageStatus, out
bool allHitZonesMaxHealth =
true)
209 HitZone defaultHitZone = damageManagerComponent.GetDefaultHitZone();
212 allHitZonesMaxHealth =
true;
213 roughHealPercentageStatus = 0;
215 int hitZonesChecked = 0;
216 bool defaultHitZoneIncluded =
false;
218 foreach (
HitZone hitZone : hitZones)
220 if (defaultHitZone == hitZone)
222 defaultHitZoneIncluded =
true;
228 roughHealPercentageStatus += hitZone.GetHealthScaled();
231 if (allHitZonesMaxHealth && hitZone.GetHealthScaled() < maxHealPercentage)
232 allHitZonesMaxHealth =
false;
236 if (hitZonesChecked > 0)
237 roughHealPercentageStatus = roughHealPercentageStatus / hitZonesChecked;
239 roughHealPercentageStatus = 1;
241 if (defaultHitZoneIncluded && defaultHitZone)
244 if (roughHealPercentageStatus > defaultHitZone.GetHealthScaled())
245 roughHealPercentageStatus = defaultHitZone.GetHealthScaled();
250 override void OnPostInit(IEntity owner)
255 BaseGameMode gameMode =
GetGame().GetGameMode();