private void FixSoundReference_CustomPlayback(int originalIndex, IWriter buffer, IStream stream) { var cplayback = _container.FindSoundCustomPlayback(originalIndex); if (_soundResources.CustomPlaybacks.Count > 0) { if (cplayback.Version != _soundResources.CustomPlaybacks[0].Version) { buffer.SeekTo(_soundLayout.GetFieldOffset("custom playback index")); buffer.WriteSByte(-1); return; } } SoundCustomPlayback newCPlayback = new SoundCustomPlayback(); if (cplayback.Mixes != null) { newCPlayback.Mixes = cplayback.Mixes.ToArray(); } newCPlayback.Flags = cplayback.Flags; newCPlayback.Unknown = cplayback.Unknown; newCPlayback.Unknown1 = cplayback.Unknown1; if (cplayback.Filters != null) { newCPlayback.Filters = cplayback.Filters.ToArray(); } if (cplayback.PitchLFOs != null) { newCPlayback.PitchLFOs = cplayback.PitchLFOs.ToArray(); } if (cplayback.FilterLFOs != null) { newCPlayback.FilterLFOs = cplayback.FilterLFOs.ToArray(); } newCPlayback.Unknown2 = cplayback.Unknown2; newCPlayback.Unknown3 = cplayback.Unknown3; newCPlayback.Unknown4 = cplayback.Unknown4; if (cplayback.OriginalRadioEffect != DatumIndex.Null) { DatumIndex newRadio = InjectTag(cplayback.OriginalRadioEffect, stream); newCPlayback.RadioEffect = _cacheFile.Tags[newRadio]; } if (cplayback.LowpassEffects != null) { newCPlayback.LowpassEffects = cplayback.LowpassEffects.ToArray(); } if (cplayback.Components != null) { var components = new List <SoundCustomPlaybackComponent>(); foreach (var c in cplayback.Components) { SoundCustomPlaybackComponent newC = new SoundCustomPlaybackComponent(); if (c.OriginalSound != DatumIndex.Null) { DatumIndex newSound = InjectTag(c.OriginalSound, stream); newC.Sound = _cacheFile.Tags[newSound]; } newC.Gain = c.Gain; newC.Flags = c.Flags; components.Add(newC); } newCPlayback.Components = components.ToArray(); } int newIndex; if (!_soundCustomPlaybacks.TryGetValue(cplayback, out newIndex)) { newIndex = _soundResources.CustomPlaybacks.FindIndex(c => c.Equals(newCPlayback)); if (newIndex == -1) { _soundResources.CustomPlaybacks.Add(newCPlayback); } _soundCustomPlaybacks[cplayback] = newIndex; } buffer.SeekTo(_soundLayout.GetFieldOffset("custom playback index")); buffer.WriteSByte((sbyte)newIndex); }