3 const ResourceName INSPECT_CASUALTY_LAYOUT =
"{11AC7D61FD4CF3F6}UI/layouts/Damage/InspectCasualtyMenu.layout";
6 protected Widget m_wCasualtyInspectWidget;
10 protected const float UPDATE_FREQ = 0.5;
11 protected const float MAX_SHOW_DURATION = 5;
12 protected const string TARGET_BONE =
"Spine4";
13 protected float m_fTimeTillUpdate;
14 protected float m_fTimeTillClose;
15 protected bool m_bShouldBeVisible;
18 override void DisplayStartDraw(IEntity owner)
25 override event void DisplayUpdate(IEntity owner,
float timeSlice)
27 if (m_fTimeTillClose < 0)
30 m_fTimeTillClose -= timeSlice;
32 if (m_fTimeTillUpdate > 0)
34 m_fTimeTillUpdate -= timeSlice;
38 m_fTimeTillUpdate = UPDATE_FREQ;
47 bool ShowInspectCasualtyWidget(IEntity targetCharacter)
49 if (!m_wCasualtyInspectWidget)
52 ChimeraCharacter
char = ChimeraCharacter.Cast(targetCharacter);
56 CharacterControllerComponent targetController =
char.GetCharacterController();
57 if (!targetController)
76 ChimeraCharacter
char = ChimeraCharacter.Cast(
m_Target);
80 CharacterControllerComponent controller =
char.GetCharacterController();
92 void UpdateWidgetData()
94 if (!
m_Target || !m_wCasualtyInspectWidget)
101 int groupDamageIntensity;
102 bool regenerating, isTourniquetted, isSalineBagged, isMorphined, isArmFractured, isLegFractured;
103 string damageIntensity, damageIntensityText, bleedingIntensityText;
104 array <bool> hZGroupsBleeding = {};
106 SCR_InventoryHitZonePointUI hitZonePointUI =
new SCR_InventoryHitZonePointUI();
107 GetDamageInfo(hitZonePointUI,
m_Target, bleedingRate, hZGroupsBleeding, groupDamageIntensity, regenerating, isTourniquetted, isSalineBagged, isMorphined);
108 hitZonePointUI.GetDamageInfoTexts(EHitZoneGroup.VIRTUAL, groupDamageIntensity, bleedingRate, damageIntensity, damageIntensityText, bleedingIntensityText);
113 damageInfoUI.SetName(sName);
114 damageInfoUI.SetDamageStateVisible(groupDamageIntensity, regenerating, damageIntensity, damageIntensityText);
115 damageInfoUI.SetBleedingStateVisible(bleedingRate > 0, bleedingIntensityText);
116 damageInfoUI.SetTourniquetStateVisible(isTourniquetted);
117 damageInfoUI.SetSalineBagStateVisible(isSalineBagged);
118 damageInfoUI.SetMorphineStateVisible(isMorphined);
119 damageInfoUI.SetFractureStateVisible(isArmFractured, isLegFractured);
130 vector boneVector[4];
131 m_Target.GetAnimation().GetBoneMatrix(
m_Target.GetAnimation().GetBoneIndex(TARGET_BONE), boneVector);
133 vector WPPos = boneVector[3] +
m_Target.GetOrigin();
134 vector pos =
GetGame().GetWorkspace().ProjWorldToScreen(WPPos,
GetGame().GetWorld());
137 WorkspaceWidget workspace =
GetGame().GetWorkspace();
138 int winX = workspace.GetWidth();
139 int winY = workspace.GetHeight();
140 int posX = workspace.DPIScale(pos[0]);
141 int posY = workspace.DPIScale(pos[1]);
144 if (posX < 0 || posX > winX || posY > winY || posY < 0)
150 FrameSlot.SetPos(m_wCasualtyInspectWidget.GetChildren(), pos[0], pos[1]);
160 float distanceOpacityReduction = 1;
163 distanceOpacityReduction = 0;
165 distanceOpacityReduction = Math.InverseLerp(3, 4, dist);
167 m_wCasualtyInspectWidget.SetOpacity(opacity - distanceOpacityReduction);
171 void GetDamageInfo(SCR_InventoryHitZonePointUI hitZonePointUI, IEntity targetEntity, inout
float bleedingRate, inout array <bool> hZGroupsBleeding, inout
int damageIntensity, inout
bool regenerating, inout
bool isTourniquetted, inout
bool isSalineBagged, inout
bool isMorphined)
173 ChimeraCharacter character = ChimeraCharacter.Cast(targetEntity);
181 float defaultHZHealth = damageMan.GetHealthScaled();
182 bleedingRate = damageMan.GetBloodHitZone().GetDamageOverTime(
EDamageType.BLEEDING);
185 hZGroupsBleeding = {};
186 hZGroupsBleeding.Resize(damageMan.LIMB_GROUPS.Count());
190 hZGroupsBleeding[damageMan.LIMB_GROUPS.Find(group)] = damageMan.GetGroupDamageOverTime(group,
EDamageType.BLEEDING) != 0;
194 array <EHitZoneGroup> limbGroups = {};
195 damageMan.GetAllLimbs(limbGroups);
196 foreach(EHitZoneGroup group : limbGroups)
198 if (!isTourniquetted)
199 isTourniquetted = damageMan.GetGroupTourniquetted(group);
202 isSalineBagged = damageMan.GetGroupSalineBagged(group);
208 isMorphined = headHitZone.GetDamageOverTime(
EDamageType.HEALING) < 0;
212 regenerating = damageMan.GetGroupDamageOverTime(group,
EDamageType.HEALING) != 0 || damageMan.GetGroupDamageOverTime(group,
EDamageType.REGENERATION) != 0;
215 if (defaultHZHealth == 1)
217 else if (defaultHZHealth < hitZonePointUI.m_fLowDamageThreshold)
219 else if (defaultHZHealth < hitZonePointUI.m_fMediumDamageThreshold)
221 else if (defaultHZHealth < hitZonePointUI.m_fHighDamageThreshold)
228 void GetCasualtyName(inout
string sName, IEntity targetCharacter)
230 string sFormat, sAlias, sSurname;
231 int playerID =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(targetCharacter);
236 sName = playerMgr.GetPlayerName(playerID);
240 SCR_CharacterIdentityComponent scrCharIdentity = SCR_CharacterIdentityComponent.Cast(targetCharacter.FindComponent(SCR_CharacterIdentityComponent));
243 scrCharIdentity.GetFormattedFullName(sFormat, sName, sAlias, sSurname);
244 sName = sName +
" " + sSurname;
248 CharacterIdentityComponent charIdentity = CharacterIdentityComponent.Cast(targetCharacter.FindComponent(CharacterIdentityComponent));
249 if (charIdentity && charIdentity.GetIdentity())
250 sName = charIdentity.GetIdentity().GetName();
256 override protected void DisplayOnSuspended()
262 void SetTarget(IEntity target)
270 return m_Target && m_wCasualtyInspectWidget && m_wCasualtyInspectWidget.GetOpacity() != 0;
276 if (m_wCasualtyInspectWidget)
277 m_wCasualtyInspectWidget.SetVisible(
false);
281 m_bShouldBeVisible =
false;
282 m_fTimeTillClose = MAX_SHOW_DURATION;
288 if (m_wCasualtyInspectWidget)
289 m_wCasualtyInspectWidget.SetVisible(
true);
292 m_bShouldBeVisible =
true;
296 override void DisplayOnResumed()
298 if (!m_bShouldBeVisible && m_wCasualtyInspectWidget)
299 m_wCasualtyInspectWidget.SetVisible(
false);