DayZ 1.24
Loading...
Searching...
No Matches
KitchenTimer.c
Go to the documentation of this file.
1class KitchenTimer : ClockBase
2{
3 const string RINGING_SOUND = "KitchenTimer_Ring_Loop_SoundSet";
4 const string DESTROYED_SOUND = "AlarmClock_Destroyed_SoundSet";
5 const string HIT_SOUND = "AlarmClock_Hit_SoundSet";
6 const string WORKING_SOUND = "KitchenTimer_Ticking_Loop_SoundSet";
7
11
13
14 override void Init()
15 {
16 super.Init();
17
18 if (GetGame().IsServer())
19 {
20 m_NoiseSystem = GetGame().GetNoiseSystem();
22 {
23 // Create and load noise parameters
25 m_NoisePar.LoadFromPath("cfgVehicles " + GetType() + " NoiseKitchenTimer");
26 }
27 }
28 }
29
30 override void SetActions()
31 {
32 super.SetActions();
33
36 }
37
39 {
40 return "TriggerKitchenTimer";
41 }
42
43 override string GetToggleSound()
44 {
45 return "";
46 }
47
48 override string GetRingingSound()
49 {
50 return RINGING_SOUND;
51 }
52
54 {
55 return "KitchenTimer_Ring_End_SoundSet";
56 }
57
58 override string GetDestroyedSound()
59 {
60 return DESTROYED_SOUND;
61 }
62
63 override string GetHitSound()
64 {
65 return HIT_SOUND;
66 }
67
68 override string GetWorkingSound()
69 {
70 return WORKING_SOUND;
71 }
72
74 {
75 return 45;
76 }
77
79 {
80 return Math.Lerp(0, GetMinutesMax() * 60, time01);
81 }
82
83
85 {
86 return Math.InverseLerp(0, GetMinutesMax() * 60, seconds);
87 }
88
89 override float GetRingingDurationMax()
90 {
91 return 60;
92 }
93
94 override void TurnOff()
95 {
96 super.TurnOff();
98 }
99
100 void OnUpdate()
101 {
102 if (m_AlarmInSecs > 0)
103 {
106 SetAnimationPhaseNow("ClockAlarm", time01);
107 if (IsRinging())
109 }
110 else if (!IsRinging())
112
113 if (IsRinging())
114 {
116
118 TurnOff();
119 else if (m_NoiseSystem)
121 }
122 }
123
124 override protected void Disarm()
125 {
126 super.Disarm();
128 }
129
130 override protected void OnRingingStopClient()
131 {
133 PlaySoundSet(m_RingingStopSound, GetRingingStopSound(), 0, 0);
134
135 super.OnRingingStopClient();
136
137 }
138
139 override bool OnStoreLoad(ParamsReadContext ctx, int version)
140 {
141 if (!super.OnStoreLoad(ctx, version))
142 return false;
143
144 if (version < 128)
145 return true;
146
148
149 if (!ctx.Read(state))
150 return false;
151
152 int time;
153 if (!ctx.Read(time))
154 return false;
155
157
158 if (state == EAlarmClockState.SET)
160 else if (state == EAlarmClockState.RINGING)
162
163 return true;
164 }
165
167 {
168 super.OnStoreSave(ctx);
169
170 ctx.Write(m_State);
171 ctx.Write(m_AlarmInSecs);
172 }
173
174
175 //---------------------------------------------------------------------------------------------------------
176 //---------------------------------------------- Public methods -------------------------------------------
177 //---------------------------------------------------------------------------------------------------------
178
179 override void SetAlarmTimeServer(float time01)
180 {
181 SetAnimationPhaseNow("ClockAlarm", time01);
183
184 if (m_AlarmInSecs > 0)
185 TurnOn();
186 }
187
192
193
194 //----------------------------------
195 //------------- DEBUG --------------
196 //----------------------------------
197
199 {
200 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ALARM_SET_AHEAD, "Set Alarm Ahead", FadeColors.LIGHT_GREY));
201 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.LIGHT_GREY));
202
203 super.GetDebugActions(outputList);
204 }
205
207 {
208 if (super.OnAction(action_id, player, ctx))
209 return true;
210
211 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
212 {
213 if (action_id == EActions.ALARM_SET_AHEAD)
215 }
216 return false;
217 }
218
219 override string GetDebugText()
220 {
221 string debug_output;
222
223 if (GetGame().IsDedicatedServer())
224 {
225 debug_output = "alarm in: " + m_AlarmInSecs.ToString() + " secs" + "\n";
226 debug_output += "current state: " + typename.EnumToString(EAlarmClockState, m_State) + "\n";
227 debug_output += "ringing for " + m_RingingDuration.ToString() + " secs" + "\n";
228 debug_output += "ringing max " + GetRingingDurationMax().ToString() + " secs" + "\n";
229 }
230 else
231 debug_output = "this is client";
232
233 return debug_output;
234 }
235
236};
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition EntityAI.c:97
eBleedingSourceType GetType()
ActionResetKitchenTimerClockCB ActionSingleUseBaseCB ActionResetKitchenTimer()
void AddAction(typename actionName)
bool IsRinging()
Definition ClockBase.c:269
EffectSound m_WorkingSound
Definition ClockBase.c:23
float m_RingingDuration
Definition ClockBase.c:16
void TurnOn()
Definition ClockBase.c:279
EAlarmClockState
Definition ClockBase.c:2
static const float UPDATE_TICK_RATE
Definition ClockBase.c:14
void MakeRingingStart()
Definition ClockBase.c:213
void MakeRingingStop()
Definition ClockBase.c:222
EffectSound m_RingingSoundLoop
Definition ClockBase.c:19
EActions
Definition EActions.c:2
class NoiseSystem NoiseParams()
Definition Noise.c:15
void SetState(bool state)
bool m_State
class JsonUndergroundAreaTriggerData GetPosition
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
override void SetAlarmTimeServer(float time01)
override string GetHitSound()
override string GetDebugText()
void SetAlarmTimeServerSecs(int inSecs)
override string GetDestroyedSound()
override void Init()
int GetMinutesMax()
const string RINGING_SOUND
Definition KitchenTimer.c:3
int Time01ToSeconds(float time01)
const string DESTROYED_SOUND
Definition KitchenTimer.c:4
EffectSound m_RingingStopSound
Definition KitchenTimer.c:8
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
override string GetExplosiveTriggerSlotName()
const string WORKING_SOUND
Definition KitchenTimer.c:6
const string HIT_SOUND
Definition KitchenTimer.c:5
string GetRingingStopSound()
override string GetToggleSound()
static ref NoiseParams m_NoisePar
Definition KitchenTimer.c:9
override void OnStoreSave(ParamsWriteContext ctx)
override float GetRingingDurationMax()
override void SetActions()
void OnRingingStopClient()
override void TurnOff()
float SecondsTo01(int seconds)
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
static NoiseSystem m_NoiseSystem
override string GetWorkingSound()
override string GetRingingSound()
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition EnMath.c:7
Manager class for managing Effect (EffectParticle, EffectSound)
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto string ToString()
proto native CGame GetGame()
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
const int SAT_DEBUG_ACTION
Definition constants.c:424