using System; using System.Linq; namespace YooAsset { [Serializable] internal class PackageBundle { /// /// 资源包名称 /// public string BundleName; /// /// Unity引擎生成的CRC /// public uint UnityCRC; /// /// 文件哈希值 /// public string FileHash; /// /// 文件校验码 /// public string FileCRC; /// /// 文件大小(字节数) /// public long FileSize; /// /// 文件是否加密 /// public bool Encrypted; /// /// 资源包的分类标签 /// public string[] Tags; /// /// 依赖的资源包ID集合 /// public int[] DependIDs; /// /// 所属的包裹名称 /// public string PackageName { private set; get; } /// /// 所属的构建管线 /// public string BuildPipeline { private set; get; } /// /// 资源包GUID /// public string BundleGUID { get { return FileHash; } } /// /// 文件名称 /// private string _fileName; public string FileName { get { if (string.IsNullOrEmpty(_fileName)) throw new Exception("Should never get here !"); return _fileName; } } /// /// 文件后缀名 /// private string _fileExtension; public string FileExtension { get { if (string.IsNullOrEmpty(_fileExtension)) throw new Exception("Should never get here !"); return _fileExtension; } } public PackageBundle() { } /// /// 解析资源包 /// public void ParseBundle(PackageManifest manifest) { PackageName = manifest.PackageName; BuildPipeline = manifest.BuildPipeline; _fileExtension = ManifestTools.GetRemoteBundleFileExtension(BundleName); _fileName = ManifestTools.GetRemoteBundleFileName(manifest.OutputNameStyle, BundleName, _fileExtension, FileHash); } /// /// 是否包含Tag /// public bool HasTag(string[] tags) { if (tags == null || tags.Length == 0) return false; if (Tags == null || Tags.Length == 0) return false; foreach (var tag in tags) { if (Tags.Contains(tag)) return true; } return false; } /// /// 是否包含任意Tags /// public bool HasAnyTags() { if (Tags != null && Tags.Length > 0) return true; else return false; } /// /// 检测资源包文件内容是否相同 /// public bool Equals(PackageBundle otherBundle) { if (FileHash == otherBundle.FileHash) return true; return false; } } }