File size: 2,702 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// PPE when player is in contaminated area trigger
class PPERequester_ContaminatedAreaTint extends PPERequester_GameplayBase
{
	protected vector m_StartRGB = vector.Zero;
	protected float m_AccumulatedTime = 0;
	protected bool m_FadeIn = false;
	protected bool m_FadeOut = false;
	
	const float FADE_TIME = 3;
	// the end result is 1 - the value set here
	const float R_TARGET = 0.142; // end value 0.858
	const float G_TARGET = 0.15; // end value 0.850
	const float B_TARGET = 0.44; // end value 0.560
	
	override protected void OnStart( Param par = null )
	{
		super.OnStart( par );
		
		m_AccumulatedTime = 0;
		
		m_FadeIn = true;
		m_FadeOut = false;
		
		SetTargetValueFloat(PostProcessEffectType.FilmGrain,PPEFilmGrain.PARAM_SHARPNESS,false,10.0,PPEFilmGrain.L_1_TOXIC_TINT,PPOperators.HIGHEST);
		SetTargetValueFloat(PostProcessEffectType.FilmGrain,PPEFilmGrain.PARAM_GRAINSIZE,false,1.0,PPEFilmGrain.L_2_TOXIC_TINT,PPOperators.LOWEST);
	}
	
	override protected void OnUpdate( float delta )
	{
		super.OnUpdate( delta );
		
		if ( m_FadeIn && m_AccumulatedTime <= FADE_TIME )
		{
			m_AccumulatedTime += delta;
		
			m_StartRGB[0] = 1 - FadeColourMult( 0, 1, m_AccumulatedTime / FADE_TIME ) * R_TARGET;
			m_StartRGB[1] = 1 - FadeColourMult( 0, 1, m_AccumulatedTime / FADE_TIME ) * G_TARGET;
			m_StartRGB[2] = 1 - FadeColourMult( 0, 1, m_AccumulatedTime / FADE_TIME ) * B_TARGET;
			
			SetTargetValueColor(PostProcessEffectType.Glow,PPEGlow.PARAM_COLORIZATIONCOLOR,{m_StartRGB[0], m_StartRGB[1], m_StartRGB[2], 0.0},PPEGlow.L_23_TOXIC_TINT,PPOperators.MULTIPLICATIVE);
		}
		
		if ( m_FadeOut )
		{
			if (m_AccumulatedTime <= FADE_TIME)
			{
				m_AccumulatedTime += delta;
			
				m_StartRGB[0] = ( 1 - R_TARGET ) + FadeColourMult( 0, R_TARGET, m_AccumulatedTime / FADE_TIME );
				m_StartRGB[1] = ( 1 - G_TARGET ) + FadeColourMult( 0, G_TARGET, m_AccumulatedTime / FADE_TIME );
				m_StartRGB[2] = ( 1 - B_TARGET ) + FadeColourMult( 0, B_TARGET, m_AccumulatedTime / FADE_TIME );
				
				SetTargetValueColor(PostProcessEffectType.Glow,PPEGlow.PARAM_COLORIZATIONCOLOR,{m_StartRGB[0], m_StartRGB[1], m_StartRGB[2], 0.0},PPEGlow.L_23_TOXIC_TINT,PPOperators.MULTIPLICATIVE);
			}
			else
			{
				Stop(); //proper termination after a fadeout
			}
		}
	}
	
	override void OnStop(Param par = null)
	{
		m_FadeIn = false;
		m_FadeOut = false;
		Param1<bool> p;
		
		if (par && Class.CastTo(p,par))
			m_FadeOut = p.param1;
		
		m_AccumulatedTime = 0;
		
		super.OnStop(par);
	}
	
	// Lerped multiplier for RGBA values
	protected float FadeColourMult( float x, float y, float deltaT )
	{
		float output;
		output = Math.Lerp( x, y, deltaT );
		Easing.EaseInOutSine( output );
		return output;
	}
}