Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
replacesoundeventhandler.c
Go to the documentation of this file.
2{
3 SOUND_COMMON = 0 // "Sound"
4 SOUND_WEAPON, // "SoundWeapon"
5 SOUND_ATTACHMENT, // "SoundAttachment"
6 SOUND_VOICE // "SoundVoice"
7}
8
9enum EReplaceSoundEventID
10{
16 EAT_FRUIT
17}
18
19// Main purpose is to intercept animation system based sound event calls and replace them with different ones based on context
21{
23
25 protected ref Timer m_UpdateTimer;
26
28 {
29 m_Player = player;
30
31 RegisterEvent(new DigPrimarySoundEvent());
32 RegisterEvent(new DigSecondarySoundEvent());
33 RegisterEvent(new CleanHandsPrimarySoundEvent());
34 RegisterEvent(new CleanHandsSecondarySoundEvent());
35 RegisterEvent(new EatingVoiceOverrideDefault());
36 RegisterEvent(new EatingVoiceOverrideFruit());
37 }
38
39 // Inserts sound replace event to array of event maps, creates new event map if first sound of an event type is being registered
40 protected void RegisterEvent(ReplaceSoundEventBase soundEvent)
41 {
42 int sType = soundEvent.GetSoundEventType();
43
44 if (!m_MainReplaceMap.Contains(sType))
45 {
47 m_MainReplaceMap.Set(sType, replaceMap);
48 }
49
50 m_MainReplaceMap[sType].Insert(soundEvent.GetSoundAnimEventClassID(), soundEvent);
51 }
52
53 int GetSoundEventID(int anim_id, ESoundEventType soundType)
54 {
55 if (!m_MainReplaceMap.Contains(soundType))
56 return 0;
57
58 ReplaceSoundEventBase soundEvent = m_MainReplaceMap[soundType].Get(anim_id);
59 if (!soundEvent)
60 return 0;
61
62 return soundEvent.GetSoundEventID();
63 }
64
66 {
67 if (!m_MainReplaceMap.Contains(soundType))
68 return null;
69
70 foreach (int animID, ReplaceSoundEventBase soundEvent : m_MainReplaceMap[soundType])
71 {
72 if (soundEvent.GetSoundEventID() == id)
73 return soundEvent;
74 }
75
76 return null;
77 }
78
79 bool PlayReplaceSound(int soundEventID, ESoundEventType soundType, int flags)
80 {
81 ReplaceSoundEventBase soundEvent = GetSoundEventByID(soundEventID, soundType);
82 if (!soundEvent)
83 return false;
84
85 ReplaceSoundEventBase soundEventObj = ReplaceSoundEventBase.Cast(soundEvent.ClassName().ToType().Spawn());
86 soundEventObj.Init(m_Player);
87
88 return soundEventObj.Play();
89 }
90
91 //DEPRECATED
93 protected static ref array< ref map<int, ref ReplaceSoundEventBase> > m_SoundEventReplaceMaps = {};
94}
void EatingVoiceOverrideDefault()
EatingVoiceOverrideDefault EatingVoiceOverrideBase EatingVoiceOverrideFruit()
class DigSoundEventBase extends ReplaceSoundEventBase DigSecondarySoundEvent
void DigPrimarySoundEvent()
class CleanHandsSoundEventBase extends ReplaceSoundEventBase CleanHandsSecondarySoundEvent
void CleanHandsPrimarySoundEvent()
map m_Player
void Init(PlayerBase player)
EReplaceSoundEventID GetSoundEventID()
ESoundEventType GetSoundEventType()
ref Timer m_UpdateTimer
Definition radialmenu.c:20
enum ESoundEventType EAT_DEFAULT
enum ESoundEventType CLEANHANDS_SECONDARY
enum ESoundEventType CLEANHANDS_PRIMARY
void ReplaceSoundEventHandler(PlayerBase player)
enum ESoundEventType DIG_PRIMARY
enum ESoundEventType DIG_SECONDARY
ReplaceSoundEventBase GetSoundEventByID(int id, ESoundEventType soundType)
bool PlayReplaceSound(int soundEventID, ESoundEventType soundType, int flags)
enum ESoundEventType m_MainReplaceMap
int GetSoundEventID()