|
16 | 16 | using System.IO; |
17 | 17 | using System.Linq; |
18 | 18 | using System.Numerics; |
| 19 | +using System.Reactive; |
19 | 20 | using System.Windows; |
20 | 21 | using static LegendaryExplorer.Misc.ExperimentsTools.PackageAutomations; |
21 | 22 | using static LegendaryExplorer.Misc.ExperimentsTools.SequenceAutomations; |
@@ -1877,7 +1878,7 @@ public static void RenameWwiseAudio(IMEPackage pcc, ExportEntry wwiseBankEntry, |
1877 | 1878 | Random random = new(); |
1878 | 1879 |
|
1879 | 1880 | Dictionary<uint, uint> idPairs = new(); |
1880 | | - idPairs.AddRange(UpdateIDs_EXPERIMENTAL(wwiseEvents, random)); |
| 1881 | + idPairs.AddRange(pcc.Game == MEGame.LE2 ? UpdateLE2EventIDs_EXPERIMENTAL(wwiseEvents, random) : UpdateIDs_EXPERIMENTAL(wwiseEvents, random)); // LE2 WwiseEvent IDs are in the Binary, instead of being a prop |
1881 | 1882 | idPairs.AddRange(UpdateIDs_EXPERIMENTAL(wwiseStreams)); |
1882 | 1883 |
|
1883 | 1884 | UpdateAudioIDs_EXPERIMENTAL(wwiseBankEntry, newWwiseBankName, idPairs, random); |
@@ -2146,13 +2147,52 @@ private static void RenameSoundNodeWaves(IMEPackage pcc, List<ExportEntry> nodeW |
2146 | 2147 | } |
2147 | 2148 | } |
2148 | 2149 |
|
2149 | | - /// <summary> |
2150 | | - /// Update the IDs of a list of ExportEntries with hashes of their names. |
2151 | | - /// </summary> |
2152 | | - /// <param name="entries">WwiseStreams to update.</param> |
2153 | | - /// <param name="random">If not null, the random object to generate ids, instead of the name.</param> |
2154 | | - /// <returns>KVP of old and new IDs. Used to update references.</returns> |
2155 | | - private static Dictionary<uint, uint> UpdateIDs_EXPERIMENTAL(List<ExportEntry> entries, Random random = null) |
| 2150 | + /// <summary> |
| 2151 | + /// Update the IDs of a list of LE2 WwiseEvents with random IDs. |
| 2152 | + /// </summary> |
| 2153 | + /// <param name="wwiseEvts">Events to update.</param> |
| 2154 | + /// <param name="random">The random object to generate ids.</param> |
| 2155 | + /// <returns>KVP of old and new IDs. Used to update references.</returns> |
| 2156 | + private static Dictionary<uint, uint> UpdateLE2EventIDs_EXPERIMENTAL(List<ExportEntry> events, Random random) |
| 2157 | + { |
| 2158 | + Dictionary<uint, uint> oldAndNewIDs = new(); |
| 2159 | + |
| 2160 | + foreach (ExportEntry evt in events) |
| 2161 | + { |
| 2162 | + (uint oldID, uint newID) = UpdateLE2EventID_EXPERIMENTAL(evt, random); |
| 2163 | + |
| 2164 | + if (newID == 0) { continue; } |
| 2165 | + |
| 2166 | + oldAndNewIDs.Add(oldID, newID); |
| 2167 | + } |
| 2168 | + |
| 2169 | + return oldAndNewIDs; |
| 2170 | + } |
| 2171 | + |
| 2172 | + /// <summary> |
| 2173 | + /// Update the ID of an LE2 WwiseEvent with a random ID, as they appear in the binary, instead of as props. |
| 2174 | + /// </summary> |
| 2175 | + /// <param name="wwiseEvt">Event to update.</param> |
| 2176 | + /// <param name="random">The random object to generate the id.</param> |
| 2177 | + /// <returns>KVP of old and new ID. Used to update references.</returns> |
| 2178 | + private static (uint, uint) UpdateLE2EventID_EXPERIMENTAL(ExportEntry wwiseEvt, Random random) |
| 2179 | + { |
| 2180 | + WwiseEvent wwiseEvent = wwiseEvt.GetBinaryData<WwiseEvent>(); |
| 2181 | + uint oldID = wwiseEvent.WwiseEventID; |
| 2182 | + uint newID = GenerateRandomID(random); |
| 2183 | + wwiseEvent.WwiseEventID = newID; |
| 2184 | + wwiseEvt.WriteBinary(wwiseEvent); |
| 2185 | + |
| 2186 | + return (oldID, newID); |
| 2187 | + } |
| 2188 | + |
| 2189 | + /// <summary> |
| 2190 | + /// Update the IDs of a list of ExportEntries with hashes of their names. |
| 2191 | + /// </summary> |
| 2192 | + /// <param name="entries">WwiseStreams to update.</param> |
| 2193 | + /// <param name="random">If not null, the random object to generate ids, instead of the name.</param> |
| 2194 | + /// <returns>KVP of old and new IDs. Used to update references.</returns> |
| 2195 | + private static Dictionary<uint, uint> UpdateIDs_EXPERIMENTAL(List<ExportEntry> entries, Random random = null) |
2156 | 2196 | { |
2157 | 2197 | Dictionary<uint, uint> oldAndNewIDs = new(); |
2158 | 2198 |
|
|
0 commit comments