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
69 #ifdef DMP_DEBUG_SETTINGS
92 protected int m_ActualTimeOfDay
106 private int m_RequestedPlaybackMode
123 m_ActualTimeOfDay = DynamicMusicPlayerTimeOfDay.ANY;
240 #ifdef DIAG_DEVELOPER
243 DisplayDebugStats(
true);
244 DisplayStaticLocations(
true);
261 int id = caller.GetID();
262 if (!m_LocationsDynamic.Contains(
id))
266 location.
m_Type = locationType;
267 location.
m_Min = minMax[0];
268 location.
m_Max = minMax[1];
269 m_LocationsDynamic.Insert(
id, location);
275 m_LocationsDynamic.Remove(caller.GetID());
349 m_RequestedPlaybackMode = value;
361 #ifdef DIAG_DEVELOPER
362 DMPDebugPrint(
string.Format(
363 "OnCategorySet() - category: %1, forced: %2",
374 #ifdef DIAG_DEVELOPER
376 DMPDebugPrint(
string.Format(
"Track END - %1",
m_CurrentTrack.m_SoundSet));
387 #ifdef DIAG_DEVELOPER
389 DMPDebugPrint(
string.Format(
"Track STOP - %1",
m_CurrentTrack.m_SoundSet));
405 #ifdef DIAG_DEVELOPER
406 DMPDebugPrint(
string.Format(
407 "WaitTime set to %1s, deferring playback of \"%2\"",
411 m_DebugWaitTime = waitTime;
419 #ifdef DIAG_DEVELOPER
420 string messagePriority;
421 if (isPriorityLocation)
422 messagePriority =
"(with priority)";
423 DMPDebugPrint(
string.Format(
"Location matched %1", messagePriority));
426 if (isPriorityLocation)
459 if (soundParams.IsValid())
462 SoundObject soundObject = soundBuilder.BuildSoundObject();
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));
531 if (locations.Count() > 0)
535 switch (track.m_Shape)
537 case DynamicMusicLocationShape.BOX:
538 foreach (
int locationId,
array<vector> bounds : track.locationBoundaries)
545 #ifdef DIAG_DEVELOPER
546 DMPDebugPrint(
string.Format(
"Player inside location <%1, %2>", bounds[0], bounds[1]));
551 case DynamicMusicLocationShape.POLYGON:
557 #ifdef DIAG_DEVELOPER
558 DMPDebugPrint(
string.Format(
"Player inside polygon location at <%1>",
m_PlayerPosition));
571 if (locations.Count() > 0)
577 #ifdef DIAG_DEVELOPER
578 DMPDebugPrint(
string.Format(
"Player inside location <%1, %2>", location.m_Min, location.m_Max));
590 if (tracklist.Count() == 0)
596 if (filteredTrack.m_TimeOfDay == m_ActualTimeOfDay || filteredTrack.m_TimeOfDay == DynamicMusicPlayerTimeOfDay.ANY)
597 filteredTracks.Insert(filteredTrack);
628 if (!track.m_HasPriority)
631 priorityFlagIndices.Insert(i);
634 if (priorityFlagIndices.Count() > 0)
635 return priorityFlagIndices[priorityFlagIndices.GetRandomIndex()];
638 return tracks.GetRandomIndex();
646 int count = tracks.Count();
653 case DynamicMusicPlayerTrackHistoryLookupType.ANY:
656 case DynamicMusicPlayerTrackHistoryLookupType.BUFFER:
675 m_ActualTimeOfDay =
g_Game.GetMission().GetWorldData().GetDaytime();
679 m_ActualTimeOfDay = DynamicMusicPlayerTimeOfDay.DAY;
690 #ifdef DIAG_DEVELOPER
691 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.DYNAMIC_MUSIC_PLAYER))
693 float timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
695 return waitTime / FeatureTimeAccel.GetFeatureTimeAccelValue();
704 #ifdef DIAG_DEVELOPER
705 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.DYNAMIC_MUSIC_PLAYER))
707 float timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
709 return waitTime / FeatureTimeAccel.GetFeatureTimeAccelValue();
727 if (track.
m_Shape == DynamicMusicLocationShape.BOX)
742 if (trackPrio.
m_Shape == DynamicMusicLocationShape.BOX)
756 #ifdef DIAG_DEVELOPER
759 private float m_DebugWaitTime = 0;
761 private void DisplayDebugStats(
bool enabled)
770 DbgUI.
Text(
string.Format(
"Day/Night: %1", DynamicMusicPlayerTimeOfDay.ToString(m_ActualTimeOfDay)));
787 DbgUI.Text(
"Player:");
792 DbgUI.Text(
"Tracks counts:");
808 string isPlaying =
"waiting";
810 isPlaying =
"playing";
812 DbgUI.Text(
string.Format(
"State: %1", isPlaying));
817 DbgUI.Text(
string.Format(
"Sound set: %1",
m_CurrentTrack.m_SoundSet));
819 DbgUI.Text(
string.Format(
"Time of day: %1", DynamicMusicPlayerTimeOfDay.ToString(
m_CurrentTrack.m_TimeOfDay)));
826 if (DbgUI.Button(
"Stop"))
829 if (DbgUI.Button(
"Reset Waiting"))
832 DbgUI.Text(
"Set Category:\n");
833 if (DbgUI.Button(
"Time"))
835 if (DbgUI.Button(
"Location"))
838 DbgUI.Text(
"Reset Timers\n");
839 if (DbgUI.Button(
"Timer ALL"))
846 if (DbgUI.Button(
"Timer Daytime"))
848 if (DbgUI.Button(
"Timer Location"))
850 if (DbgUI.Button(
"Timer Location(prio)"))
857 private void DisplayStaticLocations(
bool enabled)
863 vector position =
g_Game.GetCurrentCameraPosition();
867 foreach (array<vector> bounds : track.locationBoundaries)
869 locationMin = bounds[0];
870 locationMax = bounds[1];
872 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
875 Debug.CleanupDrawShapes(m_DebugShapesLocations);
877 locationMax[1] = locationMin[1] + 200.0;
878 locationMin[1] = locationMin[1] - 50.0;
882 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
883 DrawPolygonLocation(track);
888 foreach (array<vector> boundsPrio : trackPrio.locationBoundaries)
890 locationMin = boundsPrio[0];
891 locationMax = boundsPrio[1];
893 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
896 Debug.CleanupDrawShapes(m_DebugShapesLocations);
898 locationMax[1] = locationMin[1] + 200.0;
899 locationMin[1] = locationMin[1] - 50.0;
903 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
904 DrawPolygonLocation(trackPrio);
907 foreach (DynamicMusicLocationDynamicData locationDynamic : m_LocationsDynamic)
909 locationMin = locationDynamic.m_Min;
910 locationMax = locationDynamic.m_Max;
912 if (vector.Distance(position, Math.CenterOfRectangle(locationMin, locationMax)) > 2000)
915 Debug.CleanupDrawShapes(m_DebugShapesLocations);
917 locationMax[1] = locationMin[1] + 200.0;
918 locationMin[1] = locationMin[1] - 50.0;
924 Debug.CleanupDrawShapes(m_DebugShapesLocations);
925 Debug.CleanupDrawShapes(m_DebugShapesLocationsVertices);
929 private void DrawPolygonLocation(notnull DynamicMusicTrackData track)
931 vector first, current, last;
933 int count = track.vertices.Count();
934 foreach (
int i, vector vertexPos : track.vertices)
936 vertexPos[1] = vertexPos[1] + 0.5;
950 private void DMPDebugPrint(
string message)
952 #ifdef DMP_DEBUG_PRINT
958 private void CleanupDebugShapes(array<Shape> shapesArr)
960 Debug.CleanupDrawShapes(shapesArr);
class DynamicMusicLocationDynamicData m_MinWaitTimeSeconds
class DynamicMusicTrackData ANY
float m_PreviousTrackFadeoutSeconds
float m_MaxWaitTimeSeconds
EDynamicMusicPlayerCategory
class PresenceNotifierNoiseEvents windowPosX
dbgUI settings
proto native AbstractSoundScene GetSoundScene()
static ref ScriptInvoker m_OnIntOptionChanged
static array< vector > GetRectangularCoordsFromSize(vector origin, float size)
vector m_Min
rectangle coords (2d only)
const int CONTAMINATED_ZONE
const int TRACKS_BUFFER_HISTORY_SIZE
float m_TickLocationCacheUpdateElapsed
int SelectRandomTrackIndexFromCategory(EDynamicMusicPlayerCategory category, int lookupType, notnull array< ref DynamicMusicTrackData > tracks)
void OnFadeoutFinished(EDynamicMusicPlayerCategory category)
const float LOCATION_DISTANCE_MAX
float GetMaxWaitTimePerCategory(EDynamicMusicPlayerCategory category)
DynamicMusicTrackData m_CurrentTrack
void OnUpdate(float timeslice)
int SelectRandomTrackIndexFromCategoryPriorityFlagFirst(EDynamicMusicPlayerCategory category, notnull array< ref DynamicMusicTrackData > tracks)
const float TICK_LOCATION_CACHE_UPDATE_SECONDS
void FadeoutTrack(float fadeoutSeconds)
float m_TickLocationUpdateElapsed
float m_TickFadeOutProcessingElapsed
void RegisterDynamicLocation(notnull Entity caller, int locationType, float locationSize)
const float TICK_TIME_OF_DATE_UPDATE_SECONDS
float m_TickPriorityLocationUpdateElapsed
void SetCategory(EDynamicMusicPlayerCategory category, bool forced)
float m_FadeoutTimeElapsed
ref array< ref DynamicMusicTrackData > m_TracksLocationStaticPrioritizedCached
static + filtered by the distance between player and center of zone
EDynamicMusicPlayerCategory m_CategorySelected
float GetWaitTimeForCategory(EDynamicMusicPlayerCategory category)
float GetMinWaitTimePerCategory(EDynamicMusicPlayerCategory category)
void OnProfileOptionChanged(EDayZProfilesOptions option, int value)
bool SetSelectedTrackFromCategory(EDynamicMusicPlayerCategory category, notnull array< ref DynamicMusicTrackData > tracklist, int historyLookupType=DynamicMusicPlayerTrackHistoryLookupType.ANY)
void UnregisterDynamicLocation(notnull Entity caller)
float m_FadeoutTimeRequested
ref array< ref DynamicMusicTrackData > m_TracksLocationMatchedPlayerInside
static prio + filtered by the distance between player and center of zone
AbstractWave m_SoundPlaying
float m_TickTimeOfDateElapsed
void OnCategorySet(EDynamicMusicPlayerCategory category, bool forced)
void OnNextTrackSelected(DynamicMusicTrackData track, float waitTime)
bool IsPriotitizedCategorySelected()
ref DynamicMusicPlayerRegistry m_DynamicMusicPlayerRegistry
void RefreshTracksCache()
void OnGameEvent(EventType eventTypeId, Param params)
ref array< ref DynamicMusicTrackData > m_TracksLocationStaticCached
map of dynamically registered locations during runtime
bool PlayerInsideOfLocationFilter(array< ref DynamicMusicTrackData > locations)
void PlayTrack(DynamicMusicTrackData track)
void DetermineTrackByCategory(EDynamicMusicPlayerCategory category)
void DynamicMusicPlayer(DynamicMusicPlayerRegistry configuration)
const float TICK_FADEOUT_PROCESSOR_SECONDS
void OnLocationMatched(EDynamicMusicPlayerCategory category, bool isPriorityLocation)
bool PlayerInsideOfLocationFilter(map< int, ref DynamicMusicLocationDynamicData > locations)
const float TICK_PRIORITY_LOCATION_UPDATE_SECONDS
const float TICK_LOCATION_UPDATE_SECONDS
float GetPreviousTrackFadeoutSeconds(EDynamicMusicPlayerCategory category)
ref map< EDynamicMusicPlayerCategory, ref SimpleCircularBuffer< int > > m_LastPlayedTrackBufferPerCategory
gets the playback mode as set in sounds menu; 0 - all; 1 - menu only
bool m_WaitingForPlayback
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.
const int INDEX_NOT_FOUND
const EventType MPSessionPlayerReadyEventTypeID
no params
proto native CGame GetGame()
static proto native void Begin(string windowTitle, float x=0, float y=0)
static proto native void Text(string label)
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 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)