Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_StaminaBlurEffect.c
Go to the documentation of this file.
2 {
3  // PP constants
4  // Play Animation of StaminaEffects()
5  protected const float STAMINAEFFECT_INITIAL_OPACITY_TARGET = 0.75;
6  protected const float STAMINAEFFECT_FADEIN_PROGRESSION_TARGET = 0.35;
7  protected const float STAMINAEFFECT_FADEIN_PROGRESSION_DURATION = 1;
8  protected const float STAMINA_CLEAREFFECT_DELAY = 2000;
9  protected const float STAMINA_EFFECT_THRESHOLD = 0.45;
10 
11  [Attribute( defvalue: "0.1111", uiwidget: UIWidgets.EditBox, desc: "Blur intensity multiplier" )]
12  protected float m_fStaminaBlurMultiplier;
13 
14  //Blurriness
15  private static float s_fBlurriness;
16  private static bool s_bEnableRadialBlur;
17  protected const string RADIAL_BLUR_EMAT = "{B011FE0AD21E2447}UI/Materials/ScreenEffects_BlurPP.emat";
18 
19  // Widgets
20  private ImageWidget m_wSupression;
21 
22  // Variables connected to a material, need to be static
23  static const int RADIAL_BLUR_PRIORITY = 6;
24 
25  // Stamina
26  protected int m_iStaminaSignal = -1;
27  protected bool m_bStaminaEffectActive;
28 
29  // Owner data
30  protected SignalsManagerComponent m_pSignalsManager;
31 
32  //------------------------------------------------------------------------------------------------
33  override void DisplayStartDraw(IEntity owner)
34  {
35  m_wSupression = ImageWidget.Cast(m_wRoot.FindAnyWidget("SuppressionVignette"));
36  }
37 
38  //------------------------------------------------------------------------------------------------
39  override void DisplayControlledEntityChanged(IEntity from, IEntity to)
40  {
41  ChimeraCharacter characterEntity = ChimeraCharacter.Cast(to);
42  if (!characterEntity)
43  return;
44 
45  // Audio components for damage-related audio effects
46  m_pSignalsManager = SignalsManagerComponent.Cast(characterEntity.FindComponent(SignalsManagerComponent));
47  if (m_pSignalsManager)
48  m_iStaminaSignal = m_pSignalsManager.FindSignal("Exhaustion");
49 
50  characterEntity.GetWorld().SetCameraPostProcessEffect(characterEntity.GetWorld().GetCurrentCameraId(), RADIAL_BLUR_PRIORITY,PostProcessEffectType.RadialBlur, RADIAL_BLUR_EMAT);
51  }
52 
53  //------------------------------------------------------------------------------------------------
54  void FindStaminaValues()
55  {
56  if (!m_pSignalsManager || m_iStaminaSignal == -1)
57  return;
58 
59  float stamina = m_pSignalsManager.GetSignalValue(m_iStaminaSignal);
60  s_fBlurriness = m_wSupression.GetMaskProgress() * m_fStaminaBlurMultiplier;
61 
62  if (stamina > STAMINA_EFFECT_THRESHOLD && !m_bStaminaEffectActive)
63  {
64  s_bEnableRadialBlur = true;
65  StaminaEffects(true);
66  }
67  else if (m_bStaminaEffectActive && stamina < STAMINA_EFFECT_THRESHOLD)
68  {
69  s_bEnableRadialBlur = false;
70  GetGame().GetCallqueue().Remove(StaminaEffects);
71  GetGame().GetCallqueue().Remove(ClearStaminaEffect);
72  ClearStaminaEffect(false);
73  m_bStaminaEffectActive = false;
74  }
75  }
76 
77  //------------------------------------------------------------------------------------------------
78  void StaminaEffects(bool repeat)
79  {
80  if (!m_wSupression)
81  return;
82 
83  m_bStaminaEffectActive = true;
84  m_wSupression.SetOpacity(STAMINAEFFECT_INITIAL_OPACITY_TARGET);
85  AnimateWidget.AlphaMask(m_wSupression, STAMINAEFFECT_FADEIN_PROGRESSION_TARGET, STAMINAEFFECT_FADEIN_PROGRESSION_DURATION);
86  GetGame().GetCallqueue().CallLater(ClearStaminaEffect, STAMINA_CLEAREFFECT_DELAY, false, true);
87  }
88 
89  //------------------------------------------------------------------------------------------------
90  void ClearStaminaEffect(bool repeat)
91  {
92  if (!m_wSupression)
93  return;
94 
95  AnimateWidget.AlphaMask(m_wSupression, 0, 1);
96  if (repeat && m_bStaminaEffectActive && m_wSupression && !m_wSupression.GetOpacity() == 0)
97  GetGame().GetCallqueue().CallLater(StaminaEffects, STAMINA_CLEAREFFECT_DELAY, false, repeat);
98  }
99 
100  //------------------------------------------------------------------------------------------------
101  protected override void DisplayOnSuspended()
102  {
103  s_bEnableRadialBlur = false;
104  }
105 
106  //------------------------------------------------------------------------------------------------
107  protected override void DisplayOnResumed()
108  {
109  s_bEnableRadialBlur = true;
110  }
111 
112  //------------------------------------------------------------------------------------------------
113  override void UpdateEffect(float timeSlice)
114  {
115  if (m_pSignalsManager)
116  FindStaminaValues();
117  }
118 
119  //------------------------------------------------------------------------------------------------
120  protected override void ClearEffects()
121  {
122  if (m_wSupression)
123  {
124  AnimateWidget.StopAllAnimations(m_wSupression);
125  m_wSupression.SetOpacity(0);
126  m_wSupression.SetMaskProgress(0);
127  }
128  }
129 };
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_BaseScreenEffect
Definition: SCR_BaseScreenEffect.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_StaminaBlurEffect
Definition: SCR_StaminaBlurEffect.c:1