VeSoundNode.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #region License information
  2. // ----------------------------------------------------------------------------
  3. //
  4. // libeq2 - A library for analyzing the Everquest II File Format
  5. // Blaz (blaz@blazlabs.com)
  6. //
  7. // This program is free software; you can redistribute it and/or
  8. // modify it under the terms of the GNU General Public License
  9. // as published by the Free Software Foundation; either version 2
  10. // of the License, or (at your option) any later version.
  11. //
  12. // This program is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public License
  18. // along with this program; if not, write to the Free Software
  19. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  20. //
  21. // ( The full text of the license can be found in the License.txt file )
  22. //
  23. // ----------------------------------------------------------------------------
  24. #endregion
  25. #region Using directives
  26. using System;
  27. using System.Diagnostics;
  28. #endregion
  29. namespace Everquest2.Visualization
  30. {
  31. public class VeSoundNode : VeResourceNode
  32. {
  33. public class SoundData3D
  34. {
  35. public SoundData3D(Util.Eq2Reader reader)
  36. {
  37. version = reader.ReadByte();
  38. Debug.Assert(version <= 1, "VeSoundNode.SoundData3D version " + version + " not supported");
  39. if (version > 0)
  40. {
  41. unk1[0] = reader.ReadSingle();
  42. unk1[1] = reader.ReadSingle();
  43. unk1[2] = reader.ReadSingle();
  44. unk2[0] = reader.ReadSingle();
  45. unk2[1] = reader.ReadSingle();
  46. unk2[2] = reader.ReadSingle();
  47. unk3 = reader.ReadSingle();
  48. }
  49. else
  50. {
  51. for (uint i = 0; i < 16; ++i) unk0[i] = reader.ReadSingle();
  52. }
  53. unk4 = reader.ReadSingle();
  54. unk5 = reader.ReadSingle();
  55. unk6 = reader.ReadInt32();
  56. unk7 = reader.ReadSingle();
  57. unk8[0] = reader.ReadSingle();
  58. unk8[1] = reader.ReadSingle();
  59. unk8[2] = reader.ReadSingle();
  60. unk9 = reader.ReadSingle();
  61. unk10 = reader.ReadSingle();
  62. unk11 = reader.ReadSingle();
  63. unk12 = reader.ReadSingle();
  64. unk13 = reader.ReadSingle();
  65. unk14 = reader.ReadSingle();
  66. unk15 = reader.ReadSingle();
  67. unk16 = reader.ReadSingle();
  68. }
  69. private byte version;
  70. private float[] unk0 = new float[16];
  71. private float[] unk1 = new float[3];
  72. private float[] unk2 = new float[3];
  73. private float unk3;
  74. private float unk4;
  75. private float unk5;
  76. private int unk6;
  77. private float unk7;
  78. private float[] unk8 = new float[3];
  79. private float unk9;
  80. private float unk10;
  81. private float unk11;
  82. private float unk12;
  83. private float unk13;
  84. private float unk14;
  85. private float unk15;
  86. private float unk16;
  87. }
  88. public VeSoundNode()
  89. {
  90. }
  91. /// <summary>
  92. /// Special constructor used when deserializing the instance of the class.
  93. /// </summary>
  94. /// <param name="reader">Reader used to read the instance data.</param>
  95. protected VeSoundNode(Util.Eq2Reader reader, Util.StreamingContext context) : base(reader, context)
  96. {
  97. byte classVersion = context.ClassVersions[typeof(VeSoundNode)];
  98. Debug.Assert(classVersion >= 3 && classVersion <= 7, "VeSoundNode version " + classVersion + " not supported");
  99. if (classVersion >= 7) roomId = reader.ReadUInt32();
  100. uint soundFileCount;
  101. if (classVersion < 5)
  102. {
  103. soundFileCount = 1;
  104. }
  105. else
  106. {
  107. soundFileCount = reader.ReadUInt32();
  108. }
  109. soundFiles = new string[soundFileCount];
  110. for (uint i = 0; i < soundFileCount; ++i)
  111. {
  112. soundFiles[i] = reader.ReadString(2);
  113. }
  114. if (classVersion < 6) soundPriority = reader.ReadSingle();
  115. if (classVersion < 5)
  116. {
  117. soundData = reader.ReadBytes(116);
  118. }
  119. else
  120. {
  121. soundData3D = new SoundData3D(reader);
  122. }
  123. soundFadeTime = reader.ReadSingle();
  124. if (classVersion >= 4)
  125. {
  126. soundOnHour = reader.ReadByte();
  127. soundOnMinute = reader.ReadByte();
  128. soundOffHour = reader.ReadByte();
  129. soundOffMinute = reader.ReadByte();
  130. }
  131. if (classVersion >= 5)
  132. {
  133. minLoopMilliseconds = reader.ReadUInt32();
  134. maxLoopMilliseconds = reader.ReadUInt32();
  135. variance = reader.ReadSingle();
  136. }
  137. }
  138. public uint roomId;
  139. public string[] soundFiles;
  140. public float soundPriority;
  141. public byte[] soundData;
  142. public SoundData3D soundData3D;
  143. public float soundFadeTime;
  144. public byte soundOnHour;
  145. public byte soundOnMinute;
  146. public byte soundOffHour;
  147. public byte soundOffMinute;
  148. public uint minLoopMilliseconds;
  149. public uint maxLoopMilliseconds;
  150. public float variance;
  151. }
  152. }
  153. /* EOF */