Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DesaturationEffect.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 COLORS_PP_PRIORITY = 5;
6 
7  //Saturation
8  private static float s_fSaturation = 1;
9  protected const string DESATURATION_EMAT = "{7C202A913EB8B1A9}UI/Materials/ScreenEffects_ColorPP.emat";
10 
11  [Attribute( defvalue: "0.5", uiwidget: UIWidgets.EditBox)]
12  protected float m_fDesaturationStart;
13 
14  [Attribute( defvalue: "0.333", uiwidget: UIWidgets.EditBox)]
15  protected float m_fDesaturationEnd;
16 
17  // Enabling/Disabling of PP fx
18  private static bool s_bEnableSaturation;
19 
20  // Character
21  protected ChimeraCharacter m_pCharacterEntity;
22  protected SCR_CharacterBloodHitZone m_pBloodHZ;
23  protected SCR_CharacterDamageManagerComponent m_pDamageManager;
24  protected bool m_bLocalPlayerOutsideCharacter;
25 
26  //------------------------------------------------------------------------------------------------
27  override void DisplayStartDraw(IEntity owner)
28  {
29  m_pCharacterEntity = ChimeraCharacter.Cast(owner);
30  }
31 
32  //------------------------------------------------------------------------------------------------
33  override void SettingsChanged()
34  {
35  if (!m_pCharacterEntity)
36  return;
37 
38  m_pCharacterEntity.GetWorld().SetCameraPostProcessEffect(m_pCharacterEntity.GetWorld().GetCurrentCameraId(), COLORS_PP_PRIORITY, PostProcessEffectType.Colors, DESATURATION_EMAT);
39  }
40 
41  //------------------------------------------------------------------------------------------------
42  override void DisplayControlledEntityChanged(IEntity from, IEntity to)
43  {
44  ClearEffects();
45 
46  m_pCharacterEntity = ChimeraCharacter.Cast(to);
47  if (!m_pCharacterEntity)
48  return;
49 
50  m_pDamageManager = SCR_CharacterDamageManagerComponent.Cast(m_pCharacterEntity.GetDamageManager());
51  if (!m_pDamageManager)
52  return;
53 
54  // define hitzones for later getting
55  m_pBloodHZ = SCR_CharacterBloodHitZone.Cast(m_pDamageManager.GetBloodHitZone());
56 
57  m_pCharacterEntity.GetWorld().SetCameraPostProcessEffect(m_pCharacterEntity.GetWorld().GetCurrentCameraId(), COLORS_PP_PRIORITY, PostProcessEffectType.Colors, DESATURATION_EMAT);
58  }
59 
60  //------------------------------------------------------------------------------------------------
61  protected override void DisplayOnSuspended()
62  {
63  s_bEnableSaturation = false;
64  }
65 
66  //------------------------------------------------------------------------------------------------
67  protected override void DisplayOnResumed()
68  {
69  s_bEnableSaturation = true;
70  }
71 
72  //------------------------------------------------------------------------------------------------
73  override void UpdateEffect(float timeSlice)
74  {
75  AddDesaturationEffect();
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  void AddDesaturationEffect()
80  {
81  if (!m_pBloodHZ)
82  return;
83 
84  float bloodLevel = Math.InverseLerp(m_fDesaturationEnd, m_fDesaturationStart, m_pBloodHZ.GetHealthScaled());
85 
86  s_fSaturation = Math.Clamp(bloodLevel, 0, 1);
87  s_bEnableSaturation = s_fSaturation < 1;
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  protected override void ClearEffects()
92  {
93  s_fSaturation = 1;
94  }
95 };
SCR_BaseScreenEffect
Definition: SCR_BaseScreenEffect.c:1
SCR_CharacterBloodHitZone
Blood - does not receive damage directly, only via scripted events.
Definition: SCR_CharacterHitZone.c:480
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
SCR_DesaturationEffect
Definition: SCR_DesaturationEffect.c:1