DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
KitchenTimer.c
Go to the documentation of this file.
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 {
21 if ( m_NoiseSystem && !m_NoisePar )
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();
35 }
36
38 {
39 return "TriggerKitchenTimer";
40 }
41
42 override string GetToggleSound()
43 {
44 return "";
45 };
46
47 override string GetRingingSound()
48 {
49 return RINGING_SOUND;
50 }
51
53 {
54 return "KitchenTimer_Ring_End_SoundSet";
55 }
56
57 override string GetDestroyedSound()
58 {
59 return DESTROYED_SOUND;
60 }
61
62 override string GetHitSound()
63 {
64 return HIT_SOUND;
65 }
66
67 override string GetWorkingSound()
68 {
69 return WORKING_SOUND;
70 }
71
73 {
74 return 45;
75 }
76
77 int Time01ToSeconds(float time01)
78 {
79 return Math.Lerp(0,GetMinutesMax() * 60, time01);
80 }
81
82
83 float SecondsTo01(int seconds)
84 {
85 return Math.InverseLerp(0,GetMinutesMax() * 60, seconds);
86 }
87
88 override float GetRingingDurationMax()
89 {
90 return 60;
91 }
92
93 override void TurnOff()
94 {
95 super.TurnOff();
97 }
98
99 void OnUpdate()
100 {
101 if (m_AlarmInSecs > 0)
102 {
104 float time01 = SecondsTo01(m_AlarmInSecs);
105 SetAnimationPhaseNow("ClockAlarm", time01);
106 if (IsRinging())
107 {
109 }
110 }
111 else if (!IsRinging())
112 {
114 }
115
116 if (IsRinging())
117 {
119
121 {
122 TurnOff();
123 }
124 else if ( m_NoiseSystem )
125 {
127 }
128 }
129 }
130
131 override protected void Disarm()
132 {
133 super.Disarm();
135 }
136
137 override protected void OnRingingStopClient()
138 {
140 PlaySoundSet( m_RingingStopSound, GetRingingStopSound(), 0, 0);
141 super.OnRingingStopClient();
142
143 }
144
145 override bool OnStoreLoad( ParamsReadContext ctx, int version )
146 {
147 if (!super.OnStoreLoad(ctx, version))
148 return false;
149
150 if (version < 128)
151 {
152 return true;
153 }
154
155 EAlarmClockState state;
156
157 if ( !ctx.Read( state ) )
158 {
159 return false;
160 }
161
162 int time;
163
164 if (!ctx.Read( time ))
165 {
166 return false;
167 }
168
169 SetState(state);
170
171 if (state == EAlarmClockState.SET)
172 {
174 }
175 else if (state == EAlarmClockState.RINGING )
176 {
178 }
179
180 return true;
181 }
182
184 {
185 super.OnStoreSave(ctx);
186
187 ctx.Write(m_State);
188 ctx.Write(m_AlarmInSecs);
189
190 }
191
192
193
194 //---------------------------------------------------------------------------------------------------------
195 //---------------------------------------------- Public methods -------------------------------------------
196 //---------------------------------------------------------------------------------------------------------
197
198 override void SetAlarmTimeServer(float time01)
199 {
200 SetAnimationPhaseNow("ClockAlarm", time01);
202
203 if (m_AlarmInSecs > 0 )
204 {
205 TurnOn();
206 }
207 }
208
209 void SetAlarmTimeServerSecs(int inSecs)
210 {
212 }
213
214
215 //----------------------------------
216 //------------- DEBUG --------------
217 //----------------------------------
218
219 override void GetDebugButtonNames(out string button1, out string button2, out string button3, out string button4)
220 {
221 button1 = "SetAlarmAhead";
222 }
223
224 override void OnDebugButtonPressServer(int button_index)
225 {
226 if (button_index == 1)
227 {
229 }
230 }
231
232 override string GetDebugText()
233 {
234 string debug_output;
235
236 if( GetGame().IsDedicatedServer())
237 {
238 debug_output = "alarm in: " + m_AlarmInSecs.ToString() + " secs" + "\n";
239 debug_output += "current state: " + typename.EnumToString(EAlarmClockState, m_State) + "\n";
240 debug_output += "ringing for " + m_RingingDuration.ToString()+ " secs" + "\n";
241 debug_output += "ringing max " + GetRingingDurationMax().ToString()+ " secs" + "\n";
242 }
243 else
244 {
245 debug_output = "this is client";
246 }
247 return debug_output;
248 }
249
250};
eBleedingSourceType GetType()
ActionResetKitchenTimerClockCB ActionSingleUseBaseCB ActionResetKitchenTimer()
void AddAction(typename actionName)
bool IsRinging()
Definition ClockBase.c:290
void ClockBase()
Definition ClockBase.c:27
EffectSound m_WorkingSound
Definition ClockBase.c:23
protected void MakeRingingStop()
Definition ClockBase.c:231
float m_RingingDuration
Definition ClockBase.c:16
void TurnOn()
Definition ClockBase.c:300
EAlarmClockState
Definition ClockBase.c:2
protected void MakeRingingStart()
Definition ClockBase.c:222
static const float UPDATE_TICK_RATE
Definition ClockBase.c:14
EffectSound m_RingingSoundLoop
Definition ClockBase.c:19
class NoiseSystem NoiseParams()
Definition Noise.c:15
void SetState(bool state)
protected float m_DrainThreshold protected bool m_State
class JsonUndergroundAreaTriggerData GetPosition
proto native NoiseSystem GetNoiseSystem()
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
EffectSound m_RingingStopSound
Definition KitchenTimer.c:8
const string WORKING_SOUND
Definition KitchenTimer.c:6
void SetAlarmTimeServerSecs(int inSecs)
override protected void Disarm()
override void OnStoreSave(ParamsWriteContext ctx)
override protected void OnRingingStopClient()
override string GetDebugText()
override string GetToggleSound()
override string GetRingingSound()
override void OnDebugButtonPressServer(int button_index)
float SecondsTo01(int seconds)
const string HIT_SOUND
Definition KitchenTimer.c:5
string GetRingingStopSound()
static ref NoiseParams m_NoisePar
Definition KitchenTimer.c:9
override string GetExplosiveTriggerSlotName()
const string DESTROYED_SOUND
Definition KitchenTimer.c:4
void OnUpdate()
override void SetAlarmTimeServer(float time01)
override void Init()
static NoiseSystem m_NoiseSystem
override string GetHitSound()
int Time01ToSeconds(float time01)
override float GetRingingDurationMax()
override string GetWorkingSound()
override string GetDestroyedSound()
override bool OnStoreLoad(ParamsReadContext ctx, int version)
const string RINGING_SOUND
Definition KitchenTimer.c:3
override void TurnOff()
override void GetDebugButtonNames(out string button1, out string button2, out string button3, out string button4)
int GetMinutesMax()
override void SetActions()
Definition EnMath.c:7
proto void AddNoiseTarget(vector pos, float lifetime, NoiseParams noise_params, float external_strength_multiplier=1.0)
Will make a noise at that position which the AI will "see" for the duration of 'lifetime'.
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 bool Write(void value_out)
proto bool Read(void value_in)
proto string ToString()
proto native CGame GetGame()
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.