//------------------------------------------------------------ // 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 UpdatableVersionList { private static readonly Asset[] EmptyAssetArray = new Asset[] { }; private static readonly Resource[] EmptyResourceArray = new Resource[] { }; private static readonly FileSystem[] EmptyFileSystemArray = new FileSystem[] { }; private static readonly ResourceGroup[] EmptyResourceGroupArray = new ResourceGroup[] { }; private readonly bool m_IsValid; private readonly string m_ApplicableGameVersion; private readonly int m_InternalResourceVersion; private readonly Asset[] m_Assets; private readonly Resource[] m_Resources; private readonly FileSystem[] m_FileSystems; private readonly ResourceGroup[] m_ResourceGroups; /// /// 初始化可更新模式版本资源列表的新实例。 /// /// 适配的游戏版本号。 /// 内部资源版本号。 /// 包含的资源集合。 /// 包含的资源集合。 /// 包含的文件系统集合。 /// 包含的资源组集合。 public UpdatableVersionList(string applicableGameVersion, int internalResourceVersion, Asset[] assets, Resource[] resources, FileSystem[] fileSystems, ResourceGroup[] resourceGroups) { m_IsValid = true; m_ApplicableGameVersion = applicableGameVersion; m_InternalResourceVersion = internalResourceVersion; m_Assets = assets ?? EmptyAssetArray; m_Resources = resources ?? EmptyResourceArray; m_FileSystems = fileSystems ?? EmptyFileSystemArray; m_ResourceGroups = resourceGroups ?? EmptyResourceGroupArray; } /// /// 获取可更新模式版本资源列表是否有效。 /// public bool IsValid { get { return m_IsValid; } } /// /// 获取适配的游戏版本号。 /// public string ApplicableGameVersion { get { if (!m_IsValid) { throw new GameFrameworkException("Data is invalid."); } return m_ApplicableGameVersion; } } /// /// 获取内部资源版本号。 /// public int InternalResourceVersion { get { if (!m_IsValid) { throw new GameFrameworkException("Data is invalid."); } return m_InternalResourceVersion; } } /// /// 获取包含的资源集合。 /// /// 包含的资源集合。 public Asset[] GetAssets() { if (!m_IsValid) { throw new GameFrameworkException("Data is invalid."); } return m_Assets; } /// /// 获取包含的资源集合。 /// /// 包含的资源集合。 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; } /// /// 获取包含的资源组集合。 /// /// 包含的资源组集合。 public ResourceGroup[] GetResourceGroups() { if (!m_IsValid) { throw new GameFrameworkException("Data is invalid."); } return m_ResourceGroups; } } }