2022-03-01 10:44:12 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2022-05-02 15:03:36 +08:00
|
|
|
|
using System.IO;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
|
|
|
|
|
namespace YooAsset
|
|
|
|
|
{
|
|
|
|
|
internal class HostPlayModeImpl : IBundleServices
|
|
|
|
|
{
|
|
|
|
|
// 补丁清单
|
2022-05-05 23:11:26 +08:00
|
|
|
|
internal PatchManifest LocalPatchManifest { private set; get; }
|
2022-03-01 10:44:12 +08:00
|
|
|
|
|
|
|
|
|
// 参数相关
|
2022-05-12 23:13:21 +08:00
|
|
|
|
private bool _locationToLower;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
private string _defaultHostServer;
|
|
|
|
|
private string _fallbackHostServer;
|
2022-12-14 21:53:09 +08:00
|
|
|
|
public IQueryServices QueryServices { private set; get; }
|
2022-03-01 10:44:12 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 异步初始化
|
|
|
|
|
/// </summary>
|
2022-10-27 14:20:05 +08:00
|
|
|
|
public InitializationOperation InitializeAsync(bool locationToLower, string defaultHostServer, string fallbackHostServer, IQueryServices queryServices, string packageName)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-05-12 23:13:21 +08:00
|
|
|
|
_locationToLower = locationToLower;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
_defaultHostServer = defaultHostServer;
|
|
|
|
|
_fallbackHostServer = fallbackHostServer;
|
2022-12-14 21:53:09 +08:00
|
|
|
|
QueryServices = queryServices;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
|
2022-10-27 14:20:05 +08:00
|
|
|
|
var operation = new HostPlayModeInitializationOperation(this, packageName);
|
2022-08-06 11:23:43 +08:00
|
|
|
|
OperationSystem.StartOperation(operation);
|
2022-03-01 10:44:12 +08:00
|
|
|
|
return operation;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-17 16:04:47 +08:00
|
|
|
|
/// <summary>
|
2022-10-26 21:02:25 +08:00
|
|
|
|
/// 获取包裹的版本信息
|
2022-10-17 16:04:47 +08:00
|
|
|
|
/// </summary>
|
2022-10-26 21:02:25 +08:00
|
|
|
|
public string GetPackageVersion()
|
2022-10-17 16:04:47 +08:00
|
|
|
|
{
|
|
|
|
|
if (LocalPatchManifest == null)
|
|
|
|
|
return string.Empty;
|
2022-10-26 21:02:25 +08:00
|
|
|
|
return LocalPatchManifest.PackageVersion;
|
2022-10-17 16:04:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-12 19:15:44 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 异步更新资源版本号
|
|
|
|
|
/// </summary>
|
2022-12-03 20:03:10 +08:00
|
|
|
|
public UpdatePackageVersionOperation UpdatePackageVersionAsync(string packageName, int timeout, bool appendTimeTicks)
|
2022-04-12 19:15:44 +08:00
|
|
|
|
{
|
2022-12-03 20:03:10 +08:00
|
|
|
|
var operation = new HostPlayModeUpdatePackageVersionOperation(this, packageName, timeout, appendTimeTicks);
|
2022-08-06 11:23:43 +08:00
|
|
|
|
OperationSystem.StartOperation(operation);
|
2022-04-12 19:15:44 +08:00
|
|
|
|
return operation;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-01 10:44:12 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 异步更新补丁清单
|
|
|
|
|
/// </summary>
|
2022-11-18 21:33:58 +08:00
|
|
|
|
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageName, string packageVersion, int timeout)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-11-18 21:33:58 +08:00
|
|
|
|
var operation = new HostPlayModeUpdatePackageManifestOperation(this, packageName, packageVersion, timeout);
|
2022-08-06 11:23:43 +08:00
|
|
|
|
OperationSystem.StartOperation(operation);
|
2022-05-01 20:33:50 +08:00
|
|
|
|
return operation;
|
|
|
|
|
}
|
2022-07-07 19:10:44 +08:00
|
|
|
|
|
2022-06-28 20:13:32 +08:00
|
|
|
|
/// <summary>
|
2022-11-04 13:10:08 +08:00
|
|
|
|
/// 检查本地包裹内容的完整性
|
2022-06-28 20:13:32 +08:00
|
|
|
|
/// </summary>
|
2022-11-04 13:10:08 +08:00
|
|
|
|
public CheckPackageContentsOperation CheckPackageContentsAsync(string packageName)
|
2022-06-28 20:13:32 +08:00
|
|
|
|
{
|
2022-11-04 13:10:08 +08:00
|
|
|
|
var operation = new HostPlayModeCheckPackageContentsOperation(this, packageName);
|
2022-08-06 11:23:43 +08:00
|
|
|
|
OperationSystem.StartOperation(operation);
|
2022-06-28 20:13:32 +08:00
|
|
|
|
return operation;
|
|
|
|
|
}
|
2022-05-01 20:33:50 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 异步更新资源包裹
|
|
|
|
|
/// </summary>
|
2022-11-18 21:33:58 +08:00
|
|
|
|
public DownloadPackageOperation DownloadPackageAsync(string packageName, string packageVersion, int timeout)
|
2022-05-01 20:33:50 +08:00
|
|
|
|
{
|
2022-11-18 21:33:58 +08:00
|
|
|
|
var operation = new HostPlayModeDownloadPackageOperation(this, packageName, packageVersion, timeout);
|
2022-08-06 11:23:43 +08:00
|
|
|
|
OperationSystem.StartOperation(operation);
|
2022-03-01 10:44:12 +08:00
|
|
|
|
return operation;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-01 15:26:48 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建下载器
|
|
|
|
|
/// </summary>
|
2022-10-17 14:43:13 +08:00
|
|
|
|
public PatchDownloaderOperation CreatePatchDownloaderByAll(int fileLoadingMaxNumber, int failedTryAgain, int timeout)
|
2022-05-01 15:26:48 +08:00
|
|
|
|
{
|
2022-11-16 14:49:38 +08:00
|
|
|
|
YooLogger.Log($"Create patch downloader : {LocalPatchManifest.PackageName} {LocalPatchManifest.PackageVersion}");
|
2022-05-01 15:26:48 +08:00
|
|
|
|
List<BundleInfo> downloadList = GetDownloadListByAll();
|
2022-10-17 14:43:13 +08:00
|
|
|
|
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain, timeout);
|
2022-05-01 15:26:48 +08:00
|
|
|
|
return operation;
|
|
|
|
|
}
|
|
|
|
|
private List<BundleInfo> GetDownloadListByAll()
|
|
|
|
|
{
|
|
|
|
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
|
|
|
|
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
|
|
|
|
{
|
|
|
|
|
// 忽略缓存文件
|
2022-08-15 11:55:13 +08:00
|
|
|
|
if (CacheSystem.IsCached(patchBundle))
|
2022-05-01 15:26:48 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// 忽略APP资源
|
2022-09-28 11:55:12 +08:00
|
|
|
|
if (IsBuildinPatchBundle(patchBundle))
|
|
|
|
|
continue;
|
2022-05-01 15:26:48 +08:00
|
|
|
|
|
|
|
|
|
downloadList.Add(patchBundle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ConvertToDownloadList(downloadList);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-01 10:44:12 +08:00
|
|
|
|
/// <summary>
|
2022-03-03 18:07:20 +08:00
|
|
|
|
/// 创建下载器
|
2022-03-01 10:44:12 +08:00
|
|
|
|
/// </summary>
|
2022-10-17 14:43:13 +08:00
|
|
|
|
public PatchDownloaderOperation CreatePatchDownloaderByTags(string[] tags, int fileLoadingMaxNumber, int failedTryAgain, int timeout)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-11-16 14:49:38 +08:00
|
|
|
|
YooLogger.Log($"Create patch downloader : {LocalPatchManifest.PackageName} {LocalPatchManifest.PackageVersion}");
|
2022-03-07 21:20:58 +08:00
|
|
|
|
List<BundleInfo> downloadList = GetDownloadListByTags(tags);
|
2022-10-17 14:43:13 +08:00
|
|
|
|
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain, timeout);
|
2022-03-03 18:07:20 +08:00
|
|
|
|
return operation;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
2022-03-07 21:20:58 +08:00
|
|
|
|
private List<BundleInfo> GetDownloadListByTags(string[] tags)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
|
|
|
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
|
|
|
|
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
|
|
|
|
{
|
|
|
|
|
// 忽略缓存文件
|
2022-08-15 11:55:13 +08:00
|
|
|
|
if (CacheSystem.IsCached(patchBundle))
|
2022-03-01 10:44:12 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// 忽略APP资源
|
2022-09-28 11:55:12 +08:00
|
|
|
|
if (IsBuildinPatchBundle(patchBundle))
|
|
|
|
|
continue;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
|
2022-09-28 11:55:12 +08:00
|
|
|
|
// 如果未带任何标记,则统一下载
|
|
|
|
|
if (patchBundle.HasAnyTags() == false)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
|
|
|
|
downloadList.Add(patchBundle);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 查询DLC资源
|
2022-03-03 18:07:20 +08:00
|
|
|
|
if (patchBundle.HasTag(tags))
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
|
|
|
|
downloadList.Add(patchBundle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ConvertToDownloadList(downloadList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-03-03 18:07:20 +08:00
|
|
|
|
/// 创建下载器
|
2022-03-01 10:44:12 +08:00
|
|
|
|
/// </summary>
|
2022-10-17 14:43:13 +08:00
|
|
|
|
public PatchDownloaderOperation CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int fileLoadingMaxNumber, int failedTryAgain, int timeout)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-11-16 14:49:38 +08:00
|
|
|
|
YooLogger.Log($"Create patch downloader : {LocalPatchManifest.PackageName} {LocalPatchManifest.PackageVersion}");
|
2022-05-11 16:48:17 +08:00
|
|
|
|
List<BundleInfo> downloadList = GetDownloadListByPaths(assetInfos);
|
2022-10-17 14:43:13 +08:00
|
|
|
|
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain, timeout);
|
2022-03-03 18:07:20 +08:00
|
|
|
|
return operation;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
2022-05-11 16:48:17 +08:00
|
|
|
|
private List<BundleInfo> GetDownloadListByPaths(AssetInfo[] assetInfos)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
|
|
|
|
// 获取资源对象的资源包和所有依赖资源包
|
|
|
|
|
List<PatchBundle> checkList = new List<PatchBundle>();
|
2022-05-11 16:48:17 +08:00
|
|
|
|
foreach (var assetInfo in assetInfos)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-05-11 16:48:17 +08:00
|
|
|
|
if (assetInfo.IsInvalid)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-05-11 16:48:17 +08:00
|
|
|
|
YooLogger.Warning(assetInfo.Error);
|
|
|
|
|
continue;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-07 19:10:44 +08:00
|
|
|
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
|
|
|
|
PatchBundle mainBundle = LocalPatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
|
|
|
|
if (checkList.Contains(mainBundle) == false)
|
|
|
|
|
checkList.Add(mainBundle);
|
2022-05-11 16:48:17 +08:00
|
|
|
|
|
2022-07-07 19:10:44 +08:00
|
|
|
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
|
|
|
|
PatchBundle[] dependBundles = LocalPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
|
|
|
|
foreach (var dependBundle in dependBundles)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-07-07 19:10:44 +08:00
|
|
|
|
if (checkList.Contains(dependBundle) == false)
|
|
|
|
|
checkList.Add(dependBundle);
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
|
|
|
|
foreach (var patchBundle in checkList)
|
|
|
|
|
{
|
|
|
|
|
// 忽略缓存文件
|
2022-08-15 11:55:13 +08:00
|
|
|
|
if (CacheSystem.IsCached(patchBundle))
|
2022-03-01 10:44:12 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// 忽略APP资源
|
2022-09-28 11:55:12 +08:00
|
|
|
|
if (IsBuildinPatchBundle(patchBundle))
|
|
|
|
|
continue;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
|
|
|
|
|
downloadList.Add(patchBundle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ConvertToDownloadList(downloadList);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-07 20:13:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建解压器
|
|
|
|
|
/// </summary>
|
2022-10-17 14:43:13 +08:00
|
|
|
|
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain, int timeout)
|
2022-03-07 20:13:39 +08:00
|
|
|
|
{
|
2022-11-16 14:49:38 +08:00
|
|
|
|
YooLogger.Log($"Create patch unpacker : {LocalPatchManifest.PackageName} {LocalPatchManifest.PackageVersion}");
|
2022-06-25 11:42:50 +08:00
|
|
|
|
List<BundleInfo> unpcakList = GetUnpackListByTags(tags);
|
2022-10-17 14:43:13 +08:00
|
|
|
|
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain, timeout);
|
2022-03-07 20:13:39 +08:00
|
|
|
|
return operation;
|
|
|
|
|
}
|
2022-06-25 11:42:50 +08:00
|
|
|
|
private List<BundleInfo> GetUnpackListByTags(string[] tags)
|
|
|
|
|
{
|
|
|
|
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
2022-09-28 11:55:12 +08:00
|
|
|
|
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
2022-06-25 11:42:50 +08:00
|
|
|
|
{
|
|
|
|
|
// 忽略缓存文件
|
2022-08-15 11:55:13 +08:00
|
|
|
|
if (CacheSystem.IsCached(patchBundle))
|
2022-06-25 11:42:50 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// 查询DLC资源
|
2022-09-28 11:55:12 +08:00
|
|
|
|
if (IsBuildinPatchBundle(patchBundle))
|
2022-06-25 11:42:50 +08:00
|
|
|
|
{
|
2022-09-28 11:55:12 +08:00
|
|
|
|
if (patchBundle.HasTag(tags))
|
|
|
|
|
{
|
|
|
|
|
downloadList.Add(patchBundle);
|
|
|
|
|
}
|
2022-06-25 11:42:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-31 16:45:21 +08:00
|
|
|
|
return ConvertToUnpackList(downloadList);
|
2022-06-25 11:42:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建解压器
|
|
|
|
|
/// </summary>
|
2022-10-17 14:43:13 +08:00
|
|
|
|
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain, int timeout)
|
2022-05-11 16:48:17 +08:00
|
|
|
|
{
|
2022-11-16 14:49:38 +08:00
|
|
|
|
YooLogger.Log($"Create patch unpacker : {LocalPatchManifest.PackageName} {LocalPatchManifest.PackageVersion}");
|
2022-06-25 11:42:50 +08:00
|
|
|
|
List<BundleInfo> unpcakList = GetUnpackListByAll();
|
2022-10-17 14:43:13 +08:00
|
|
|
|
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain, timeout);
|
2022-05-11 16:48:17 +08:00
|
|
|
|
return operation;
|
|
|
|
|
}
|
2022-06-25 11:42:50 +08:00
|
|
|
|
private List<BundleInfo> GetUnpackListByAll()
|
|
|
|
|
{
|
|
|
|
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
2022-09-28 11:55:12 +08:00
|
|
|
|
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
2022-06-25 11:42:50 +08:00
|
|
|
|
{
|
|
|
|
|
// 忽略缓存文件
|
2022-08-15 11:55:13 +08:00
|
|
|
|
if (CacheSystem.IsCached(patchBundle))
|
2022-06-25 11:42:50 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
2022-09-28 11:55:12 +08:00
|
|
|
|
if (IsBuildinPatchBundle(patchBundle))
|
|
|
|
|
{
|
|
|
|
|
downloadList.Add(patchBundle);
|
|
|
|
|
}
|
2022-06-25 11:42:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-31 16:45:21 +08:00
|
|
|
|
return ConvertToUnpackList(downloadList);
|
2022-06-25 11:42:50 +08:00
|
|
|
|
}
|
2022-03-07 20:13:39 +08:00
|
|
|
|
|
2022-03-01 10:44:12 +08:00
|
|
|
|
// WEB相关
|
2022-04-12 19:15:44 +08:00
|
|
|
|
public string GetPatchDownloadMainURL(string fileName)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-04-12 19:15:44 +08:00
|
|
|
|
return $"{_defaultHostServer}/{fileName}";
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
2022-04-12 19:15:44 +08:00
|
|
|
|
public string GetPatchDownloadFallbackURL(string fileName)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-04-12 19:15:44 +08:00
|
|
|
|
return $"{_fallbackHostServer}/{fileName}";
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 下载相关
|
2022-05-01 20:33:50 +08:00
|
|
|
|
public List<BundleInfo> ConvertToDownloadList(List<PatchBundle> downloadList)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-03-07 21:20:58 +08:00
|
|
|
|
List<BundleInfo> result = new List<BundleInfo>(downloadList.Count);
|
2022-03-01 10:44:12 +08:00
|
|
|
|
foreach (var patchBundle in downloadList)
|
|
|
|
|
{
|
|
|
|
|
var bundleInfo = ConvertToDownloadInfo(patchBundle);
|
|
|
|
|
result.Add(bundleInfo);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2022-10-31 16:45:21 +08:00
|
|
|
|
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
2022-03-07 20:13:39 +08:00
|
|
|
|
{
|
2022-07-25 15:46:20 +08:00
|
|
|
|
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.FileName);
|
|
|
|
|
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.FileName);
|
2022-04-18 15:08:39 +08:00
|
|
|
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
|
2022-03-07 20:13:39 +08:00
|
|
|
|
return bundleInfo;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-31 16:45:21 +08:00
|
|
|
|
// 解压相关
|
|
|
|
|
public List<BundleInfo> ConvertToUnpackList(List<PatchBundle> unpackList)
|
|
|
|
|
{
|
|
|
|
|
List<BundleInfo> result = new List<BundleInfo>(unpackList.Count);
|
|
|
|
|
foreach (var patchBundle in unpackList)
|
|
|
|
|
{
|
|
|
|
|
var bundleInfo = ConvertToUnpackInfo(patchBundle);
|
|
|
|
|
result.Add(bundleInfo);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
public static BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
|
|
|
|
{
|
|
|
|
|
// 注意:我们把流加载路径指定为远端下载地址
|
|
|
|
|
string streamingPath = PathHelper.ConvertToWWWPath(patchBundle.StreamingFilePath);
|
|
|
|
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming, streamingPath, streamingPath);
|
|
|
|
|
return bundleInfo;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-05 23:11:26 +08:00
|
|
|
|
internal void SetLocalPatchManifest(PatchManifest patchManifest)
|
|
|
|
|
{
|
|
|
|
|
LocalPatchManifest = patchManifest;
|
2022-05-12 23:13:21 +08:00
|
|
|
|
LocalPatchManifest.InitAssetPathMapping(_locationToLower);
|
2022-05-05 23:11:26 +08:00
|
|
|
|
}
|
2022-09-28 11:55:12 +08:00
|
|
|
|
internal bool IsBuildinPatchBundle(PatchBundle patchBundle)
|
|
|
|
|
{
|
2022-12-14 21:53:09 +08:00
|
|
|
|
return QueryServices.QueryStreamingAssets(patchBundle.FileName);
|
2022-09-28 11:55:12 +08:00
|
|
|
|
}
|
2022-05-05 23:11:26 +08:00
|
|
|
|
|
2022-03-01 10:44:12 +08:00
|
|
|
|
#region IBundleServices接口
|
2022-07-07 19:10:44 +08:00
|
|
|
|
private BundleInfo CreateBundleInfo(PatchBundle patchBundle)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-07-07 19:10:44 +08:00
|
|
|
|
if (patchBundle == null)
|
|
|
|
|
throw new Exception("Should never get here !");
|
|
|
|
|
|
|
|
|
|
// 查询沙盒资源
|
2022-08-15 11:55:13 +08:00
|
|
|
|
if (CacheSystem.IsCached(patchBundle))
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-07-07 19:10:44 +08:00
|
|
|
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache);
|
|
|
|
|
return bundleInfo;
|
|
|
|
|
}
|
2022-04-18 15:08:39 +08:00
|
|
|
|
|
2022-07-07 19:10:44 +08:00
|
|
|
|
// 查询APP资源
|
2022-09-28 11:55:12 +08:00
|
|
|
|
if (IsBuildinPatchBundle(patchBundle))
|
2022-07-07 19:10:44 +08:00
|
|
|
|
{
|
2022-09-28 11:55:12 +08:00
|
|
|
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
|
|
|
|
return bundleInfo;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
2022-07-07 19:10:44 +08:00
|
|
|
|
|
|
|
|
|
// 从服务端下载
|
|
|
|
|
return ConvertToDownloadInfo(patchBundle);
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
2022-05-11 16:48:17 +08:00
|
|
|
|
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
2022-05-06 23:15:03 +08:00
|
|
|
|
{
|
2022-05-11 16:48:17 +08:00
|
|
|
|
if (assetInfo.IsInvalid)
|
|
|
|
|
throw new Exception("Should never get here !");
|
|
|
|
|
|
2022-07-07 19:10:44 +08:00
|
|
|
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
|
|
|
|
var patchBundle = LocalPatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
|
|
|
|
return CreateBundleInfo(patchBundle);
|
2022-05-06 23:15:03 +08:00
|
|
|
|
}
|
2022-05-11 16:48:17 +08:00
|
|
|
|
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
2022-05-03 12:23:08 +08:00
|
|
|
|
{
|
2022-05-11 16:48:17 +08:00
|
|
|
|
if (assetInfo.IsInvalid)
|
|
|
|
|
throw new Exception("Should never get here !");
|
|
|
|
|
|
2022-07-07 19:10:44 +08:00
|
|
|
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
2022-05-11 16:48:17 +08:00
|
|
|
|
var depends = LocalPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
|
|
|
|
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
2022-07-07 19:10:44 +08:00
|
|
|
|
foreach (var patchBundle in depends)
|
2022-05-11 16:48:17 +08:00
|
|
|
|
{
|
2022-07-07 19:10:44 +08:00
|
|
|
|
BundleInfo bundleInfo = CreateBundleInfo(patchBundle);
|
2022-05-11 16:48:17 +08:00
|
|
|
|
result.Add(bundleInfo);
|
|
|
|
|
}
|
|
|
|
|
return result.ToArray();
|
2022-05-03 12:23:08 +08:00
|
|
|
|
}
|
2022-05-11 16:48:17 +08:00
|
|
|
|
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
2022-04-28 17:23:31 +08:00
|
|
|
|
{
|
2022-10-31 16:45:21 +08:00
|
|
|
|
return LocalPatchManifest.GetAssetsInfoByTags(tags);
|
2022-04-28 17:23:31 +08:00
|
|
|
|
}
|
2022-05-11 16:48:17 +08:00
|
|
|
|
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-07-07 19:10:44 +08:00
|
|
|
|
if (LocalPatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
2022-05-11 16:48:17 +08:00
|
|
|
|
return patchAsset;
|
|
|
|
|
else
|
|
|
|
|
return null;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
2022-05-11 16:48:17 +08:00
|
|
|
|
string IBundleServices.MappingToAssetPath(string location)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-05-11 16:48:17 +08:00
|
|
|
|
return LocalPatchManifest.MappingToAssetPath(location);
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
2022-10-21 18:36:03 +08:00
|
|
|
|
string IBundleServices.TryMappingToAssetPath(string location)
|
|
|
|
|
{
|
|
|
|
|
return LocalPatchManifest.TryMappingToAssetPath(location);
|
|
|
|
|
}
|
2022-09-29 18:40:43 +08:00
|
|
|
|
string IBundleServices.GetPackageName()
|
|
|
|
|
{
|
|
|
|
|
return LocalPatchManifest.PackageName;
|
|
|
|
|
}
|
2022-10-18 11:56:05 +08:00
|
|
|
|
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
|
|
|
|
{
|
|
|
|
|
return LocalPatchManifest.IsIncludeBundleFile(fileName);
|
|
|
|
|
}
|
2022-12-03 19:48:17 +08:00
|
|
|
|
bool IBundleServices.IsServicesValid()
|
|
|
|
|
{
|
|
|
|
|
return LocalPatchManifest != null;
|
|
|
|
|
}
|
2022-03-01 10:44:12 +08:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|