Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_NoisyCameraShakeProgress.c
Go to the documentation of this file.
1
5{
6 protected float m_fCurrent;
7 protected float m_fVelocity;
8 protected float m_fMaxVelocity;
9
10 protected float m_fLinearMagnitude;
11 protected float m_fAngularMagnitude;
12
13 protected float m_fInTime;
14 protected float m_fSustainTime;
15 protected float m_fOutTime;
16
17 protected float m_fElapsedTime;
18 protected float m_fDuration;
19
20 override void Update(IEntity owner, float timeSlice)
21 {
22 if (!IsRunning())
23 return;
24
25 float smoothTime;
26 float targetValue;
27 // Check which state of transition this shake is in
29 {
30 // Blend in
31 targetValue = 1.0;
32 smoothTime = m_fInTime;
33 }
35 {
36 // Sustain
37 targetValue = 1.0;
38 smoothTime = m_fSustainTime;
39 }
40 else
41 {
42 // Blend out
43 targetValue = 0.0;
44 smoothTime = m_fOutTime;
45 }
46
47 // Update elapsed time
48 m_fElapsedTime += timeSlice;
49
50 // Interpolate progress
51 m_fCurrent = Math.SmoothCD(m_fCurrent, targetValue, m_fVelocity, smoothTime, m_fMaxVelocity, timeSlice);
52
53 // Calculate new state
55 Vector(
56 Math.RandomFloat(-0.005, 0.005),
57 Math.RandomFloat(-0.005, 0.005),
58 0.0
59 );
61 Vector(
62 Math.RandomFloat(-0.25, 0.25),
63 Math.RandomFloat(-0.25, 0.25),
64 Math.RandomFloat(-1, 1)
65 );
66
67 m_fFovScale = 1.0;
68
69 // Finished, clear state
70 if (targetValue <= 0 && m_fCurrent <= 0.0001)
71 {
72 m_bIsRunning = false;
73 m_fCurrent = 0.0;
74 m_fVelocity = 0.0;
76 m_vRotation = vector.Zero;
77 m_fFovScale = 1.0;
78 }
79 }
80
81 void SetParams(float linearMagnitude, float angularMagnitude, float inTime, float sustainTime, float outTime)
82 {
83 m_fLinearMagnitude = linearMagnitude;
84 m_fAngularMagnitude = angularMagnitude;
85 m_fInTime = inTime;
86 m_fSustainTime = sustainTime;
87 m_fOutTime = outTime;
88 }
89
90 override void Start()
91 {
92 if (m_fInTime <= 0.0 || m_fOutTime <= 0.0)
93 {
94 Print("Camera Shake: In and out time can not be less or equal to zero!", LogLevel.ERROR);
95 m_bIsRunning = false;
96 return;
97 }
98
99 // Immediate values
100 m_fCurrent = 0.0;
101 m_fMaxVelocity = 10.0;
102 m_fElapsedTime = 0.0;
104
105 // Start progress
106 m_bIsRunning = true;
107 }
108
109 override void Clear()
110 {
111 super.Clear();
112 m_bIsRunning = false;
113 }
114};
Definition Math.c:13
void SetParams(float linearMagnitude, float angularMagnitude, float inTime, float sustainTime, float outTime)
override void Update(IEntity owner, float timeSlice)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto native vector Vector(float x, float y, float z)