DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
DynamicMusicPlayer.c
См. документацию.
1//#define DMP_DEBUG_PRINT
2//#define DMP_DEBUG_SETTINGS
3
5{
6 const int NONE = -1;
7 const int CONTAMINATED_ZONE = 0;
8 const int UNDERGROUND = 1;
9}
10
11class DynamicMusicLocationShape
12{
13 const int BOX = 0;
14 const int POLYGON = 1;
15}
16
18{
20
24
26 {
27 vector min = Vector(origin[0] - size, origin[1], origin[2] - size);
28 vector max = Vector(origin[0] + size, origin[1], origin[2] + size);
29
30 return {min, max};
31 }
32}
33
34class DynamicMusicPlayerSettings
35{
38
40}
41
60
61class DynamicMusicPlayerTrackHistoryLookupType
62{
63 const int ANY = 0;
64 const int BUFFER = 1;
65}
66
68{
69 #ifdef DMP_DEBUG_SETTINGS
70 protected const float TICK_TIME_OF_DATE_UPDATE_SECONDS = 10.0;
71 protected const float TICK_LOCATION_CACHE_UPDATE_SECONDS = 10.0;
72 protected const float TICK_LOCATION_UPDATE_SECONDS = 5.0;
73 protected const float TICK_PRIORITY_LOCATION_UPDATE_SECONDS = 2.0;
74 #else
75 protected const float TICK_TIME_OF_DATE_UPDATE_SECONDS = 300.0;
76 protected const float TICK_LOCATION_CACHE_UPDATE_SECONDS = 120.0;
77 protected const float TICK_LOCATION_UPDATE_SECONDS = 120.0;
78 protected const float TICK_PRIORITY_LOCATION_UPDATE_SECONDS = 30.0;
79 #endif
80
81 protected const float TICK_FADEOUT_PROCESSOR_SECONDS = 0.2;
82
83 protected const int TRACKS_BUFFER_HISTORY_SIZE = 2;
84 protected const float LOCATION_DISTANCE_MAX = 500;
85
86 protected float m_TickTimeOfDateElapsed;
91
92 protected int m_ActualTimeOfDay
96
97 protected ref map<int, ref DynamicMusicLocationDynamicData> m_LocationsDynamic
98
101
103
106 private int m_RequestedPlaybackMode
107
109
111
112 private float m_FadeoutTimeElapsed;
115
116 private bool m_Created;
117
119 {
120 m_DynamicMusicPlayerRegistry = configuration;
121 m_RequestedPlaybackMode = g_Game.GetProfileOptionInt(EDayZProfilesOptions.AMBIENT_MUSIC_MODE);
122
123 m_ActualTimeOfDay = DynamicMusicPlayerTimeOfDay.ANY;
125
127
130
131 m_LastPlayedTrackBufferPerCategory[EDynamicMusicPlayerCategory.LOCATION_STATIC] = new SimpleCircularBuffer<int>(TRACKS_BUFFER_HISTORY_SIZE, -1);
132 m_LastPlayedTrackBufferPerCategory[EDynamicMusicPlayerCategory.LOCATION_STATIC_PRIORITY] = new SimpleCircularBuffer<int>(TRACKS_BUFFER_HISTORY_SIZE, -1);
133 m_LastPlayedTrackBufferPerCategory[EDynamicMusicPlayerCategory.LOCATION_DYNAMIC] = new SimpleCircularBuffer<int>(TRACKS_BUFFER_HISTORY_SIZE, -1);
134
135 m_LocationsDynamic = new map<int, ref DynamicMusicLocationDynamicData>();
138
140
142
146
147 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(RefreshTracksCache, 5000);
148
150
151 m_Created = true;
152 }
153
154 void OnUpdate(float timeslice)
155 {
157 return;
158
159 m_TickTimeOfDateElapsed += timeslice;
161 m_TickLocationUpdateElapsed += timeslice;
164
167 {
171 {
174 m_FadeoutInProgress = false;
176 }
177 else
179 }
180 else
181 {
183 {
186 {
189 }
190
192 {
193 if (g_Game.GetPlayer())
194 {
195 m_PlayerPosition = g_Game.GetPlayer().GetPosition();
196 m_PlayerPosition[1] = 0.0;
197 }
198
200
203 {
204 if (PlayerInsideOfLocationFilter(m_LocationsDynamic))
205 OnLocationMatched(EDynamicMusicPlayerCategory.LOCATION_DYNAMIC, true);
207 OnLocationMatched(EDynamicMusicPlayerCategory.LOCATION_STATIC_PRIORITY, true);
208 }
209 }
210
212 {
214
215 if (!IsPlaybackActive())
216 {
218 OnLocationMatched(EDynamicMusicPlayerCategory.LOCATION_STATIC, false);
219 }
220 }
221
223 {
226
230 }
231 }
232 else
233 {
234 if (!IsPlaybackActive())
236 }
237
238 }
239
240 #ifdef DIAG_DEVELOPER
241 if (DiagMenu.GetBool(DiagMenuIDs.SOUNDS_DYNAMIC_MUSIC_PLAYER_STATS))
242 {
243 DisplayDebugStats(true);
244 DisplayStaticLocations(true);
245 }
246 #endif
247 }
248
249 void SetCategory(EDynamicMusicPlayerCategory category, bool forced)
250 {
252 return;
253
254 m_CategorySelected = category;
255
256 OnCategorySet(category, forced);
257 }
258
259 void RegisterDynamicLocation(notnull Entity caller, int locationType, float locationSize)
260 {
261 int id = caller.GetID();
262 if (!m_LocationsDynamic.Contains(id))
263 {
264 array<vector> minMax = DynamicMusicLocationDynamicData.GetRectangularCoordsFromSize(caller.GetPosition(), locationSize);
266 location.m_Type = locationType;
267 location.m_Min = minMax[0];
268 location.m_Max = minMax[1];
269 m_LocationsDynamic.Insert(id, location);
270 }
271 }
272
274 {
275 m_LocationsDynamic.Remove(caller.GetID());
276 }
277
278 void OnGameEvent(EventType eventTypeId, Param params)
279 {
280 if (eventTypeId == MPSessionPlayerReadyEventTypeID)
281 {
284 }
285 }
286
288 {
289 return m_CategorySelected == EDynamicMusicPlayerCategory.LOCATION_STATIC_PRIORITY || m_CategorySelected == EDynamicMusicPlayerCategory.LOCATION_DYNAMIC;
290 }
291
293 {
294 if (m_CategorySelected != EDynamicMusicPlayerCategory.MENU && m_RequestedPlaybackMode == 1)
295 return;
296
297 if (IsPlaybackActive())
298 return;
299
300 switch (category)
301 {
303 if (SetSelectedTrackFromCategory(category, m_DynamicMusicPlayerRegistry.m_TracksMenu, DynamicMusicPlayerTrackHistoryLookupType.BUFFER))
304 break;
305
306 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DetermineTrackByCategory, 5000, false, category);
307 break;
308
310 if (SetSelectedTrackFromCategory(category, m_DynamicMusicPlayerRegistry.m_TracksTime, DynamicMusicPlayerTrackHistoryLookupType.BUFFER))
311 break;
312
313 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DetermineTrackByCategory, 5000, false, category);
314 break;
315 case EDynamicMusicPlayerCategory.LOCATION_STATIC:
317 break;
318
319 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DetermineTrackByCategory, 5000, false, category);
320 break;
321 case EDynamicMusicPlayerCategory.LOCATION_STATIC_PRIORITY:
323 break;
324
325 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DetermineTrackByCategory, 5000, false, category);
326 break;
327 case EDynamicMusicPlayerCategory.LOCATION_DYNAMIC:
328 if (SetSelectedTrackFromCategory(category, m_DynamicMusicPlayerRegistry.m_TracksLocationDynamic))
329 break;
330
331 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DetermineTrackByCategory, 5000, false, category);
332
333 break;
334 }
335 }
336
337 protected bool IsPlaybackActive()
338 {
340 }
341
344
345 protected void OnProfileOptionChanged(EDayZProfilesOptions option, int value)
346 {
347 if (option == EDayZProfilesOptions.AMBIENT_MUSIC_MODE)
348 {
349 m_RequestedPlaybackMode = value;
350
351 if (value == 1 && m_CategorySelected != EDynamicMusicPlayerCategory.MENU)
352 {
353 StopTrack();
355 }
356 }
357 }
358
359 protected void OnCategorySet(EDynamicMusicPlayerCategory category, bool forced)
360 {
361 #ifdef DIAG_DEVELOPER
362 DMPDebugPrint(string.Format(
363 "OnCategorySet() - category: %1, forced: %2",
365 forced),
366 );
367 #endif
368
369 DetermineTrackByCategory(category);
370 }
371
372 protected void OnTrackEnded()
373 {
374 #ifdef DIAG_DEVELOPER
375 if (m_CurrentTrack)
376 DMPDebugPrint(string.Format("Track END - %1", m_CurrentTrack.m_SoundSet));
377 #endif
378
379 m_SoundPlaying = null;
380 m_CurrentTrack = null;
381 m_WaitingForPlayback = false;
382 }
383
384 protected void OnTrackStopped()
385 {
387 #ifdef DIAG_DEVELOPER
388 if (m_CurrentTrack)
389 DMPDebugPrint(string.Format("Track STOP - %1", m_CurrentTrack.m_SoundSet));
390 #endif
391
392 m_SoundPlaying = null;
393 m_CurrentTrack = null;
394 m_WaitingForPlayback = false;
395 }
396
397 protected void OnNextTrackSelected(DynamicMusicTrackData track, float waitTime)
398 {
400 m_CurrentTrack = track;
401
402 if (m_Created)
403 m_Created = false;
404
405 #ifdef DIAG_DEVELOPER
406 DMPDebugPrint(string.Format(
407 "WaitTime set to %1s, deferring playback of \"%2\"",
408 (int)waitTime,
409 track.m_SoundSet),
410 );
411 m_DebugWaitTime = waitTime;
412 #endif
413
414 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(PlayTrack, (int)waitTime * 1000, false, track);
415 }
416
417 protected void OnLocationMatched(EDynamicMusicPlayerCategory category, bool isPriorityLocation)
418 {
419 #ifdef DIAG_DEVELOPER
420 string messagePriority;
421 if (isPriorityLocation)
422 messagePriority = "(with priority)";
423 DMPDebugPrint(string.Format("Location matched %1", messagePriority));
424 #endif
425
426 if (isPriorityLocation)
427 {
429 {
430 m_CategorySelected = category;
433
434 if (m_SoundPlaying)
436
437 SetCategory(category, isPriorityLocation);
438 }
439 else
440 SetCategory(category, true);
441 }
442 else
443 SetCategory(category, false);
444 }
445
447 {
448 if (m_SoundPlaying)
449 m_SoundPlaying.GetEvents().Event_OnSoundWaveEnded.Remove(OnTrackEnded);
450
451 StopTrack();
453 }
454
455
457 {
458 SoundParams soundParams = new SoundParams(track.m_SoundSet);
459 if (soundParams.IsValid())
460 {
461 SoundObjectBuilder soundBuilder = new SoundObjectBuilder(soundParams);
462 SoundObject soundObject = soundBuilder.BuildSoundObject();
463 soundObject.SetKind(WaveKind.WAVEMUSIC);
464
465 m_SoundPlaying = GetGame().GetSoundScene().Play2D(soundObject, soundBuilder);
466 if (m_SoundPlaying)
467 {
468 m_SoundPlaying.Loop(false);
469 m_SoundPlaying.Play();
470
472 m_SoundPlaying.GetEvents().Event_OnSoundWaveEnded.Insert(OnTrackEnded);
473 m_SoundPlaying.GetEvents().Event_OnSoundWaveStopped.Insert(OnTrackStopped);
474
475 m_WaitingForPlayback = false;
476 }
477 }
478 else
479 {
480 m_WaitingForPlayback = false;
481 m_CurrentTrack = null;
482 }
483
484 }
485
486 private void StopTrack()
487 {
488 if (m_SoundPlaying)
489 m_SoundPlaying.Stop();
490 }
491
492 private void ResetWaitingQueue()
493 {
495 {
496 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(PlayTrack);
497 m_WaitingForPlayback = false;
498 m_CurrentTrack = null;
499 }
500 }
501
502 private void FadeoutTrack(float fadeoutSeconds)
503 {
505 return;
506
508 {
509 #ifdef DIAG_DEVELOPER
510 DMPDebugPrint(string.Format("Stopping currently played track %1", m_CurrentTrack.m_SoundSet));
511 DMPDebugPrint(string.Format("-- Setting fadeout to %1", fadeoutSeconds));
512 #endif
513 m_FadeoutInProgress = true;
514 m_FadeoutTimeRequested = fadeoutSeconds;
515 }
516 }
517
518 private void ProcessFadeOut()
519 {
520 if (m_SoundPlaying)
521 {
522 float volume = 1 - (m_FadeoutTimeElapsed / m_FadeoutTimeRequested);
523 m_SoundPlaying.SetFadeOutFactor(volume);
524 }
525 }
526
528 {
530
531 if (locations.Count() > 0)
532 {
533 foreach (DynamicMusicTrackData track : locations)
534 {
535 switch (track.m_Shape)
536 {
537 case DynamicMusicLocationShape.BOX:
538 foreach (int locationId, array<vector> bounds : track.locationBoundaries)
539 {
540 if (Math.IsPointInRectangle(bounds[0], bounds[1], m_PlayerPosition))
541 {
544
545 #ifdef DIAG_DEVELOPER
546 DMPDebugPrint(string.Format("Player inside location <%1, %2>", bounds[0], bounds[1]));
547 #endif
548 }
549 }
550 break;
551 case DynamicMusicLocationShape.POLYGON:
552 if (Math2D.IsPointInPolygonXZ(track.vertices, m_PlayerPosition))
553 {
556
557 #ifdef DIAG_DEVELOPER
558 DMPDebugPrint(string.Format("Player inside polygon location at <%1>", m_PlayerPosition));
559 #endif
560 }
561 break;
562 }
563 }
564 }
565
566 return m_TracksLocationMatchedPlayerInside.Count() > 0;
567 }
568
570 {
571 if (locations.Count() > 0)
572 {
573 foreach (int locationId, DynamicMusicLocationDynamicData location : locations)
574 {
575 if (Math.IsPointInRectangle(location.m_Min, location.m_Max, m_PlayerPosition))
576 {
577 #ifdef DIAG_DEVELOPER
578 DMPDebugPrint(string.Format("Player inside location <%1, %2>", location.m_Min, location.m_Max));
579 #endif
580 return true;
581 }
582 }
583 }
584
585 return false;
586 }
587
588 private bool SetSelectedTrackFromCategory(EDynamicMusicPlayerCategory category, notnull array<ref DynamicMusicTrackData> tracklist, int historyLookupType = DynamicMusicPlayerTrackHistoryLookupType.ANY)
589 {
590 if (tracklist.Count() == 0)
591 return true;
592
594 foreach (DynamicMusicTrackData filteredTrack : tracklist)
595 {
596 if (filteredTrack.m_TimeOfDay == m_ActualTimeOfDay || filteredTrack.m_TimeOfDay == DynamicMusicPlayerTimeOfDay.ANY)
597 filteredTracks.Insert(filteredTrack);
598 }
599
600 float trackIndex;
602 if (m_Created && category == EDynamicMusicPlayerCategory.MENU)
603 trackIndex = SelectRandomTrackIndexFromCategoryPriorityFlagFirst(category, filteredTracks);
604 else
605 trackIndex = SelectRandomTrackIndexFromCategory(category, historyLookupType, filteredTracks);
606
607 if (trackIndex > INDEX_NOT_FOUND)
608 {
609 m_LastPlayedTrackBufferPerCategory[category].Add(trackIndex);
610 OnNextTrackSelected(filteredTracks[trackIndex], GetWaitTimeForCategory(category));
611
612 return true;
613 }
614
615 return false;
616 }
617
619 {
621 if (category == EDynamicMusicPlayerCategory.MENU)
622 {
623 array<int> priorityFlagIndices = new array<int>();
624
625 foreach (int i, DynamicMusicTrackData track : tracks)
626 {
627
628 if (!track.m_HasPriority)
629 continue;
630
631 priorityFlagIndices.Insert(i);
632 }
633
634 if (priorityFlagIndices.Count() > 0)
635 return priorityFlagIndices[priorityFlagIndices.GetRandomIndex()];
636
638 return tracks.GetRandomIndex();
639 }
640
641 return INDEX_NOT_FOUND;
642 }
643
645 {
646 int count = tracks.Count();
647 if (count > 0)
648 {
649 int index = Math.RandomInt(0, count);
650
651 switch (lookupType)
652 {
653 case DynamicMusicPlayerTrackHistoryLookupType.ANY:
654 return index;
655
656 case DynamicMusicPlayerTrackHistoryLookupType.BUFFER:
657 // fallback - num of track is smaller than actual history size;
658 if (count <= TRACKS_BUFFER_HISTORY_SIZE)
659 return index;
660
661 if (m_LastPlayedTrackBufferPerCategory[category].GetValues().Find(index) == INDEX_NOT_FOUND)
662 return index;
663
664 return INDEX_NOT_FOUND;
665 }
666 }
667
668 return INDEX_NOT_FOUND;
669 }
670
671 private void SetTimeOfDate()
672 {
673 if (g_Game.GetMission())
674 {
675 m_ActualTimeOfDay = g_Game.GetMission().GetWorldData().GetDaytime();
676 return;
677 }
678
679 m_ActualTimeOfDay = DynamicMusicPlayerTimeOfDay.DAY;
680 }
681
686
688 {
689 float waitTime = m_DynamicMusicPlayerRegistry.m_SettingsByCategory[category].m_MinWaitTimeSeconds;
690 #ifdef DIAG_DEVELOPER
691 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.DYNAMIC_MUSIC_PLAYER))
692 {
693 float timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
694 if (timeAccel > 0)
695 return waitTime / FeatureTimeAccel.GetFeatureTimeAccelValue();
696 }
697 #endif
698 return waitTime;
699 }
700
702 {
703 float waitTime = m_DynamicMusicPlayerRegistry.m_SettingsByCategory[category].m_MaxWaitTimeSeconds;
704 #ifdef DIAG_DEVELOPER
705 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.DYNAMIC_MUSIC_PLAYER))
706 {
707 float timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
708 if (timeAccel > 0)
709 return waitTime / FeatureTimeAccel.GetFeatureTimeAccelValue();
710 }
711 #endif
712 return waitTime;
713 }
714
716 {
717 return m_DynamicMusicPlayerRegistry.m_SettingsByCategory[category].m_PreviousTrackFadeoutSeconds;
718 }
719
720 private void RefreshTracksCache()
721 {
723 {
725 foreach (DynamicMusicTrackData track : m_DynamicMusicPlayerRegistry.m_TracksLocationStatic)
726 {
727 if (track.m_Shape == DynamicMusicLocationShape.BOX)
728 {
729 foreach (array<vector> bounds : track.locationBoundaries)
730 {
732 continue;
733 }
734 }
735
736 m_TracksLocationStaticCached.Insert(track);
737 }
738
740 foreach (DynamicMusicTrackData trackPrio : m_DynamicMusicPlayerRegistry.m_TracksLocationStaticPrioritized)
741 {
742 if (trackPrio.m_Shape == DynamicMusicLocationShape.BOX)
743 {
744 foreach (array<vector> boundsPrio : trackPrio.locationBoundaries)
745 {
746 if (vector.Distance(m_PlayerPosition, Math.CenterOfRectangle(boundsPrio[0], boundsPrio[1])) > LOCATION_DISTANCE_MAX)
747 continue;
748 }
749 }
750
752 }
753 }
754 }
755
756 #ifdef DIAG_DEVELOPER
757 private ref array<Shape> m_DebugShapesLocations = new array<Shape>();
758 private ref array<Shape> m_DebugShapesLocationsVertices = new array<Shape>();
759 private float m_DebugWaitTime = 0;
760
761 private void DisplayDebugStats(bool enabled)
762 {
763 int windowPosX = 10;
764 int windowPosY = 200;
765
766 DbgUI.Begin("DMP - Overall stats", windowPosX, windowPosY);
767 if (enabled)
768 {
769 bool isPlaybackActive = m_SoundPlaying != null;
770 DbgUI.Text(string.Format("Day/Night: %1", DynamicMusicPlayerTimeOfDay.ToString(m_ActualTimeOfDay)));
771 DbgUI.Text("Playback:");
772 DbgUI.Text(string.Format(" active: %1", isPlaybackActive.ToString()));
773 DbgUI.Text(string.Format(" waiting: %1", m_WaitingForPlayback.ToString()));
774 DbgUI.Text(string.Format("Selected Category: %1", EnumTools.EnumToString(EDynamicMusicPlayerCategory, m_CategorySelected)));
775
777 {
778 DbgUI.Text("Update timers:");
783 }
784
786 {
787 DbgUI.Text("Player:");
788 DbgUI.Text(string.Format(" position: %1", m_PlayerPosition.ToString()));
789 DbgUI.Text(string.Format(" matched num tracks(location): %1", m_TracksLocationMatchedPlayerInside.Count()));
790 }
791
792 DbgUI.Text("Tracks counts:");
794 DbgUI.Text(string.Format(" Menu: %1", m_DynamicMusicPlayerRegistry.m_TracksMenu.Count()));
795 else
796 {
797 DbgUI.Text(string.Format(" Time: %1", m_DynamicMusicPlayerRegistry.m_TracksTime.Count()));
798 DbgUI.Text(string.Format(" Static[cache]: %1", m_TracksLocationStaticCached.Count()));
799 DbgUI.Text(string.Format(" Static(prio)[cache]: %1", m_TracksLocationStaticPrioritizedCached.Count()));
800 DbgUI.Text(string.Format(" Dynamic(prio): %1", m_DynamicMusicPlayerRegistry.m_TracksLocationDynamic.Count()));
801 }
802 }
803 DbgUI.End();
804
805 DbgUI.Begin("DMP - Current track", windowPosX, windowPosY+380);
806 if (enabled && m_CurrentTrack)
807 {
808 string isPlaying = "waiting";
809 if (m_SoundPlaying != null)
810 isPlaying = "playing";
811
812 DbgUI.Text(string.Format("State: %1", isPlaying));
814 {
815 DbgUI.Text(string.Format("Wait time: %1s (%2s)", (int)m_DebugWaitTime, (int)(g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).GetRemainingTime(PlayTrack) * 0.001)));
816 }
817 DbgUI.Text(string.Format("Sound set: %1", m_CurrentTrack.m_SoundSet));
818 DbgUI.Text(string.Format("Category: %1", EnumTools.EnumToString(EDynamicMusicPlayerCategory, m_CurrentTrack.m_Category)));
819 DbgUI.Text(string.Format("Time of day: %1", DynamicMusicPlayerTimeOfDay.ToString(m_CurrentTrack.m_TimeOfDay)));
820 }
821 DbgUI.End();
822
823 DbgUI.Begin("DMP - Controls", windowPosX + 500, windowPosY);
824 if (enabled)
825 {
826 if (DbgUI.Button("Stop"))
827 StopTrack();
828
829 if (DbgUI.Button("Reset Waiting"))
831
832 DbgUI.Text("Set Category:\n");
833 if (DbgUI.Button("Time"))
835 if (DbgUI.Button("Location"))
836 SetCategory(EDynamicMusicPlayerCategory.LOCATION_STATIC, false);
837
838 DbgUI.Text("Reset Timers\n");
839 if (DbgUI.Button("Timer ALL"))
840 {
844 }
845
846 if (DbgUI.Button("Timer Daytime"))
848 if (DbgUI.Button("Timer Location"))
850 if (DbgUI.Button("Timer Location(prio)"))
852
853 }
854 DbgUI.End();
855 }
856
857 private void DisplayStaticLocations(bool enabled)
858 {
859 if (enabled)
860 {
861 vector locationMin;
862 vector locationMax;
863 vector position = g_Game.GetCurrentCameraPosition();
864
865 foreach (DynamicMusicTrackData track : m_TracksLocationStaticCached)
866 {
867 foreach (array<vector> bounds : track.locationBoundaries)
868 {
869 locationMin = bounds[0];
870 locationMax = bounds[1];
871
872 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
873 continue;
874
875 Debug.CleanupDrawShapes(m_DebugShapesLocations);
876
877 locationMax[1] = locationMin[1] + 200.0;
878 locationMin[1] = locationMin[1] - 50.0;
879 m_DebugShapesLocations.Insert(Debug.DrawBoxEx(locationMin, locationMax, Colors.PURPLE, ShapeFlags.NOZWRITE|ShapeFlags.ONCE));
880 }
881
882 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
883 DrawPolygonLocation(track);
884 }
885
886 foreach (DynamicMusicTrackData trackPrio : m_TracksLocationStaticPrioritizedCached)
887 {
888 foreach (array<vector> boundsPrio : trackPrio.locationBoundaries)
889 {
890 locationMin = boundsPrio[0];
891 locationMax = boundsPrio[1];
892
893 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
894 continue;
895
896 Debug.CleanupDrawShapes(m_DebugShapesLocations);
897
898 locationMax[1] = locationMin[1] + 200.0;
899 locationMin[1] = locationMin[1] - 50.0;
900 m_DebugShapesLocations.Insert(Debug.DrawBoxEx(locationMin, locationMax, Colors.RED, ShapeFlags.NOZWRITE|ShapeFlags.ONCE));
901 }
902
903 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
904 DrawPolygonLocation(trackPrio);
905 }
906
907 foreach (DynamicMusicLocationDynamicData locationDynamic : m_LocationsDynamic)
908 {
909 locationMin = locationDynamic.m_Min;
910 locationMax = locationDynamic.m_Max;
911
912 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
913 continue;
914
915 Debug.CleanupDrawShapes(m_DebugShapesLocations);
916
917 locationMax[1] = locationMin[1] + 200.0;
918 locationMin[1] = locationMin[1] - 50.0;
919 m_DebugShapesLocations.Insert(Debug.DrawBoxEx(locationMin, locationMax, Colors.YELLOW, ShapeFlags.NOZWRITE|ShapeFlags.ONCE));
920 }
921 }
922 else
923 {
924 Debug.CleanupDrawShapes(m_DebugShapesLocations);
925 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
926 }
927 }
928
929 private void DrawPolygonLocation(notnull DynamicMusicTrackData track)
930 {
931 vector first, current, last;
932
933 int count = track.vertices.Count();
934 foreach (int i, vector vertexPos : track.vertices)
935 {
936 vertexPos[1] = vertexPos[1] + 0.5;
937 current = vertexPos;
938
939 if (i == 0)
940 first = vertexPos;
941 else
942 m_DebugShapesLocationsVertices.Insert(Debug.DrawLine(last, current, COLOR_WHITE, ShapeFlags.TRANSP|ShapeFlags.NOZWRITE|ShapeFlags.ONCE));
943
944 last = current;
945 }
946
947 m_DebugShapesLocationsVertices.Insert(Debug.DrawLine(current, first, COLOR_WHITE, ShapeFlags.TRANSP|ShapeFlags.NOZWRITE|ShapeFlags.ONCE));
948 }
949
950 private void DMPDebugPrint(string message)
951 {
952 #ifdef DMP_DEBUG_PRINT
953 Debug.Log(message);
954 #endif
955 }
956
958 private void CleanupDebugShapes(array<Shape> shapesArr)
959 {
960 Debug.CleanupDrawShapes(shapesArr);
961 }
962
963 #endif
964}
965
966
968class DynamicMusicPlayerTimeOfDay : WorldDataDaytime {}
map
Определения ControlsXboxNew.c:4
DayZGame g_Game
Определения DayZGame.c:3868
class DynamicMusicLocationDynamicData m_MinWaitTimeSeconds
const int POLYGON
Определения DynamicMusicPlayer.c:14
const int BUFFER
Определения DynamicMusicPlayer.c:64
class DynamicMusicTrackData ANY
float m_PreviousTrackFadeoutSeconds
Определения DynamicMusicPlayer.c:39
float m_MaxWaitTimeSeconds
Определения DynamicMusicPlayer.c:37
EDayZProfilesOptions
Определения EDayZProfilesOptions.c:2
DiagMenuIDs
Определения EDiagMenuIDs.c:2
EDynamicMusicPlayerCategory
Определения EDynamicMusicPlayerCategory.c:2
string m_SoundPlaying
Определения Edible_Base.c:1123
class PresenceNotifierNoiseEvents windowPosX
dbgUI settings
const int windowPosY
Определения PluginPresenceNotifier.c:77
WaveKind
Определения Sound.c:2
void Debug()
Определения UniversalTemperatureSource.c:349
proto native AbstractSoundScene GetSoundScene()
static ref ScriptInvoker m_OnIntOptionChanged
Определения DayZGame.c:408
Определения DayZGame.c:403
Определения DbgUI.c:60
Определения EnDebug.c:233
static array< vector > GetRectangularCoordsFromSize(vector origin, float size)
Определения DynamicMusicPlayer.c:25
vector m_Min
rectangle coords (2d only)
Определения DynamicMusicPlayer.c:22
const int NONE
Определения DynamicMusicPlayer.c:6
const int UNDERGROUND
Определения DynamicMusicPlayer.c:8
const int CONTAMINATED_ZONE
Определения DynamicMusicPlayer.c:7
const int TRACKS_BUFFER_HISTORY_SIZE
Определения DynamicMusicPlayer.c:83
float m_TickLocationCacheUpdateElapsed
Определения DynamicMusicPlayer.c:87
int SelectRandomTrackIndexFromCategory(EDynamicMusicPlayerCategory category, int lookupType, notnull array< ref DynamicMusicTrackData > tracks)
Определения DynamicMusicPlayer.c:644
void OnFadeoutFinished(EDynamicMusicPlayerCategory category)
Определения DynamicMusicPlayer.c:446
const float LOCATION_DISTANCE_MAX
Определения DynamicMusicPlayer.c:84
float GetMaxWaitTimePerCategory(EDynamicMusicPlayerCategory category)
Определения DynamicMusicPlayer.c:701
DynamicMusicTrackData m_CurrentTrack
Определения DynamicMusicPlayer.c:94
void OnUpdate(float timeslice)
Определения DynamicMusicPlayer.c:154
int SelectRandomTrackIndexFromCategoryPriorityFlagFirst(EDynamicMusicPlayerCategory category, notnull array< ref DynamicMusicTrackData > tracks)
Определения DynamicMusicPlayer.c:618
bool IsPlaybackActive()
Определения DynamicMusicPlayer.c:337
const float TICK_LOCATION_CACHE_UPDATE_SECONDS
Определения DynamicMusicPlayer.c:76
void FadeoutTrack(float fadeoutSeconds)
Определения DynamicMusicPlayer.c:502
float m_TickLocationUpdateElapsed
Определения DynamicMusicPlayer.c:88
void ProcessFadeOut()
Определения DynamicMusicPlayer.c:518
float m_TickFadeOutProcessingElapsed
Определения DynamicMusicPlayer.c:90
void RegisterDynamicLocation(notnull Entity caller, int locationType, float locationSize)
Определения DynamicMusicPlayer.c:259
const float TICK_TIME_OF_DATE_UPDATE_SECONDS
Определения DynamicMusicPlayer.c:75
float m_TickPriorityLocationUpdateElapsed
Определения DynamicMusicPlayer.c:89
void SetCategory(EDynamicMusicPlayerCategory category, bool forced)
Определения DynamicMusicPlayer.c:249
bool m_FadeoutInProgress
Определения DynamicMusicPlayer.c:114
float m_FadeoutTimeElapsed
Определения DynamicMusicPlayer.c:112
ref array< ref DynamicMusicTrackData > m_TracksLocationStaticPrioritizedCached
static + filtered by the distance between player and center of zone
Определения DynamicMusicPlayer.c:100
void OnTrackStopped()
Определения DynamicMusicPlayer.c:384
EDynamicMusicPlayerCategory m_CategorySelected
Определения DynamicMusicPlayer.c:93
float GetWaitTimeForCategory(EDynamicMusicPlayerCategory category)
Определения DynamicMusicPlayer.c:682
float GetMinWaitTimePerCategory(EDynamicMusicPlayerCategory category)
Определения DynamicMusicPlayer.c:687
void OnTrackEnded()
Определения DynamicMusicPlayer.c:372
void OnProfileOptionChanged(EDayZProfilesOptions option, int value)
Определения DynamicMusicPlayer.c:345
void ResetWaitingQueue()
Определения DynamicMusicPlayer.c:492
bool SetSelectedTrackFromCategory(EDynamicMusicPlayerCategory category, notnull array< ref DynamicMusicTrackData > tracklist, int historyLookupType=DynamicMusicPlayerTrackHistoryLookupType.ANY)
Определения DynamicMusicPlayer.c:588
void UnregisterDynamicLocation(notnull Entity caller)
Определения DynamicMusicPlayer.c:273
void SetTimeOfDate()
Определения DynamicMusicPlayer.c:671
float m_FadeoutTimeRequested
Определения DynamicMusicPlayer.c:113
ref array< ref DynamicMusicTrackData > m_TracksLocationMatchedPlayerInside
static prio + filtered by the distance between player and center of zone
Определения DynamicMusicPlayer.c:102
AbstractWave m_SoundPlaying
Определения DynamicMusicPlayer.c:104
float m_TickTimeOfDateElapsed
Определения DynamicMusicPlayer.c:86
void OnCategorySet(EDynamicMusicPlayerCategory category, bool forced)
Определения DynamicMusicPlayer.c:359
void OnNextTrackSelected(DynamicMusicTrackData track, float waitTime)
Определения DynamicMusicPlayer.c:397
bool IsPriotitizedCategorySelected()
Определения DynamicMusicPlayer.c:287
ref DynamicMusicPlayerRegistry m_DynamicMusicPlayerRegistry
Определения DynamicMusicPlayer.c:95
void RefreshTracksCache()
Определения DynamicMusicPlayer.c:720
void OnGameEvent(EventType eventTypeId, Param params)
Определения DynamicMusicPlayer.c:278
bool m_Created
Определения DynamicMusicPlayer.c:116
ref array< ref DynamicMusicTrackData > m_TracksLocationStaticCached
map of dynamically registered locations during runtime
Определения DynamicMusicPlayer.c:99
bool PlayerInsideOfLocationFilter(array< ref DynamicMusicTrackData > locations)
Определения DynamicMusicPlayer.c:527
void PlayTrack(DynamicMusicTrackData track)
Определения DynamicMusicPlayer.c:456
void DetermineTrackByCategory(EDynamicMusicPlayerCategory category)
Определения DynamicMusicPlayer.c:292
void DynamicMusicPlayer(DynamicMusicPlayerRegistry configuration)
Определения DynamicMusicPlayer.c:118
const float TICK_FADEOUT_PROCESSOR_SECONDS
Определения DynamicMusicPlayer.c:81
void StopTrack()
Определения DynamicMusicPlayer.c:486
vector m_PlayerPosition
Определения DynamicMusicPlayer.c:110
void OnLocationMatched(EDynamicMusicPlayerCategory category, bool isPriorityLocation)
Определения DynamicMusicPlayer.c:417
bool PlayerInsideOfLocationFilter(map< int, ref DynamicMusicLocationDynamicData > locations)
Определения DynamicMusicPlayer.c:569
const float TICK_PRIORITY_LOCATION_UPDATE_SECONDS
Определения DynamicMusicPlayer.c:78
const float TICK_LOCATION_UPDATE_SECONDS
Определения DynamicMusicPlayer.c:77
float GetPreviousTrackFadeoutSeconds(EDynamicMusicPlayerCategory category)
Определения DynamicMusicPlayer.c:715
ref map< EDynamicMusicPlayerCategory, ref SimpleCircularBuffer< int > > m_LastPlayedTrackBufferPerCategory
gets the playback mode as set in sounds menu; 0 - all; 1 - menu only
Определения DynamicMusicPlayer.c:108
bool m_WaitingForPlayback
Определения DynamicMusicPlayer.c:105
int m_LocationType
Определения DynamicMusicPlayer.c:46
EDynamicMusicPlayerCategory m_Category
Определения DynamicMusicPlayer.c:50
void InsertLocation(vector min, vector max)
Определения DynamicMusicPlayer.c:55
ref array< vector > vertices
Определения DynamicMusicPlayer.c:53
ref array< ref array< vector > > locationBoundaries
Определения DynamicMusicPlayer.c:52
string m_SoundSet
Определения DynamicMusicPlayer.c:48
bool m_HasPriority
Определения DynamicMusicPlayer.c:44
int m_TimeOfDay
Определения DynamicMusicPlayer.c:45
Определения Camera.c:2
static string EnumToString(typename e, int enumValue)
Return string name of enum value.
Определения EnConvert.c:601
Определения EnConvert.c:590
Определения EnMath.c:7
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
Определения Sound.c:112
Определения WorldData.c:463
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
string ToString()
Определения EnConvert.c:3
static const vector Zero
Определения EnConvert.c:110
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Определения EnConvert.c:106
const int INDEX_NOT_FOUND
Определения gameplay.c:13
const EventType MPSessionPlayerReadyEventTypeID
no params
Определения gameplay.c:481
proto native CGame GetGame()
@ Colors
Определения EnWorld.c:88
const int COLOR_WHITE
Определения constants.c:63
ShapeFlags
Определения EnDebug.c:126
static proto native void Begin(string windowTitle, float x=0, float y=0)
static proto native void Text(string label)
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
enum WindingOrder Math2D()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:106
static proto bool IsPointInRectangle(vector mi, vector ma, vector p)
Returns if point is inside rectangle.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static vector CenterOfRectangle(vector min, vector max)
Определения EnMath.c:751
proto native AbstractWave Play2D(SoundObject soundObject, SoundObjectBuilder soundBuilder)
class AbstractSoundScene SoundObjectBuilder(SoundParams soundParams)
void AbstractWave()
Определения Sound.c:167
class SoundObject SoundParams(string name)
proto native void SetKind(WaveKind kind)
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8
TypeID EventType
Определения EnWidgets.c:55
@ BOX
Определения EnWorld.c:190