Skip to content

Commit 9bfcaae

Browse files
committed
Change Notes:
- Moved states info into the event dat as we didn't need them as separate dats.
1 parent f37f9ff commit 9bfcaae

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

Editors/Audio/Shared/AudioProject/Compiler/AudioProjectCompilerService.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,20 +239,24 @@ private void GenerateSoundBanks(AudioProjectFile audioProject)
239239

240240
private void GenerateDatFiles(AudioProjectFile audioProject, string audioProjectFileNameWithoutExtension)
241241
{
242-
// The .dat file is seems to only necessary for playing movie Action Events and any triggered via common.trigger_soundevent()
243-
// but without testing all the different types of Action Event sounds it's safer to just make a .dat for all as it's little overhead.
242+
// The .dat file is seems to only necessary for Action Events for movies, quest battles or anything triggered via common.trigger_soundevent()
243+
// but without testing all the different types of Action Event sounds it's safer to just make a .dat for all.
244+
// We store States in there so we can display them in the Audio Explorer.
244245
var actionEvents = audioProject.GetActionEvents();
245-
if (actionEvents.Count != 0)
246+
if (actionEvents.Count != 0 && audioProject.StateGroups != null && audioProject.StateGroups.Count != 0)
246247
{
247-
_logger.Here().Information($"Generating Event .dat");
248-
_datGeneratorService.GenerateEventDatFile(actionEvents, audioProjectFileNameWithoutExtension);
248+
_logger.Here().Information($"Generating event data .dat");
249+
_datGeneratorService.GenerateEventDatFile(audioProjectFileNameWithoutExtension, actionEvents, audioProject.StateGroups);
249250
}
250-
251-
// We create the states .dat file so we can see the modded states in the Audio Explorer, it isn't necessary for the game
252-
if (audioProject.StateGroups != null && audioProject.StateGroups.Count != 0)
251+
else if (actionEvents.Count != 0 && audioProject.StateGroups == null)
252+
{
253+
_logger.Here().Information($"Generating event data .dat");
254+
_datGeneratorService.GenerateEventDatFile(audioProjectFileNameWithoutExtension, actionEvents: actionEvents);
255+
}
256+
else if (actionEvents.Count == 0 && audioProject.StateGroups != null && audioProject.StateGroups.Count != 0)
253257
{
254-
_logger.Here().Information($"Generating States .dat");
255-
_datGeneratorService.GenerateStatesDatFile(audioProject.StateGroups, audioProjectFileNameWithoutExtension);
258+
_logger.Here().Information($"Generating event data .dat");
259+
_datGeneratorService.GenerateEventDatFile(audioProjectFileNameWithoutExtension, stateGroups: audioProject.StateGroups);
256260
}
257261
}
258262
}

Editors/Audio/Shared/Dat/DatGeneratorService.cs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,39 @@ namespace Editors.Audio.Shared.Dat
88
{
99
public interface IDatGeneratorService
1010
{
11-
void GenerateEventDatFile(List<ActionEvent> actionEvents, string audioProjectFileNameWithoutExtension);
12-
void GenerateStatesDatFile(List<StateGroup> stateGroups, string audioProjectFileNameWithoutExtension);
11+
void GenerateEventDatFile(string audioProjectFileNameWithoutExtension, List<ActionEvent> actionEvents = null, List<StateGroup> stateGroups = null);
1312
}
1413

1514
public class DatGeneratorService(IFileSaveService fileSaveService) : IDatGeneratorService
1615
{
1716
private readonly IFileSaveService _fileSaveService = fileSaveService;
1817

19-
public void GenerateEventDatFile(List<ActionEvent> actionEvents, string audioProjectFileNameWithoutExtension)
18+
public void GenerateEventDatFile(string audioProjectFileNameWithoutExtension, List<ActionEvent> actionEvents = null, List<StateGroup> stateGroups = null)
2019
{
21-
var soundDatFile = new SoundDatFile();
20+
var datFile = new SoundDatFile();
2221

23-
foreach (var actionEvent in actionEvents)
24-
soundDatFile.EventWithStateGroup.Add(new SoundDatFile.DatEventWithStateGroup() { Event = actionEvent.Name, Value = 400 });
25-
26-
var datFileName = $"event_data__{audioProjectFileNameWithoutExtension}.dat";
27-
var datFilePath = $"audio\\wwise\\{datFileName}";
28-
SaveDatFileToPack(soundDatFile, datFileName, datFilePath);
29-
}
30-
31-
public void GenerateStatesDatFile(List<StateGroup> stateGroups, string audioProjectFileNameWithoutExtension)
32-
{
33-
var stateDatFile = new SoundDatFile();
22+
if (actionEvents != null && actionEvents.Count > 0)
23+
{
24+
foreach (var actionEvent in actionEvents)
25+
datFile.EventWithStateGroup.Add(new SoundDatFile.DatEventWithStateGroup() { Event = actionEvent.Name, Value = 400 });
26+
}
3427

35-
foreach (var stateGroup in stateGroups)
28+
if (stateGroups != null && stateGroups.Count > 0)
3629
{
37-
var states = new List<string>();
38-
foreach (var state in stateGroup.States)
39-
states.Add(state.Name);
4030

41-
stateDatFile.StateGroupsWithStates1.Add(new SoundDatFile.DatStateGroupsWithStates() { StateGroup = stateGroup.Name, States = states });
31+
foreach (var stateGroup in stateGroups)
32+
{
33+
var states = new List<string>();
34+
foreach (var state in stateGroup.States)
35+
states.Add(state.Name);
36+
37+
datFile.StateGroupsWithStates1.Add(new SoundDatFile.DatStateGroupsWithStates() { StateGroup = stateGroup.Name, States = states });
38+
}
4239
}
4340

44-
var datFileName = $"states_data__{audioProjectFileNameWithoutExtension}.dat";
41+
var datFileName = $"event_data__{audioProjectFileNameWithoutExtension}.dat";
4542
var datFilePath = $"audio\\wwise\\{datFileName}";
46-
SaveDatFileToPack(stateDatFile, datFileName, datFilePath);
43+
SaveDatFileToPack(datFile, datFileName, datFilePath);
4744
}
4845

4946
private void SaveDatFileToPack(SoundDatFile datFile, string datFileName, string datFilePath)

0 commit comments

Comments
 (0)