Dayz Explorer 1.28.160049
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"
8
9enum EReplaceSoundEventID
10{
14 CLEANHANDS_SECONDARY
15}
16
17// Main purpose is to intercept animation system based sound event calls and replace them with different ones based on context
19{
21
23 protected ref Timer m_UpdateTimer;
24
26 {
27 m_Player = player;
28
29 RegisterEvent(new DigPrimarySoundEvent());
30 RegisterEvent(new DigSecondarySoundEvent());
31 RegisterEvent(new CleanHandsPrimarySoundEvent());
32 RegisterEvent(new CleanHandsSecondarySoundEvent());
33 }
34
35 // Inserts sound replace event to array of event maps, creates new event map if first sound of an event type is being registered
36 protected void RegisterEvent(ReplaceSoundEventBase soundEvent)
37 {
38 int sType = soundEvent.GetSoundEventType();
39
40 if (!m_SoundEventReplaceMaps.IsValidIndex(sType))
41 {
43 m_SoundEventReplaceMaps.InsertAt(replaceMap, sType);
44 }
45
46 m_SoundEventReplaceMaps[sType].Insert(soundEvent.GetSoundAnimEventClassID(), soundEvent);
47 }
48
49 int GetSoundEventID(int anim_id, ESoundEventType soundType)
50 {
51 if (!m_SoundEventReplaceMaps.IsValidIndex(soundType))
52 return 0;
53
54 ReplaceSoundEventBase soundEvent = m_SoundEventReplaceMaps[soundType].Get(anim_id);
55 if (!soundEvent)
56 return 0;
57
58 return soundEvent.GetSoundEventID();
59 }
60
62 {
63 if (!m_SoundEventReplaceMaps.IsValidIndex(soundType))
64 return null;
65
66 foreach (int animID, ReplaceSoundEventBase soundEvent : m_SoundEventReplaceMaps[soundType])
67 {
68 if (soundEvent.GetSoundEventID() == id)
69 return soundEvent;
70 }
71
72 return null;
73 }
74
75 bool PlayReplaceSound(int soundEventID, ESoundEventType soundType, int flags)
76 {
77 ReplaceSoundEventBase soundEvent = GetSoundEventByID(soundEventID, soundType);
78 if (!soundEvent)
79 return false;
80
81 ReplaceSoundEventBase soundEventObj = ReplaceSoundEventBase.Cast(soundEvent.ClassName().ToType().Spawn());
82 soundEventObj.Init(m_Player);
83 if (soundEventObj.Play())
84 return true;
85
86 return false;
87 }
88}
class DigSoundEventBase extends ReplaceSoundEventBase DigSecondarySoundEvent
void DigPrimarySoundEvent()
class CleanHandsSoundEventBase extends ReplaceSoundEventBase CleanHandsSecondarySoundEvent
void CleanHandsPrimarySoundEvent()
void Init(PlayerBase player)
EReplaceSoundEventID GetSoundEventID()
ESoundEventType GetSoundEventType()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayer m_Player
Definition hand_events.c:42
ref Timer m_UpdateTimer
Definition radialmenu.c:20
enum ESoundEventType m_SoundEventReplaceMaps
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)
int GetSoundEventID()