DayZ 1.27
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
154 {
155 SetEventMask(EntityEvent.POSTSIMULATE);
156
157 Init();
158 }
159
165
166 override void EOnPostSimulate(IEntity other, float timeSlice)
167 {
168 #ifndef SERVER
171 #endif
172
173 if (!GetGame().IsServer())
174 {
175 return;
176 }
177
178 int valve;
179 float waterHeight, pressureLevel;
180 WaterLevelSettings wlStageSettings, wlStageSettingsPrev;
181 PressureLevelSettings plStageSettings, plStageSettingsPrev;
182
185 for (valve = 0; valve < VALVES_COUNT; ++valve)
186 {
187 if (m_LastActiveValve != INDEX_NOT_FOUND && m_LastActiveValve != valve && m_ValveStates[valve] == true)
188 {
189 wlStageSettings = ActualWaterLevelStageSettings(valve);
192 m_WaterLevelSnapshot.RemainingDuration = Math.Clamp(wlStageSettings.Duration - m_WaterLevelTimesAccumulated[valve], 0, wlStageSettings.Duration);
193 m_ValveStates[valve] = false;
194 m_PressureDeanimationRequests[valve] = true;
195 break;
196 }
197 }
198
200 for (valve = 0; valve < VALVES_COUNT; ++valve)
201 {
202 if (m_ValveStates[valve] == true)
203 {
204 wlStageSettingsPrev = PreviousWaterLevelStageSettings(valve);
205 wlStageSettings = ActualWaterLevelStageSettings(valve);
206
208 if (wlStageSettings.Duration == -1.0)
209 {
210 m_ValveStates[valve] = false;
214 return;
215 }
216
217 float adjustedWaterHeight = WaterLevelToHeight(wlStageSettingsPrev.WaterLevel);
218 float adjustedDuration = wlStageSettings.Duration;
220 {
221 adjustedWaterHeight = m_WaterLevelSnapshot.WaterHeight;
222 adjustedDuration = wlStageSettings.Duration + m_WaterLevelSnapshot.RemainingDuration;
223 }
224
225 if (m_WaterLevelTimesAccumulated[valve] <= adjustedDuration)
226 {
227 float start = adjustedWaterHeight;
228 float target = WaterLevelToHeight(wlStageSettings.WaterLevel);
229 waterHeight = Math.Lerp(start, target, Easing.EaseInOutSine(m_WaterLevelTimesAccumulated[valve] / adjustedDuration));
230 SetWaterLevelHeight(waterHeight);
231 }
232 else
233 {
237 SetSynchDirty();
238 }
239
241 }
242 else
243 {
246 }
247 }
248
249 int allValvesStates = 0;
250
252 for (valve = 0; valve < VALVES_COUNT; ++valve)
253 {
254 if (m_PressureAnimationRequests[valve] == true)
255 {
256 bool hasToBeDeanimated = m_PressureAnimationRequests[valve] == m_PressureDeanimationRequests[valve];
257 plStageSettingsPrev = PreviousPressureLevelStageSettings(valve, hasToBeDeanimated);
258 plStageSettings = ActualPressureLevelStageSettings(valve, hasToBeDeanimated);
259
261 if (plStageSettings.Duration == -1.0)
262 {
264 m_PressureAnimationRequests[valve] = false;
266 return;
267 }
268
269 if (m_PressureTimesAccumulated[valve] <= plStageSettings.Duration)
270 {
271 float plStart = PressureLevelToValue(plStageSettingsPrev.PressureLevel);
272 float plTarget = PressureLevelToValue(plStageSettings.PressureLevel);
273 pressureLevel = Math.Lerp(plStart, plTarget, m_PressureTimesAccumulated[valve] / plStageSettings.Duration);
274 SetValvePressureLevelGauge(valve, pressureLevel);
275 }
276 else
277 {
280 if (hasToBeDeanimated && IsValvePressureLevelGaugeAtBase(valve))
281 {
282 m_PressureDeanimationRequests[valve] = false;
284 }
285 else
286 {
288 SetSynchDirty();
289 }
290 }
291
293 }
294 else
295 {
297 }
298
299
300 allValvesStates += m_PressureAnimationRequests[valve];
301 if (allValvesStates == false)
302 {
304 }
305 }
306 }
307
320
321 override void SetActions()
322 {
323 super.SetActions();
324
326 }
327
329 {
330 return true;
331 }
332
333 protected void Init()
334 {
349
352
356
360
362 int i = 0;
363 for (i = 0; i < VALVES_COUNT; ++i)
364 {
365 m_ValveNames.Insert("none");
366 m_ValveStates.Insert(false);
367 m_PressureAnimationRequests.Insert(false);
368 m_PressureDeanimationRequests.Insert(false);
371 m_PipeSounds.Insert(null);
372 m_ValveParticles.Insert(null);
373 }
374
375 for (i = 0; i < PIPES_BROKEN_COUNT; ++i)
376 {
377 m_PipeBrokenParticles.Insert(null);
378 }
379
380 RegisterNetSyncVariableInt("m_ValveStatesPacked", 0);
381 RegisterNetSyncVariableInt("m_ValveManipulatedIndex", -1, VALVES_COUNT - 1);
382 RegisterNetSyncVariableInt("m_WaterLevelActual", WL_MIN, WL_MAX);
383 RegisterNetSyncVariableInt("m_WaterLevelPrev", WL_MIN, WL_MAX);
384
386 }
387
409
411 {
417
423
427
433
439
443 }
444
445 override bool IsValveTurnable(int pValveIndex)
446 {
447 return !IsValveActive(pValveIndex) && IsValvePressureLevelGaugeAtBase(pValveIndex);
448 }
449
450 protected bool IsAnyValveActive()
451 {
452 for (int i = 0; i < m_ValveStates.Count(); ++i)
453 {
454 if (m_ValveStates[i])
455 {
456 return true;
457 }
458 }
459
460 return false;
461 }
462
463 protected bool IsValveActive(int pValveIndex)
464 {
465 return pValveIndex >= 0 && pValveIndex <= VALVES_COUNT && m_ValveStates[pValveIndex];
466 }
467
468 override int GetTurnableValveIndex(int pComponentIndex)
469 {
470 string targetedValveName = GetActionComponentName(pComponentIndex);
471 for (int i = 0; i < m_ValveNames.Count(); ++i)
472 {
473 if (m_ValveNames[i] == targetedValveName)
474 {
475 return i;
476 }
477 }
478
479 return INDEX_NOT_FOUND;
480 }
481
482 void OnValveManipulationStart(int pValveIndex)
483 {
484 if (GetGame().IsServer())
485 {
486 AnimateValve(pValveIndex, 1);
487 m_ValveManipulatedIndex = pValveIndex;
488 SetSynchDirty();
489 }
490 }
491
492 void OnValveManipulationEnd(int pValveIndex)
493 {
494 if (GetGame().IsServer())
495 {
496 switch (pValveIndex)
497 {
499 m_ValveStates[pValveIndex] = true;
500 m_PressureAnimationRequests[pValveIndex] = true;
503 SetLastActiveValve(pValveIndex);
504 AnimateValve(pValveIndex, 0);
505 break;
506 case VALVE_INDEX_FILL:
507 m_ValveStates[pValveIndex] = true;
508 m_PressureAnimationRequests[pValveIndex] = true;
511 AnimateValve(pValveIndex, 0);
512 SetLastActiveValve(pValveIndex);
513 break;
514 }
515
517 }
518 }
519
520 void OnValveManipulationCanceled(int pValveIndex)
521 {
522 if (GetGame().IsServer())
523 {
524 AnimateValve(pValveIndex, 0);
526 SetSynchDirty();
527 }
528 }
529
533 {
534 vector posPoint, dirPoint = vector.Zero;
535
536 switch (pValveIndex)
537 {
539 posPoint = GetMemoryPointPosition(string.Format("%1_align_pos", VALVE_NAME_DRAIN));
540 dirPoint = GetMemoryPointPosition(string.Format("%1_align_dir", VALVE_NAME_DRAIN));
541 break;
542 case VALVE_INDEX_FILL:
543 posPoint = GetMemoryPointPosition(string.Format("%1_align_pos", VALVE_NAME_FILL));
544 dirPoint = GetMemoryPointPosition(string.Format("%1_align_dir", VALVE_NAME_FILL));
545 break;
546 }
547
548 array<vector> valvePositions = new array<vector>();
549 valvePositions.Insert(posPoint);
550 valvePositions.Insert(dirPoint);
551
552 return valvePositions;
553 }
554
555 protected void SetLastActiveValve(int pValveIndex)
556 {
557 m_LastActiveValve = pValveIndex;
558 }
559
560 protected void SetWaterLevelHeight(float pHeight)
561 {
562 if (GetGame() && GetGame().IsServer())
563 {
565 m_WaterLevelHeightActual = pHeight;
567
569 {
570 m_SpawnedWaterObject.SetPosition(pos);
571 }
572 }
573 }
574
575 protected void RegisterValve(string pCompName, int pIndex)
576 {
577 m_ValveNames.Set(pIndex, pCompName);
578 m_ValveStates.Set(pIndex, false);
579 m_PressureAnimationRequests.Set(pIndex, 0);
580 m_PressureDeanimationRequests.Set(pIndex, 0);
581 m_WaterLevelTimesAccumulated.Set(pIndex, 0);
582 m_PressureTimesAccumulated.Set(pIndex, false);
583 m_PipeSounds.Set(pIndex, null);
584 }
585
587 {
589 for (int i = 0; i < WATER_LEVELS_COUNT; ++i)
590 {
591 if (MemoryPointExists(WATER_LEVELS[i]))
592 {
593 if (!m_WaterLevelsAvailable.Contains(WATER_LEVELS[i]))
594 {
595 m_WaterLevelsAvailable.Insert(WATER_LEVELS[i], ModelToWorld(GetMemoryPointPos(WATER_LEVELS[i])));
596 }
597 }
598 }
599 }
600
601 protected float WaterLevelToHeight(int pWaterLevel)
602 {
603 switch (pWaterLevel)
604 {
605 case WL_MIN:
607 case WL_ABOVE_PIPES:
609 case WL_AVERAGE:
611 case WL_MAX:
613 }
614
615 return 0;
616 }
617
618 protected int HeightToWaterLevel(float pHeight)
619 {
620 if (pHeight <= m_WaterLevelsAvailable[WATER_LEVEL_MIN][1])
621 {
622 return WL_MIN;
623 }
625 {
626 return WL_ABOVE_PIPES;
627 }
629 {
630 return WL_AVERAGE;
631 }
633 {
634 return WL_AVERAGE;
635 }
636
637 return WL_MAX;
638 }
639
640 protected float PressureLevelToValue(int pPressureLevel)
641 {
642 switch (pPressureLevel)
643 {
644 case PL_MIN:
645 return 0.0;
646 case PL_AVERAGE:
647 return 0.5;
648 case PL_MAX:
649 return 1.0;
650 }
651
652 return 0.0;
653 }
654
656 {
657 WaterLevelSettings wlStageSettings;
658
659 switch (pValveIndex)
660 {
663 {
665 }
666 else
667 {
669 }
670 break;
671 case VALVE_INDEX_FILL:
673 {
675 }
676 else
677 {
679 }
680 break;
681 }
682
683 m_WaterLevelPrev = wlStageSettings.WaterLevel;
684 SetSynchDirty();
685
686 return wlStageSettings;
687 }
688
690 {
691 WaterLevelSettings wlStageSettings;
692
693 switch (pValveIndex)
694 {
697 break;
698 case VALVE_INDEX_FILL:
700 break;
701 }
702
703 return wlStageSettings;
704 }
705
706 protected void AdvanceToNextWaterLevelStageSettings(int pValveIndex)
707 {
708 switch (pValveIndex)
709 {
712 {
714 }
715 else
716 {
718 }
719 break;
720 case VALVE_INDEX_FILL:
722 {
724 }
725 else
726 {
728 }
729 break;
730 }
731 }
732
733 protected PressureLevelSettings PreviousPressureLevelStageSettings(int pValveIndex, bool pDeanimationRequest = false)
734 {
735 PressureLevelSettings plStageSettings;
736
737 switch (pValveIndex)
738 {
740 if (pDeanimationRequest)
741 {
742 plStageSettings = m_FillValvePressureDeanimationSettings[0];
743 return plStageSettings;
744 }
745
747 {
749 }
750 else
751 {
753 }
754 break;
755 case VALVE_INDEX_FILL:
756 if (pDeanimationRequest)
757 {
758 plStageSettings = m_FillValvePressureDeanimationSettings[0];
759 return plStageSettings;
760 }
761
763 {
765 }
766 else
767 {
769 }
770 break;
771 }
772
773 return plStageSettings;
774 }
775
776 protected PressureLevelSettings ActualPressureLevelStageSettings(int pValveIndex, bool pDeanimationRequest = false)
777 {
778 PressureLevelSettings plStageSettings;
779
780 switch (pValveIndex)
781 {
783 if (pDeanimationRequest)
784 {
785 plStageSettings = m_DrainValvePressureDeanimationSettings[1];
786 return plStageSettings;
787 }
788
790 break;
791 case VALVE_INDEX_FILL:
792 if (pDeanimationRequest)
793 {
794 plStageSettings = m_FillValvePressureDeanimationSettings[1];
795 return plStageSettings;
796 }
797
799 break;
800 }
801
802 return plStageSettings;
803 }
804
805 protected void AdvanceToNextPressureLevelStageSettings(int pValveIndex)
806 {
807 switch (pValveIndex)
808 {
811 {
813 }
814 else
815 {
817 }
818 break;
819 case VALVE_INDEX_FILL:
821 {
823 }
824 else
825 {
827 }
828 break;
829 }
830 }
831
832 protected void SetDefaultPressureLevelStageSettings(int pValveIndex)
833 {
834 switch (pValveIndex)
835 {
838 break;
839 case VALVE_INDEX_FILL:
841 break;
842 }
843 }
844
845 protected void AnimateValve(int pValveIndex, float pPhase)
846 {
847 switch (pValveIndex)
848 {
850 SetAnimationPhase(ANIM_PHASE_VALVE_DRAIN, pPhase);
851 break;
852 case VALVE_INDEX_FILL:
853 SetAnimationPhase(ANIM_PHASE_VALVE_FILL, pPhase);
854 break;
855 }
856 }
857
858 protected void SetValvePressureLevelGauge(int pValveIndex, float pValue)
859 {
860 switch (pValveIndex)
861 {
863 SetAnimationPhase(ANIM_PHASE_VALVE_GAUGE_DRAIN, pValue);
864 break;
865 case VALVE_INDEX_FILL:
866 SetAnimationPhase(ANIM_PHASE_VALVE_GAUGE_FILL, pValue);
867 break;
868 }
869 }
870
871 protected float GetValvePressureLevelGauge(int pValveIndex)
872 {
873 switch (pValveIndex)
874 {
876 return GetAnimationPhase(ANIM_PHASE_VALVE_GAUGE_DRAIN);
877 break;
878 case VALVE_INDEX_FILL:
879 return GetAnimationPhase(ANIM_PHASE_VALVE_GAUGE_FILL);
880 break;
881 }
882
883 return 0;
884 }
885
886 protected bool IsValvePressureLevelGaugeAtBase(int pValveIndex)
887 {
888 switch (pValveIndex)
889 {
891 return GetValvePressureLevelGauge(pValveIndex) <= 0.01;
892 break;
893 case VALVE_INDEX_FILL:
894 return GetValvePressureLevelGauge(pValveIndex) >= 0.99;
895 break;
896 }
897
898 return 0.0;
899 }
900
901 protected float AdjustTime(float originalTime)
902 {
903 #ifdef DIAG_DEVELOPER
904 float timeAccel = 1;
905 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.UNDERGROUND_RESERVOIR))
906 {
907 timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
908 return originalTime * timeAccel;
909 }
910 #endif
911 return originalTime;
912 }
913
914 protected vector GetMemoryPointPosition(string pMemoryPoint)
915 {
916 vector pos = vector.Zero;
917
918 if (MemoryPointExists(pMemoryPoint))
919 {
920 pos = GetMemoryPointPos(pMemoryPoint);
921 pos = ModelToWorld(pos);
922 }
923 else
924 {
925 ErrorEx(string.Format("Memory point %1 not found, falling back to vector.Zero", pMemoryPoint));
926 }
927
928 return pos;
929 }
930
938
951
953 {
954 if (IsAnyValveActive())
955 {
957 {
961 }
962 }
963 else
964 {
966 {
967 StopSoundSet(m_PipeCreakingSounds);
969 }
970 }
971 }
972
974 {
975 if (!m_PipeSounds || m_PipeSounds.Count() == 0)
976 {
977 return;
978 }
979
980 EffectSound sndDrain, sndFill;
981 float drainPressureLevel = GetValvePressureLevelGauge(VALVE_INDEX_DRAIN);
982 if (drainPressureLevel >= 0.4 && drainPressureLevel < 0.8)
983 {
984 if (m_PipeSounds[VALVE_INDEX_DRAIN] == null)
985 {
986 PlaySoundSetAtMemoryPoint(sndDrain, SOUND_NAME_PIPE_SPRINKLING_START, VALVE_NAME_DRAIN, false, 0.0, 0.5);
988 StopSoundSet(m_PipeSounds[VALVE_INDEX_DRAIN]);
990 PlaySoundSetAtMemoryPointLooped(sndDrain, SOUND_NAME_PIPE_SPRINKLING_LOOP1, VALVE_NAME_DRAIN, 0.5, 0.5);
992 }
993 }
994
995 if (drainPressureLevel < 0.4)
996 {
997 if (m_PipeSounds[VALVE_INDEX_DRAIN] != null)
998 {
999 StopSoundSet(m_PipeSounds[VALVE_INDEX_DRAIN]);
1001 }
1002 }
1003
1005
1006 float fillPressureLevel = GetValvePressureLevelGauge(VALVE_INDEX_FILL);
1007 if (fillPressureLevel >= 0.4)
1008 {
1009 if (m_PipeSounds[VALVE_INDEX_FILL] == null)
1010 {
1011 PlaySoundSetAtMemoryPoint(sndFill, SOUND_NAME_PIPE_SPRINKLING_START, VALVE_NAME_FILL, false, 0.0, 0.5);
1012 StopSoundSet(m_PipeSounds[VALVE_INDEX_FILL]);
1014 PlaySoundSetAtMemoryPointLooped(sndFill, SOUND_NAME_PIPE_SPRINKLING_LOOP2, VALVE_NAME_FILL, 0.5, 0.5);
1015 m_PipeSounds[VALVE_INDEX_FILL] = sndFill;
1016 }
1017 }
1018
1019 if (fillPressureLevel < 0.4)
1020 {
1021 if (m_PipeSounds[VALVE_INDEX_FILL] != null)
1022 {
1023 StopSoundSet(m_PipeSounds[VALVE_INDEX_FILL]);
1025 }
1026 }
1027 }
1028
1030 {
1033 {
1035 {
1036 if (m_PipeUnderwaterSound == null)
1037 {
1038 PlaySoundSetAtMemoryPoint(m_PipeUnderwaterSound, SOUND_NAME_UPIPE_SPRINKLING_START, PIPE_NAME_BROKEN1, false, 0.0, 0.5);
1039 StopSoundSet(m_PipeUnderwaterSound);
1040 m_PipeUnderwaterSound = null;
1041 m_PipeUnderwaterSoundRunning = PlaySoundSetAtMemoryPointLooped(m_PipeUnderwaterSound, SOUND_NAME_UPIPE_SPRINKLING_LOOP, PIPE_NAME_BROKEN1, 0.0, 0.5);
1042 }
1043 }
1045 {
1047 {
1048 StopSoundSet(m_PipeUnderwaterSound);
1049 if (m_PipeUnderwaterSoundRunning)
1050 {
1051 PlaySoundSetAtMemoryPoint(m_PipeUnderwaterSound, SOUND_NAME_UPIPE_SPRINKLING_END, PIPE_NAME_BROKEN1, false, 0.0, 0.5);
1052 m_PipeUnderwaterSoundRunning = false;
1053 }
1054 }
1055 }
1056 }
1057 }
1058
1060 {
1062 {
1063 if (m_WaterLevelMovementSound == null)
1064 {
1065 PlaySoundSetAtMemoryPointLooped(m_WaterLevelMovementSound, SOUND_NAME_WATER_DRAIN_LOOP, PIPE_NAME_BROKEN1, 0.0, 0.5);
1066 }
1067 }
1069 {
1070 if (m_WaterLevelMovementSound == null)
1071 {
1072 PlaySoundSetAtMemoryPointLooped(m_WaterLevelMovementSound, SOUND_NAME_WATER_FILL_LOOP, PIPE_NAME_BROKEN1, 0.0, 0.5);
1073 }
1074 }
1076 {
1078 {
1079 StopSoundSet(m_WaterLevelMovementSound);
1080 }
1081 }
1082 }
1083
1089
1096
1097 protected void HandleVisualEffects()
1098 {
1100 {
1102 {
1104 }
1105 }
1106
1108 {
1110 {
1111 m_ValveParticles[VALVE_INDEX_DRAIN].StopParticle();
1113 }
1114 }
1115
1117 {
1119 {
1121 }
1122 }
1123
1125 {
1127 {
1128 m_ValveParticles[VALVE_INDEX_FILL].StopParticle();
1130 }
1131 }
1132
1133
1136 {
1138 {
1140 {
1142 }
1143
1146 {
1149 }
1150 }
1151 }
1152
1155 {
1157 {
1159 }
1160 }
1161
1163 {
1164 for (int pipe = 0; pipe < m_PipeBrokenParticles.Count(); ++pipe)
1165 {
1166 if (m_PipeBrokenParticles[pipe])
1167 {
1168 m_PipeBrokenParticles[pipe].StopParticle();
1169 m_PipeBrokenParticles[pipe] = null;
1170 }
1171 }
1172 }
1173 }
1174
1175 protected void CleanVisualEffects()
1176 {
1177 for (int valve = 0; valve < VALVES_COUNT; ++valve)
1178 {
1179 if (m_ValveParticles[valve])
1180 {
1181 m_ValveParticles[valve].StopParticle();
1182 m_ValveParticles[valve] = null;
1183 }
1184 }
1185
1186 for (int pipe = 0; pipe < m_PipeBrokenParticles.Count(); ++pipe)
1187 {
1188 if (m_PipeBrokenParticles[pipe])
1189 {
1190 m_PipeBrokenParticles[pipe].StopParticle();
1191 m_PipeBrokenParticles[pipe] = null;
1192 }
1193 }
1194 }
1195
1196
1197
1220
1221 protected void SyncValveVariables()
1222 {
1223 if (GetGame())
1224 {
1227 {
1229 SetSynchDirty();
1230 }
1231 }
1232 }
1233
1235 {
1236 int packedBits = 0;
1237
1238 for (int i = 0; i < pStates.Count(); ++i)
1239 {
1240 if (pStates[i] == true)
1241 {
1242 packedBits |= 1 << i;
1243 }
1244 }
1245
1246 return packedBits;
1247 }
1248
1249 protected array<bool> UnpackBitsToArrayOfBoolStates(int pPackedBits, int pArrayLength)
1250 {
1251 array<bool> unpackedBools = new array<bool>();
1252 for (int i = 0; i < pArrayLength; ++i)
1253 {
1254 if ((pPackedBits & 1 << i) != 0)
1255 {
1256 unpackedBools.Insert(true);
1257 }
1258 else
1259 {
1260 unpackedBools.Insert(false);
1261 }
1262 }
1263
1264 return unpackedBools;
1265 }
1266
1267#ifdef DEVELOPER
1268 override protected string GetDebugText()
1269 {
1270 string debug_output = "";
1271 debug_output += string.Format("\nm_WaterLevelActual: %1", m_WaterLevelActual);
1272 debug_output += string.Format("\nm_WaterLevelPrev: %1", m_WaterLevelPrev);
1273 debug_output += string.Format("\nm_ValveManipulatedIndex: %1", m_ValveManipulatedIndex);
1274
1275 int valve;
1276 for (valve = 0; valve < VALVES_COUNT; ++valve)
1277 {
1278 debug_output += string.Format("\nvalve %1 state:%2 | pressure req: %2", valve, m_ValveStates[valve], m_PressureAnimationRequests[valve]);
1279 }
1280
1281 return debug_output;
1282 }
1283
1284 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
1285 {
1286 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SPECIALIZED_ACTION1, "Reset state", FadeColors.LIGHT_GREY));
1287 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SPECIALIZED_ACTION2, "Drain", FadeColors.LIGHT_GREY));
1288 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SPECIALIZED_ACTION3, "Fill", FadeColors.LIGHT_GREY));
1289 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.LIGHT_GREY));
1290
1291 super.GetDebugActions(outputList);
1292 }
1293
1294 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
1295 {
1296 if (super.OnAction(action_id, player, ctx))
1297 return true;
1298 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
1299 {
1300 if (action_id == EActions.SPECIALIZED_ACTION1)
1301 {
1302 ResetState();
1307 }
1308 else if (action_id == EActions.SPECIALIZED_ACTION2)
1309 {
1310 ResetState();
1316 }
1317 else if (action_id == EActions.SPECIALIZED_ACTION3)
1318 {
1319 ResetState();
1325 SetSynchDirty();
1326 }
1327 }
1328 return false;
1329 }
1330
1331
1332#endif
1333}
1334
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения EntityAI.c:97
void BuildingBase()
Определения Building.c:14
ActionTurnValveUndergroundReservoirCB ActionTurnValveCB ActionTurnValveUndergroundReservoir()
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void SetActions()
Определения AdvancedCommunication.c:213
override void OnVariablesSynchronized()
Определения AnniversaryMusicSource.c:42
vector GetOrientation()
Определения AreaDamageManager.c:306
const int ECE_CREATEPHYSICS
Определения CentralEconomy.c:16
map
Определения ControlsXboxNew.c:4
override Widget Init()
Определения DayZGame.c:127
EActions
Определения EActions.c:2
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения ItemBase.c:7114
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения ItemBase.c:7071
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
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
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:103
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native bool RegisterNetworkStaticObject(Object object)
Static objects cannot be replicated by default (there are too many objects on the map)....
proto native Object CreateObjectEx(string type, vector pos, int iFlags, int iRotation=RF_DEFAULT)
Creates object of certain type.
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:332
static const int WATER_JET_WEAK
Определения ParticleList.c:333
static const int WATER_SPILLING
Определения ParticleList.c:334
Определения ParticleList.c:12
static bool DestroySound(EffectSound sound_effect)
Legacy, backwards compatibility.
Определения EffectManager.c:432
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
proto void CallLater(func fn, int delay=0, bool repeat=false, 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)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
void WaterLevelSettings(int pWaterLevel, float pDuration)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Определения EnConvert.c:110
Определения EnConvert.c:106
const int INDEX_NOT_FOUND
Определения gameplay.c:13
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
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
Определения constants.c:452
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
Определения tools.c:8