Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
dayzanimeventmaps.c
Go to the documentation of this file.
1 //individual sound table consisting of map of parameter hashes as keys and soundbuilder array as values
3 {
4  void SoundLookupTable()
5  {
6  m_soundBuilders = new map<int, ref array<SoundObjectBuilder>>();
7  }
8 
9  void InitTable(string tableCategoryName, string parameterName)
10  {
11  m_tableCategoryName = tableCategoryName;
12  m_parameterName = parameterName;
13  }
14 
15  void LoadTable(string soundLookupTableName)
16  {
17  string path = "CfgSoundTables " + m_tableCategoryName + " " + soundLookupTableName;
18 
19  //load all classes names
20  int soundCount = GetGame().ConfigGetChildrenCount(path);
21 
22  for(int i = 0; i < soundCount; i++)
23  {
24  string soundClassName;
25  GetGame().ConfigGetChildName(path, i, soundClassName);
26  string soundClassPath = path + " " + soundClassName + " ";
27 
28  string parameter;
29  GetGame().ConfigGetText(soundClassPath + m_parameterName, parameter);
30 
31  array<string> soundSetNames = new array<string>;
32  GetGame().ConfigGetTextArray(soundClassPath + "soundSets", soundSetNames);
33 
34  //TODO create SoundObject for every entry, save in Game?
35  array<SoundObjectBuilder> soundObjectBuilders = new array<SoundObjectBuilder>;
36  for(int j = 0; j < soundSetNames.Count(); j++)
37  {
39  SoundObjectBuilder soundObjectBuilder = bank.GetBuilder(soundSetNames.Get(j));
40 
41  if(soundObjectBuilder != NULL)
42  soundObjectBuilders.Insert(soundObjectBuilder);
43  }
44 
45  if(soundObjectBuilders.Count() > 0)
46  {
47  //Print("SoundLookupTable::LoadTable: path: " + path + " param:" + parameter + " param#:" + parameter.Hash() + " objBuildersCount: " + soundObjectBuilders.Count());
48  m_soundBuilders.Insert(parameter.Hash(), soundObjectBuilders);
49  }
50  }
51  }
52 
53  SoundObjectBuilder GetSoundBuilder(int parameterHash)
54  {
55  array<SoundObjectBuilder> soundObjects = m_soundBuilders.Get(parameterHash);
56 
57  if(soundObjects == NULL || soundObjects.Count() == 0)
58  {
59  return NULL;
60  }
61  else if (soundObjects.Count() == 1)
62  {
63  return soundObjects.Get(0);
64  }
65  else
66  {
67  int index = Math.RandomInt(0, soundObjects.Count());
68  return soundObjects.Get(index);
69  }
70  }
71 
72 
73  private string m_tableCategoryName;
74  private string m_parameterName;
75  private ref map<int, ref array<SoundObjectBuilder>> m_soundBuilders;
76 }
77 
78 
80 {
82  {
83  InitTable("CfgStepSoundTables", "surface");
84  }
85 }
86 
87 class AttachmentSoundLookupTable extends SoundLookupTable
88 {
89  void AttachmentSoundLookupTable()
90  {
91  InitTable("CfgAttachmentSoundTables", "category");
92  }
93 }
94 
96 {
98 
100  {
101  InitTable("CfgVoiceSoundTables", "category");
102  }
103 
105  {
106  m_NoiseParams = param;
107  }
108 
110  {
111  return m_NoiseParams;
112  }
113 }
114 
115 
117 {
119  {
120  InitTable("CfgImpactSoundTables", "surface");
121  }
122 }
123 
125 {
127  {
128  InitTable("CfgActionsSoundTables", "category");
129  }
130 }
131 
132 
134 {
136  {
137  m_pBuilders = new map<int, ref SoundObjectBuilder>();
138  }
139 
140 
141  static AnimSoundObjectBuilderBank GetInstance()
142  {
143  if(m_instance == NULL)
144  m_instance = new AnimSoundObjectBuilderBank();
145 
146  return m_instance;
147  }
148 
149 
150  SoundObjectBuilder GetBuilder(string soundSetName)
151  {
152  int soundSetNameHash = soundSetName.Hash();
153 
154  SoundObjectBuilder builder = m_pBuilders.Get(soundSetNameHash);
155  if(builder == NULL)
156  {
157  SoundParams params = new SoundParams(soundSetName);
158  if(params.IsValid())
159  {
160  builder = new SoundObjectBuilder(params);
161  m_pBuilders.Insert(soundSetNameHash, builder);
162  }
163  else
164  {
165  Print("AnimSoundObjectBuilderBank: Invalid sound set \"" + soundSetName + "\".");
166  return NULL;
167  }
168  }
169  return builder;
170  }
171 
172  private static ref AnimSoundObjectBuilderBank m_instance;
173  private autoptr map<int, ref SoundObjectBuilder> m_pBuilders;
174 }
175 
176 
178 {
180  {
182  }
183 
184 
185  static AnimSoundLookupTableBank GetInstance()
186  {
187  if(m_instance == NULL)
188  m_instance = new AnimSoundLookupTableBank();
189 
190  return m_instance;
191  }
192 
193 
194  SoundLookupTable GetStepTable(string tableName)
195  {
196  int tableNameHash = tableName.Hash();
197 
198  SoundLookupTable table = m_pTables.Get(tableNameHash);
199  if(table == NULL)
200  {
201  table = new StepSoundLookupTable();
202  table.LoadTable(tableName);
203  m_pTables.Insert(tableNameHash, table);
204  }
205  return table;
206  }
207 
209  {
210  int tableNameHash = tableName.Hash();
211 
212  SoundLookupTable table = m_pTables.Get(tableNameHash);
213  if(table == NULL)
214  {
215  table = new ImpactSoundLookupTable();
216  table.LoadTable(tableName);
217  m_pTables.Insert(tableNameHash, table);
218  }
219  return table;
220  }
221 
223  {
224  int tableNameHash = tableName.Hash();
225 
226  SoundLookupTable table = m_pTables.Get(tableNameHash);
227  if(table == NULL)
228  {
229  table = new ActionSoundLookupTable();
230  table.LoadTable(tableName);
231  m_pTables.Insert(tableNameHash, table);
232  }
233  return table;
234  }
235 
236  private static ref AnimSoundLookupTableBank m_instance;
238 }
PlayerVoiceLookupTable
void PlayerVoiceLookupTable()
Definition: dayzanimeventmaps.c:99
GetGame
proto native CGame GetGame()
m_NoiseParams
class AttachmentSoundLookupTable extends SoundLookupTable m_NoiseParams
InitTable
void InitTable(string tableCategoryName, string parameterName)
Definition: dayzanimeventmaps.c:7
ActionSoundLookupTable
class ImpactSoundLookupTable extends SoundLookupTable ActionSoundLookupTable()
Definition: dayzanimeventmaps.c:126
GetImpactTable
SoundLookupTable GetImpactTable(string tableName)
Definition: dayzanimeventmaps.c:208
Print
proto void Print(void var)
Prints content of variable to console/log.
SoundObjectBuilder
void SoundObjectBuilder(SoundParams soundParams)
StepSoundLookupTable
class SoundLookupTable StepSoundLookupTable()
Definition: dayzanimeventmaps.c:81
AnimSoundObjectBuilderBank
Definition: dayzanimeventmaps.c:133
ImpactSoundLookupTable
void ImpactSoundLookupTable()
Definition: dayzanimeventmaps.c:110
GetNoiseParam
NoiseParams GetNoiseParam()
Definition: dayzanimeventmaps.c:109
SoundParams
Definition: sound.c:100
map
map
Definition: controlsxboxnew.c:3
NoiseParams
class ObjectSpawnerHandler NoiseParams
m_pTables
private autoptr map< int, ref SoundLookupTable > m_pTables
Definition: dayzanimeventmaps.c:237
array< string >
GetActionTable
SoundLookupTable GetActionTable(string tableName)
Definition: dayzanimeventmaps.c:222
SetNoiseParam
void SetNoiseParam(NoiseParams param)
Definition: dayzanimeventmaps.c:104
AnimSoundLookupTableBank
class AnimSoundObjectBuilderBank AnimSoundLookupTableBank()
Definition: dayzanimeventmaps.c:179
SoundObjectBuilder
Definition: sound.c:45
SoundLookupTable
Definition: dayzanimeventmaps.c:2
Math
Definition: enmath.c:6
GetStepTable
SoundLookupTable GetStepTable(string tableName)
Definition: dayzanimeventmaps.c:194
path
string path
Definition: optionselectormultistate.c:135