Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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
23enum EUndegroundDoorType
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{
59 EUndegroundDoorType m_DoorType;
60
64
65 #ifndef SERVER
67 #endif
68 private const float TEMP_HOTIX_TIMESLICE = 0.01;
69
71 {
72 m_DoorType = EUndegroundDoorType.MAIN;
73 Land_Underground_Panel.RegisterEntrance(this);
74 RegisterNetSyncVariableFloat("m_AnimPhase", 0,1,5);
75 RegisterNetSyncVariableInt("m_DoorState", 0, EnumTools.GetLastEnumValue(EUndegroundEntranceState));
76
77 #ifndef SERVER
78 g_Game.GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( CreateLights, 250);
79
82 m_TempHotfixTimer.Run(TEMP_HOTIX_TIMESLICE, this, "EOnPostSimulate", null, true);
83 #endif
84 }
85
87
89 {
90 Land_Underground_Panel.UnregisterEntrance(this);
91 #ifndef SERVER
93
95 {
96 m_TempHotfixTimer.Stop();
97 m_TempHotfixTimer = null;
98 }
99 #endif
100 }
101 //---------------------
102
103
105 {
106 //anything we might have started playing when the door was activated
108 }
109
110
112
113 bool CanManipulate(Param param = null)
114 {
115 return m_DoorState == EUndegroundEntranceState.CLOSED;
116 }
117
118 void Manipulate(Param param = null)
119 {
120 OpenServer();
121 }
122
124 {
125 }
126
127 void OnUpdateClient(float timeSlice);
128
129 override void EOnPostSimulate(IEntity other, float timeSlice)
130 {
131 #ifndef SERVER
133 #endif
134 }
135
137 {
138 m_AnimPhase = m_AnimTimerDoorServer.GetValue() / AdjustTime(GetOpeningTime());// make 0..1
139 SetAnimationPhaseNow("EntranceDoor",m_AnimPhase);
140
141 g_Game.GetWorld().UpdatePathgraphDoorByAnimationSourceName(this, "EntranceDoor");
142
143 SetSynchDirty();
144 }
145
147 {
148 if (!Land_Underground_Panel.m_Panels)
149 {
150 return;
151 }
153 {
154 if (p.GetClosestDoor() == this)
155 {
156 panels.Insert(p);
157 }
158 }
159 }
160
161 // 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
162 // 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
163 // meaning the client just connected in/the item entered their multiplayer bubble
165 {
166 return m_DoorState == state || ( IsInitDoorStateSync() && m_DoorState > state && m_DoorState <= lastValidState);
167 }
168
169 float AdjustTime(float originalTime, float adjustedTime = -1)
170 {
171 #ifdef DIAG_DEVELOPER
172 float timeAccel = 1;
173
174 if (adjustedTime != -1)
175 {
176 return adjustedTime;
177 }
178 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.UNDERGROUND_ENTRANCE))
179 {
180 timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
181 return originalTime / timeAccel;
182 }
183 #endif
184 return originalTime;
185 }
186
188 {
189 return 30;
190 }
191
193 {
194 if (targetState == EUndegroundEntranceState.UNINITIALIZED)
195 {
196 targetState = m_DoorState + 1;
197 }
198 g_Game.GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( SetDoorStateServer, time * 1000, false, targetState);
199 }
200
202 {
203 m_DoorState = newState;
204 OnDoorStateChangedServer(newState);
205 SetSynchDirty();
206 }
207
209
211 {
212 if (newState > EUndegroundEntranceState.CLOSED)
213 {
214 SetEventMask(EntityEvent.POSTSIMULATE);
215 }
216 else
217 {
218 ClearEventMask(EntityEvent.POSTSIMULATE);
220 }
221
222 HandleAudioPlayback(newState, prevState);
223 HandleVisualPlayback(newState, prevState);
224
226 {
229 }
231 {
232 p.OnDoorStateChangedClient(newState, prevState);
233 }
234 }
235
236 void OpenServer(bool force = false)
237 {
238 g_Game.RegisterNetworkStaticObject(this);
239 if (m_DoorState == EUndegroundEntranceState.CLOSED || force)
240 {
242 }
243 }
244
247
249
251 {
252 super.OnVariablesSynchronized();
253
255 {
258 }
259 }
260
262 {
263 return m_DoorStatePrev == EUndegroundEntranceState.UNINITIALIZED;
264 }
265
266
267 #ifdef DEVELOPER
268 override string GetDebugText()
269 {
270 string debug_output;
271
272 if (g_Game.IsDedicatedServer())
273 {
274 debug_output += "current state: " + typename.EnumToString(EUndegroundEntranceState, m_DoorState) + "\n";
275 /*
276 if(g_Game.GetCallQueue( CALL_CATEGORY_SYSTEM ))
277 debug_output += "next stage timer: " + g_Game.GetCallQueue( CALL_CATEGORY_SYSTEM ).GetRemainingTimeByName(this, "SetDoorStateServer").ToString();
278 */
279 }
280 else
281 {
282 debug_output += "current state: " + typename.EnumToString(EUndegroundEntranceState, m_DoorState) + "\n";
283 }
284 return debug_output;
285 }
286
287 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
288 {
289 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Open", FadeColors.LIGHT_GREY));
290 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEACTIVATE_ENTITY, "Close", FadeColors.LIGHT_GREY));
291 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
292
293 super.GetDebugActions(outputList);
294 }
295
296 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
297 {
298 if (super.OnAction(action_id, player, ctx))
299 return true;
300 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
301 {
302 if (action_id == EActions.ACTIVATE_ENTITY)
303 {
305 OpenServer(true);
306 }
307 else if (action_id == EActions.DEACTIVATE_ENTITY)
308 {
309 // just for debug controls
311 m_AnimTimerDoorServer = new AnimationTimer();
312
313 if (m_DoorState == EUndegroundEntranceState.OPENING_G)
314 {
315 g_Game.GetCallQueue( CALL_CATEGORY_SYSTEM ).Remove(SetDoorStateServer);
317 }
318 }
319 }
320 return false;
321 }
322 #endif
323}
324
325
326//---------------------------------------------------------------------------------------------------------
327//-------------------------------------- Land_Underground_Entrance ----------------------------------------
328//---------------------------------------------------------------------------------------------------------
329
330class Land_Underground_Entrance : Land_Underground_EntranceBase
331{
340
341
343
344 const string SIREN_SOUNDSET = "UndergroundDoor_Alarm_Loop_SoundSet";
345 const string ENGINE_SOUNDSET_LOOP_IN = "UndergroundDoor_ElectricMotor_Start_SoundSet";
346 const string ENGINE_SOUNDSET_LOOP = "UndergroundDoor_ElectricMotor_Loop_SoundSet";
347 const string ENGINE_SOUNDSET_LOOP_OUT = "UndergroundDoor_ElectricMotor_End_SoundSet";
348 const string LOCKING_SOUNDSET = "UndergroundDoor_Lock_SoundSet";
349 const string DOORMOVING_SOUNDSET_LOOP = "UndergroundDoor_DoorOpen_Loop_SoundSet";
350 const string DOORMOVING_SOUNDSET_LOOP_OUT = "UndergroundDoor_DoorOpen_End_SoundSet";
351 const string DOORMOVING_SOUNDSET_LOOP_IN = "UndergroundDoor_DoorOpen_Start_SoundSet";
352
353 const float LIGHT_ROT_SPEED = -400;
354
355 override void CreateLights()
356 {
357 m_InteriorLight1 = EntranceLight.Cast(ScriptedLightBase.CreateLightAtObjMemoryPoint(EntranceLightMain1, this, "InteriorLightPos1"));
358 m_InteriorLight2 = EntranceLight.Cast(ScriptedLightBase.CreateLightAtObjMemoryPoint(EntranceLightMain2, this, "InteriorLightPos2"));
359 }
360
377
379 {
380 switch (newState)
381 {
382 case EUndegroundEntranceState.OPENING_A:
384 break;
385 case EUndegroundEntranceState.OPENING_B:
387 break;
388 case EUndegroundEntranceState.OPENING_C:
390 break;
391 case EUndegroundEntranceState.OPENING_D:
392 m_AnimTimerDoorServer = new AnimationTimer();
393 m_AnimTimerDoorServer.Run(AdjustTime(GetOpeningTime()), this, "OnUpdateServer", "OnFinishedTimerServer",0, false,/*1/ AdjustTime(1)*/ 1);
394 m_NavmeshTimer = new Timer();
395 m_NavmeshTimer.Run(3, this, "NavmeshUpdate", NULL, true);
397 break;
398 case EUndegroundEntranceState.OPENING_E:
399 m_AnimTimerDoorServer.Stop();
401 m_NavmeshTimer = null;
403 break;
404 case EUndegroundEntranceState.OPENING_F:
406 break;
407 case EUndegroundEntranceState.OPENING_G:
409 break;
410 case EUndegroundEntranceState.CLOSING_A:
412 break;
413 case EUndegroundEntranceState.CLOSING_B:
415 break;
416 case EUndegroundEntranceState.CLOSING_C:
417 m_NavmeshTimer = new Timer();
418 m_NavmeshTimer.Run(3, this, "NavmeshUpdate", NULL, true);
419 m_AnimTimerDoorServer.Run(0, this, "OnUpdateServer", "OnFinishedTimerServer", AdjustTime(GetOpeningTime()),false, /*1/ AdjustTime(1)*/ 1);
421 break;
422 case EUndegroundEntranceState.CLOSING_D:
424 m_NavmeshTimer = null;
426 break;
427 case EUndegroundEntranceState.CLOSING_E:
429 break;
430 case EUndegroundEntranceState.CLOSING_F:
432 break;
433 case EUndegroundEntranceState.CLOSING_G:
435 break;
436 }
437 }
438
440 {
441 vector pos;
442 if (MemoryPointExists("SirenLightPos"))
443 {
444 pos = GetMemoryPointPos("SirenLightPos");
445 pos = ModelToWorld(pos);
446 }
447 else
448 {
449 ErrorEx("GetLightPosition could not locate memory point 'SirenLightPos'");
450 }
451 return pos;
452 }
453
455 {
456 if (eff == m_DoorMovementSoundIn)
457 {
458 PlaySoundSetAtMemoryPointLooped(m_DoorMovementSoundLoop, DOORMOVING_SOUNDSET_LOOP, "DoorEngineSoundPos");
460 }
461 else if (eff == m_DoorEngineSoundIn)
462 {
463 PlaySoundSetAtMemoryPointLooped(m_DoorEngineSoundLoop, ENGINE_SOUNDSET_LOOP, "DoorEngineSoundPos");
464 m_DoorEngineSoundIn = null;
465 }
466 }
467
468 //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
469 //we can prevent such effects from playing by checking for IsInitDoorStateSync(), but that seems unnecessary as the issue is really small
471 {
472 //Print("HandleAudioVisualPlayback " + newState + ", " + prevState);
473 //opening
475 {
476 PlaySoundSetAtMemoryPointLooped(m_SirenSound, SIREN_SOUNDSET, "SirenSoundPos",0.5,0.5);
477 }
478 if (newState == EUndegroundEntranceState.OPENING_B)
479 {
480 if (prevState == EUndegroundEntranceState.OPENING_A)//if they connected already during B, do not play the in
481 {
482 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundIn, ENGINE_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
484 m_DoorEngineSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
485 }
486 }
487
489 {
490 if (!m_DoorEngineSoundLoop && !m_DoorEngineSoundIn)//missed playing of the IN soundset which automatically triggers playing of the loop(connected after ?)
491 {
492 PlaySoundSetAtMemoryPointLooped(m_DoorEngineSoundLoop, ENGINE_SOUNDSET_LOOP, "DoorEngineSoundPos");
493 }
494 }
495 if (newState == EUndegroundEntranceState.OPENING_C)
496 {
497 PlaySoundSetAtMemoryPoint(m_LockingSound, LOCKING_SOUNDSET, "DoorEngineSoundPos");
498 }
499 if (newState == EUndegroundEntranceState.OPENING_D)
500 {
501 if (prevState == EUndegroundEntranceState.OPENING_C)//if they connected already during C, do not play the in
502 {
503 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundIn, DOORMOVING_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
505 m_DoorMovementSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
506 }
507 else if (!m_DoorMovementSoundIn && !m_DoorMovementSoundLoop)//missed playing of the IN soundset which automatically triggers playing of the loop(connected after ?)
508 {
509 PlaySoundSetAtMemoryPointLooped(m_DoorMovementSoundLoop, DOORMOVING_SOUNDSET_LOOP, "DoorEngineSoundPos");
510 }
511 }
512
513 if (newState == EUndegroundEntranceState.OPENING_E)
514 {
515 StopSoundSet(m_DoorMovementSoundLoop);
516 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundOut, DOORMOVING_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
517 }
518 if (newState == EUndegroundEntranceState.OPENING_F)
519 {
520 StopSoundSet(m_DoorEngineSoundLoop);
521 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundOut, ENGINE_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
522 }
523 if (newState == EUndegroundEntranceState.OPENING_G)
524 {
525 StopSoundSet(m_SirenSound);
526 }
527
528 //closing
530 {
531 PlaySoundSetAtMemoryPointLooped(m_SirenSound, SIREN_SOUNDSET, "SirenSoundPos",0.5,0.5);
532 }
534 {
535 if (prevState == EUndegroundEntranceState.CLOSING_A)//if they connected already during B, do not play the in
536 {
537 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundIn, ENGINE_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
539 m_DoorEngineSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
540 }
541 }
542 if ( newState == EUndegroundEntranceState.CLOSING_C)
543 {
544 if (prevState == EUndegroundEntranceState.CLOSING_B)//if they connected already during C, do not play the in
545 {
546 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundIn, DOORMOVING_SOUNDSET_LOOP_IN, "DoorEngineSoundPos");
548 m_DoorMovementSoundIn.Event_OnEffectEnded.Insert(SoundEnded);
549 }
550 else if (!m_DoorMovementSoundIn && !m_DoorMovementSoundLoop)//missed playing of the IN soundset which automatically triggers playing of the loop(connected after ?)
551 {
552 PlaySoundSetAtMemoryPointLooped(m_DoorMovementSoundLoop, DOORMOVING_SOUNDSET_LOOP, "DoorEngineSoundPos");
553 }
554 }
555 if (newState == EUndegroundEntranceState.CLOSING_D)
556 {
557 StopSoundSet(m_DoorMovementSoundLoop);
558 PlaySoundSetAtMemoryPoint(m_DoorMovementSoundOut, DOORMOVING_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
559 }
560 if (newState == EUndegroundEntranceState.CLOSING_E)
561 {
562 PlaySoundSetAtMemoryPoint(m_LockingSound, LOCKING_SOUNDSET, "DoorEngineSoundPos");
563 }
564 if (newState == EUndegroundEntranceState.CLOSING_F)
565 {
566 StopSoundSet(m_DoorEngineSoundLoop);
567 PlaySoundSetAtMemoryPoint(m_DoorEngineSoundOut, ENGINE_SOUNDSET_LOOP_OUT, "DoorEngineSoundPos");
568 }
569 if (newState == EUndegroundEntranceState.CLOSING_G || newState == EUndegroundEntranceState.CLOSED)
570 {
571 StopSoundSet(m_SirenSound);
572 }
573 }
574
575 override void OnUpdateClient(float timeSlice)
576 {
577 SetAnimationPhaseNow("EntranceDoor",m_AnimPhase);
578 if (m_AlarmLight)
579 {
580 vector newOri = m_AlarmLight.GetOrientation() + Vector(timeSlice * LIGHT_ROT_SPEED,0,0);
581 m_AlarmLight.SetOrientation(newOri);
582 }
583 }
584
586 {
587 if ( CheckShouldPlayPersistent(EUndegroundEntranceState.OPENING_A, EUndegroundEntranceState.OPENING_F) || CheckShouldPlayPersistent(EUndegroundEntranceState.CLOSING_A, EUndegroundEntranceState.CLOSING_F))
588 {
590 }
591 if ( newState == EUndegroundEntranceState.CLOSING_G || newState == EUndegroundEntranceState.CLOSED || newState == EUndegroundEntranceState.OPENING_G )
592 {
593 if (m_AlarmLight)
594 {
595 m_AlarmLight.Destroy();
596 }
597 }
598 }
599
600}
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition entityai.c:104
AnimationTimer class.
Definition tools.c:651
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition building.c:193
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition building.c:172
Wrapper class for managing sound through SEffectManager.
Definition effectsound.c:5
void Man()
Definition man.c:43
static int GetLastEnumValue(typename e)
Return amount of values in enum.
Definition enconvert.c:660
void House()
Definition building.c:87
Internal ancestor of all Entity implementations.
Definition enentity.c:165
void OnDoorStateChangedServer(EUndegroundEntranceState newState)
void RequestLatentTransition(float time, EUndegroundEntranceState targetState=EUndegroundEntranceState.UNINITIALIZED)
override void EOnPostSimulate(IEntity other, float timeSlice)
ref array< Land_Underground_Panel > m_ConnectedPanels
float AdjustTime(float originalTime, float adjustedTime=-1)
void HandleVisualPlayback(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
void OnDoorStateChangedClient(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
void OnUpdateClient(float timeSlice)
bool CheckShouldPlayPersistent(EUndegroundEntranceState state, EUndegroundEntranceState lastValidState)
EUndegroundEntranceState m_DoorStatePrev
void SetDoorStateServer(EUndegroundEntranceState newState)
void GetConnectedPanels(array< Land_Underground_Panel > panels)
void HandleAudioPlayback(EUndegroundEntranceState newState, EUndegroundEntranceState prevState)
Base Param Class with no parameters.
Definition param.c:12
Manager class for managing Effect (EffectParticle, EffectSound).
static bool DestroySound(EffectSound sound_effect)
Legacy, backwards compatibility.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3942
EActions
Definition eactions.c:2
void Effect()
ctor
Definition effect.c:72
void EntranceLight()
Serializer ParamsReadContext
Definition gameplay.c:15
enum ShapeType ErrorEx
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition enentity.c:45
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
const int SAT_DEBUG_ACTION
Definition constants.c:457
proto void Insert(int index, string input)
Inserts a string into the n-th index, increasing the string length by the size of the input.
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
enum EUndegroundEntranceState AlarmLight()
const string ENGINE_SOUNDSET_LOOP_IN
const string LOCKING_SOUNDSET
vector GetLightPosition()
AlarmLight m_AlarmLight
enum EUndegroundEntranceState MAIN
Land_Underground_EntranceBase m_SirenSound
EffectSound m_DoorEngineSoundIn
const string DOORMOVING_SOUNDSET_LOOP
EffectSound m_DoorMovementSoundLoop
const string DOORMOVING_SOUNDSET_LOOP_OUT
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
const string SIREN_SOUNDSET
void Land_Underground_Panel()
string GetDebugText()