using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace YooAsset.Editor { public class BuildAssetInfo { private bool _isAddAssetTags = false; private readonly HashSet _referenceBundleNames = new HashSet(); /// /// 收集器类型 /// public ECollectorType CollectorType { private set; get; } /// /// 资源包完整名称 /// public string BundleName { private set; get; } /// /// 可寻址地址 /// public string Address { private set; get; } /// /// 资源信息 /// public AssetInfo AssetInfo { private set; get; } /// /// 资源的分类标签 /// public readonly List AssetTags = new List(); /// /// 依赖的所有资源 /// 注意:包括零依赖资源和冗余资源(资源包名无效) /// public List AllDependAssetInfos { private set; get; } public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, AssetInfo assetInfo) { CollectorType = collectorType; BundleName = bundleName; Address = address; AssetInfo = assetInfo; } public BuildAssetInfo(AssetInfo assetInfo) { CollectorType = ECollectorType.None; BundleName = string.Empty; Address = string.Empty; AssetInfo = assetInfo; } /// /// 设置所有依赖的资源 /// public void SetDependAssetInfos(List dependAssetInfos) { if (AllDependAssetInfos != null) throw new System.Exception("Should never get here !"); AllDependAssetInfos = dependAssetInfos; } /// /// 设置资源包名称 /// public void SetBundleName(string bundleName) { if (HasBundleName()) throw new System.Exception("Should never get here !"); BundleName = bundleName; } /// /// 添加资源的分类标签 /// 说明:原始定义的资源分类标签 /// public void AddAssetTags(List tags) { if (_isAddAssetTags) throw new Exception("Should never get here !"); _isAddAssetTags = true; foreach (var tag in tags) { if (AssetTags.Contains(tag) == false) { AssetTags.Add(tag); } } } /// /// 添加关联的资源包名称 /// public void AddReferenceBundleName(string bundleName) { if (string.IsNullOrEmpty(bundleName)) throw new Exception("Should never get here !"); if (_referenceBundleNames.Contains(bundleName) == false) _referenceBundleNames.Add(bundleName); } /// /// 资源包名是否存在 /// public bool HasBundleName() { if (string.IsNullOrEmpty(BundleName)) return false; else return true; } /// /// 获取关联资源包的数量 /// public int GetReferenceBundleCount() { return _referenceBundleNames.Count; } } }