4 protected string m_sBleedingHitZoneName;
7 protected string m_sDamageHitZoneName;
9 protected SCR_InventoryHitZonePointUI m_pDamageHandler;
11 protected ref array<HitZone> m_aGroupHitZones = {};
14 protected IEntity m_Player;
17 protected TNodeId m_iBoneIndex;
19 protected Widget m_wRoot;
20 protected Widget m_wGlow;
22 protected BaseInventoryStorageComponent m_pStorage;
25 protected bool m_bSelected;
26 protected bool m_bApplicableItemsShown;
30 override void HandlerAttached(Widget w)
34 m_wGlow = w.FindAnyWidget(
"Glow");
35 m_wGlow.SetVisible(
false);
37 Widget damageW = w.FindAnyWidget(m_sDamageHitZoneName);
38 m_pDamageHandler = SCR_InventoryHitZonePointUI.Cast(damageW.FindHandler(SCR_InventoryHitZonePointUI));
41 override bool OnClick(Widget w,
int x,
int y,
int button)
45 if (!m_bApplicableItemsShown)
46 ShowApplicableItems();
48 HideApplicableItems();
54 void RemoveTourniquetFromSlot()
56 if (m_TourniquetStorage)
60 override bool OnMouseEnter(Widget w,
int x,
int y)
67 int id = spinbox.FindItem(GetHitZoneName());
69 spinbox.SetCurrentItem(
id);
72 m_pStorageUI.OnFocus(m_pStorageUI.GetRootWidget(), 0, 0);
77 override bool OnMouseLeave(Widget w, Widget enterW,
int x,
int y)
81 m_pStorageUI.OnFocusLost(m_pStorageUI.GetRootWidget(), 0, 0);
86 protected void Highlight(
bool highlight)
88 m_pDamageHandler.Highlight(highlight);
91 void SetGlowVisible(
bool visible)
93 m_wGlow.SetVisible(visible);
96 void Select(
bool select =
true)
100 s_pSelectedPoint.m_bSelected =
false;
101 s_pSelectedPoint.Highlight(
false);
108 s_pSelectedPoint =
this;
112 s_pSelectedPoint =
null;
117 void ShowApplicableItems()
119 m_bApplicableItemsShown =
true;
121 SCR_ApplicableMedicalItemPredicate predicate =
new SCR_ApplicableMedicalItemPredicate();
122 predicate.characterEntity =
m_Player;
124 m_pInventoryMenu.ShowAttachmentStorage(predicate);
127 void HideApplicableItems()
129 m_bApplicableItemsShown =
false;
130 if (m_pInventoryMenu.GetAttachmentStorageUI())
132 m_pInventoryMenu.RemoveAttachmentStorage(m_pInventoryMenu.GetAttachmentStorageUI());
133 m_pStorageUI.GetRootWidget().SetVisible(
false);
145 string GetHitZoneName()
151 return "#AR-Inventory_Head";
156 return "#AR-Inventory_Chest";
161 return "#AR-Inventory_Abdomen";
166 return "#AR-Inventory_LeftArm";
171 return "#AR-Inventory_RightArm";
176 return "#AR-Inventory_LeftLeg";
181 return "#AR-Inventory_RightLeg";
189 void InitializeHitZoneUI(BaseInventoryStorageComponent storage,
SCR_InventoryMenuUI menuManager,
int hitZoneId, IEntity player)
191 m_pStorage = storage;
192 m_pInventoryMenu = menuManager;
196 m_TourniquetStorage.GetOnTourniquetMoved().Insert(OnTourniquetMoved);
199 if (!m_pCharDmgManager)
203 m_pDamageHandler.SetParentContainer(
this);
206 m_pBloodHitZone.GetOnDamageStateChanged().Insert(UpdateHitZoneState);
209 UpdateHitZoneState(m_pBloodHitZone);
211 m_pCharDmgManager.GetOnDamageOverTimeAdded().Insert(UpdateHitZoneDOTAdded);
212 m_pCharDmgManager.GetOnDamageOverTimeRemoved().Insert(UpdateHitZoneDOTRemoved);
215 m_iBoneIndex =
m_Player.GetAnimation().GetBoneIndex(boneName);
222 scrHZ.GetOnDamageStateChanged().Insert(UpdateHitZoneState);
223 UpdateHitZoneState(scrHZ);
227 bool tourniquetted = m_pCharDmgManager.GetGroupTourniquetted(
m_eHitZoneGroup);
228 Widget newStorage =
GetGame().GetWorkspace().CreateWidgets(m_pInventoryMenu.BACKPACK_STORAGE_LAYOUT,
m_wRoot);
230 newStorage.AddHandler(m_pStorageUI);
231 m_pStorageUI.GetRootWidget().SetVisible(
false);
234 protected void OnTourniquetMoved(
int hzGroupId)
236 array<HitZone> hzs = {};
237 m_pCharDmgManager.GetHitZonesOfGroup(hzGroupId, hzs);
278 float health = m_pCharDmgManager.GetGroupHealthScaled(
m_eHitZoneGroup);
283 if (groupHZ == m_pBloodHitZone)
286 if (groupHZ.GetDamageOverTime(
EDamageType.BLEEDING))
295 float regen = (dotHealing + dotRegen);
297 bool tourniquetted = m_pCharDmgManager.GetGroupTourniquetted(
m_eHitZoneGroup);
298 bool salineBagged = m_pCharDmgManager.GetGroupSalineBagged(
m_eHitZoneGroup);
301 m_pStorageUI.SetTourniquetted(tourniquetted);
303 bool bleedingVisible = (bleeding > 0 || tourniquetted || salineBagged);
304 bool damageVisible = (health < 1 && bleeding == 0);
305 m_pDamageHandler.GetRootWidget().SetVisible(damageVisible || bleedingVisible);
306 m_pDamageHandler.UpdateHitZoneState(health, bleeding, regen, tourniquetted, salineBagged);
308 SetGlowVisible(bleedingVisible);
310 if (!m_pInventoryMenu)
313 if (
m_bSelected || m_pInventoryMenu.IsUsingGamepad())
314 ShowApplicableItems();
316 if (bleeding > 0 || health < 1 || tourniquetted || salineBagged)
317 m_pInventoryMenu.AddItemToAttachmentSelection(GetHitZoneName(),
this);
319 m_pInventoryMenu.RemoveItemFromAttachmentSelection(GetHitZoneName());
322 void SetGlowColor(Color color)
325 m_wGlow.SetColor(color);
329 Widget GetRootWidget()
334 TNodeId GetBoneIndex()
341 return m_pInventoryMenu;
351 class SCR_InventoryHitZonePointUI : ScriptedWidgetComponent
395 protected static SCR_InventoryHitZonePointUI s_pSelectedPoint;
421 protected const string DAMAGE_INFO =
"{55AFA256E1C20FB2}UI/layouts/Menus/Inventory/InventoryDamageInfo.layout";
459 m_wButton = ButtonWidget.Cast(w.FindAnyWidget(
"Btn"));
468 Widget damageOverlay = w.FindAnyWidget(
"DamageOverlay");
488 if (w.GetName() ==
"BigBloodIcon")
490 else if (w.GetName() ==
"BigDamageIcon")
499 if (w.GetName() ==
"BigBloodIcon")
501 else if (w.GetName() ==
"BigDamageIcon")
510 if (s_pSelectedPoint)
512 s_pSelectedPoint.m_bSelected =
false;
513 s_pSelectedPoint.Highlight(
false);
519 s_pSelectedPoint =
this;
521 s_pSelectedPoint =
null;
544 if (!inventoryMenuUI)
547 return inventoryMenuUI;
554 if (!bloodIcon && !fractureIcon)
557 int groupDamageIntensity;
559 float bleedingRate, bloodHealth;
560 bool isTourniquetted, isSalineBagged, isMorphined, isArmFractured, isLegFractured;
561 string damageIntensity, damageIntensityText, bleedingIntensityText, bloodLevelText;
567 Widget localInfoWidget;
571 if (!inventoryMenuUI)
574 localInfoWidget =
GetGame().GetWorkspace().CreateWidgets(
DAMAGE_INFO, inventoryMenuUI.GetRootWidget());
575 if (!localInfoWidget)
578 localInfoWidget.SetVisible(
true);
579 localInfoWidget.SetOpacity(0);
590 m_DamageInfo.SetFractureStateVisible(isArmFractured, isLegFractured);
592 m_DamageInfo.SetBleedingStateVisible(bloodHealth < 1, bloodLevelText);
606 w.GetScreenPos(x, y);
609 w.GetScreenSize(width, height);
611 float screenSizeX, screenSizeY;
612 GetGame().GetWorkspace().GetScreenSize(screenSizeX, screenSizeY);
614 localInfoWidget.SetOpacity(1);
616 float infoWidth, infoHeight;
617 int iMouseX, iMouseY;
619 localInfoWidget.GetScreenSize(infoWidth, infoHeight);
621 iMouseY = y + height;
622 if (x + infoWidth > screenSizeX)
623 iMouseX = screenSizeX - infoWidth - width * 0.5;
625 m_DamageInfo.Move(
GetGame().GetWorkspace().DPIUnscale( iMouseX ) - infoWidth * 0.60,
GetGame().GetWorkspace().DPIUnscale( iMouseY ) );
641 if (!show && !virtualHZ)
651 int groupDamageIntensity;
653 float bleedingRate, bloodHealth;
654 bool isTourniquetted, isSalineBagged, isMorphined, isArmFractured, isLegFractured;
655 string damageIntensity, damageIntensityText, bleedingIntensityText;
657 GetHitZoneInfo(group, groupDamageIntensity, regenerating, bleedingRate, bloodHealth, isTourniquetted, isSalineBagged, isArmFractured, isLegFractured);
658 GetDamageInfoTexts(group, groupDamageIntensity, bleedingRate, damageIntensity, damageIntensityText, bleedingIntensityText);
662 groupDamageIntensity != 0,
672 bleedingIntensityText
683 void GetDamageInfoTexts(EHitZoneGroup group,
int groupDamageIntensity,
float bleedingRate, out
string damageIntensity, out
string damageIntensityText, out
string bleedingIntensityText)
685 if (groupDamageIntensity == 0)
687 damageIntensity =
"";
688 damageIntensityText =
"";
690 else if (groupDamageIntensity == 1)
692 damageIntensity =
"Wound_1_UI";
695 else if (groupDamageIntensity == 2)
697 damageIntensity =
"Wound_2_UI";
700 else if (groupDamageIntensity == 3)
702 damageIntensity =
"Wound_3_UI";
705 else if (groupDamageIntensity == 4)
707 damageIntensity =
"Wound_4_UI";
735 protected void GetHitZoneInfo(EHitZoneGroup group, out
int groupDamageIntensity, out
bool regenerating, out
float bleedingRate, out
float bloodHealth, out
bool isTourniquetted, out
bool isSalineBagged, out
bool isArmFractured, out
bool isLegFractured)
745 float groupHealth = damageMan.GetGroupHealthScaled(group);
746 bleedingRate = damageMan.GetGroupDamageOverTime(group,
EDamageType.BLEEDING);
747 isTourniquetted = damageMan.GetGroupTourniquetted(group);
748 isSalineBagged = damageMan.GetGroupSalineBagged(group);
752 isArmFractured = damageMan.GetAimingDamage() > 0;
753 isLegFractured = damageMan.GetMovementDamage() > 0;
758 bleedingRate = hz.GetDamageOverTime(
EDamageType.BLEEDING);
759 bloodHealth = hz.GetHealthScaled();
763 isArmFractured = damageMan.GetAimingDamage() > 0;
765 isLegFractured = damageMan.GetMovementDamage() > 0;
767 if (damageMan.GetGroupDamageOverTime(group,
EDamageType.HEALING) == 0 && damageMan.GetGroupDamageOverTime(group,
EDamageType.REGENERATION) == 0)
768 regenerating =
false;
772 if (groupHealth == 1)
773 groupDamageIntensity = 0;
775 groupDamageIntensity = 4;
777 groupDamageIntensity = 3;
779 groupDamageIntensity = 2;
781 groupDamageIntensity = 1;
785 void UpdateHitZoneState(
float health,
float bleeding,
float regen,
bool tourniquetted,
bool salineBagged)
792 if (tourniquetted || salineBagged)
803 float bleedRate, bloodHealth;
805 bool isArmFractured, isLegFractured;
806 GetHitZoneInfo(
m_eHitZoneGroup, damageIntensity, regenerating, bleedRate, bloodHealth, tourniquetted, salineBagged, isArmFractured, isLegFractured);
807 if (damageIntensity > 0)
812 m_wIcon.SetVisible(!tourniquetted && !salineBagged);
824 bool isRegen = (regen < 0);
825 float regenSpeed = Math.AbsFloat(regen);
826 if (regenSpeed < 0.3)
829 if (isRegen && !bleeding)
838 if (isRegen && bleeding == 0)
898 float opacitySpeed = speed;
906 float targetSize[2] = {32, 32};
961 float mask = Math.Lerp(0.25, 0.75, 1 - bloodLevel);