Beispiel #1
0
        public ExtractedSoundCustomPlayback(int index, SoundCustomPlayback src)
        {
            OriginalIndex = index;

            Version = src.Version;

            if (src.Mixes != null)
            {
                Mixes = new List <SoundCustomPlaybackMix>();
                Mixes.AddRange(src.Mixes);
            }

            Flags = src.Flags;

            Unknown  = src.Unknown;
            Unknown1 = src.Unknown1;

            if (src.Filters != null)
            {
                Filters = new List <SoundCustomPlaybackFilter>();
                Filters.AddRange(src.Filters);
            }

            if (src.PitchLFOs != null)
            {
                PitchLFOs = new List <SoundCustomPlaybackPitchLFO>();
                PitchLFOs.AddRange(src.PitchLFOs);
            }

            if (src.FilterLFOs != null)
            {
                FilterLFOs = new List <SoundCustomPlaybackFilterLFO>();
                FilterLFOs.AddRange(src.FilterLFOs);
            }

            Unknown2 = src.Unknown2;
            Unknown3 = src.Unknown3;
            Unknown4 = src.Unknown4;

            OriginalRadioEffect = src.RadioEffect != null ? src.RadioEffect.Index : DatumIndex.Null;

            if (src.LowpassEffects != null)
            {
                LowpassEffects = new List <SoundCustomPlaybackLowpassEffect>();
                LowpassEffects.AddRange(src.LowpassEffects);
            }

            if (src.Components != null)
            {
                Components = new List <ExtractedSoundCustomPlaybackComponent>();
                foreach (var comp in src.Components)
                {
                    Components.Add(new ExtractedSoundCustomPlaybackComponent(comp));
                }
            }
        }
        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);
        }