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\"",
451 m_DebugWaitTime = waitTime;
459 #ifdef ENABLE_LOGGING
460 string messagePriority;
461 if (isPriorityLocation)
462 messagePriority =
"(with priority)";
463 DMPDebugPrint(
string.Format(
"Location matched %1", messagePriority));
469 if (isPriorityLocation)
471 playbackData.
m_Forced = isPriorityLocation;
511 if (soundParams.IsValid())
514 SoundObject soundObject = soundBuilder.BuildSoundObject();
562 #ifdef ENABLE_LOGGING
563 DMPDebugPrint(
string.Format(
"Stopping currently played track %1",
m_CurrentTrack.m_SoundSet));
564 DMPDebugPrint(
string.Format(
"-- Setting fadeout to %1", fadeoutSeconds));
584 if (locations.Count() > 0)
588 switch (track.m_Shape)
590 case DynamicMusicLocationShape.BOX:
591 foreach (
int locationId,
array<vector> bounds : track.locationBoundaries)
598 #ifdef ENABLE_LOGGING
599 DMPDebugPrint(
string.Format(
"Player inside location <%1, %2>", bounds[0], bounds[1]));
604 case DynamicMusicLocationShape.POLYGON:
610 #ifdef ENABLE_LOGGING
611 DMPDebugPrint(
string.Format(
"Player inside polygon location at <%1>",
m_PlayerPosition));
624 if (locations.Count() > 0)
630 #ifdef ENABLE_LOGGING
631 DMPDebugPrint(
string.Format(
"Player inside location <%1, %2>", location.m_Min, location.m_Max));
643 if (tracklist.Count() == 0)
650 filteredTracks.Insert(filteredTrack);
681 if (!track.m_HasPriority)
684 priorityFlagIndices.Insert(i);
687 if (priorityFlagIndices.Count() > 0)
688 return priorityFlagIndices[priorityFlagIndices.GetRandomIndex()];
691 return tracks.GetRandomIndex();
699 int count = tracks.Count();
706 case DynamicMusicPlayerTrackHistoryLookupType.ANY:
709 case DynamicMusicPlayerTrackHistoryLookupType.BUFFER:
728 m_ActualTimeOfDay =
g_Game.GetMission().GetWorldData().GetDaytime();
743 #ifdef DIAG_DEVELOPER
744 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.DYNAMIC_MUSIC_PLAYER))
746 float timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
748 return waitTime / FeatureTimeAccel.GetFeatureTimeAccelValue();
757 #ifdef DIAG_DEVELOPER
758 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.DYNAMIC_MUSIC_PLAYER))
760 float timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
762 return waitTime / FeatureTimeAccel.GetFeatureTimeAccelValue();
780 if (track.
m_Shape == DynamicMusicLocationShape.BOX)
795 if (trackPrio.
m_Shape == DynamicMusicLocationShape.BOX)
809 #ifdef DIAG_DEVELOPER
810 private ref array<Shape> m_DebugShapesLocations =
new array<Shape>();
811 private ref array<Shape> m_DebugShapesLocationsVertices =
new array<Shape>();
812 private float m_DebugWaitTime = 0;
814 private void DisplayDebugStats(
bool enabled)
823 DbgUI.Text(
string.Format(
"Day/Night: %1", DynamicMusicPlayerTimeOfDay.ToString(m_ActualTimeOfDay)));
824 DbgUI.Text(
"Playback:");
825 DbgUI.Text(
string.Format(
" active: %1", isPlaybackActive.
ToString()));
831 DbgUI.Text(
"Update timers:");
840 DbgUI.Text(
"Player:");
845 DbgUI.Text(
"Tracks counts:");
864 string isPlaying =
"waiting";
866 isPlaying =
"playing";
868 DbgUI.Text(
string.Format(
"State: %1", isPlaying));
882 if (DbgUI.Button(
"Stop"))
885 if (DbgUI.Button(
"Reset Waiting"))
888 DynamicMusicPlayerCategoryPlaybackData playbackData =
new DynamicMusicPlayerCategoryPlaybackData();
891 DbgUI.Text(
"Set Category:\n");
892 if (DbgUI.Button(
"Time"))
894 if (DbgUI.Button(
"Location"))
899 if (DbgUI.Button(
"Menu"))
904 if (DbgUI.Button(
"Credits"))
910 DbgUI.Text(
"Reset Timers\n");
911 if (DbgUI.Button(
"Timer ALL"))
918 if (DbgUI.Button(
"Timer Daytime"))
920 if (DbgUI.Button(
"Timer Location"))
922 if (DbgUI.Button(
"Timer Location(prio)"))
929 private void DisplayStaticLocations(
bool enabled)
935 vector position =
g_Game.GetCurrentCameraPosition();
939 foreach (array<vector> bounds : track.locationBoundaries)
941 locationMin = bounds[0];
942 locationMax = bounds[1];
944 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
947 Debug.CleanupDrawShapes(m_DebugShapesLocations);
949 locationMax[1] = locationMin[1] + 200.0;
950 locationMin[1] = locationMin[1] - 50.0;
954 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
955 DrawPolygonLocation(track);
960 foreach (array<vector> boundsPrio : trackPrio.locationBoundaries)
962 locationMin = boundsPrio[0];
963 locationMax = boundsPrio[1];
965 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
968 Debug.CleanupDrawShapes(m_DebugShapesLocations);
970 locationMax[1] = locationMin[1] + 200.0;
971 locationMin[1] = locationMin[1] - 50.0;
975 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
976 DrawPolygonLocation(trackPrio);
979 foreach (DynamicMusicLocationDynamicData locationDynamic : m_LocationsDynamic)
981 locationMin = locationDynamic.m_Min;
982 locationMax = locationDynamic.m_Max;
984 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
987 Debug.CleanupDrawShapes(m_DebugShapesLocations);
989 locationMax[1] = locationMin[1] + 200.0;
990 locationMin[1] = locationMin[1] - 50.0;
996 Debug.CleanupDrawShapes(m_DebugShapesLocations);
997 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
1001 private void DrawPolygonLocation(notnull DynamicMusicTrackData track)
1003 vector first, current, last;
1005 int count = track.vertices.Count();
1006 foreach (
int i, vector vertexPos : track.vertices)
1008 vertexPos[1] = vertexPos[1] + 0.5;
1009 current = vertexPos;
1022 #ifdef ENABLE_LOGGING
1023 private void DMPDebugPrint(
string message)
1025 #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
class DynamicMusicTrackData ANY
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
proto native AbstractSoundScene GetSoundScene()
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
proto native CGame GetGame()
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)
proto native AbstractWave Play2D(SoundObject soundObject, SoundObjectBuilder soundBuilder)
class AbstractSoundScene SoundObjectBuilder(SoundParams soundParams)
class SoundObject SoundParams(string name)
proto native void SetKind(WaveKind kind)