DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ItemSoundHandler.c
См. документацию.
2{
3 float m_FadeIn = 0;
4 float m_FadeOut = 0;
5 bool m_Loop = false;
6}
7
8/*
9Provides functionality to start item related sound from server and synchronize it to clients
10Useful in situations where unique animation can't be used to bind the sound
11
12Steps to add new item sound:
13 1) Add new sound ID to SoundConstants class
14 2) Override InitItemSounds() method on subject item to link the new sound ID to a soundset
15 2.5) Generally soundset is retreived by adding override to the subject item class, but retreiving from config or using other means could also be used here
16 3) Start sound using ItemBase::StartItemSoundServer(int id) called from server side
17 3.5) For looped sounds which do not end on their own, use ItemBase::StopItemSoundServer(int id)
18
19Limitations:
20 Avoid starting two sounds at the same time using this handler as just single variable is used for synchronization (can be solved by secondary synch var if need arises)
21
22*/
24{
25 protected ItemBase m_Parent;
26
30
32 {
33 m_Parent = parent;
34 Init();
35 }
36
38 {
39 if (!m_PlayingSounds)
40 return;
41
42 foreach (EffectSound sound : m_PlayingSounds)
43 {
44 if (sound)
45 sound.SoundStop();
46 }
47 }
48
55
57 {
58 string soundSet = m_AvailableSoundsets.Get(id);
59 if (soundSet == string.Empty)
60 {
61 Debug.Log("Attempting to play soundID " + id + " without defined soundset. Item: " + m_Parent.GetType());
62 return;
63 }
64
65 if (m_PlayingSounds.Get(id)) // already playing
66 return;
67
68 EffectSound sound;
69 SoundParameters params = m_SoundParamsMap.Get(id);
70 if (params)
71 sound = SEffectManager.PlaySoundCachedParams(soundSet, m_Parent.GetPosition(), params.m_FadeIn, params.m_FadeOut, params.m_Loop);
72 else
73 sound = SEffectManager.PlaySound(soundSet, m_Parent.GetPosition());
74
75 if (sound)
76 sound.SetAutodestroy(true);
77 else
78 Debug.Log("Null when creating sound from set: " + soundSet + " Item: " + m_Parent.GetType() );
79
80 m_PlayingSounds.Insert(id, sound);
81 }
82
84 {
85 if (GetGame().IsDedicatedServer())
86 return;
87
88 EffectSound sound = m_PlayingSounds.Get(id);
89 if (sound)
90 {
91 sound.SetSoundFadeOut(0.1);
92 sound.SoundStop();
93 }
94
95 m_PlayingSounds.Remove(id);
96 }
97
98 void AddSound(int sound, string soundset, SoundParameters params = null)
99 {
100 m_AvailableSoundsets.Insert(sound, soundset);
101
102 if (params)
103 m_SoundParamsMap.Insert(sound, params);
104 }
105}
map
Определения ControlsXboxNew.c:4
Empty
Определения Hand_States.c:14
void PlayItemSoundClient(int id)
Определения ItemSoundHandler.c:56
ref map< int, string > m_AvailableSoundsets
Определения ItemSoundHandler.c:28
void ~ItemSoundHandler()
Определения ItemSoundHandler.c:37
void AddSound(int sound, string soundset, SoundParameters params=null)
Определения ItemSoundHandler.c:98
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
void StopItemSoundClient(int id)
Определения ItemSoundHandler.c:83
ref map< int, ref EffectSound > m_PlayingSounds
Определения ItemSoundHandler.c:27
ref map< int, ref SoundParameters > m_SoundParamsMap
Определения ItemSoundHandler.c:29
Widget m_Parent
Определения SizeToChild.c:92
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Определения Debug.c:122
Определения Debug.c:2
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
void SetSoundFadeOut(float fade_out)
Set the sound fade out duration.
Определения EffectSound.c:891
void SoundStop()
Stops sound.
Определения EffectSound.c:217
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения InventoryItem.c:731
static void Init()
Определения PPERequesterBank.c:51
TODO doc.
Определения EnScript.c:118
static EffectSound PlaySoundCachedParams(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound, using or creating cached SoundParams.
Определения EffectManager.c:207
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
Определения EffectManager.c:169
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
bool m_Loop
Определения ItemSoundHandler.c:5
float m_FadeIn
Определения ItemSoundHandler.c:3
float m_FadeOut
Определения ItemSoundHandler.c:4
proto native CGame GetGame()