DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Land_Underground_WaterReservoir.c
См. документацию.
2{
4 float Duration;
5
6 void WaterLevelSettings(int pWaterLevel, float pDuration)
7 {
8 WaterLevel = pWaterLevel;
9 Duration = pDuration;
10 }
11}
12
14{
16 float Duration;
17
18 void PressureLevelSettings(int pPressureLevel, float pDuration)
19 {
20 PressureLevel = pPressureLevel;
21 Duration = pDuration;
22 }
23}
24
30
32{
33 protected const string OBJECT_NAME_WATER_PLANE = "Land_Underground_WaterReservoir_Water";
34
35 protected const int WL_MIN = 0;
36 protected const int WL_ABOVE_PIPES = 1;
37 protected const int WL_AVERAGE = 2;
38 protected const int WL_MAX = 3;
39
40 protected const int PL_MIN = 0;
41 protected const int PL_AVERAGE = 1;
42 protected const int PL_MAX = 2;
43
44 protected const int VALVES_COUNT = 2;
45 protected const int VALVE_INDEX_DRAIN = 0;
46 protected const int VALVE_INDEX_FILL = 1;
47
48 protected const int PIPES_BROKEN_COUNT = 2;
49 protected const int PIPE_INDEX_BROKEN1 = 0;
50 protected const int PIPE_INDEX_BROKEN2 = 1;
51
52 protected const string ANIM_PHASE_VALVE_GAUGE_DRAIN = "ValveGauge1";
53 protected const string ANIM_PHASE_VALVE_GAUGE_FILL = "ValveGauge2";
54 protected const string ANIM_PHASE_VALVE_DRAIN = "Valve1";
55 protected const string ANIM_PHASE_VALVE_FILL = "Valve2";
56 protected const string VALVE_NAME_DRAIN = "valve1";
57 protected const string VALVE_NAME_FILL = "valve2";
58 protected const string PIPE_NAME_BROKEN1 = "pipe_broken_1";
59 protected const string PIPE_NAME_BROKEN2 = "pipe_broken_2";
60 protected const string PIPE_NAME_LEAKING_DRAIN = "pipe_leaking_1";
61 protected const string PIPE_NAME_LEAKING_FILL = "pipe_leaking_2";
62
63 protected const string SOUND_NAME_PIPE_CREAKING = "WaterObjectUndergroundPipeCreaking_SoundSet";
64 protected const string SOUND_NAME_VALVE_MANIPULATION = "WaterObjectUndergroundValve_SoundSet";
65 protected const string SOUND_NAME_PIPE_SPRINKLING_START = "WaterObjectUndergroundPipeSprinkling_Start_SoundSet";
66 protected const string SOUND_NAME_PIPE_SPRINKLING_END = "WaterObjectUndergroundPipeSprinkling_End_SoundSet";
67 protected const string SOUND_NAME_PIPE_SPRINKLING_LOOP1 = "WaterObjectUndergroundPipeSprinkling_Loop1_SoundSet";
68 protected const string SOUND_NAME_PIPE_SPRINKLING_LOOP2 = "WaterObjectUndergroundPipeSprinkling_Loop2_SoundSet";
69 protected const string SOUND_NAME_UPIPE_SPRINKLING_START = "WaterObjectUndergroundUnderwaterPipe_Start_SoundSet";
70 protected const string SOUND_NAME_UPIPE_SPRINKLING_END = "WaterObjectUndergroundUnderwaterPipe_End_SoundSet";
71 protected const string SOUND_NAME_UPIPE_SPRINKLING_LOOP = "WaterObjectUndergroundUnderwaterPipe_Loop_SoundSet";
72 protected const string SOUND_NAME_WATER_FILL_LOOP = "WaterObjectUndergroundUnderwaterFill_Loop_SoundSet";
73 protected const string SOUND_NAME_WATER_DRAIN_LOOP = "WaterObjectUndergroundUnderwaterEmpty_Loop_SoundSet";
74
79
88
94
95 protected static const string WATER_LEVEL_MAX = "water_level_max";
96 protected static const string WATER_LEVEL_AVERAGE = "water_level_average";
97 protected static const string WATER_LEVEL_ABOVE_PIPES = "water_level_above_pipes";
98 protected static const string WATER_LEVEL_MIN = "water_level_min";
99
100 protected const int WATER_LEVELS_COUNT = 4;
107
108 protected int m_ValveStatesPacked;
115 protected int m_WaterLevelActual;
116 protected int m_WaterLevelPrev;
121 protected int m_LastActiveValve;
122
126
131
134
135 protected bool m_PipeUnderwaterSoundRunning
137
139
140 protected const int PIPE_CREAKING_MIN_TIME_DELAY_MS = 10000;
141 protected const int PIPE_CREAKING_MAX_TIME_DELAY_MS = 15000;
142 protected const int PIPE_CREAKING_SOUND_LOCATIONS_COUNT = 4;
144 "pipe_creaking_sound_pos_1",
145 "pipe_creaking_sound_pos_2",
146 "pipe_creaking_sound_pos_3",
147 "pipe_creaking_sound_pos_4"
148 };
149
152
153
155 private const float TEMP_HOTIX_TIMESLICE = 0.01;
156
158 {
159 SetEventMask(EntityEvent.POSTSIMULATE);
160
161 Init();
162 }
163
165 {
168
170 {
171 m_TempHotfixTimer.Stop();
172 m_TempHotfixTimer = null;
173 }
174 }
175
176 override void EOnPostSimulate(IEntity other, float timeSlice)
177 {
178 #ifndef SERVER
179 #ifndef NO_GUI
182 #endif
183 #endif
184
185 if (!g_Game.IsServer())
186 {
187 return;
188 }
189
190 int valve;
191 float waterHeight, pressureLevel;
192 WaterLevelSettings wlStageSettings, wlStageSettingsPrev;
193 PressureLevelSettings plStageSettings, plStageSettingsPrev;
194
197 for (valve = 0; valve < VALVES_COUNT; ++valve)
198 {
199 if (m_LastActiveValve != INDEX_NOT_FOUND && m_LastActiveValve != valve && m_ValveStates[valve] == true)
200 {
201 wlStageSettings = ActualWaterLevelStageSettings(valve);
204 m_WaterLevelSnapshot.RemainingDuration = Math.Clamp(wlStageSettings.Duration - m_WaterLevelTimesAccumulated[valve], 0, wlStageSettings.Duration);
205 m_ValveStates[valve] = false;
206 m_PressureDeanimationRequests[valve] = true;
207 break;
208 }
209 }
210
212 for (valve = 0; valve < VALVES_COUNT; ++valve)
213 {
214 if (m_ValveStates[valve] == true)
215 {
216 wlStageSettingsPrev = PreviousWaterLevelStageSettings(valve);
217 wlStageSettings = ActualWaterLevelStageSettings(valve);
218
220 if (wlStageSettings.Duration == -1.0)
221 {
222 m_ValveStates[valve] = false;
226 return;
227 }
228
229 float adjustedWaterHeight = WaterLevelToHeight(wlStageSettingsPrev.WaterLevel);
230 float adjustedDuration = wlStageSettings.Duration;
232 {
233 adjustedWaterHeight = m_WaterLevelSnapshot.WaterHeight;
234 adjustedDuration = wlStageSettings.Duration + m_WaterLevelSnapshot.RemainingDuration;
235 }
236
237 if (m_WaterLevelTimesAccumulated[valve] <= adjustedDuration)
238 {
239 float start = adjustedWaterHeight;
240 float target = WaterLevelToHeight(wlStageSettings.WaterLevel);
241 waterHeight = Math.Lerp(start, target, Easing.EaseInOutSine(m_WaterLevelTimesAccumulated[valve] / adjustedDuration));
242 SetWaterLevelHeight(waterHeight);
243 }
244 else
245 {
249 SetSynchDirty();
250 }
252 }
253 else
254 {
257 }
258 }
259
260 int allValvesStates = 0;
261
263 for (valve = 0; valve < VALVES_COUNT; ++valve)
264 {
265 if (m_PressureAnimationRequests[valve] == true)
266 {
267 bool hasToBeDeanimated = m_PressureAnimationRequests[valve] == m_PressureDeanimationRequests[valve];
268 plStageSettingsPrev = PreviousPressureLevelStageSettings(valve, hasToBeDeanimated);
269 plStageSettings = ActualPressureLevelStageSettings(valve, hasToBeDeanimated);
270
272 if (plStageSettings.Duration == -1.0)
273 {
275 m_PressureAnimationRequests[valve] = false;
277 return;
278 }
279
280 if (m_PressureTimesAccumulated[valve] <= plStageSettings.Duration)
281 {
282 float plStart = PressureLevelToValue(plStageSettingsPrev.PressureLevel);
283 float plTarget = PressureLevelToValue(plStageSettings.PressureLevel);
284 pressureLevel = Math.Lerp(plStart, plTarget, m_PressureTimesAccumulated[valve] / plStageSettings.Duration);
285 SetValvePressureLevelGauge(valve, pressureLevel);
286 }
287 else
288 {
291 if (hasToBeDeanimated && IsValvePressureLevelGaugeAtBase(valve))
292 {
293 m_PressureDeanimationRequests[valve] = false;
295 }
296 else
297 {
299 SetSynchDirty();
300 }
301 }
302
304 }
305 else
306 {
308 }
309
310
311 allValvesStates += m_PressureAnimationRequests[valve];
312 if (allValvesStates == false)
313 {
315 }
316 }
317 }
318
331
332 override void SetActions()
333 {
334 super.SetActions();
335
337 }
338
340 {
341 return true;
342 }
343
344 protected void Init()
345 {
360
363
367
371
373 int i = 0;
374 for (i = 0; i < VALVES_COUNT; ++i)
375 {
376 m_ValveNames.Insert("none");
377 m_ValveStates.Insert(false);
378 m_PressureAnimationRequests.Insert(false);
379 m_PressureDeanimationRequests.Insert(false);
382 m_PipeSounds.Insert(null);
383 m_ValveParticles.Insert(null);
384 }
385
386 for (i = 0; i < PIPES_BROKEN_COUNT; ++i)
387 {
388 m_PipeBrokenParticles.Insert(null);
389 }
390
391 RegisterNetSyncVariableInt("m_ValveStatesPacked", 0);
392 RegisterNetSyncVariableInt("m_ValveManipulatedIndex", -1, VALVES_COUNT - 1);
393 RegisterNetSyncVariableInt("m_WaterLevelActual", WL_MIN, WL_MAX);
394 RegisterNetSyncVariableInt("m_WaterLevelPrev", WL_MIN, WL_MAX);
395
396 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(LateInit, 250);
397
399 m_TempHotfixTimer = new Timer();
400 m_TempHotfixTimer.Run(TEMP_HOTIX_TIMESLICE, this, "EOnPostSimulate", null, true);
401 }
402
424
426 {
432
438
442
448
454
458 }
459
460 override bool IsValveTurnable(int pValveIndex)
461 {
462 return !IsValveActive(pValveIndex) && IsValvePressureLevelGaugeAtBase(pValveIndex);
463 }
464
465 protected bool IsAnyValveActive()
466 {
467 for (int i = 0; i < m_ValveStates.Count(); ++i)
468 {
469 if (m_ValveStates[i])
470 {
471 return true;
472 }
473 }
474
475 return false;
476 }
477
478 protected bool IsValveActive(int pValveIndex)
479 {
480 return pValveIndex >= 0 && pValveIndex <= VALVES_COUNT && m_ValveStates[pValveIndex];
481 }
482
483 override int GetTurnableValveIndex(int pComponentIndex)
484 {
485 string targetedValveName = GetActionComponentName(pComponentIndex);
486 for (int i = 0; i < m_ValveNames.Count(); ++i)
487 {
488 if (m_ValveNames[i] == targetedValveName)
489 {
490 return i;
491 }
492 }
493
494 return INDEX_NOT_FOUND;
495 }
496
497 void OnValveManipulationStart(int pValveIndex)
498 {
499 if (g_Game.IsServer())
500 {
501 AnimateValve(pValveIndex, 1);
502 m_ValveManipulatedIndex = pValveIndex;
503 SetSynchDirty();
504 }
505 }
506
507 void OnValveManipulationEnd(int pValveIndex)
508 {
509 if (g_Game.IsServer())
510 {
511 switch (pValveIndex)
512 {
514 m_ValveStates[pValveIndex] = true;
515 m_PressureAnimationRequests[pValveIndex] = true;
518 SetLastActiveValve(pValveIndex);
519 AnimateValve(pValveIndex, 0);
520 break;
521 case VALVE_INDEX_FILL:
522 m_ValveStates[pValveIndex] = true;
523 m_PressureAnimationRequests[pValveIndex] = true;
526 AnimateValve(pValveIndex, 0);
527 SetLastActiveValve(pValveIndex);
528 break;
529 }
530
532 }
533 }
534
535 void OnValveManipulationCanceled(int pValveIndex)
536 {
537 if (g_Game.IsServer())
538 {
539 AnimateValve(pValveIndex, 0);
541 SetSynchDirty();
542 }
543 }
544
548 {
549 vector posPoint, dirPoint = vector.Zero;
550
551 switch (pValveIndex)
552 {
554 posPoint = GetMemoryPointPosition(string.Format("%1_align_pos", VALVE_NAME_DRAIN));
555 dirPoint = GetMemoryPointPosition(string.Format("%1_align_dir", VALVE_NAME_DRAIN));
556 break;
557 case VALVE_INDEX_FILL:
558 posPoint = GetMemoryPointPosition(string.Format("%1_align_pos", VALVE_NAME_FILL));
559 dirPoint = GetMemoryPointPosition(string.Format("%1_align_dir", VALVE_NAME_FILL));
560 break;
561 }
562
563 array<vector> valvePositions = new array<vector>();
564 valvePositions.Insert(posPoint);
565 valvePositions.Insert(dirPoint);
566
567 return valvePositions;
568 }
569
570 protected void SetLastActiveValve(int pValveIndex)
571 {
572 m_LastActiveValve = pValveIndex;
573 }
574
575 protected void SetWaterLevelHeight(float pHeight)
576 {
577 if (g_Game && g_Game.IsServer())
578 {
580 m_WaterLevelHeightActual = pHeight;
582
584 {
585 m_SpawnedWaterObject.SetPosition(pos);
586 }
587 }
588 }
589
590 protected void RegisterValve(string pCompName, int pIndex)
591 {
592 m_ValveNames.Set(pIndex, pCompName);
593 m_ValveStates.Set(pIndex, false);
594 m_PressureAnimationRequests.Set(pIndex, 0);
595 m_PressureDeanimationRequests.Set(pIndex, 0);
596 m_WaterLevelTimesAccumulated.Set(pIndex, 0);
597 m_PressureTimesAccumulated.Set(pIndex, false);
598 m_PipeSounds.Set(pIndex, null);
599 }
600
602 {
604 for (int i = 0; i < WATER_LEVELS_COUNT; ++i)
605 {
606 if (MemoryPointExists(WATER_LEVELS[i]))
607 {
608 if (!m_WaterLevelsAvailable.Contains(WATER_LEVELS[i]))
609 {
610 m_WaterLevelsAvailable.Insert(WATER_LEVELS[i], ModelToWorld(GetMemoryPointPos(WATER_LEVELS[i])));
611 }
612 }
613 }
614 }
615
616 protected float WaterLevelToHeight(int pWaterLevel)
617 {
618 switch (pWaterLevel)
619 {
620 case WL_MIN:
622 case WL_ABOVE_PIPES:
624 case WL_AVERAGE:
626 case WL_MAX:
628 }
629
630 return 0;
631 }
632
633 protected int HeightToWaterLevel(float pHeight)
634 {
635 if (pHeight <= m_WaterLevelsAvailable[WATER_LEVEL_MIN][1])
636 {
637 return WL_MIN;
638 }
640 {
641 return WL_ABOVE_PIPES;
642 }
644 {
645 return WL_AVERAGE;
646 }
648 {
649 return WL_AVERAGE;
650 }
651
652 return WL_MAX;
653 }
654
655 protected float PressureLevelToValue(int pPressureLevel)
656 {
657 switch (pPressureLevel)
658 {
659 case PL_MIN:
660 return 0.0;
661 case PL_AVERAGE:
662 return 0.5;
663 case PL_MAX:
664 return 1.0;
665 }
666
667 return 0.0;
668 }
669
671 {
672 WaterLevelSettings wlStageSettings;
673
674 switch (pValveIndex)
675 {
678 {
680 }
681 else
682 {
684 }
685 break;
686 case VALVE_INDEX_FILL:
688 {
690 }
691 else
692 {
694 }
695 break;
696 }
697
698 m_WaterLevelPrev = wlStageSettings.WaterLevel;
699 SetSynchDirty();
700
701 return wlStageSettings;
702 }
703
705 {
706 WaterLevelSettings wlStageSettings;
707
708 switch (pValveIndex)
709 {
712 break;
713 case VALVE_INDEX_FILL:
715 break;
716 }
717
718 return wlStageSettings;
719 }
720
721 protected void AdvanceToNextWaterLevelStageSettings(int pValveIndex)
722 {
723 switch (pValveIndex)
724 {
727 {
729 }
730 else
731 {
733 }
734 break;
735 case VALVE_INDEX_FILL:
737 {
739 }
740 else
741 {
743 }
744 break;
745 }
746 }
747
748 protected PressureLevelSettings PreviousPressureLevelStageSettings(int pValveIndex, bool pDeanimationRequest = false)
749 {
750 PressureLevelSettings plStageSettings;
751
752 switch (pValveIndex)
753 {
755 if (pDeanimationRequest)
756 {
757 plStageSettings = m_FillValvePressureDeanimationSettings[0];
758 return plStageSettings;
759 }
760
762 {
764 }
765 else
766 {
768 }
769 break;
770 case VALVE_INDEX_FILL:
771 if (pDeanimationRequest)
772 {
773 plStageSettings = m_FillValvePressureDeanimationSettings[0];
774 return plStageSettings;
775 }
776
778 {
780 }
781 else
782 {
784 }
785 break;
786 }
787
788 return plStageSettings;
789 }
790
791 protected PressureLevelSettings ActualPressureLevelStageSettings(int pValveIndex, bool pDeanimationRequest = false)
792 {
793 PressureLevelSettings plStageSettings;
794
795 switch (pValveIndex)
796 {
798 if (pDeanimationRequest)
799 {
800 plStageSettings = m_DrainValvePressureDeanimationSettings[1];
801 return plStageSettings;
802 }
803
805 break;
806 case VALVE_INDEX_FILL:
807 if (pDeanimationRequest)
808 {
809 plStageSettings = m_FillValvePressureDeanimationSettings[1];
810 return plStageSettings;
811 }
812
814 break;
815 }
816
817 return plStageSettings;
818 }
819
820 protected void AdvanceToNextPressureLevelStageSettings(int pValveIndex)
821 {
822 switch (pValveIndex)
823 {
826 {
828 }
829 else
830 {
832 }
833 break;
834 case VALVE_INDEX_FILL:
836 {
838 }
839 else
840 {
842 }
843 break;
844 }
845 }
846
847 protected void SetDefaultPressureLevelStageSettings(int pValveIndex)
848 {
849 switch (pValveIndex)
850 {
853 break;
854 case VALVE_INDEX_FILL:
856 break;
857 }
858 }
859
860 protected void AnimateValve(int pValveIndex, float pPhase)
861 {
862 switch (pValveIndex)
863 {
865 SetAnimationPhase(ANIM_PHASE_VALVE_DRAIN, pPhase);
866 break;
867 case VALVE_INDEX_FILL:
868 SetAnimationPhase(ANIM_PHASE_VALVE_FILL, pPhase);
869 break;
870 }
871 }
872
873 protected void SetValvePressureLevelGauge(int pValveIndex, float pValue)
874 {
875 switch (pValveIndex)
876 {
878 SetAnimationPhase(ANIM_PHASE_VALVE_GAUGE_DRAIN, pValue);
879 break;
880 case VALVE_INDEX_FILL:
881 SetAnimationPhase(ANIM_PHASE_VALVE_GAUGE_FILL, pValue);
882 break;
883 }
884 }
885
886 protected float GetValvePressureLevelGauge(int pValveIndex)
887 {
888 switch (pValveIndex)
889 {
891 return GetAnimationPhase(ANIM_PHASE_VALVE_GAUGE_DRAIN);
892 break;
893 case VALVE_INDEX_FILL:
894 return GetAnimationPhase(ANIM_PHASE_VALVE_GAUGE_FILL);
895 break;
896 }
897
898 return 0;
899 }
900
901 protected bool IsValvePressureLevelGaugeAtBase(int pValveIndex)
902 {
903 switch (pValveIndex)
904 {
906 return GetValvePressureLevelGauge(pValveIndex) <= 0.01;
907 break;
908 case VALVE_INDEX_FILL:
909 return GetValvePressureLevelGauge(pValveIndex) >= 0.99;
910 break;
911 }
912
913 return 0.0;
914 }
915
916 protected float AdjustTime(float originalTime)
917 {
918 #ifdef DIAG_DEVELOPER
919 float timeAccel = 1;
920 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.UNDERGROUND_RESERVOIR))
921 {
922 timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
923 return originalTime * timeAccel;
924 }
925 #endif
926 return originalTime;
927 }
928
929 protected vector GetMemoryPointPosition(string pMemoryPoint)
930 {
931 vector pos = vector.Zero;
932
933 if (MemoryPointExists(pMemoryPoint))
934 {
935 pos = GetMemoryPointPos(pMemoryPoint);
936 pos = ModelToWorld(pos);
937 }
938 else
939 {
940 ErrorEx(string.Format("Memory point %1 not found, falling back to vector.Zero", pMemoryPoint));
941 }
942
943 return pos;
944 }
945
953
966
968 {
969 if (IsAnyValveActive())
970 {
972 {
975 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(PlayPipeCreakingSoundOnLocation, randomDelay, false);
976 }
977 }
978 else
979 {
981 {
982 StopSoundSet(m_PipeCreakingSounds);
984 }
985 }
986 }
987
989 {
990 if (!m_PipeSounds || m_PipeSounds.Count() == 0)
991 {
992 return;
993 }
994
995 EffectSound snd;
996
997 EffectSound sndDrain, sndFill;
998 float drainPressureLevel = GetValvePressureLevelGauge(VALVE_INDEX_DRAIN);
999 if (drainPressureLevel >= 0.4 && drainPressureLevel < 0.8)
1000 {
1001 if (m_PipeSounds[VALVE_INDEX_DRAIN] == null)
1002 {
1003 PlaySoundSetAtMemoryPoint(sndDrain, SOUND_NAME_PIPE_SPRINKLING_START, VALVE_NAME_DRAIN, false, 0.0, 0.5);
1004 m_PipeSounds[VALVE_INDEX_DRAIN] = sndDrain;
1006 StopSoundSet(snd);
1008 PlaySoundSetAtMemoryPointLooped(sndDrain, SOUND_NAME_PIPE_SPRINKLING_LOOP1, VALVE_NAME_DRAIN, 0.5, 0.5);
1009 m_PipeSounds[VALVE_INDEX_DRAIN] = sndDrain;
1010 }
1011 }
1012
1013 if (drainPressureLevel < 0.4)
1014 {
1015 if (m_PipeSounds[VALVE_INDEX_DRAIN] != null)
1016 {
1018 StopSoundSet(snd);
1020 }
1021 }
1022
1024
1025 float fillPressureLevel = GetValvePressureLevelGauge(VALVE_INDEX_FILL);
1026 if (fillPressureLevel >= 0.4)
1027 {
1028 if (m_PipeSounds[VALVE_INDEX_FILL] == null)
1029 {
1030 PlaySoundSetAtMemoryPoint(sndFill, SOUND_NAME_PIPE_SPRINKLING_START, VALVE_NAME_FILL, false, 0.0, 0.5);
1032 StopSoundSet(snd);
1034 PlaySoundSetAtMemoryPointLooped(sndFill, SOUND_NAME_PIPE_SPRINKLING_LOOP2, VALVE_NAME_FILL, 0.5, 0.5);
1035 m_PipeSounds[VALVE_INDEX_FILL] = sndFill;
1036 }
1037 }
1038
1039 if (fillPressureLevel < 0.4)
1040 {
1041 if (m_PipeSounds[VALVE_INDEX_FILL] != null)
1042 {
1044 StopSoundSet(snd);
1046 }
1047 }
1048 }
1049
1051 {
1054 {
1056 {
1057 if (m_PipeUnderwaterSound == null)
1058 {
1059 PlaySoundSetAtMemoryPoint(m_PipeUnderwaterSound, SOUND_NAME_UPIPE_SPRINKLING_START, PIPE_NAME_BROKEN1, false, 0.0, 0.5);
1060 StopSoundSet(m_PipeUnderwaterSound);
1061 m_PipeUnderwaterSound = null;
1062 m_PipeUnderwaterSoundRunning = PlaySoundSetAtMemoryPointLooped(m_PipeUnderwaterSound, SOUND_NAME_UPIPE_SPRINKLING_LOOP, PIPE_NAME_BROKEN1, 0.0, 0.5);
1063 }
1064 }
1066 {
1068 {
1069 StopSoundSet(m_PipeUnderwaterSound);
1070 if (m_PipeUnderwaterSoundRunning)
1071 {
1072 PlaySoundSetAtMemoryPoint(m_PipeUnderwaterSound, SOUND_NAME_UPIPE_SPRINKLING_END, PIPE_NAME_BROKEN1, false, 0.0, 0.5);
1073 m_PipeUnderwaterSoundRunning = false;
1074 }
1075 }
1076 }
1077 }
1078 }
1079
1081 {
1083 {
1084 if (m_WaterLevelMovementSound == null)
1085 {
1086 PlaySoundSetAtMemoryPointLooped(m_WaterLevelMovementSound, SOUND_NAME_WATER_DRAIN_LOOP, PIPE_NAME_BROKEN1, 0.0, 0.5);
1087 }
1088 }
1090 {
1091 if (m_WaterLevelMovementSound == null)
1092 {
1093 PlaySoundSetAtMemoryPointLooped(m_WaterLevelMovementSound, SOUND_NAME_WATER_FILL_LOOP, PIPE_NAME_BROKEN1, 0.0, 0.5);
1094 }
1095 }
1097 {
1099 {
1100 StopSoundSet(m_WaterLevelMovementSound);
1101 }
1102 }
1103 }
1104
1110
1117
1118 protected void HandleVisualEffects()
1119 {
1121 {
1123 {
1125 }
1126 }
1127
1129 {
1131 {
1132 m_ValveParticles[VALVE_INDEX_DRAIN].StopParticle();
1134 }
1135 }
1136
1138 {
1140 {
1142 }
1143 }
1144
1146 {
1148 {
1149 m_ValveParticles[VALVE_INDEX_FILL].StopParticle();
1151 }
1152 }
1153
1154
1157 {
1159 {
1161 {
1163 }
1164
1167 {
1170 }
1171 }
1172 }
1173
1176 {
1178 {
1180 }
1181 }
1182
1184 {
1185 for (int pipe = 0; pipe < m_PipeBrokenParticles.Count(); ++pipe)
1186 {
1187 if (m_PipeBrokenParticles[pipe])
1188 {
1189 m_PipeBrokenParticles[pipe].StopParticle();
1190 m_PipeBrokenParticles[pipe] = null;
1191 }
1192 }
1193 }
1194 }
1195
1196 protected void CleanVisualEffects()
1197 {
1198 for (int valve = 0; valve < VALVES_COUNT; ++valve)
1199 {
1200 if (m_ValveParticles[valve])
1201 {
1202 m_ValveParticles[valve].StopParticle();
1203 m_ValveParticles[valve] = null;
1204 }
1205 }
1206
1207 for (int pipe = 0; pipe < m_PipeBrokenParticles.Count(); ++pipe)
1208 {
1209 if (m_PipeBrokenParticles[pipe])
1210 {
1211 m_PipeBrokenParticles[pipe].StopParticle();
1212 m_PipeBrokenParticles[pipe] = null;
1213 }
1214 }
1215 }
1216
1217
1218
1241
1242 protected void SyncValveVariables()
1243 {
1244 if (g_Game)
1245 {
1248 {
1250 SetSynchDirty();
1251 }
1252 }
1253 }
1254
1256 {
1257 int packedBits = 0;
1258
1259 for (int i = 0; i < pStates.Count(); ++i)
1260 {
1261 if (pStates[i] == true)
1262 {
1263 packedBits |= 1 << i;
1264 }
1265 }
1266
1267 return packedBits;
1268 }
1269
1270 protected array<bool> UnpackBitsToArrayOfBoolStates(int pPackedBits, int pArrayLength)
1271 {
1272 array<bool> unpackedBools = new array<bool>();
1273 for (int i = 0; i < pArrayLength; ++i)
1274 {
1275 if ((pPackedBits & 1 << i) != 0)
1276 {
1277 unpackedBools.Insert(true);
1278 }
1279 else
1280 {
1281 unpackedBools.Insert(false);
1282 }
1283 }
1284
1285 return unpackedBools;
1286 }
1287
1288#ifdef DEVELOPER
1289 override protected string GetDebugText()
1290 {
1291 string debug_output = "";
1292 debug_output += string.Format("\nm_WaterLevelActual: %1", m_WaterLevelActual);
1293 debug_output += string.Format("\nm_WaterLevelPrev: %1", m_WaterLevelPrev);
1294 debug_output += string.Format("\nm_ValveManipulatedIndex: %1", m_ValveManipulatedIndex);
1295
1296 int valve;
1297 for (valve = 0; valve < VALVES_COUNT; ++valve)
1298 {
1299 debug_output += string.Format("\nvalve %1 state:%2 | pressure req: %2", valve, m_ValveStates[valve], m_PressureAnimationRequests[valve]);
1300 }
1301
1302 return debug_output;
1303 }
1304
1305 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
1306 {
1307 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SPECIALIZED_ACTION1, "Reset state", FadeColors.LIGHT_GREY));
1308 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SPECIALIZED_ACTION2, "Drain", FadeColors.LIGHT_GREY));
1309 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SPECIALIZED_ACTION3, "Fill", FadeColors.LIGHT_GREY));
1310 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
1311
1312 super.GetDebugActions(outputList);
1313 }
1314
1315 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
1316 {
1317 if (super.OnAction(action_id, player, ctx))
1318 return true;
1319 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
1320 {
1321 if (action_id == EActions.SPECIALIZED_ACTION1)
1322 {
1323 ResetState();
1328 }
1329 else if (action_id == EActions.SPECIALIZED_ACTION2)
1330 {
1331 ResetState();
1337 }
1338 else if (action_id == EActions.SPECIALIZED_ACTION3)
1339 {
1340 ResetState();
1346 SetSynchDirty();
1347 }
1348 }
1349 return false;
1350 }
1351
1352
1353#endif
1354}
1355
Param4< int, int, string, int > TSelectableActionInfoWithColor
void BuildingBase()
ActionTurnValveUndergroundReservoirCB ActionTurnValveCB ActionTurnValveUndergroundReservoir()
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
vector GetOrientation()
Определения AreaDamageManager.c:306
const int ECE_CREATEPHYSICS
Определения CentralEconomy.c:17
override void OnVariablesSynchronized()
Определения ContaminatedArea_Dynamic.c:94
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения DayZAnimal.c:136
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения DayZAnimal.c:125
DayZGame g_Game
Определения DayZGame.c:4074
override Widget Init()
Определения DayZGame.c:127
EActions
Определения EActions.c:2
ref ParticleSourceArray m_PipeBrokenParticles
int m_WaterLevelActual
ref array< ref PressureLevelSettings > m_DrainValvePressureDeanimationSettings
float m_WaterLevelHeightActual
void RegisterValve(string pCompName, int pIndex)
const int PIPE_INDEX_BROKEN1
override void EOnPostSimulate(IEntity other, float timeSlice)
ref ParticleSourceArray m_ValveParticles
const int PL_MAX
ref map< string, vector > m_WaterLevelsAvailable
const string SOUND_NAME_PIPE_SPRINKLING_START
void SetDefaultPressureLevelStageSettings(int pValveIndex)
bool IsValvePressureLevelGaugeAtBase(int pValveIndex)
int m_ValveManipulatedIndexPrev
void HandleSoundEffectsWaterLevelMovementSounds()
const string SOUND_NAME_PIPE_CREAKING
ref array< ref PressureLevelSettings > m_FillValvePressureStageSettings
override bool HasTurnableValveBehavior()
const string ANIM_PHASE_VALVE_GAUGE_FILL
float Duration
const int PARTICLE_FILL_PIPE_JET
PressureLevelSettings ActualPressureLevelStageSettings(int pValveIndex, bool pDeanimationRequest=false)
ref array< ref PressureLevelSettings > m_FillValvePressureDeanimationSettings
ref Timer m_TempHotfixTimer
const string SOUND_NAME_WATER_FILL_LOOP
static const string WATER_LEVEL_MIN
const int PARTICLE_FILL_PIPE_MAX_PRESSURE
ref array< ref WaterLevelSettings > m_DrainValveWaterStageSettings
valve/pipe stages for water and pressure levels
int m_DrainValvePressureLevelStageIndex
ref array< ref WaterLevelSettings > m_FillValveWaterStageSettings
for deanimation purposes
void CleanSoundEffects()
ref EffectSound m_WaterLevelMovementSound
const string VALVE_NAME_FILL
const string WATER_LEVELS[WATER_LEVELS_COUNT]
void PlayPipeCreakingSoundOnLocation()
ref array< bool > m_PressureDeanimationRequests
const string PIPE_NAME_BROKEN1
const string ANIM_PHASE_VALVE_FILL
WaterLevelSettings ActualWaterLevelStageSettings(int pValveIndex)
void OnValveManipulationStart(int pValveIndex)
void SetLastActiveValve(int pValveIndex)
void HandleSoundEffectsUnderwaterPipeSounds()
const string PIPE_NAME_LEAKING_DRAIN
const int VALVES_COUNT
const int PARTICLE_DRAIN_PIPE_MAX_PRESSURE
class WaterLevelSettings PressureLevel
const string SOUND_NAME_PIPE_SPRINKLING_LOOP2
void AdvanceToNextPressureLevelStageSettings(int pValveIndex)
bool m_ValveManipulationSoundRequested
VFX/SFX.
ref array< ref PressureLevelSettings > m_DrainValvePressureStageSettings
const int WL_MAX
const string SOUND_NAME_VALVE_MANIPULATION
const int VALVE_INDEX_DRAIN
const string ANIM_PHASE_VALVE_DRAIN
PressureLevelSettings PreviousPressureLevelStageSettings(int pValveIndex, bool pDeanimationRequest=false)
const string SOUND_NAME_WATER_DRAIN_LOOP
int PackArrayOfBoolStatesIntoBits(array< bool > pStates)
void SetWaterLevelHeight(float pHeight)
void OnValveManipulationEnd(int pValveIndex)
ref array< bool > m_ValveStates
void SetValvePressureLevelGauge(int pValveIndex, float pValue)
ref array< string > m_ValveNames
array< bool > UnpackBitsToArrayOfBoolStates(int pPackedBits, int pArrayLength)
float WaterLevelToHeight(int pWaterLevel)
void Land_Underground_WaterReservoir()
array< vector > GetValveAligningPointsWS(int pValveIndex)
void HandleSoundEffectsPipeCreaking()
ref EffectSound m_ValveManipulationSound
const string PIPE_NAME_LEAKING_FILL
const int WL_MIN
float GetValvePressureLevelGauge(int pValveIndex)
static const string WATER_LEVEL_MAX
const int PIPE_CREAKING_SOUND_LOCATIONS_COUNT
const int PIPE_INDEX_BROKEN2
main broken pipe
void OnValveManipulationCanceled(int pValveIndex)
bool m_PipeCreakingSoundRequested
ref array< float > m_PressureTimesAccumulated
WaterLevelSettings PreviousWaterLevelStageSettings(int pValveIndex)
const int WATER_LEVELS_COUNT
bool IsValveActive(int pValveIndex)
ref array< EffectSound > m_PipeSounds
override bool IsValveTurnable(int pValveIndex)
const int PARTICLE_FILL_PIPE_JET_WEAK
const string PIPE_CREAKING_SOUND_LOCATIONS[PIPE_CREAKING_SOUND_LOCATIONS_COUNT]
static const string WATER_LEVEL_ABOVE_PIPES
void AdvanceToNextWaterLevelStageSettings(int pValveIndex)
const string VALVE_NAME_DRAIN
void HandleSoundEffects()
const int PIPE_CREAKING_MIN_TIME_DELAY_MS
float PressureLevelToValue(int pPressureLevel)
void ~Land_Underground_WaterReservoir()
const int VALVE_INDEX_FILL
void HandleSoundEffectsPipeSprinkling()
const string SOUND_NAME_PIPE_SPRINKLING_LOOP1
ref WaterLevelSnapshot m_WaterLevelSnapshot
for deanimation purposes
int m_DrainValveWaterLevelStageIndex
pointing to specific stage for each valve/pipe
bool IsAnyValveActive()
const int PIPES_BROKEN_COUNT
int m_FillValveWaterLevelStageIndex
override int GetTurnableValveIndex(int pComponentIndex)
const int WL_AVERAGE
float AdjustTime(float originalTime)
const string SOUND_NAME_UPIPE_SPRINKLING_START
const string PIPE_NAME_BROKEN2
void SyncValveVariables()
const string SOUND_NAME_UPIPE_SPRINKLING_END
int m_ValveStatesPackedPrev
const int PL_MIN
int HeightToWaterLevel(float pHeight)
ref array< float > m_WaterLevelTimesAccumulated
void TranslateMemoryPointsToWaterLevels()
int m_ValveManipulatedIndex
int m_FillValvePressureLevelStageIndex
int m_ValveStatesPacked
Object m_SpawnedWaterObject
int m_WaterLevelPrev
void AnimateValve(int pValveIndex, float pPhase)
void ResetState()
ref EffectSound m_PipeUnderwaterSound
ref array< bool > m_PressureAnimationRequests
class WaterLevelSnapshot OBJECT_NAME_WATER_PLANE
const string SOUND_NAME_PIPE_SPRINKLING_END
const int WL_ABOVE_PIPES
const string SOUND_NAME_UPIPE_SPRINKLING_LOOP
ref EffectSound m_PipeCreakingSounds
static const string WATER_LEVEL_AVERAGE
vector m_WaterLevelDefault
int m_LastActiveValve
const string ANIM_PHASE_VALVE_GAUGE_DRAIN
tighter broken pipe
void PlayValveManipulationSound()
void PressureLevelSettings(int pPressureLevel, float pDuration)
void CleanVisualEffects()
const int PIPE_CREAKING_MAX_TIME_DELAY_MS
const float TEMP_HOTIX_TIMESLICE
void ConfigureValvesAndGaugesCourse()
vector GetMemoryPointPosition(string pMemoryPoint)
const int PL_AVERAGE
void HandleVisualEffects()
string GetDebugText()
Определения ModifierBase.c:71
void LateInit()
Определения OutdoorThermometer.c:95
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
array< ParticleSource > ParticleSourceArray
Определения ParticleSource.c:107
static float EaseInOutSine(float t)
Определения Easing.c:14
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Определения Easing.c:3
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения EnEntity.c:165
Определения EnMath.c:7
Определения ObjectTyped.c:2
static const int WATER_JET
Определения ParticleList.c:350
static const int WATER_JET_WEAK
Определения ParticleList.c:351
static const int WATER_SPILLING
Определения ParticleList.c:352
Определения ParticleList.c:12
static bool DestroySound(EffectSound sound_effect)
Legacy, backwards compatibility.
Определения EffectManager.c:441
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
Определения DayZPlayerImplement.c:39
void WaterLevelSettings(int pWaterLevel, float pDuration)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения Transport.c:70
static const vector Zero
Определения EnConvert.c:123
Определения EnConvert.c:119
Keffiyeh_LightBlue SetActions
Определения consumables.c:149
const int INDEX_NOT_FOUND
Определения gameplay.c:13
Serializer ParamsReadContext
Определения gameplay.c:15
enum ShapeType ErrorEx
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:486
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.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8