Exemple #1
0
        internal void ReadFrom(BinaryReader reader, MapSoundsFormatVersion formatVersion)
        {
            Name              = reader.ReadChars();
            FilePath          = reader.ReadChars();
            EaxSetting        = reader.ReadChars();
            Flags             = reader.ReadInt32 <SoundFlags>();
            FadeInRate        = reader.ReadInt32();
            FadeOutRate       = reader.ReadInt32();
            Volume            = reader.ReadInt32();
            Pitch             = reader.ReadSingle();
            PitchVariance     = reader.ReadSingle();
            Priority          = reader.ReadInt32();
            Channel           = reader.ReadInt32 <SoundChannel>();
            MinDistance       = reader.ReadSingle();
            MaxDistance       = reader.ReadSingle();
            DistanceCutoff    = reader.ReadSingle();
            ConeAngleInside   = reader.ReadSingle();
            ConeAngleOutside  = reader.ReadSingle();
            ConeOutsideVolume = reader.ReadInt32();
            ConeOrientation   = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

            if (formatVersion >= MapSoundsFormatVersion.Reforged)
            {
                var repeatVariableName = reader.ReadChars();
                SoundName = reader.ReadChars();
                var repeatSoundPath = reader.ReadChars();

                if (repeatVariableName != Name || repeatSoundPath != FilePath)
                {
                    throw new InvalidDataException($"Expected sound's {nameof(Name)} and {nameof(FilePath)} to be repeated.");
                }

                var unk2 = reader.ReadInt32();
                var unk3 = reader.ReadByte();
                var unk4 = reader.ReadInt32();
                var unk5 = reader.ReadByte();
                var unk6 = reader.ReadInt32();
                var unk7 = reader.ReadInt32();

                if (formatVersion >= MapSoundsFormatVersion.ReforgedV3)
                {
                    var unk8 = reader.ReadInt32();
                }
            }
        }
Exemple #2
0
        internal void WriteTo(BinaryWriter writer, MapSoundsFormatVersion formatVersion)
        {
            writer.WriteString(Name);
            writer.WriteString(FilePath);
            writer.WriteString(EaxSetting);
            writer.Write((int)Flags);
            writer.Write(FadeInRate);
            writer.Write(FadeOutRate);
            writer.Write(Volume);
            writer.Write(Pitch);
            writer.Write(PitchVariance);
            writer.Write(Priority);
            writer.Write((int)Channel);
            writer.Write(MinDistance);
            writer.Write(MaxDistance);
            writer.Write(DistanceCutoff);
            writer.Write(ConeAngleInside);
            writer.Write(ConeAngleOutside);
            writer.Write(ConeOutsideVolume);
            writer.Write(ConeOrientation.X);
            writer.Write(ConeOrientation.Y);
            writer.Write(ConeOrientation.Z);

            if (formatVersion >= MapSoundsFormatVersion.Reforged)
            {
                writer.WriteString(Name);
                writer.WriteString(SoundName);
                writer.WriteString(FilePath);

                writer.Write(-1);
                writer.Write((byte)0);
                writer.Write(-1);
                writer.Write((byte)0);
                writer.Write(0);
                writer.Write(0);

                if (formatVersion >= MapSoundsFormatVersion.ReforgedV3)
                {
                    writer.Write(1);
                }
            }
        }
 public MapSounds(MapSoundsFormatVersion version, params Sound[] sounds)
 {
     _sounds  = new List <Sound>(sounds);
     _version = version;
 }
Exemple #4
0
 public static Sound ReadSound(this BinaryReader reader, MapSoundsFormatVersion formatVersion) => new Sound(reader, formatVersion);
Exemple #5
0
 public static void Write(this BinaryWriter writer, Sound sound, MapSoundsFormatVersion formatVersion) => sound.WriteTo(writer, formatVersion);
Exemple #6
0
 internal Sound(BinaryReader reader, MapSoundsFormatVersion formatVersion)
 {
     ReadFrom(reader, formatVersion);
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapSounds"/> class.
 /// </summary>
 /// <param name="formatVersion"></param>
 public MapSounds(MapSoundsFormatVersion formatVersion)
 {
     FormatVersion = formatVersion;
 }