DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ClockBase.c
См. документацию.
2{
6 //-----------
8}
9
11{
14 static const float UPDATE_TICK_RATE = 1; // Clock update tick frequency
17 int m_StatePrev = -1;
18
24
25 const float RINGING_DURATION_MAX = 60;//in secs, at or past this value, the clock stops ringing
26
27 void ClockBase()
28 {
29 Init();
30 }
31
40
41 void Init()
42 {
43 RegisterNetSyncVariableInt("m_State", 0, EAlarmClockState.COUNT - 1);
44 }
45
46 override void SetActions()
47 {
48 super.SetActions();
49
51 }
52
53 protected int GetAlarmInMin()
54 {
55 int alarm_hand_in_mins = ConvertAlarmHand01ToMins12h(m_AlarmTime01);
56
57 int pass, hour, minute;
58 GetGame().GetWorld().GetDate(pass, pass, pass, hour, minute);
59
60 int curr_time_in_minutes = ConvertTimeToMins12h(hour, minute);
61 int ring_in_mins = GetTimeDiffInMins12h(curr_time_in_minutes, alarm_hand_in_mins);
62 return ring_in_mins;
63 }
64
65 static int ConvertAlarmHand01ToMins12h(float time01)
66 {
67 return Math.Lerp(0,12*60,time01);
68 }
69
70 static int ConvertAlarmHand01ToMins(float time01, int mins_max/*what's the upper range in minutes we are trying to map the time01 to*/)
71 {
72 return Math.Lerp(0,mins_max,time01);
73 }
74
75 static float ConvertMins12hToAlarmHand01(int mins)
76 {
77 return Math.InverseLerp(0,12*60,mins);
78 }
79
80
81 static int ConvertTimeToMins12h(int hour, int minute)
82 {
83 if (hour >= 12)
84 hour -= 12;
85 return hour * 60 + minute;
86 }
87
88 static int GetTimeDiffInMins12h(int from_mins, int to_mins)
89 {
90 if (to_mins > from_mins)
91 {
92 return to_mins - from_mins;
93 }
94 else if (to_mins < from_mins)
95 {
96 return ((12 * 60) - from_mins) + to_mins;
97 }
98 else return 0;
99 }
100
102 {
103 return "";
104 }
106 {
107 return "";
108 }
109 string GetHitSound()
110 {
111 return "";
112 }
114 {
115 return "";
116 }
118 {
119 return "";
120 }
121
122 override void EEKilled(Object killer)
123 {
124 super.EEKilled(killer);
125 TurnOff();
126 }
127
128 override void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
129 {
130 super.EEHitByRemote(damageType, source, component, dmgZone, ammo, modelPos);
131 PlaySoundSet( m_HitSound, GetHitSound(), 0, 0 );
132 }
133
134 override void OnDamageDestroyed(int oldLevel)
135 {
136 super.OnDamageDestroyed(oldLevel);
137
138 if (GetGame().IsClient())
139 {
141
142 if (oldLevel != -1)
143 {
144 PlaySoundSet(m_DestoryedSound, GetDestroyedSound(), 0, 0);
145 }
146 }
147 }
148
149 protected void OnRingingStartServer()
150 {
152 }
153
154 protected void OnRingingStartClient()
155 {
156 PlaySoundSetLoop( m_RingingSoundLoop, GetRingingSound(), 0, 0 );
157
158 if (m_WorkingSound)
159 {
161 }
162 }
163
164 protected void OnRingingStopServer();
165
170
171 void SetAlarmInXMins(int in_mins)
172 {
173 int pass, hour, minute;
174 GetGame().GetWorld().GetDate(pass, pass, pass, hour, minute);
175 int mins12h = ConvertTimeToMins12h(hour, minute) + in_mins;
176 float time01 = ConvertMins12hToAlarmHand01(mins12h);
177 SetAlarmTimeServer(time01);
178 Arm();
179 }
180
182 {
184 }
185
186
187 protected void SetupTimerServer()
188 {
189 m_TimerUpdate = new Timer();
190 m_TimerUpdate.Run(UPDATE_TICK_RATE , this, "OnUpdate", null, true);
191 }
192
193 protected void SetState(EAlarmClockState state)
194 {
195 m_State = state;
196 SetSynchDirty();
197 }
198
199 protected void Disarm()
200 {
202 }
203
204 protected void Arm()
205 {
209 }
210
211 protected void ActivateParent()
212 {
213 if (GetHierarchyParent())
214 {
215 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
216 if (parent)
217 {
218 parent.OnActivatedByItem(this);
219 }
220 }
221 }
222
223 protected void MakeRingingStart()
224 {
225 if (!m_TimerUpdate)
227 SetState(EAlarmClockState.RINGING);
228
230 }
231
232 protected void MakeRingingStop()
233 {
235
237 }
238
240
242
244 {
245 super.OnVariablesSynchronized();
246
247 if (m_State != m_StatePrev)//state changed
248 {
249 if (m_StatePrev == EAlarmClockState.RINGING)
250 {
252 }
253 else if (m_State == EAlarmClockState.RINGING)
254 {
256 }
257 if (m_State == EAlarmClockState.SET)
258 {
259 if (m_StatePrev != -1 || IsInitialized())
260 {
261 PlaySoundSet( m_TurnOnSound, GetToggleSound(), 0, 0 );
262 }
263 if (GetWorkingSound())
264 {
265 PlaySoundSet( m_WorkingSound, GetWorkingSound(), 0, 0, true );
266 }
267 }
268 else if (m_State == EAlarmClockState.UNSET)
269 {
270 if (m_StatePrev == EAlarmClockState.SET)
271 {
272 if (m_WorkingSound)
273 {
275 }
276 if (m_StatePrev != -1 || IsInitialized())
277 {
278 PlaySoundSet( m_TurnOnSound, GetToggleSound(), 0, 0 );
279 }
280 }
281 }
283 }
284 }
285
286
287 //---------------------------------------------------------------------------------------------------------
288 //---------------------------------------------- Public methods -------------------------------------------
289 //---------------------------------------------------------------------------------------------------------
290
292 {
293 return (m_State == EAlarmClockState.RINGING);
294 }
295
297 {
298 return (m_State == EAlarmClockState.SET);
299 }
300
301 void TurnOn()
302 {
303 Arm();
304 }
305
306 void TurnOff()
307 {
308 if ( IsRinging() )
309 {
311 }
312 else
313 {
314 Disarm();
315 }
316
317 m_TimerUpdate = null;
318 }
319
320 void SetAlarmTimeServer(float time01)
321 {
322 SetAnimationPhaseNow("ClockAlarm", time01);
323 m_AlarmTime01 = time01;
324 }
325}
ActionAttachExplosivesTriggerCB ActionContinuousBaseCB ActionAttachExplosivesTrigger()
Определения ActionAttachExplosivesTrigger.c:11
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void SetActions()
Определения AdvancedCommunication.c:213
override void OnDamageDestroyed(int oldLevel)
Определения AnimalBase.c:145
override void OnVariablesSynchronized()
Определения AnniversaryMusicSource.c:42
@ UNSET
Определения BoatWaterEffects.c:3
void SetupTimerServer()
Определения ClockBase.c:187
enum EAlarmClockState m_AlarmTime01
void TurnOff()
Определения ClockBase.c:306
bool IsRinging()
Определения ClockBase.c:291
ref Timer m_TimerUpdate
Определения ClockBase.c:15
void ActivateParent()
Определения ClockBase.c:211
string GetHitSound()
Определения ClockBase.c:109
void OnRingingStopClient()
Определения ClockBase.c:166
void ClockBase()
Определения ClockBase.c:27
static int ConvertAlarmHand01ToMins(float time01, int mins_max)
Определения ClockBase.c:70
EffectSound m_WorkingSound
Определения ClockBase.c:23
bool IsAlarmOn()
Определения ClockBase.c:296
void OnRingingStartServer()
Определения ClockBase.c:149
const float RINGING_DURATION_MAX
Определения ClockBase.c:25
int m_StatePrev
Определения ClockBase.c:17
string GetRingingSound()
Определения ClockBase.c:105
static int GetTimeDiffInMins12h(int from_mins, int to_mins)
Определения ClockBase.c:88
string GetToggleSound()
Определения ClockBase.c:101
void TurnOnClient()
void SetAlarmInXMins(int in_mins)
Определения ClockBase.c:171
float m_RingingDuration
Определения ClockBase.c:16
void TurnOn()
Определения ClockBase.c:301
int GetAlarmInMin()
Определения ClockBase.c:53
EffectSound m_TurnOnSound
Определения ClockBase.c:20
void OnRingingStartClient()
Определения ClockBase.c:154
EffectSound m_DestoryedSound
Определения ClockBase.c:21
static float ConvertMins12hToAlarmHand01(int mins)
Определения ClockBase.c:75
EAlarmClockState
Определения ClockBase.c:2
@ RINGING
Определения ClockBase.c:5
override void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
Определения ClockBase.c:128
static int ConvertAlarmHand01ToMins12h(float time01)
Определения ClockBase.c:65
float GetRingingDurationMax()
Определения ClockBase.c:181
EffectSound m_HitSound
Определения ClockBase.c:22
static const float UPDATE_TICK_RATE
Определения ClockBase.c:14
void Disarm()
Определения ClockBase.c:199
void TurnOffClient()
void MakeRingingStart()
Определения ClockBase.c:223
void MakeRingingStop()
Определения ClockBase.c:232
void OnRingingStopServer()
EffectSound m_RingingSoundLoop
Определения ClockBase.c:19
void SetAlarmTimeServer(float time01)
Определения ClockBase.c:320
void ~ClockBase()
Определения ClockBase.c:32
string GetWorkingSound()
Определения ClockBase.c:117
string GetDestroyedSound()
Определения ClockBase.c:113
static int ConvertTimeToMins12h(int hour, int minute)
Определения ClockBase.c:81
override bool IsInitialized()
Определения CombinationLock.c:70
override Widget Init()
Определения DayZGame.c:127
@ COUNT
Определения EGameStateIcons.c:7
override void EEKilled(Object killer)
Определения ExplosivesBase.c:100
void Arm()
Определения ExplosivesBase.c:237
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
enum EObjectTemperatureState m_State
@ SET
Определения PPEConstants.c:63
void SetState(bool state)
Определения StaminaHandler.c:32
proto native World GetWorld()
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения Building.c:6
Определения InventoryItem.c:731
Определения EnMath.c:7
Определения ObjectTyped.c:2
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Определения EffectManager.c:271
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
Определения DayZPlayerImplement.c:63
proto void GetDate(out int year, out int month, out int day, out int hour, out int minute)
Get actual ingame world time.
Определения EnConvert.c:106
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,...