11class DynamicMusicLocationShape
27 vector min =
Vector(origin[0] - size, origin[1], origin[2] - size);
28 vector max =
Vector(origin[0] + size, origin[1], origin[2] + size);
34class DynamicMusicPlayerSettings
47 int m_Shape = DynamicMusicLocationShape.BOX;
61class DynamicMusicPlayerTrackHistoryLookupType
83 #ifdef DMP_DEBUG_SETTINGS
106 protected int m_ActualTimeOfDay
120 private int m_RequestedPlaybackMode
259 #ifdef DIAG_DEVELOPER
262 DisplayDebugStats(
true);
263 DisplayStaticLocations(
true);
291 int id = caller.GetID();
292 if (!m_LocationsDynamic.Contains(
id))
296 location.
m_Type = locationType;
297 location.
m_Min = minMax[0];
298 location.
m_Max = minMax[1];
299 m_LocationsDynamic.Insert(
id, location);
305 m_LocationsDynamic.Remove(caller.GetID());
389 m_RequestedPlaybackMode = value;
401 #ifdef ENABLE_LOGGING
402 DMPDebugPrint(
string.Format(
403 "OnCategorySet() - category: %1, forced: %2",
414 #ifdef ENABLE_LOGGING
416 DMPDebugPrint(
string.Format(
"Track END - %1",
m_CurrentTrack.m_SoundSet));
427 #ifdef ENABLE_LOGGING
429 DMPDebugPrint(
string.Format(
"Track STOP - %1",
m_CurrentTrack.m_SoundSet));
445 #ifdef ENABLE_LOGGING
446 DMPDebugPrint(
string.Format(
447 "WaitTime set to %1s, deferring playback of \"%2\"",
453 #ifdef DIAG_DEVELOPER
454 m_DebugWaitTime = waitTime;
462 #ifdef ENABLE_LOGGING
463 string messagePriority;
464 if (isPriorityLocation)
465 messagePriority =
"(with priority)";
466 DMPDebugPrint(
string.Format(
"Location matched %1", messagePriority));
472 if (isPriorityLocation)
474 playbackData.
m_Forced = isPriorityLocation;
514 if (soundParams.IsValid())
517 SoundObject soundObject = soundBuilder.BuildSoundObject();
565 #ifdef ENABLE_LOGGING
566 DMPDebugPrint(
string.Format(
"Stopping currently played track %1",
m_CurrentTrack.m_SoundSet));
567 DMPDebugPrint(
string.Format(
"-- Setting fadeout to %1", fadeoutSeconds));
587 if (locations.Count() > 0)
591 switch (track.m_Shape)
593 case DynamicMusicLocationShape.BOX:
594 foreach (
int locationId,
array<vector> bounds : track.locationBoundaries)
601 #ifdef ENABLE_LOGGING
602 DMPDebugPrint(
string.Format(
"Player inside location <%1, %2>", bounds[0], bounds[1]));
607 case DynamicMusicLocationShape.POLYGON:
613 #ifdef ENABLE_LOGGING
614 DMPDebugPrint(
string.Format(
"Player inside polygon location at <%1>",
m_PlayerPosition));
627 if (locations.Count() > 0)
633 #ifdef ENABLE_LOGGING
634 DMPDebugPrint(
string.Format(
"Player inside location <%1, %2>", location.m_Min, location.m_Max));
646 if (tracklist.Count() == 0)
653 filteredTracks.Insert(filteredTrack);
684 if (!track.m_HasPriority)
687 priorityFlagIndices.Insert(i);
690 if (priorityFlagIndices.Count() > 0)
691 return priorityFlagIndices[priorityFlagIndices.GetRandomIndex()];
694 return tracks.GetRandomIndex();
702 int count = tracks.Count();
709 case DynamicMusicPlayerTrackHistoryLookupType.ANY:
712 case DynamicMusicPlayerTrackHistoryLookupType.BUFFER:
732 m_ActualTimeOfDay =
mission.GetWorldData().GetDaytime();
747 #ifdef DIAG_DEVELOPER
748 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.DYNAMIC_MUSIC_PLAYER))
750 float timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
752 return waitTime / FeatureTimeAccel.GetFeatureTimeAccelValue();
761 #ifdef DIAG_DEVELOPER
762 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.DYNAMIC_MUSIC_PLAYER))
764 float timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
766 return waitTime / FeatureTimeAccel.GetFeatureTimeAccelValue();
784 if (track.
m_Shape == DynamicMusicLocationShape.BOX)
799 if (trackPrio.
m_Shape == DynamicMusicLocationShape.BOX)
813 #ifdef DIAG_DEVELOPER
814 private ref array<Shape> m_DebugShapesLocations =
new array<Shape>();
815 private ref array<Shape> m_DebugShapesLocationsVertices =
new array<Shape>();
816 private float m_DebugWaitTime = 0;
818 private void DisplayDebugStats(
bool enabled)
827 DbgUI.Text(
string.Format(
"Day/Night: %1", DynamicMusicPlayerTimeOfDay.ToString(m_ActualTimeOfDay)));
828 DbgUI.Text(
"Playback:");
829 DbgUI.Text(
string.Format(
" active: %1", isPlaybackActive.
ToString()));
835 DbgUI.Text(
"Update timers:");
844 DbgUI.Text(
"Player:");
849 DbgUI.Text(
"Tracks counts:");
868 string isPlaying =
"waiting";
870 isPlaying =
"playing";
872 DbgUI.Text(
string.Format(
"State: %1", isPlaying));
886 if (DbgUI.Button(
"Stop"))
889 if (DbgUI.Button(
"Reset Waiting"))
892 DynamicMusicPlayerCategoryPlaybackData playbackData =
new DynamicMusicPlayerCategoryPlaybackData();
895 DbgUI.Text(
"Set Category:\n");
896 if (DbgUI.Button(
"Time"))
898 if (DbgUI.Button(
"Location"))
903 if (DbgUI.Button(
"Menu"))
908 if (DbgUI.Button(
"Credits"))
914 DbgUI.Text(
"Reset Timers\n");
915 if (DbgUI.Button(
"Timer ALL"))
922 if (DbgUI.Button(
"Timer Daytime"))
924 if (DbgUI.Button(
"Timer Location"))
926 if (DbgUI.Button(
"Timer Location(prio)"))
933 private void DisplayStaticLocations(
bool enabled)
939 vector position =
g_Game.GetCurrentCameraPosition();
943 foreach (array<vector> bounds : track.locationBoundaries)
945 locationMin = bounds[0];
946 locationMax = bounds[1];
948 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
951 Debug.CleanupDrawShapes(m_DebugShapesLocations);
953 locationMax[1] = locationMin[1] + 200.0;
954 locationMin[1] = locationMin[1] - 50.0;
958 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
959 DrawPolygonLocation(track);
964 foreach (array<vector> boundsPrio : trackPrio.locationBoundaries)
966 locationMin = boundsPrio[0];
967 locationMax = boundsPrio[1];
969 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
972 Debug.CleanupDrawShapes(m_DebugShapesLocations);
974 locationMax[1] = locationMin[1] + 200.0;
975 locationMin[1] = locationMin[1] - 50.0;
979 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
980 DrawPolygonLocation(trackPrio);
983 foreach (DynamicMusicLocationDynamicData locationDynamic : m_LocationsDynamic)
985 locationMin = locationDynamic.m_Min;
986 locationMax = locationDynamic.m_Max;
988 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
991 Debug.CleanupDrawShapes(m_DebugShapesLocations);
993 locationMax[1] = locationMin[1] + 200.0;
994 locationMin[1] = locationMin[1] - 50.0;
1000 Debug.CleanupDrawShapes(m_DebugShapesLocations);
1001 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
1005 private void DrawPolygonLocation(notnull DynamicMusicTrackData track)
1007 vector first, current, last;
1009 int count = track.vertices.Count();
1010 foreach (
int i, vector vertexPos : track.vertices)
1012 vertexPos[1] = vertexPos[1] + 0.5;
1013 current = vertexPos;
1027 #ifdef ENABLE_LOGGING
1028 private void DMPDebugPrint(
string message)
1030 #ifdef DMP_DEBUG_PRINT
const int TRACKS_BUFFER_HISTORY_SIZE
class DynamicMusicLocationDynamicData m_MinWaitTimeSeconds
float m_FadeoutTimeRequested
bool m_WaitingForPlayback
EDynamicMusicPlayerCategory m_CategorySelected
const float TICK_PRIORITY_LOCATION_UPDATE_SECONDS
float m_TickLocationCacheUpdateElapsed
const float LOCATION_DISTANCE_MAX
void SetCategory(DynamicMusicPlayerCategoryPlaybackData playbackData)
void CleanupDebugShapes(array< Shape > shapesArr)
DEPRECATED.
float GetWaitTimeForCategory(EDynamicMusicPlayerCategory category)
void OnCategorySet(EDynamicMusicPlayerCategory category, bool forced)
const float TICK_FADEOUT_PROCESSOR_SECONDS
int SelectRandomTrackIndexFromCategory(EDynamicMusicPlayerCategory category, int lookupType, notnull array< ref DynamicMusicTrackData > tracks)
AbstractWave m_SoundPlaying
float m_PreviousTrackFadeoutSeconds
float m_TickTimeOfDateElapsed
ref DynamicMusicPlayerRegistry m_DynamicMusicPlayerRegistry
float GetMinWaitTimePerCategory(EDynamicMusicPlayerCategory category)
bool IsPriotitizedCategorySelected()
void UnregisterDynamicLocation(notnull Entity caller)
ref map< EDynamicMusicPlayerCategory, ref SimpleCircularBuffer< int > > m_LastPlayedTrackBufferPerCategory
gets the playback mode as set in sounds menu; 0 - all; 1 - menu only
float GetPreviousTrackFadeoutSeconds(EDynamicMusicPlayerCategory category)
float m_TickFadeOutProcessingElapsed
void RegisterDynamicLocation(notnull Entity caller, int locationType, float locationSize)
void OnProfileOptionChanged(EDayZProfilesOptions option, int value)
void OnGameEvent(EventType eventTypeId, Param params)
bool PlayerInsideOfLocationFilter(array< ref DynamicMusicTrackData > locations)
void OnNextTrackSelected(DynamicMusicTrackData track, float waitTime)
void DetermineTrackByCategory(EDynamicMusicPlayerCategory category)
void OnLocationMatched(EDynamicMusicPlayerCategory category, bool isPriorityLocation)
void DynamicMusicPlayer(DynamicMusicPlayerRegistry configuration)
float GetMaxWaitTimePerCategory(EDynamicMusicPlayerCategory category)
float m_FadeoutTimeElapsed
const float TICK_LOCATION_CACHE_UPDATE_SECONDS
void RefreshTracksCache()
void FadeoutTrack(float fadeoutSeconds)
const float TICK_LOCATION_UPDATE_SECONDS
int SelectRandomTrackIndexFromCategoryPriorityFlagFirst(EDynamicMusicPlayerCategory category, notnull array< ref DynamicMusicTrackData > tracks)
ref array< ref DynamicMusicTrackData > m_TracksLocationStaticPrioritizedCached
static + filtered by the distance between player and center of zone
bool SetSelectedTrackFromCategory(EDynamicMusicPlayerCategory category, notnull array< ref DynamicMusicTrackData > tracklist, int historyLookupType=DynamicMusicPlayerTrackHistoryLookupType.ANY)
class DynamicMusicPlayerCategoryPlaybackData TICK_TIME_OF_DATE_UPDATE_SECONDS
DynamicMusicTrackData m_CurrentTrack
void PlayTrack(DynamicMusicTrackData track)
float m_TickPriorityLocationUpdateElapsed
ref array< ref DynamicMusicTrackData > m_TracksLocationMatchedPlayerInside
static prio + filtered by the distance between player and center of zone
void OnFadeoutFinished(EDynamicMusicPlayerCategory category)
ref array< ref DynamicMusicTrackData > m_TracksLocationStaticCached
map of dynamically registered locations during runtime
float m_TickLocationUpdateElapsed
float m_MaxWaitTimeSeconds
EDynamicMusicPlayerCategory
class PresenceNotifierNoiseEvents windowPosX
dbgUI settings
static ref ScriptInvoker m_OnIntOptionChanged
static void CleanupDrawShapes(array< Shape > shapes)
static array< vector > GetRectangularCoordsFromSize(vector origin, float size)
vector m_Min
rectangle coords (2d only)
const int CONTAMINATED_ZONE
EDynamicMusicPlayerCategory m_Category
ref array< ref DynamicMusicTrackData > m_TracksLocationDynamic
ref array< ref DynamicMusicTrackData > m_TracksCredits
ref array< ref DynamicMusicTrackData > m_TracksTime
ref array< ref DynamicMusicTrackData > m_TracksMenu
for backward compatibility
EDynamicMusicPlayerCategory m_Category
void InsertLocation(vector min, vector max)
ref array< vector > vertices
ref array< ref array< vector > > locationBoundaries
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto string ToString(bool beautify=true)
Vector to string.
const int INDEX_NOT_FOUND
const EventType MPSessionPlayerReadyEventTypeID
no params
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].
static proto bool IsPointInRectangle(vector mi, vector ma, vector p)
Returns if point is inside rectangle.
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].
static vector CenterOfRectangle(vector min, vector max)
class AbstractSoundScene SoundObjectBuilder(SoundParams soundParams)
class SoundObject SoundParams(string name)
proto native void SetKind(WaveKind kind)