using System; using System.Linq; namespace YooAsset { [Serializable] internal class PatchBundle { /// /// 资源包名称 /// public string BundleName; /// /// 文件哈希值 /// public string Hash; /// /// 文件校验码 /// public string CRC; /// /// 文件大小(字节数) /// public long SizeBytes; /// /// 资源包的分类标签 /// public string[] Tags; /// /// Flags /// public int Flags; /// /// 是否为加密文件 /// public bool IsEncrypted { private set; get; } /// /// 是否为内置文件 /// public bool IsBuildin { private set; get; } /// /// 是否为原生文件 /// public bool IsRawFile { private set; get; } public PatchBundle(string bundleName, string hash, string crc, long sizeBytes, string[] tags) { BundleName = bundleName; Hash = hash; CRC = crc; SizeBytes = sizeBytes; Tags = tags; } /// /// 设置Flags /// public void SetFlagsValue(bool isEncrypted, bool isBuildin, bool isRawFile) { IsEncrypted = isEncrypted; IsBuildin = isBuildin; IsRawFile = isRawFile; BitMask32 mask = new BitMask32(0); if (isEncrypted) mask.Open(0); if (isBuildin) mask.Open(1); if (isRawFile) mask.Open(2); Flags = mask; } /// /// 解析Flags /// public void ParseFlagsValue() { BitMask32 value = Flags; IsEncrypted = value.Test(0); IsBuildin = value.Test(1); IsRawFile = value.Test(2); } /// /// 是否包含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; } /// /// 是否为纯内置资源(不带任何Tag的资源) /// public bool IsPureBuildin() { if (Tags == null || Tags.Length == 0) return true; else return false; } } }