Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BloodTooltipDetail.c
Go to the documentation of this file.
3 {
4  protected SCR_CharacterDamageManagerComponent m_CharacterDamageManager;
5 
6  [Attribute("BloodUnconsciousBar", desc: "Image that shows when Character becomes conscious")]
7  protected string m_sUnconsciousBarName;
8 
9  [Attribute("BloodUnconsciousBarTop", desc: "Set at the end of the bar")]
10  protected string m_sUnconsciousBarTopName;
11 
12  [Attribute("BloodUnconsciousFillRight", desc: "Filler make sure the bar is set the correct size")]
13  protected string m_sUnconsciousFillerRightName;
14 
15  [Attribute("0.025", desc: "Size of the BarTop")]
16  protected float m_iUnconsciousBarTopSize;
17 
18  protected float m_fBloodLevelLoseDeath;
19  protected float m_fBloodLevelContiousness;
20  protected float m_fBloodLevel;
21 
22  protected Widget m_UnconsciousBar;
23  protected Widget m_UnconsciousBarTop;
24  protected Widget m_UnconsciousFillerRight;
25 
26  //------------------------------------------------------------------------------------------------
27  override bool NeedUpdate()
28  {
29  return m_CharacterDamageManager != null;
30  }
31 
32  //------------------------------------------------------------------------------------------------
33  override void UpdateDetail(SCR_EditableEntityComponent entity)
34  {
35  super.UpdateDetail(entity);
36 
37  HitZone bloodHitZone = m_CharacterDamageManager.GetBloodHitZone();
38  if (!bloodHitZone)
39  return;
40 
41  //~ If character dead set blood 0
42  if (m_CharacterDamageManager.GetState() == EDamageState.DESTROYED)
43  {
44 
45  if (m_UnconsciousBar)
46  m_UnconsciousBar.SetVisible(false);
47 
48  if (m_UnconsciousBarTop)
49  m_UnconsciousBarTop.SetVisible(false);
50 
51  if (m_UnconsciousFillerRight)
52  m_UnconsciousFillerRight.SetVisible(false);
53 
54  SetBarAndPercentageValue(0);
55  return;
56  }
57 
58  float bloodLevel = Math.InverseLerp(bloodHitZone.GetDamageStateThreshold(ECharacterBloodState.DESTROYED), 1, bloodHitZone.GetHealthScaled());
59 
60  //~ Update blood visual
61  bloodLevel = Math.Clamp(bloodLevel, 0, 1);
62  UpdateBloodBar(bloodLevel, bloodHitZone.GetDamageStateThreshold(ECharacterBloodState.UNCONSCIOUS));
63  SetBarAndPercentageValue(bloodLevel);
64  }
65 
66  //------------------------------------------------------------------------------------------------
67  protected void UpdateBloodBar(float bloodLevel, float unconsciousLevel)
68  {
69  if (bloodLevel >= unconsciousLevel)
70  {
71  m_UnconsciousBarTop.SetVisible(true);
72  LayoutSlot.SetFillWeight(m_UnconsciousBar, Math.Clamp(unconsciousLevel - m_iUnconsciousBarTopSize, 0, 1));
73  LayoutSlot.SetFillWeight(m_UnconsciousFillerRight, Math.Clamp(1 - unconsciousLevel, 0, 1));
74  }
75  else
76  {
77  if (bloodLevel >= m_iUnconsciousBarTopSize)
78  {
79  m_UnconsciousBarTop.SetVisible(true);
80  LayoutSlot.SetFillWeight(m_UnconsciousBar, Math.Clamp(bloodLevel - m_iUnconsciousBarTopSize, 0 , 1));
81  LayoutSlot.SetFillWeight(m_UnconsciousFillerRight, Math.Clamp(1 - bloodLevel, 0, 1));
82  }
83  else
84  {
85  m_UnconsciousBarTop.SetVisible(false);
86  LayoutSlot.SetFillWeight(m_UnconsciousBar, Math.Clamp(bloodLevel, 0 , 1));
87  LayoutSlot.SetFillWeight(m_UnconsciousFillerRight, Math.Clamp(1 - bloodLevel, 0, 1));
88  }
89  }
90  }
91 
92  //------------------------------------------------------------------------------------------------
93  override void SetBarColor(bool SetConditionColor)
94  {
95  super.SetBarColor(SetConditionColor);
96 
97  if (!m_UnconsciousBar || !m_UnconsciousBarTop)
98  return;
99 
100  //~ Reverse colors of unconciouss amount
101  if (m_bBarIsColored)
102  {
103  m_UnconsciousBar.SetColor(m_cDefaultBarColor);
104  m_UnconsciousBarTop.SetColor(m_cDefaultBarColor);
105  }
106  else
107  {
108  m_UnconsciousBar.SetColor(m_cHasDpsBarColor);
109  m_UnconsciousBarTop.SetColor(m_cHasDpsBarColor);
110  }
111  }
112 
113  //------------------------------------------------------------------------------------------------
114  override bool InitDetail(SCR_EditableEntityComponent entity, Widget widget)
115  {
116  if (!super.InitDetail(entity, widget))
117  return false;
118 
119  m_CharacterDamageManager = SCR_CharacterDamageManagerComponent.Cast(m_DamageManager);
120  if (!m_CharacterDamageManager)
121  return false;
122 
123  HitZone bloodHitZone = m_CharacterDamageManager.GetBloodHitZone();
124  if (!bloodHitZone)
125  return false;
126 
127  m_UnconsciousBarTop = widget.FindAnyWidget(m_sUnconsciousBarTopName);
128  m_UnconsciousBar = widget.FindAnyWidget(m_sUnconsciousBarName);
129  m_UnconsciousFillerRight = widget.FindAnyWidget(m_sUnconsciousFillerRightName);
130 
131  if (!m_UnconsciousBarTop || !m_UnconsciousBar || !m_UnconsciousFillerRight)
132  {
133  Print("'SCR_BloodTooltipDetail' is missing UI to display which means it will be hidden!", LogLevel.ERROR);
134  return false;
135  }
136 
137  if (m_CharacterDamageManager.GetState() == EDamageState.DESTROYED)
138  return false;
139 
140  if (m_CharacterDamageManager.GetState() == EDamageState.DESTROYED)
141  {
142  m_UnconsciousBar.SetVisible(false);
143  m_UnconsciousBarTop.SetVisible(false);
144  m_UnconsciousFillerRight.SetVisible(false);
145  return false;
146  }
147 
148  LayoutSlot.SetFillWeight(m_UnconsciousBarTop, m_iUnconsciousBarTopSize);
149 
150  UpdateDetail(entity);
151  return true;
152  }
153 }
HitZone
Definition: HitZone.c:12
EDamageState
EDamageState
Definition: EDamageState.c:12
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_BloodTooltipDetail
Definition: SCR_BloodTooltipDetail.c:2
BaseContainerCustomTitleField
class SCR_KeyBindingFilter BaseContainerCustomTitleField("m_sBindString")
Definition: SCR_KeyBindingMenuConfig.c:113
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_DpsConditionBarBaseTooltipDetail
Definition: SCR_DpsConditionBarBaseTooltipDetail.c:2
ECharacterBloodState
ECharacterBloodState
Definition: SCR_CharacterHitZone.c:13
m_DamageManager
DamageManagerComponent m_DamageManager
Definition: SCR_AITargetInfo.c:19
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468