//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System.Runtime.InteropServices;
namespace GameFramework.Resource
{
public partial struct UpdatableVersionList
{
///
/// 资源。
///
[StructLayout(LayoutKind.Auto)]
public struct Resource
{
private static readonly int[] EmptyIntArray = new int[] { };
private readonly string m_Name;
private readonly string m_Variant;
private readonly string m_Extension;
private readonly byte m_LoadType;
private readonly int m_Length;
private readonly int m_HashCode;
private readonly int m_CompressedLength;
private readonly int m_CompressedHashCode;
private readonly int[] m_AssetIndexes;
///
/// 初始化资源的新实例。
///
/// 资源名称。
/// 资源变体名称。
/// 资源扩展名称。
/// 资源加载方式。
/// 资源长度。
/// 资源哈希值。
/// 资源压缩后长度。
/// 资源压缩后哈希值。
/// 资源包含的资源索引集合。
public Resource(string name, string variant, string extension, byte loadType, int length, int hashCode, int compressedLength, int compressedHashCode, int[] assetIndexes)
{
if (string.IsNullOrEmpty(name))
{
throw new GameFrameworkException("Name is invalid.");
}
m_Name = name;
m_Variant = variant;
m_Extension = extension;
m_LoadType = loadType;
m_Length = length;
m_HashCode = hashCode;
m_CompressedLength = compressedLength;
m_CompressedHashCode = compressedHashCode;
m_AssetIndexes = assetIndexes ?? EmptyIntArray;
}
///
/// 获取资源名称。
///
public string Name
{
get
{
return m_Name;
}
}
///
/// 获取资源变体名称。
///
public string Variant
{
get
{
return m_Variant;
}
}
///
/// 获取资源扩展名称。
///
public string Extension
{
get
{
return m_Extension;
}
}
///
/// 获取资源加载方式。
///
public byte LoadType
{
get
{
return m_LoadType;
}
}
///
/// 获取资源长度。
///
public int Length
{
get
{
return m_Length;
}
}
///
/// 获取资源哈希值。
///
public int HashCode
{
get
{
return m_HashCode;
}
}
///
/// 获取资源压缩后长度。
///
public int CompressedLength
{
get
{
return m_CompressedLength;
}
}
///
/// 获取资源压缩后哈希值。
///
public int CompressedHashCode
{
get
{
return m_CompressedHashCode;
}
}
///
/// 获取资源包含的资源索引集合。
///
/// 资源包含的资源索引集合。
public int[] GetAssetIndexes()
{
return m_AssetIndexes;
}
}
}
}