Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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
28  if (m_fElapsedTime <= m_fInTime)
29  {
30  // Blend in
31  targetValue = 1.0;
32  smoothTime = m_fInTime;
33  }
34  else if (m_fElapsedTime <= m_fInTime + m_fSustainTime)
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
54  m_vTranslation = m_fLinearMagnitude * m_fCurrent *
55  Vector(
56  Math.RandomFloat(-0.005, 0.005),
57  Math.RandomFloat(-0.005, 0.005),
58  0.0
59  );
60  m_vRotation = m_fAngularMagnitude * m_fCurrent *
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;
75  m_vTranslation = vector.Zero;
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;
103  m_fDuration = m_fInTime + m_fSustainTime + m_fOutTime;
104 
105  // Start progress
106  m_bIsRunning = true;
107  }
108 
109  override void Clear()
110  {
111  super.Clear();
112  m_bIsRunning = false;
113  }
114 };
SCR_NoisyCameraShakeProgress
Definition: SCR_NoisyCameraShakeProgress.c:4
m_fDuration
float m_fDuration
Definition: SendGoalMessage.c:437
m_fElapsedTime
protected float m_fElapsedTime
Definition: SCR_MoveInCircleComponent.c:8
SCR_GenericCameraShakeProgress
Definition: SCR_GenericCameraShakeProgress.c:5
m_fFovScale
protected float m_fFovScale
Definition: SCR_CameraShakeManagerComponent.c:11