namespace XGame.Editor.Build.AssetBundles
{
    /// <summary>
    /// AssetBundle分类
    /// </summary>
    public enum AssetBundleType
    {
        Addressable = 0x01,
        Raw = 0x02,
        Dependency = 0x04,
    }
    /// <summary>
    ///   <para>AssetBundle building map entry.</para>
    /// </summary>
    public struct AssetBundleData
    {
        /// <summary>
        ///   <para>AssetBundle name.</para>
        /// </summary>
        public string assetBundleName;
        /// <summary>
        ///   <para>AssetBundle variant.</para>
        /// </summary>
        public string assetBundleVariant;
        /// <summary>
        ///   <para>Asset names which belong to the given AssetBundle.</para>
        /// </summary>
        public string[] assetNames;
        /// <summary>
        ///   <para>Addressable name used to load an asset.</para>
        /// </summary>
        public string[] addressableNames;

        public uint bundleId;
        public string originBundleName;
        /// <summary>
        /// assetNames全部为贴图为true
        /// </summary>
        public bool isTextureBundle;
        /// <summary>
        /// AB类型
        /// </summary>
        public AssetBundleType bundleType;

        public string FullName
        {
            get
            {
                if (string.IsNullOrEmpty(assetBundleName))
                {
                    return string.Empty;
                }
                return string.IsNullOrEmpty(assetBundleVariant) ? assetBundleName : $"{assetBundleName}.{assetBundleVariant}";
            }
        }

        public UnityEditor.AssetBundleBuild ToUniBuild()
        {
            var build = new UnityEditor.AssetBundleBuild()
            {
                assetBundleName = assetBundleName,
                assetBundleVariant = assetBundleVariant,
                assetNames = assetNames,
                addressableNames = addressableNames,
            };
            return build;
        }
    }

}