DayZ 1.24
Loading...
Searching...
No Matches
Land_Underground_Entrance.c
Go to the documentation of this file.
2{
4 CLOSED,//fully closed
5 //opening
10 OPENING_E,//fully open
13 //closing
21}
22
24{
27}
28
29class AlarmLight : SpotlightLight
30{
31 void AlarmLight()
32 {
33 SetVisibleDuringDaylight(true);
34 SetRadiusTo(15);
35 SetBrightnessTo(10);
36 SetFlareVisible(false);
37 SetAmbientColor(1.0, 0.0, 0.0);
38 SetDiffuseColor(1.0, 0.0, 0.0);
39 SetLifetime(1000);
40 SetDisableShadowsWithinRadius(-1);
41 SetFadeOutTime(1);
42 SetCastShadow(false);
43 m_FadeInTime = 0.25;
44 }
47//---------------------------------------------------------------------------------------------------------
48//------------------------------------ Land_Underground_EntranceBase --------------------------------------
49//---------------------------------------------------------------------------------------------------------
50
52{
60
61 EntranceLight m_InteriorLight1;
62 EntranceLight m_InteriorLight2;
63 EntranceLight m_InteriorLight3;
64
66 {
68 Land_Underground_Panel.RegisterEntrance(this);
69 RegisterNetSyncVariableFloat("m_AnimPhase", 0, 1, 5);
70 RegisterNetSyncVariableInt("m_DoorState", 0, EnumTools.GetLastEnumValue(EUndegroundEntranceState));
71
72#ifndef SERVER
73 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(CreateLights, 250);
74#endif
75 }
76
78
80 {
81 Land_Underground_Panel.UnregisterEntrance(this);
82#ifndef SERVER
84#endif
85 }
86 //---------------------
87
88
90 {
91 //anything we might have started playing when the door was activated
93 }
94
95
97
99 {
100 return m_DoorState == EUndegroundEntranceState.CLOSED;
101 }
102
104 {
105 OpenServer();
106 }
107
109 {
110 }
111
113
115 {
116#ifndef SERVER
118#endif
119 }
120
122 {
123 m_AnimPhase = m_AnimTimerDoorServer.GetValue() / AdjustTime(GetOpeningTime());// make 0..1
124 SetAnimationPhaseNow("EntranceDoor", m_AnimPhase);
125
126 GetGame().GetWorld().UpdatePathgraphDoorByAnimationSourceName(this, "EntranceDoor");
127
128 SetSynchDirty();
129 }
130
132 {
133 if (!Land_Underground_Panel.m_Panels)
134 return;
135 foreach (Land_Underground_Panel p: Land_Underground_Panel.m_Panels)
136 {
137 if (p.GetClosestDoor() == this)
138 panels.Insert(p);
139 }
140 }
141
142 // checks whether we want to play this effect even when we are at a different(more advanced) state, as this effect is supposed to be playing over multiple states and was supposed to start during some earlier state switch
143 // param 'state' is the state this effect is supposed to be played in, and 'lastValidState' is the latests state where we still want to play this effect provided previous state for the client is UNINITIALIZED
144 // meaning the client just connected in/the item entered their multiplayer bubble
149
150 float AdjustTime(float originalTime, float adjustedTime = -1)
151 {
152#ifdef DIAG_DEVELOPER
153 float timeAccel = 1;
154
155 if (adjustedTime != -1)
156 return adjustedTime;
157 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.UNDERGROUND_ENTRANCE))
158 {
159 timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
160 return originalTime / timeAccel;
161 }
162#endif
163 return originalTime;
164 }
165
167 {
168 return 30;
169 }
170
172 {
173 if (targetState == EUndegroundEntranceState.UNINITIALIZED)
175 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SetDoorStateServer, time * 1000, false, targetState);
176 }
177
184
186
188 {
190 SetEventMask(EntityEvent.POSTSIMULATE);
191 else
192 {
193 ClearEventMask(EntityEvent.POSTSIMULATE);
195 }
196
199
201 {
204 }
205 foreach (Land_Underground_Panel p: m_ConnectedPanels)
206 p.OnDoorStateChangedClient(newState, prevState);
207 }
208
209 void OpenServer(bool force = false)
210 {
211 GetGame().RegisterNetworkStaticObject(this);
214 }
215
218
220
222 {
223 super.OnVariablesSynchronized();
224
226 {
229 }
230 }
231
233 {
234 return m_DoorStatePrev == EUndegroundEntranceState.UNINITIALIZED;
235 }
236
237
238#ifdef DEVELOPER
239 override string GetDebugText()
240 {
241 string debug_output;
242
243 if (GetGame().IsDedicatedServer())
244 {
245 debug_output += "current state: " + typename.EnumToString(EUndegroundEntranceState, m_DoorState) + "\n";
246 /*
247 if(GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ))
248 debug_output += "next stage timer: " + GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).GetRemainingTimeByName(this, "SetDoorStateServer").ToString();
249 */
250 }
251 else
252 debug_output += "current state: " + typename.EnumToString(EUndegroundEntranceState, m_DoorState) + "\n";
253 return debug_output;
254 }
255
257 {
258 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Open", FadeColors.LIGHT_GREY));
259 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEACTIVATE_ENTITY, "Close", FadeColors.LIGHT_GREY));
260 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.LIGHT_GREY));
261
262 super.GetDebugActions(outputList);
263 }
264
265 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
266 {
267 if (super.OnAction(action_id, player, ctx))
268 return true;
269 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
270 {
271 if (action_id == EActions.ACTIVATE_ENTITY)
272 {
274 OpenServer(true);
275 }
276 else if (action_id == EActions.DEACTIVATE_ENTITY)
277 {
278 // just for debug controls
281
282 if (m_DoorState == EUndegroundEntranceState.OPENING_G)
283 {
284 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(SetDoorStateServer);
286 }
287 }
288 }
289 return false;
290 }
291#endif
292}
293
294
295//---------------------------------------------------------------------------------------------------------
296//-------------------------------------- Land_Underground_Entrance ----------------------------------------
297//---------------------------------------------------------------------------------------------------------
298
300{
309
310
312
313 const string SIREN_SOUNDSET = "UndergroundDoor_Alarm_Loop_SoundSet";
314 const string ENGINE_SOUNDSET_LOOP_IN = "UndergroundDoor_ElectricMotor_Start_SoundSet";
315 const string ENGINE_SOUNDSET_LOOP = "UndergroundDoor_ElectricMotor_Loop_SoundSet";
316 const string ENGINE_SOUNDSET_LOOP_OUT = "UndergroundDoor_ElectricMotor_End_SoundSet";
317 const string LOCKING_SOUNDSET = "UndergroundDoor_Lock_SoundSet";
318 const string DOORMOVING_SOUNDSET_LOOP = "UndergroundDoor_DoorOpen_Loop_SoundSet";
319 const string DOORMOVING_SOUNDSET_LOOP_OUT = "UndergroundDoor_DoorOpen_End_SoundSet";
320 const string DOORMOVING_SOUNDSET_LOOP_IN = "UndergroundDoor_DoorOpen_Start_SoundSet";
321
322 const float LIGHT_ROT_SPEED = -400;
323
324 override void CreateLights()
325 {
326 m_InteriorLight1 = EntranceLight.Cast(ScriptedLightBase.CreateLightAtObjMemoryPoint(EntranceLightMain1, this, "InteriorLightPos1"));
327 m_InteriorLight2 = EntranceLight.Cast(ScriptedLightBase.CreateLightAtObjMemoryPoint(EntranceLightMain2, this, "InteriorLightPos2"));
328 }
329
344
346 {
347 switch (newState)
348 {
349 case EUndegroundEntranceState.OPENING_A:
350 RequestLatentTransition(AdjustTime(3));
351 break;
352 case EUndegroundEntranceState.OPENING_B:
353 RequestLatentTransition(AdjustTime(2));
354 break;
355 case EUndegroundEntranceState.OPENING_C:
356 RequestLatentTransition(AdjustTime(1));
357 break;
358 case EUndegroundEntranceState.OPENING_D:
359 m_AnimTimerDoorServer = new AnimationTimer();
360 m_AnimTimerDoorServer.Run(AdjustTime(GetOpeningTime()), this, "OnUpdateServer", "OnFinishedTimerServer", 0, false,/*1/ AdjustTime(1)*/ 1);
361 m_NavmeshTimer = new Timer();
362 m_NavmeshTimer.Run(3, this, "NavmeshUpdate", NULL, true);
363 RequestLatentTransition(AdjustTime(GetOpeningTime()));
364 break;
365 case EUndegroundEntranceState.OPENING_E:
366 m_AnimTimerDoorServer.Stop();
367 NavmeshUpdate();
368 m_NavmeshTimer = null;
369 RequestLatentTransition(AdjustTime(3));
370 break;
371 case EUndegroundEntranceState.OPENING_F:
372 RequestLatentTransition(AdjustTime(3));
373 break;
374 case EUndegroundEntranceState.OPENING_G:
375 RequestLatentTransition(AdjustTime(300));
376 break;
377 case EUndegroundEntranceState.CLOSING_A:
378 RequestLatentTransition(AdjustTime(3));
379 break;
380 case EUndegroundEntranceState.CLOSING_B:
381 RequestLatentTransition(AdjustTime(3));
382 break;
383 case EUndegroundEntranceState.CLOSING_C:
384 m_NavmeshTimer = new Timer();
385 m_NavmeshTimer.Run(3, this, "NavmeshUpdate", NULL, true);
386 m_AnimTimerDoorServer.Run(0, this, "OnUpdateServer", "OnFinishedTimerServer", AdjustTime(GetOpeningTime()), false, /*1/ AdjustTime(1)*/ 1);
387 RequestLatentTransition(AdjustTime(GetOpeningTime()));
388 break;
389 case EUndegroundEntranceState.CLOSING_D:
390 NavmeshUpdate();
391 m_NavmeshTimer = null;
392 RequestLatentTransition(AdjustTime(2));
393 break;
394 case EUndegroundEntranceState.CLOSING_E:
395 RequestLatentTransition(AdjustTime(1));
396 break;
397 case EUndegroundEntranceState.CLOSING_F:
398 RequestLatentTransition(AdjustTime(3));
399 break;
400 case EUndegroundEntranceState.CLOSING_G:
401 RequestLatentTransition(0.25, EUndegroundEntranceState.CLOSED);
402 break;
403 }
404 }
405
407 {
408 vector pos;
409 if (MemoryPointExists("SirenLightPos"))
410 {
411 pos = GetMemoryPointPos("SirenLightPos");
412 pos = ModelToWorld(pos);
413 }
414 else
415 ErrorEx("GetLightPosition could not locate memory point 'SirenLightPos'");
416 return pos;
417 }
418
419 void SoundEnded(Effect eff)
420 {
422 {
423 PlaySoundSetAtMemoryPointLooped(m_DoorMovementSoundLoop, DOORMOVING_SOUNDSET_LOOP, "DoorEngineSoundPos");
425 }
426 else if (eff == m_DoorEngineSoundIn)
427 {
428 PlaySoundSetAtMemoryPointLooped(m_DoorEngineSoundLoop, ENGINE_SOUNDSET_LOOP, "DoorEngineSoundPos");
430 }
431 }
432
433 //do note that one-time effects are played even if the client connects and misses the state switch, ie. they are not connected the exact moment when the effect is supposed to be played(just after a state switch), but connect sometime later
434 //we can prevent such effects from playing by checking for IsInitDoorStateSync(), but that seems unnecessary as the issue is really small
436 {
437 //Print("HandleAudioVisualPlayback " + newState + ", " + prevState);
438 //opening
439 if (CheckShouldPlayPersistent(EUndegroundEntranceState.OPENING_A, EUndegroundEntranceState.OPENING_F))
440 PlaySoundSetAtMemoryPointLooped(m_SirenSound, SIREN_SOUNDSET, "SirenSoundPos", 0.5, 0.5);
441 if (newState == EUndegroundEntranceState.OPENING_B)
442 {
443 if (prevState == EUndegroundEntranceState.OPENING_A)//if they connected already during B, do not play the in
444 {
445 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundIn, ENGINE_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
447 m_DoorEngineSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
448 }
449 }
450
451 if (CheckShouldPlayPersistent(EUndegroundEntranceState.OPENING_B, EUndegroundEntranceState.OPENING_E))
452 {
453 if (!m_DoorEngineSoundLoop && !m_DoorEngineSoundIn)//missed playing of the IN soundset which automatically triggers playing of the loop(connected after ?)
454 PlaySoundSetAtMemoryPointLooped(m_DoorEngineSoundLoop, ENGINE_SOUNDSET_LOOP, "DoorEngineSoundPos");
455 }
456 if (newState == EUndegroundEntranceState.OPENING_C)
457 PlaySoundSetAtMemoryPoint(m_LockingSound, LOCKING_SOUNDSET, "DoorEngineSoundPos");
458 if (newState == EUndegroundEntranceState.OPENING_D)
459 {
460 if (prevState == EUndegroundEntranceState.OPENING_C)//if they connected already during C, do not play the in
461 {
462 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundIn, DOORMOVING_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
464 m_DoorMovementSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
465 }
466 else if (!m_DoorMovementSoundIn && !m_DoorMovementSoundLoop)//missed playing of the IN soundset which automatically triggers playing of the loop(connected after ?)
467 PlaySoundSetAtMemoryPointLooped(m_DoorMovementSoundLoop, DOORMOVING_SOUNDSET_LOOP, "DoorEngineSoundPos");
468 }
469
470 if (newState == EUndegroundEntranceState.OPENING_E)
471 {
472 StopSoundSet(m_DoorMovementSoundLoop);
473 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundOut, DOORMOVING_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
474 }
475 if (newState == EUndegroundEntranceState.OPENING_F)
476 {
477 StopSoundSet(m_DoorEngineSoundLoop);
478 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundOut, ENGINE_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
479 }
480 if (newState == EUndegroundEntranceState.OPENING_G)
481 StopSoundSet(m_SirenSound);
482
483 //closing
484 if (CheckShouldPlayPersistent(EUndegroundEntranceState.CLOSING_A, EUndegroundEntranceState.CLOSING_F))
485 PlaySoundSetAtMemoryPointLooped(m_SirenSound, SIREN_SOUNDSET, "SirenSoundPos", 0.5, 0.5);
486 if (CheckShouldPlayPersistent(EUndegroundEntranceState.CLOSING_B, EUndegroundEntranceState.CLOSING_E))
487 {
488 if (prevState == EUndegroundEntranceState.CLOSING_A)//if they connected already during B, do not play the in
489 {
490 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundIn, ENGINE_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
492 m_DoorEngineSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
493 }
494 }
495 if (newState == EUndegroundEntranceState.CLOSING_C)
496 {
497 if (prevState == EUndegroundEntranceState.CLOSING_B)//if they connected already during C, do not play the in
498 {
499 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundIn, DOORMOVING_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
501 m_DoorMovementSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
502 }
503 else if (!m_DoorMovementSoundIn && !m_DoorMovementSoundLoop)//missed playing of the IN soundset which automatically triggers playing of the loop(connected after ?)
504 PlaySoundSetAtMemoryPointLooped(m_DoorMovementSoundLoop, DOORMOVING_SOUNDSET_LOOP, "DoorEngineSoundPos");
505 }
506 if (newState == EUndegroundEntranceState.CLOSING_D)
507 {
508 StopSoundSet(m_DoorMovementSoundLoop);
509 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundOut, DOORMOVING_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
510 }
511 if (newState == EUndegroundEntranceState.CLOSING_E)
512 PlaySoundSetAtMemoryPoint(m_LockingSound, LOCKING_SOUNDSET, "DoorEngineSoundPos");
513 if (newState == EUndegroundEntranceState.CLOSING_F)
514 {
515 StopSoundSet(m_DoorEngineSoundLoop);
516 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundOut, ENGINE_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
517 }
519 StopSoundSet(m_SirenSound);
520 }
521
522 override void OnUpdateClient(float timeSlice)
523 {
524 SetAnimationPhaseNow("EntranceDoor", m_AnimPhase);
525 if (m_AlarmLight)
526 {
527 vector newOri = m_AlarmLight.GetOrientation() + Vector(timeSlice * LIGHT_ROT_SPEED, 0, 0);
528 m_AlarmLight.SetOrientation(newOri);
529 }
530 }
531
533 {
534 if (CheckShouldPlayPersistent(EUndegroundEntranceState.OPENING_A, EUndegroundEntranceState.OPENING_F) || CheckShouldPlayPersistent(EUndegroundEntranceState.CLOSING_A, EUndegroundEntranceState.CLOSING_F))
537 {
538 if (m_AlarmLight)
539 m_AlarmLight.Destroy();
540 }
541 }
542
543}
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition EntityAI.c:97
void OnUpdateClient(ActionData action_data)
Definition ActionBase.c:923
EActions
Definition EActions.c:2
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition ItemBase.c:6834
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition ItemBase.c:6792
enum EUndegroundEntranceState AlarmLight()
const string ENGINE_SOUNDSET_LOOP_IN
const string LOCKING_SOUNDSET
override void HandleAudioPlayback(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
vector GetLightPosition()
AlarmLight m_AlarmLight
enum EUndegroundEntranceState MAIN
Land_Underground_EntranceBase m_SirenSound
override void OnDoorStateChangedServer(EUndegroundEntranceState newState)
EffectSound m_DoorEngineSoundIn
const string DOORMOVING_SOUNDSET_LOOP
EffectSound m_DoorMovementSoundLoop
const string DOORMOVING_SOUNDSET_LOOP_OUT
override void CleanUpOnClosedClient()
override void CreateLights()
void SoundEnded(Effect eff)
enum EUndegroundEntranceState SMALL
EffectSound m_DoorEngineSoundOut
const float LIGHT_ROT_SPEED
EffectSound m_DoorEngineSoundLoop
const string DOORMOVING_SOUNDSET_LOOP_IN
EffectSound m_LockingSound
EffectSound m_DoorMovementSoundOut
EffectSound m_DoorMovementSoundIn
const string ENGINE_SOUNDSET_LOOP_OUT
const string ENGINE_SOUNDSET_LOOP
override void HandleVisualPlayback(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
const string SIREN_SOUNDSET
float AdjustTime(float originalTime)
string GetDebugText()
AnimationTimer class. This timer is for animating float value. usage:
Definition tools.c:618
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
static int GetLastEnumValue(typename e)
Return amount of values in enum.
Definition EnConvert.c:644
void SetDoorStateServer(EUndegroundEntranceState newState)
void OnUpdateClient(float timeSlice)
void GetConnectedPanels(array< Land_Underground_Panel > panels)
void OnDoorStateChangedClient(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
ref array< Land_Underground_Panel > m_ConnectedPanels
void HandleAudioPlayback(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
EUndegroundEntranceState m_DoorStatePrev
bool CheckShouldPlayPersistent(EUndegroundEntranceState state, EUndegroundEntranceState lastValidState)
override void EOnPostSimulate(IEntity other, float timeSlice)
float AdjustTime(float originalTime, float adjustedTime=-1)
void OnDoorStateChangedServer(EUndegroundEntranceState newState)
void HandleVisualPlayback(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
void RequestLatentTransition(float time, EUndegroundEntranceState targetState=EUndegroundEntranceState.UNINITIALIZED)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Manager class for managing Effect (EffectParticle, EffectSound)
static bool DestroySound(EffectSound sound_effect)
Legacy, backwards compatibility.
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto native CGame GetGame()
enum ShapeType ErrorEx
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:44
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
const int SAT_DEBUG_ACTION
Definition constants.c:424
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8