ResourcePackVersionList.Resource.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 Jiang Yin. All rights reserved.
  4. // Homepage: https://gameframework.cn/
  5. // Feedback: mailto:ellan@gameframework.cn
  6. //------------------------------------------------------------
  7. using System.Runtime.InteropServices;
  8. namespace GameFramework.Resource
  9. {
  10. public partial struct ResourcePackVersionList
  11. {
  12. /// <summary>
  13. /// 资源。
  14. /// </summary>
  15. [StructLayout(LayoutKind.Auto)]
  16. public struct Resource
  17. {
  18. private readonly string m_Name;
  19. private readonly string m_Variant;
  20. private readonly string m_Extension;
  21. private readonly byte m_LoadType;
  22. private readonly long m_Offset;
  23. private readonly int m_Length;
  24. private readonly int m_HashCode;
  25. private readonly int m_CompressedLength;
  26. private readonly int m_CompressedHashCode;
  27. /// <summary>
  28. /// 初始化资源的新实例。
  29. /// </summary>
  30. /// <param name="name">资源名称。</param>
  31. /// <param name="variant">资源变体名称。</param>
  32. /// <param name="extension">资源扩展名称。</param>
  33. /// <param name="loadType">资源加载方式。</param>
  34. /// <param name="offset">资源偏移。</param>
  35. /// <param name="length">资源长度。</param>
  36. /// <param name="hashCode">资源哈希值。</param>
  37. /// <param name="compressedLength">资源压缩后长度。</param>
  38. /// <param name="compressedHashCode">资源压缩后哈希值。</param>
  39. public Resource(string name, string variant, string extension, byte loadType, long offset, int length, int hashCode, int compressedLength, int compressedHashCode)
  40. {
  41. if (string.IsNullOrEmpty(name))
  42. {
  43. throw new GameFrameworkException("Name is invalid.");
  44. }
  45. m_Name = name;
  46. m_Variant = variant;
  47. m_Extension = extension;
  48. m_LoadType = loadType;
  49. m_Offset = offset;
  50. m_Length = length;
  51. m_HashCode = hashCode;
  52. m_CompressedLength = compressedLength;
  53. m_CompressedHashCode = compressedHashCode;
  54. }
  55. /// <summary>
  56. /// 获取资源名称。
  57. /// </summary>
  58. public string Name
  59. {
  60. get
  61. {
  62. return m_Name;
  63. }
  64. }
  65. /// <summary>
  66. /// 获取资源变体名称。
  67. /// </summary>
  68. public string Variant
  69. {
  70. get
  71. {
  72. return m_Variant;
  73. }
  74. }
  75. /// <summary>
  76. /// 获取资源扩展名称。
  77. /// </summary>
  78. public string Extension
  79. {
  80. get
  81. {
  82. return m_Extension;
  83. }
  84. }
  85. /// <summary>
  86. /// 获取资源加载方式。
  87. /// </summary>
  88. public byte LoadType
  89. {
  90. get
  91. {
  92. return m_LoadType;
  93. }
  94. }
  95. /// <summary>
  96. /// 获取资源偏移。
  97. /// </summary>
  98. public long Offset
  99. {
  100. get
  101. {
  102. return m_Offset;
  103. }
  104. }
  105. /// <summary>
  106. /// 获取资源长度。
  107. /// </summary>
  108. public int Length
  109. {
  110. get
  111. {
  112. return m_Length;
  113. }
  114. }
  115. /// <summary>
  116. /// 获取资源哈希值。
  117. /// </summary>
  118. public int HashCode
  119. {
  120. get
  121. {
  122. return m_HashCode;
  123. }
  124. }
  125. /// <summary>
  126. /// 获取资源压缩后长度。
  127. /// </summary>
  128. public int CompressedLength
  129. {
  130. get
  131. {
  132. return m_CompressedLength;
  133. }
  134. }
  135. /// <summary>
  136. /// 获取资源压缩后哈希值。
  137. /// </summary>
  138. public int CompressedHashCode
  139. {
  140. get
  141. {
  142. return m_CompressedHashCode;
  143. }
  144. }
  145. }
  146. }
  147. }