//------------------------------------------------------------ // 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 LocalVersionList { private static readonly Resource[] EmptyResourceArray = new Resource[] { }; private static readonly FileSystem[] EmptyFileSystemArray = new FileSystem[] { }; private readonly bool m_IsValid; private readonly Resource[] m_Resources; private readonly FileSystem[] m_FileSystems; /// /// 初始化本地版本资源列表的新实例。 /// /// 包含的资源集合。 /// 包含的文件系统集合。 public LocalVersionList(Resource[] resources, FileSystem[] fileSystems) { m_IsValid = true; m_Resources = resources ?? EmptyResourceArray; m_FileSystems = fileSystems ?? EmptyFileSystemArray; } /// /// 获取本地版本资源列表是否有效。 /// public bool IsValid { get { return m_IsValid; } } /// /// 获取包含的资源集合。 /// /// 包含的资源集合。 public Resource[] GetResources() { if (!m_IsValid) { throw new GameFrameworkException("Data is invalid."); } return m_Resources; } /// /// 获取包含的文件系统集合。 /// /// 包含的文件系统集合。 public FileSystem[] GetFileSystems() { if (!m_IsValid) { throw new GameFrameworkException("Data is invalid."); } return m_FileSystems; } } }