DayZ 1.24
Loading...
Searching...
No Matches
ClockBase.c File Reference

Go to the source code of this file.

Enumerations

enum  EAlarmClockState { UNSET , SET , RINGING , COUNT }
 

Functions

void ClockBase ()
 
void ~ClockBase ()
 
void Init ()
 Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)
 
override void SetActions ()
 
int GetAlarmInMin ()
 
static int ConvertAlarmHand01ToMins12h (float time01)
 
static int ConvertAlarmHand01ToMins (float time01, int mins_max)
 
static float ConvertMins12hToAlarmHand01 (int mins)
 
static int ConvertTimeToMins12h (int hour, int minute)
 
static int GetTimeDiffInMins12h (int from_mins, int to_mins)
 
string GetToggleSound ()
 
string GetRingingSound ()
 
string GetHitSound ()
 
string GetDestroyedSound ()
 
string GetWorkingSound ()
 
override void EEKilled (Object killer)
 
override void EEHitByRemote (int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
 
override void OnDamageDestroyed (int oldLevel)
 
void OnRingingStartServer ()
 
void OnRingingStartClient ()
 
void OnRingingStopServer ()
 
void OnRingingStopClient ()
 
void SetAlarmInXMins (int in_mins)
 
float GetRingingDurationMax ()
 
void SetupTimerServer ()
 
void SetState (EAlarmClockState state)
 
void Disarm ()
 
void Arm ()
 
void ActivateParent ()
 
void MakeRingingStart ()
 
void MakeRingingStop ()
 
void TurnOnClient ()
 
void TurnOffClient ()
 
override void OnVariablesSynchronized ()
 
bool IsRinging ()
 
bool IsAlarmOn ()
 
void TurnOn ()
 
void TurnOff ()
 
void SetAlarmTimeServer (float time01)
 

Variables

enum EAlarmClockState m_AlarmTime01
 
int m_State = EAlarmClockState.UNSET
 
static const float UPDATE_TICK_RATE = 1
 
ref Timer m_TimerUpdate
 
float m_RingingDuration
 
int m_StatePrev = -1
 
EffectSound m_RingingSoundLoop
 
EffectSound m_TurnOnSound
 
EffectSound m_DestoryedSound
 
EffectSound m_HitSound
 
EffectSound m_WorkingSound
 
const float RINGING_DURATION_MAX = 60
 

Enumeration Type Documentation

◆ EAlarmClockState

Enumerator
UNSET 
SET 
RINGING 
COUNT 

Definition at line 1 of file ClockBase.c.

2{
3 UNSET,
4 SET,
6 //-----------
8}
@ COUNT
Definition ClockBase.c:7
@ SET
Definition ClockBase.c:4
@ RINGING
Definition ClockBase.c:5
@ UNSET
Definition ClockBase.c:3

Function Documentation

◆ ActivateParent()

void ActivateParent ( )
protected

Definition at line 203 of file ClockBase.c.

204 {
205 if (GetHierarchyParent())
206 {
207 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
208 if (parent)
209 parent.OnActivatedByItem(this);
210 }
211 }

Referenced by OnRingingStartServer().

◆ Arm()

void Arm ( )
protected

Definition at line 196 of file ClockBase.c.

197 {
201 }
void SetupTimerServer()
Definition ClockBase.c:179
void SetState(EAlarmClockState state)
Definition ClockBase.c:185
float m_RingingDuration
Definition ClockBase.c:16
EAlarmClockState
Definition ClockBase.c:2

References m_RingingDuration, SetState(), and SetupTimerServer().

◆ ClockBase()

void ClockBase ( )

Definition at line 27 of file ClockBase.c.

28 {
29 Init();
30 }
void Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
Definition ClockBase.c:41

References Init().

◆ ConvertAlarmHand01ToMins()

static int ConvertAlarmHand01ToMins ( float time01,
int mins_max )
staticprotected

Definition at line 70 of file ClockBase.c.

71 {
72 return Math.Lerp(0, mins_max, time01);
73 }
Definition EnMath.c:7
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.

References Math::Lerp().

◆ ConvertAlarmHand01ToMins12h()

static int ConvertAlarmHand01ToMins12h ( float time01)
staticprotected

Definition at line 65 of file ClockBase.c.

66 {
67 return Math.Lerp(0, 12 * 60, time01);
68 }

References Math::Lerp().

Referenced by GetAlarmInMin(), and AlarmClock_ColorBase::OnUpdate().

◆ ConvertMins12hToAlarmHand01()

static float ConvertMins12hToAlarmHand01 ( int mins)
staticprotected

Definition at line 75 of file ClockBase.c.

76 {
77 return Math.InverseLerp(0, 12 * 60, mins);
78 }
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...

References Math::InverseLerp().

Referenced by SetAlarmInXMins().

◆ ConvertTimeToMins12h()

static int ConvertTimeToMins12h ( int hour,
int minute )
staticprotected

Definition at line 81 of file ClockBase.c.

82 {
83 if (hour >= 12)
84 hour -= 12;
85 return hour * 60 + minute;
86 }

Referenced by GetAlarmInMin(), AlarmClock_ColorBase::OnUpdate(), and SetAlarmInXMins().

◆ Disarm()

void Disarm ( )
protected

Definition at line 191 of file ClockBase.c.

192 {
194 }

References SetState().

Referenced by TurnOff().

◆ EEHitByRemote()

override void EEHitByRemote ( int damageType,
EntityAI source,
int component,
string dmgZone,
string ammo,
vector modelPos )
protected

Definition at line 124 of file ClockBase.c.

125 {
127 PlaySoundSet(m_HitSound, GetHitSound(), 0, 0);
128 }
string GetHitSound()
Definition ClockBase.c:105
EffectSound m_HitSound
Definition ClockBase.c:22
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.

References component, GetHitSound(), and m_HitSound.

◆ EEKilled()

override void EEKilled ( Object killer)
protected

Definition at line 118 of file ClockBase.c.

119 {
120 super.EEKilled(killer);
121 TurnOff();
122 }
void TurnOff()
Definition ClockBase.c:284

References TurnOff().

◆ GetAlarmInMin()

int GetAlarmInMin ( )
protected

Definition at line 53 of file ClockBase.c.

54 {
56
57 int pass, hour, minute;
58 GetGame().GetWorld().GetDate(pass, pass, pass, hour, minute);
59
62 return ring_in_mins;
63 }
enum EAlarmClockState m_AlarmTime01
static int GetTimeDiffInMins12h(int from_mins, int to_mins)
Definition ClockBase.c:88
static int ConvertAlarmHand01ToMins12h(float time01)
Definition ClockBase.c:65
static int ConvertTimeToMins12h(int hour, int minute)
Definition ClockBase.c:81
proto native CGame GetGame()

References ConvertAlarmHand01ToMins12h(), ConvertTimeToMins12h(), GetGame(), GetTimeDiffInMins12h(), and m_AlarmTime01.

Referenced by AlarmClock_ColorBase::GetDebugText().

◆ GetDestroyedSound()

string GetDestroyedSound ( )
protected

Definition at line 109 of file ClockBase.c.

110 {
111 return "";
112 }

Referenced by OnDamageDestroyed().

◆ GetHitSound()

string GetHitSound ( )
protected

Definition at line 105 of file ClockBase.c.

106 {
107 return "";
108 }

Referenced by EEHitByRemote().

◆ GetRingingDurationMax()

float GetRingingDurationMax ( )
protected

Definition at line 173 of file ClockBase.c.

174 {
176 }
const float RINGING_DURATION_MAX
Definition ClockBase.c:25

References RINGING_DURATION_MAX.

Referenced by AlarmClock_ColorBase::GetDebugText(), and AlarmClock_ColorBase::OnUpdate().

◆ GetRingingSound()

string GetRingingSound ( )
protected

Definition at line 101 of file ClockBase.c.

102 {
103 return "";
104 }

Referenced by OnRingingStartClient().

◆ GetTimeDiffInMins12h()

static int GetTimeDiffInMins12h ( int from_mins,
int to_mins )
staticprotected

Definition at line 88 of file ClockBase.c.

89 {
90 if (to_mins > from_mins)
91 return to_mins - from_mins;
92 else if (to_mins < from_mins)
93 return ((12 * 60) - from_mins) + to_mins;
94 else return 0;
95 }

Referenced by GetAlarmInMin().

◆ GetToggleSound()

string GetToggleSound ( )
protected

Definition at line 97 of file ClockBase.c.

98 {
99 return "";
100 }

Referenced by OnVariablesSynchronized().

◆ GetWorkingSound()

string GetWorkingSound ( )
protected

Definition at line 113 of file ClockBase.c.

114 {
115 return "";
116 }

Referenced by OnVariablesSynchronized().

◆ Init()

void Init ( )

Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)

pre-init arrays

Definition at line 41 of file ClockBase.c.

42 {
43 RegisterNetSyncVariableInt("m_State", 0, EAlarmClockState.COUNT - 1);
44 }

◆ IsAlarmOn()

bool IsAlarmOn ( )
protected

Definition at line 274 of file ClockBase.c.

275 {
276 return (m_State == EAlarmClockState.SET);
277 }
int m_State
Definition ClockBase.c:13

References m_State.

Referenced by AlarmClock_ColorBase::OnUpdate().

◆ IsRinging()

bool IsRinging ( )
protected

Definition at line 269 of file ClockBase.c.

270 {
271 return (m_State == EAlarmClockState.RINGING);
272 }

References m_State.

Referenced by AlarmClock_ColorBase::OnUpdate(), KitchenTimer::OnUpdate(), and TurnOff().

◆ MakeRingingStart()

void MakeRingingStart ( )
protected

◆ MakeRingingStop()

void MakeRingingStop ( )
protected

Definition at line 222 of file ClockBase.c.

223 {
225
227 }
void OnRingingStopServer()

References OnRingingStopServer(), and SetState().

Referenced by KitchenTimer::OnUpdate(), and TurnOff().

◆ OnDamageDestroyed()

override void OnDamageDestroyed ( int oldLevel)
protected

Definition at line 130 of file ClockBase.c.

131 {
132 super.OnDamageDestroyed(oldLevel);
133
134 if (GetGame().IsClient())
135 {
137
138 if (oldLevel != -1)
139 PlaySoundSet(m_DestoryedSound, GetDestroyedSound(), 0, 0);
140 }
141 }
void OnRingingStopClient()
Definition ClockBase.c:158
EffectSound m_DestoryedSound
Definition ClockBase.c:21
string GetDestroyedSound()
Definition ClockBase.c:109

References GetDestroyedSound(), GetGame(), m_DestoryedSound, and OnRingingStopClient().

◆ OnRingingStartClient()

void OnRingingStartClient ( )
protected

Definition at line 148 of file ClockBase.c.

149 {
150 PlaySoundSetLoop(m_RingingSoundLoop, GetRingingSound(), 0, 0);
151
152 if (m_WorkingSound)
154 }
EffectSound m_WorkingSound
Definition ClockBase.c:23
string GetRingingSound()
Definition ClockBase.c:101
EffectSound m_RingingSoundLoop
Definition ClockBase.c:19
Manager class for managing Effect (EffectParticle, EffectSound)
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.

References SEffectManager::DestroyEffect(), GetRingingSound(), m_RingingSoundLoop, and m_WorkingSound.

Referenced by OnVariablesSynchronized().

◆ OnRingingStartServer()

void OnRingingStartServer ( )
protected

Definition at line 143 of file ClockBase.c.

144 {
146 }
void ActivateParent()
Definition ClockBase.c:203

References ActivateParent().

Referenced by MakeRingingStart().

◆ OnRingingStopClient()

◆ OnRingingStopServer()

void OnRingingStopServer ( )
protected

Referenced by MakeRingingStop().

◆ OnVariablesSynchronized()

override void OnVariablesSynchronized ( )
protected

Definition at line 233 of file ClockBase.c.

234 {
235 super.OnVariablesSynchronized();
236
237 if (m_State != m_StatePrev)//state changed
238 {
239 if (m_StatePrev == EAlarmClockState.RINGING)
241 else if (m_State == EAlarmClockState.RINGING)
243 if (m_State == EAlarmClockState.SET)
244 {
245 if (m_StatePrev != -1 || IsInitialized())
246 PlaySoundSet(m_TurnOnSound, GetToggleSound(), 0, 0);
247 if (GetWorkingSound())
248 PlaySoundSet(m_WorkingSound, GetWorkingSound(), 0, 0, true);
249 }
250 else if (m_State == EAlarmClockState.UNSET)
251 {
252 if (m_StatePrev == EAlarmClockState.SET)
253 {
254 if (m_WorkingSound)
256 if (m_StatePrev != -1 || IsInitialized())
257 PlaySoundSet(m_TurnOnSound, GetToggleSound(), 0, 0);
258 }
259 }
261 }
262 }
int m_StatePrev
Definition ClockBase.c:17
string GetToggleSound()
Definition ClockBase.c:97
EffectSound m_TurnOnSound
Definition ClockBase.c:20
void OnRingingStartClient()
Definition ClockBase.c:148
string GetWorkingSound()
Definition ClockBase.c:113
override bool IsInitialized()

References SEffectManager::DestroyEffect(), GetToggleSound(), GetWorkingSound(), IsInitialized(), m_State, m_StatePrev, m_TurnOnSound, m_WorkingSound, OnRingingStartClient(), and OnRingingStopClient().

◆ SetActions()

override void SetActions ( )

Definition at line 46 of file ClockBase.c.

47 {
48 super.SetActions();
49
51 }
ActionAttachExplosivesTriggerCB ActionContinuousBaseCB ActionAttachExplosivesTrigger()
void AddAction(typename actionName)

References ActionAttachExplosivesTrigger(), and AddAction().

◆ SetAlarmInXMins()

void SetAlarmInXMins ( int in_mins)
protected

Definition at line 163 of file ClockBase.c.

164 {
165 int pass, hour, minute;
166 GetGame().GetWorld().GetDate(pass, pass, pass, hour, minute);
170 Arm();
171 }
static float ConvertMins12hToAlarmHand01(int mins)
Definition ClockBase.c:75
void Arm()
Definition ClockBase.c:196
void SetAlarmTimeServer(float time01)
Definition ClockBase.c:294

References Arm(), ConvertMins12hToAlarmHand01(), ConvertTimeToMins12h(), GetGame(), and SetAlarmTimeServer().

Referenced by AlarmClock_ColorBase::OnAction().

◆ SetAlarmTimeServer()

void SetAlarmTimeServer ( float time01)
protected

Definition at line 294 of file ClockBase.c.

295 {
296 SetAnimationPhaseNow("ClockAlarm", time01);
298 }

References m_AlarmTime01.

Referenced by AlarmClock_ColorBase::OnStoreLoad(), and SetAlarmInXMins().

◆ SetState()

void SetState ( EAlarmClockState state)
protected

Definition at line 185 of file ClockBase.c.

186 {
187 m_State = state;
188 SetSynchDirty();
189 }

References m_State.

◆ SetupTimerServer()

void SetupTimerServer ( )
protected

Definition at line 179 of file ClockBase.c.

180 {
181 m_TimerUpdate = new Timer();
182 m_TimerUpdate.Run(UPDATE_TICK_RATE, this, "OnUpdate", null, true);
183 }
static const float UPDATE_TICK_RATE
Definition ClockBase.c:14

References m_TimerUpdate, and UPDATE_TICK_RATE.

Referenced by Arm(), and MakeRingingStart().

◆ TurnOff()

void TurnOff ( )
protected

Definition at line 284 of file ClockBase.c.

285 {
286 if (IsRinging())
288 else
289 Disarm();
290
292 }
bool IsRinging()
Definition ClockBase.c:269
void Disarm()
Definition ClockBase.c:191
void MakeRingingStop()
Definition ClockBase.c:222

References Disarm(), IsRinging(), m_TimerUpdate, and MakeRingingStop().

Referenced by EEKilled(), and AlarmClock_ColorBase::OnUpdate().

◆ TurnOffClient()

void TurnOffClient ( )
protected

◆ TurnOn()

void TurnOn ( )
protected

Definition at line 279 of file ClockBase.c.

280 {
281 Arm();
282 }

References Arm().

Referenced by AlarmClock_ColorBase::OnDebugSpawn(), AlarmClock_ColorBase::OnStoreLoad(), and KitchenTimer::SetAlarmTimeServer().

◆ TurnOnClient()

void TurnOnClient ( )
protected

◆ ~ClockBase()

Variable Documentation

◆ m_AlarmTime01

◆ m_DestoryedSound

EffectSound m_DestoryedSound

Definition at line 21 of file ClockBase.c.

Referenced by OnDamageDestroyed(), and ~ClockBase().

◆ m_HitSound

EffectSound m_HitSound

Definition at line 22 of file ClockBase.c.

Referenced by EEHitByRemote(), and ~ClockBase().

◆ m_RingingDuration

◆ m_RingingSoundLoop

EffectSound m_RingingSoundLoop

◆ m_State

Definition at line 13 of file ClockBase.c.

◆ m_StatePrev

int m_StatePrev = -1

Definition at line 17 of file ClockBase.c.

Referenced by OnVariablesSynchronized(), and SetState().

◆ m_TimerUpdate

ref Timer m_TimerUpdate

Definition at line 15 of file ClockBase.c.

Referenced by Init(), MakeRingingStart(), SetupTimerServer(), TurnOff(), and ~HudDebug().

◆ m_TurnOnSound

EffectSound m_TurnOnSound

Definition at line 20 of file ClockBase.c.

Referenced by OnVariablesSynchronized(), and ~ClockBase().

◆ m_WorkingSound

EffectSound m_WorkingSound

◆ RINGING_DURATION_MAX

const float RINGING_DURATION_MAX = 60

Definition at line 25 of file ClockBase.c.

Referenced by GetRingingDurationMax().

◆ UPDATE_TICK_RATE

const float UPDATE_TICK_RATE = 1
static