5 static const int GAUSS_BLUR_PRIORITY = 7;
8 [
Attribute( defvalue:
"0.25", uiwidget: UIWidgets.EditBox,
desc:
"Duration of the blurriness upon taking damage" )]
9 protected float m_fMomentaryDamageBlurDuration;
11 [
Attribute( defvalue:
"5", uiwidget: UIWidgets.EditBox,
desc:
"Minimum amount of damage in one event for effect to appear" )]
12 protected float m_fGaussBlurMinDamage;
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;
21 protected SignalsManagerComponent m_pSignalsManager;
24 protected ChimeraCharacter m_pCharacterEntity;
28 override void DisplayStartDraw(IEntity owner)
33 override void DisplayControlledEntityChanged(IEntity from, IEntity to)
37 m_pCharacterEntity = ChimeraCharacter.Cast(to);
38 if (!m_pCharacterEntity)
41 m_pCharacterEntity.GetWorld().SetCameraPostProcessEffect(m_pCharacterEntity.GetWorld().GetCurrentCameraId(), GAUSS_BLUR_PRIORITY,PostProcessEffectType.GaussFilter, GAUSS_BLUR_EMAT);
45 m_pDamageManager.GetOnDamage().Insert(OnDamage);
51 if (damageContext.damageValue > m_fGaussBlurMinDamage)
52 m_fGaussBlurReduction = Math.Clamp(++m_fGaussBlurReduction, 0, 2);
56 protected override void DisplayOnSuspended()
58 s_bEnableGaussBlur =
false;
62 protected override void DisplayOnResumed()
64 s_bEnableGaussBlur =
true;
68 override void UpdateEffect(
float timeSlice)
70 if (m_fGaussBlurReduction > 0)
71 MomentaryDamageEffect(timeSlice);
73 s_fGaussBlurriness = 0;
77 void MomentaryDamageEffect(
float timeslice)
80 s_bEnableGaussBlur =
true;
83 if (!s_bRemoveGaussBlur)
85 s_fGaussBlurriness = 1;
86 s_bRemoveGaussBlur =
true;
90 m_fGaussBlurReduction -= timeslice / m_fMomentaryDamageBlurDuration;
91 s_fGaussBlurriness = Math.Lerp(0, 1, m_fGaussBlurReduction);
93 if (s_fGaussBlurriness <= 0)
95 s_bRemoveGaussBlur =
false;
96 s_fGaussBlurriness = 0;
97 m_fGaussBlurReduction = 0;
98 s_bEnableGaussBlur =
false;
103 protected override void ClearEffects()
105 s_fGaussBlurriness = 0;
107 if (!m_pDamageManager)
110 m_pDamageManager.GetOnDamage().Remove(OnDamage);