Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RegenerationScreenEffect.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 CHROM_ABER_PRIORITY = 9;
6 
7  [Attribute( defvalue: "6", uiwidget: UIWidgets.EditBox, desc: "Duration of the regeneration effect in seconds" )]
8  protected float m_fRegenEffectDuration;
9 
10  [Attribute("0 0 1 1", UIWidgets.GraphDialog, desc: "Trajectory of the intensity of the regenerationEffect")]
11  protected ref Curve m_Curve;
12 
13  //Character
14  protected ChimeraCharacter m_pCharacterEntity;
15  protected SCR_CharacterDamageManagerComponent m_pDamageManager;
16  protected const string CHROMATIC_ABERIATION_EMAT = "{A78A424C3179C706}UI/Materials/ScreenEffects_ChromAberrPP.emat";
17  protected bool m_bRegenerationEffect;
18  protected float m_fRegenEffectTimeRemaining;
19 
20  // Variables connected to a material, need to be static
21  private static bool s_bEnabled;
22  private static float s_fChromAberPower;
23 
24 
25  //------------------------------------------------------------------------------------------------
26  override void DisplayStartDraw(IEntity owner)
27  {
28  m_pCharacterEntity = ChimeraCharacter.Cast(owner);
29  }
30 
31  //------------------------------------------------------------------------------------------------
32  override void DisplayControlledEntityChanged(IEntity from, IEntity to)
33  {
34  ClearEffects();
35 
36  m_pCharacterEntity = ChimeraCharacter.Cast(to);
37  if (!m_pCharacterEntity)
38  return;
39 
40  m_pDamageManager = SCR_CharacterDamageManagerComponent.Cast(m_pCharacterEntity.GetDamageManager());
41  if (!m_pDamageManager)
42  return;
43 
44  m_pDamageManager.GetOnDamageOverTimeAdded().Insert(OnDamageOverTimeAdded);
45 
46  m_pCharacterEntity.GetWorld().SetCameraPostProcessEffect(m_pCharacterEntity.GetWorld().GetCurrentCameraId(), CHROM_ABER_PRIORITY, PostProcessEffectType.ChromAber, CHROMATIC_ABERIATION_EMAT);
47  }
48 
49  //------------------------------------------------------------------------------------------------
50  override protected void DisplayOnSuspended()
51  {
52  s_bEnabled = false;
53  }
54 
55  //------------------------------------------------------------------------------------------------
56  override protected void DisplayOnResumed()
57  {
58  s_bEnabled = true;
59  }
60 
61  //------------------------------------------------------------------------------------------------
62  override void UpdateEffect(float timeSlice)
63  {
64  if (m_bRegenerationEffect)
65  RegenerationEffect(timeSlice);
66  }
67 
68  //------------------------------------------------------------------------------------------------
69  protected void RegenerationEffect(float timeSlice)
70  {
71  m_fRegenEffectTimeRemaining -= timeSlice;
72 
73  float chromAberProgress = Math.InverseLerp(m_fRegenEffectDuration, 0, m_fRegenEffectTimeRemaining);
74 
75  vector chromAberPowerScaled = Math3D.Curve(ECurveType.CatmullRom, chromAberProgress, m_Curve);
76 
77  // The maximum value of the EMAT is 0.05. The chromatic aberiation cannot go over this value
78  s_fChromAberPower = Math.Lerp(0, 0.05, chromAberPowerScaled[1]);
79 
80  if (m_fRegenEffectTimeRemaining <= 0)
81  {
82  m_bRegenerationEffect = false;
83  m_fRegenEffectTimeRemaining = 0;
84  s_fChromAberPower = 0;
85  }
86  }
87 
88  //------------------------------------------------------------------------------------------------
89  protected void OnDamageOverTimeAdded(EDamageType dType, float dps, HitZone hz)
90  {
91  if (dType != EDamageType.HEALING)
92  return;
93 
94  m_fRegenEffectTimeRemaining = m_fRegenEffectDuration;
95  m_bRegenerationEffect = true;
96  }
97 
98  //------------------------------------------------------------------------------------------------
99  protected override void ClearEffects()
100  {
101  m_fRegenEffectTimeRemaining = 0;
102  s_fChromAberPower = 0;
103 
104  if (m_pDamageManager)
105  m_pDamageManager.GetOnDamageOverTimeAdded().Remove(OnDamageOverTimeAdded);
106  }
107 };
SCR_BaseScreenEffect
Definition: SCR_BaseScreenEffect.c:1
HitZone
Definition: HitZone.c:12
SCR_RegenerationScreenEffect
Definition: SCR_RegenerationScreenEffect.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
EDamageType
EDamageType
Definition: EDamageType.c:12