<commit_before>using System.Collections.Generic;
using UELib.Core;

namespace UELib.Engine
{
    [UnrealRegisterClass]
    public class USound : UObject, IUnrealViewable, IUnrealExportable
    {
        private const string WAVExtension = "wav";

        public IEnumerable<string> ExportableExtensions
        {
            get { return new[] { WAVExtension }; }
        }

        private string SoundFormat { get; set; }

        private byte[] _SoundBuffer;

        public USound()
        {
            ShouldDeserializeOnDemand = true;
        }

        public bool CompatableExport()
        {
            return Package.Version >= 61 && Package.Version <= 129
                                         && SoundFormat != null && SoundFormat.ToLower() == WAVExtension &&
                                         _SoundBuffer != null;
        }

        public void SerializeExport(string desiredExportExtension, System.IO.Stream exportStream)
        {
            switch (desiredExportExtension)
            {
                case WAVExtension:
                    exportStream.Write(_SoundBuffer, 0, _SoundBuffer.Length);
                    break;
            }
        }

        protected override void Deserialize()
        {
            base.Deserialize();

            // Format
            SoundFormat = Package.GetIndexName(_Buffer.ReadNameIndex());
            Record("SoundFormat", SoundFormat);
#if UT
            if ((Package.Build == UnrealPackage.GameBuild.BuildName.UT2004
                 || Package.Build == UnrealPackage.GameBuild.BuildName.UT2003) /*&& Package.LicenseeVersion >= 2*/)
            {
                float unknownFloat = _Buffer.ReadFloat();
                Record("???", unknownFloat);
            }
#endif
            if (Package.Version >= 63)
            {
                // OffsetNext
                _Buffer.Skip(4);
                Record("OffsetNext");
            }

            int size = _Buffer.ReadIndex();
            Record("soundSize", size);
            // Resource Interchange File Format
            _Buffer.Read(_SoundBuffer = new byte[size], 0, size);
        }
    }
}<commit_msg>Cleanup USound.<commit_after>using System.Collections.Generic;
using UELib.Core;

namespace UELib.Engine
{
    [UnrealRegisterClass]
    public class USound : UObject, IUnrealViewable, IUnrealExportable
    {
        #region Serialized Members

        public UName FileType;
        /// <summary>
        /// The likely hood that this sound will be selected from an array of sounds, see "USoundGroup".
        /// Null if not serialized.
        /// </summary>
        public float? Likelihood;
        public byte[] Data;

        #endregion

        private const string WAVExtension = "wav";

        public IEnumerable<string> ExportableExtensions => new[] { WAVExtension };

        public USound()
        {
            ShouldDeserializeOnDemand = true;
        }

        public bool CompatableExport()
        {
            return Package.Version >= 61 && Package.Version <= 129
                                         && FileType != null && FileType.ToString().ToLower() == WAVExtension &&
                                         Data != null;
        }

        public void SerializeExport(string desiredExportExtension, System.IO.Stream exportStream)
        {
            switch (desiredExportExtension)
            {
                case WAVExtension:
                    exportStream.Write(Data, 0, Data.Length);
                    break;
            }
        }

        protected override void Deserialize()
        {
            base.Deserialize();

            FileType = _Buffer.ReadNameReference();
            Record(nameof(FileType), FileType);
#if UT
            if ((Package.Build == UnrealPackage.GameBuild.BuildName.UT2004
                 || Package.Build == UnrealPackage.GameBuild.BuildName.UT2003) /*&& Package.LicenseeVersion >= 2*/)
            {
                Likelihood = _Buffer.ReadFloat();
                Record(nameof(Likelihood), Likelihood);
            }
#endif
            if (Package.Version >= 63)
            {
                // Offset in package to the next object, wth is this for?
                int nextSerialOffset = _Buffer.ReadInt32();
                Record(nameof(nextSerialOffset), nextSerialOffset);
            }

            // Resource Interchange File Format
            Data = new byte[_Buffer.ReadIndex()];
            _Buffer.Read(Data, 0, Data.Length);
            Record(nameof(Data), Data);
        }
    }
}
{'fraction_non_alphanumeric': 0.09428129829984544, 'fraction_numerical': 0.008611172444248178, 'mean_word_length': 1.591533180778032, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4246511', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1072, 'n_words': 255}