Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DeathScreenEffect.c
Go to the documentation of this file.
2 {
3  // Play Animation of DeathEffect()
4  protected const float DEATHEFFECT_START_OPACITY = 0.7;
5  protected const float DEATHEFFECT_FADEIN_OPACITY_DURATION = 0.8;
6  protected const float DEATHEFFECT_FADEIN_PROGRESSION_DURACTION = 0.5;
7  protected const float DEATHEFFECT_FADEIN_OPACITY_TARGET = 1;
8  protected const float DEATHEFFECT_FADEIN_PROGRESSION_TARGET = 1;
9 
10  // Play Animation of InstaDeathEffect()
11  protected const float INSTADEATHEFFECT_START_OPACITY = 0.4;
12  protected const float INSTADEATHEFFECT_START_PROGRESSION = 0.4;
13  protected const float INSTADEATHEFFECT_FADEIN_OPACITY_DURATION = 8.5;
14  protected const float INSTADEATHEFFECT_FADEIN_PROGRESSION_DURACTION = 10;
15  protected const float INSTADEATHEFFECT_FADEIN_OPACITY_TARGET = 1;
16  protected const float INSTADEATHEFFECT_FADEIN_PROGRESSION_TARGET = 1;
17 
18  // Widgets
19  protected ImageWidget m_wDeath;
20  protected ImageWidget m_wBlackOut;
21 
22  // Character
23  protected ChimeraCharacter m_pCharacterEntity;
24  protected SCR_HitZone m_pHeadHitZone;
25  protected SCR_CharacterDamageManagerComponent m_pDamageManager;
26 
27 
28  //------------------------------------------------------------------------------------------------
29  override void DisplayStartDraw(IEntity owner)
30  {
31  m_pCharacterEntity = ChimeraCharacter.Cast(owner);
32 
33  m_wDeath = ImageWidget.Cast(m_wRoot.FindAnyWidget("DeathOverlay"));
34  m_wBlackOut = ImageWidget.Cast(m_wRoot.FindAnyWidget("BlackOut"));
35  }
36 
37  //------------------------------------------------------------------------------------------------
38  override void DisplayControlledEntityChanged(IEntity from, IEntity to)
39  {
40  if (!to)
41  return;
42 
43  m_pCharacterEntity = ChimeraCharacter.Cast(to);
44  if (!m_pCharacterEntity)
45  return;
46 
47  //Don't remove effects until new entity was aquired, so death effects persist through death
48  ClearEffects();
49 
50  m_pDamageManager = SCR_CharacterDamageManagerComponent.Cast(m_pCharacterEntity.GetDamageManager());
51  if (!m_pDamageManager)
52  return;
53 
54  // Invoker for momentary damage events and DOT damage events
55  m_pHeadHitZone = SCR_HitZone.Cast(m_pDamageManager.GetHeadHitZone());
56 
57  if (m_pHeadHitZone)
58  m_pHeadHitZone.GetOnDamageStateChanged().Insert(InstaDeathEffect);
59 
60  m_pDamageManager.GetOnDamageStateChanged().Insert(OnDamageStateChanged);
61  }
62 
63  //------------------------------------------------------------------------------------------------
64  private void OnDamageStateChanged()
65  {
66  if (m_pDamageManager.GetState() != EDamageState.DESTROYED)
67  return;
68 
69  if (m_pHeadHitZone.GetDamageState() != EDamageState.DESTROYED)
70  DeathEffect();
71  else
72  InstaDeathEffect();
73  }
74 
75  //------------------------------------------------------------------------------------------------
76  void DeathEffect()
77  {
78  if (!m_wDeath)
79  return;
80 
81  AnimateWidget.StopAllAnimations(m_wDeath);
82  AnimateWidget.Opacity(m_wDeath, DEATHEFFECT_FADEIN_OPACITY_TARGET, DEATHEFFECT_FADEIN_OPACITY_DURATION);
83  AnimateWidget.AlphaMask(m_wDeath, DEATHEFFECT_FADEIN_PROGRESSION_TARGET, DEATHEFFECT_FADEIN_PROGRESSION_DURACTION);
84  }
85 
86  //------------------------------------------------------------------------------------------------
87  void InstaDeathEffect()
88  {
89  if (m_wDeath.GetOpacity() >= 0.99 )
90  return;
91 
92  if (m_pHeadHitZone.GetDamageState() != EDamageState.DESTROYED)
93  return;
94 
95  if (m_pDamageManager.GetState() != EDamageState.DESTROYED)
96  return;
97 
98  AnimateWidget.StopAllAnimations(m_wDeath);
99  AnimateWidget.Opacity(m_wDeath, INSTADEATHEFFECT_FADEIN_OPACITY_TARGET, INSTADEATHEFFECT_FADEIN_OPACITY_DURATION);
100  AnimateWidget.AlphaMask(m_wDeath, INSTADEATHEFFECT_FADEIN_PROGRESSION_TARGET, INSTADEATHEFFECT_FADEIN_PROGRESSION_DURACTION);
101  }
102 
103  //------------------------------------------------------------------------------------------------
104  protected override void ClearEffects()
105  {
106  if (m_pDamageManager)
107  m_pDamageManager.GetOnDamageStateChanged().Remove(OnDamageStateChanged);
108 
109  if (m_pHeadHitZone)
110  m_pHeadHitZone.GetOnDamageStateChanged().Remove(InstaDeathEffect);
111 
112  if (m_wDeath)
113  {
114  AnimateWidget.StopAllAnimations(m_wDeath);
115  m_wDeath.SetOpacity(0);
116  m_wDeath.SetMaskProgress(0);
117  }
118  }
119 };
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_BaseScreenEffect
Definition: SCR_BaseScreenEffect.c:1
EDamageState
EDamageState
Definition: EDamageState.c:12
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
SCR_DeathScreenEffect
Definition: SCR_DeathScreenEffect.c:1
SCR_HitZone
Definition: SCR_HitZone.c:1