Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DamageBlurEffect.c
Go to the documentation of this file.
2 {
3  // PP constants
4  // Variables connected to a material, need to be static
5  static const int GAUSS_BLUR_PRIORITY = 7;
6 
7  //GaussBlurriness
8  [Attribute( defvalue: "0.25", uiwidget: UIWidgets.EditBox, desc: "Duration of the blurriness upon taking damage" )]
9  protected float m_fMomentaryDamageBlurDuration;
10 
11  [Attribute( defvalue: "5", uiwidget: UIWidgets.EditBox, desc: "Minimum amount of damage in one event for effect to appear" )]
12  protected float m_fGaussBlurMinDamage;
13 
14  protected const string GAUSS_BLUR_EMAT = "{790527EE96732730}UI/Materials/ScreenEffects_GaussBlurPP.emat";
15  private static float s_fGaussBlurriness;
16  private static bool s_bRemoveGaussBlur = true;
17  private float m_fGaussBlurReduction = 1;
18  private static bool s_bEnableGaussBlur;
19 
20  // Owner data
21  protected SignalsManagerComponent m_pSignalsManager;
22 
23  // Character
24  protected ChimeraCharacter m_pCharacterEntity;
25  protected SCR_CharacterDamageManagerComponent m_pDamageManager;
26 
27  //------------------------------------------------------------------------------------------------
28  override void DisplayStartDraw(IEntity owner)
29  {
30  }
31 
32  //------------------------------------------------------------------------------------------------
33  override void DisplayControlledEntityChanged(IEntity from, IEntity to)
34  {
35  ClearEffects();
36 
37  m_pCharacterEntity = ChimeraCharacter.Cast(to);
38  if (!m_pCharacterEntity)
39  return;
40 
41  m_pCharacterEntity.GetWorld().SetCameraPostProcessEffect(m_pCharacterEntity.GetWorld().GetCurrentCameraId(), GAUSS_BLUR_PRIORITY,PostProcessEffectType.GaussFilter, GAUSS_BLUR_EMAT);
42 
43  m_pDamageManager = SCR_CharacterDamageManagerComponent.Cast(m_pCharacterEntity.GetDamageManager());
44  if (m_pDamageManager)
45  m_pDamageManager.GetOnDamage().Insert(OnDamage);
46  }
47 
48  //------------------------------------------------------------------------------------------------
49  void OnDamage(BaseDamageContext damageContext)
50  {
51  if (damageContext.damageValue > m_fGaussBlurMinDamage)
52  m_fGaussBlurReduction = Math.Clamp(++m_fGaussBlurReduction, 0, 2);
53  }
54 
55  //------------------------------------------------------------------------------------------------
56  protected override void DisplayOnSuspended()
57  {
58  s_bEnableGaussBlur = false;
59  }
60 
61  //------------------------------------------------------------------------------------------------
62  protected override void DisplayOnResumed()
63  {
64  s_bEnableGaussBlur = true;
65  }
66 
67  //------------------------------------------------------------------------------------------------
68  override void UpdateEffect(float timeSlice)
69  {
70  if (m_fGaussBlurReduction > 0)
71  MomentaryDamageEffect(timeSlice);
72  else
73  s_fGaussBlurriness = 0;
74  }
75 
76  //------------------------------------------------------------------------------------------------
77  void MomentaryDamageEffect(float timeslice)
78  {
79  // enable the gaussblur ematerial
80  s_bEnableGaussBlur = true;
81 
82  // gaussblur is set to max, then drained back to 0
83  if (!s_bRemoveGaussBlur)
84  {
85  s_fGaussBlurriness = 1;
86  s_bRemoveGaussBlur = true;
87  return;
88  }
89 
90  m_fGaussBlurReduction -= timeslice / m_fMomentaryDamageBlurDuration;
91  s_fGaussBlurriness = Math.Lerp(0, 1, m_fGaussBlurReduction);
92 
93  if (s_fGaussBlurriness <= 0)
94  {
95  s_bRemoveGaussBlur = false;
96  s_fGaussBlurriness = 0;
97  m_fGaussBlurReduction = 0;
98  s_bEnableGaussBlur = false;
99  }
100  }
101 
102  //------------------------------------------------------------------------------------------------
103  protected override void ClearEffects()
104  {
105  s_fGaussBlurriness = 0;
106 
107  if (!m_pDamageManager)
108  return;
109 
110  m_pDamageManager.GetOnDamage().Remove(OnDamage);
111  }
112 };
BaseDamageContext
Definition: BaseDamageContext.c:12
SCR_BaseScreenEffect
Definition: SCR_BaseScreenEffect.c:1
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_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
SCR_DamageBlurEffect
Definition: SCR_DamageBlurEffect.c:1