//------------------------------------------------------------
// 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
{
///
/// 资源包版本资源列表。
///
[StructLayout(LayoutKind.Auto)]
public partial struct ResourcePackVersionList
{
private static readonly Resource[] EmptyResourceArray = new Resource[] { };
private readonly bool m_IsValid;
private readonly int m_Offset;
private readonly long m_Length;
private readonly int m_HashCode;
private readonly Resource[] m_Resources;
///
/// 初始化资源包版本资源列表的新实例。
///
/// 资源数据偏移。
/// 资源数据长度。
/// 资源数据哈希值。
/// 包含的资源集合。
public ResourcePackVersionList(int offset, long length, int hashCode, Resource[] resources)
{
m_IsValid = true;
m_Offset = offset;
m_Length = length;
m_HashCode = hashCode;
m_Resources = resources ?? EmptyResourceArray;
}
///
/// 获取资源包版本资源列表是否有效。
///
public bool IsValid
{
get
{
return m_IsValid;
}
}
///
/// 获取资源数据偏移。
///
public int Offset
{
get
{
if (!m_IsValid)
{
throw new GameFrameworkException("Data is invalid.");
}
return m_Offset;
}
}
///
/// 获取资源数据长度。
///
public long Length
{
get
{
if (!m_IsValid)
{
throw new GameFrameworkException("Data is invalid.");
}
return m_Length;
}
}
///
/// 获取资源数据哈希值。
///
public int HashCode
{
get
{
if (!m_IsValid)
{
throw new GameFrameworkException("Data is invalid.");
}
return m_HashCode;
}
}
///
/// 获取包含的资源集合。
///
/// 包含的资源集合。
public Resource[] GetResources()
{
if (!m_IsValid)
{
throw new GameFrameworkException("Data is invalid.");
}
return m_Resources;
}
}
}