DayZ 1.24
Loading...
Searching...
No Matches
AlarmClock.c
Go to the documentation of this file.
1class AlarmClock_ColorBase: ClockBase
2{
3 const string RINGING_SOUND = "AlarmClock_Ring_Loop_SoundSet";
4 const string TURN_TOGGLE_SOUND = "AlarmClock_Turn_Off_SoundSet";
5 const string DESTROYED_SOUND = "AlarmClock_Destroyed_SoundSet";
6 const string HIT_SOUND = "AlarmClock_Hit_SoundSet";
7
8
11
12 override void Init()
13 {
14 super.Init();
15 if (GetGame().IsServer())
16 {
17 m_NoiseSystem = GetGame().GetNoiseSystem();
19 {
20 // Create and load noise parameters
22 m_NoisePar.LoadFromPath("cfgVehicles " + GetType() + " NoiseAlarmClock");
23 }
24 }
25 }
26
28 {
29#ifndef SERVER
31#endif
32 }
33
34
43
44 override string GetToggleSound()
45 {
46 return TURN_TOGGLE_SOUND;
47 }
48
49 override string GetRingingSound()
50 {
51 return RINGING_SOUND;
52 }
53
54 override string GetDestroyedSound()
55 {
56 return DESTROYED_SOUND;
57 }
58
59 override string GetHitSound()
60 {
61 return HIT_SOUND;
62 }
63
65 {
66 return "TriggerAlarmClock";
67 }
68
70 {
71 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "SetAlarmAhead1Min", FadeColors.LIGHT_GREY));
72 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.LIGHT_GREY));
73
74 super.GetDebugActions(outputList);
75 }
76
78 {
79 if (super.OnAction(action_id, player, ctx))
80 return true;
81 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
82 {
83 if (action_id == EActions.ACTIVATE_ENTITY)
85
86 }
87 return false;
88 }
89
90 override string GetDebugText()
91 {
92 string debug_output;
93
94 if (GetGame().IsDedicatedServer())
95 {
96 debug_output = "alarm in: " + GetAlarmInMin().ToString() + " mins" + "\n";
97 debug_output += "current state: " + typename.EnumToString(EAlarmClockState, m_State) + "\n";;
98 debug_output += "ringing for " + m_RingingDuration.ToString() + " secs" + "\n";
99 debug_output += "ringing max " + GetRingingDurationMax().ToString() + " secs" + "\n";
100 }
101 else
102 debug_output = "this is client";
103 return debug_output;
104 }
105
106 void OnUpdate()
107 {
108 if (IsAlarmOn())
109 {
110 //due to variable server time flow(day-night time accel), it's not possible to simply set a timer for X secs without some convoluted math/code, so we need to check at regular intervals
112
113 int pass, hour, minute;
114 GetGame().GetWorld().GetDate(pass, pass, pass, hour, minute);
115
117
118 //Print(GetAlarmInMin());
119
122 }
123
124 if (IsRinging())
125 {
127
129 TurnOff();
130 else if (m_NoiseSystem)
132 }
133 }
134
135 protected void AnimateAlarmHand(float value)
136 {
137 SetAnimationPhaseNow("ClockAlarm", value);
138 }
139
140
141 override bool OnStoreLoad(ParamsReadContext ctx, int version)
142 {
143 if (!super.OnStoreLoad(ctx, version))
144 return false;
145
146 if (version < 126)
147 return true;
148
150
151 if (!ctx.Read(state))
152 return false;
153
154 float time;
155
156 if (!ctx.Read(time))
157 return false;
158
161 if (state == EAlarmClockState.SET)
162 TurnOn();
163 else if (state == EAlarmClockState.RINGING)
165
166 return true;
167 }
168
170 {
171 super.OnStoreSave(ctx);
172
173 ctx.Write(m_State);
174 ctx.Write(m_AlarmTime01);
175 }
176
177 override void OnDebugSpawn()
178 {
179 TurnOn();
181 }
182
183};
184
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition EntityAI.c:97
eBleedingSourceType GetType()
ActionTurnOffAlarmClockCB ActionSingleUseBaseCB ActionTurnOffAlarmClock()
ActionTurnOnAlarmClockCB ActionSingleUseBaseCB ActionTurnOnAlarmClock()
void AddAction(typename actionName)
enum EAlarmClockState m_AlarmTime01
void TurnOff()
Definition ClockBase.c:284
bool IsRinging()
Definition ClockBase.c:269
void OnRingingStopClient()
Definition ClockBase.c:158
bool IsAlarmOn()
Definition ClockBase.c:274
void SetAlarmInXMins(int in_mins)
Definition ClockBase.c:163
float m_RingingDuration
Definition ClockBase.c:16
void TurnOn()
Definition ClockBase.c:279
int GetAlarmInMin()
Definition ClockBase.c:53
EAlarmClockState
Definition ClockBase.c:2
static int ConvertAlarmHand01ToMins12h(float time01)
Definition ClockBase.c:65
float GetRingingDurationMax()
Definition ClockBase.c:173
static const float UPDATE_TICK_RATE
Definition ClockBase.c:14
void MakeRingingStart()
Definition ClockBase.c:213
void SetAlarmTimeServer(float time01)
Definition ClockBase.c:294
static int ConvertTimeToMins12h(int hour, int minute)
Definition ClockBase.c:81
EActions
Definition EActions.c:2
class NoiseSystem NoiseParams()
Definition Noise.c:15
void SetState(bool state)
bool m_State
class JsonUndergroundAreaTriggerData GetPosition
void AnimateAlarmHand(float value)
Definition AlarmClock.c:135
const string RINGING_SOUND
Definition AlarmClock.c:3
override string GetHitSound()
Definition AlarmClock.c:59
override void OnStoreSave(ParamsWriteContext ctx)
Definition AlarmClock.c:169
const string TURN_TOGGLE_SOUND
Definition AlarmClock.c:4
override string GetDestroyedSound()
Definition AlarmClock.c:54
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition AlarmClock.c:141
override string GetDebugText()
Definition AlarmClock.c:90
override void OnDebugSpawn()
Definition AlarmClock.c:177
const string DESTROYED_SOUND
Definition AlarmClock.c:5
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition AlarmClock.c:77
static ref NoiseParams m_NoisePar
Definition AlarmClock.c:9
override string GetToggleSound()
Definition AlarmClock.c:44
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition AlarmClock.c:69
override string GetRingingSound()
Definition AlarmClock.c:49
void ~AlarmClock_ColorBase()
Definition AlarmClock.c:27
override string GetExplosiveTriggerSlotName()
Definition AlarmClock.c:64
static NoiseSystem m_NoiseSystem
Definition AlarmClock.c:10
override void SetActions()
Definition AlarmClock.c:35
const string HIT_SOUND
Definition AlarmClock.c:6
override void Init()
Definition AlarmClock.c:12
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto string ToString()
proto native CGame GetGame()
const int SAT_DEBUG_ACTION
Definition constants.c:424