update runtime code

代码里移除了Patch敏感字。
This commit is contained in:
hevinci
2023-03-11 00:06:40 +08:00
parent 10e04c7645
commit 67d09d95fa
38 changed files with 692 additions and 580 deletions
@@ -94,9 +94,9 @@ namespace YooAsset
if (downloadList != null)
{
TotalDownloadCount = downloadList.Count;
foreach (var patchBundle in downloadList)
foreach (var packageBundle in downloadList)
{
TotalDownloadBytes += patchBundle.Bundle.FileSize;
TotalDownloadBytes += packageBundle.Bundle.FileSize;
}
}
}
@@ -249,9 +249,9 @@ namespace YooAsset
}
}
public sealed class PatchDownloaderOperation : DownloaderOperation
public sealed class ResourceDownloaderOperation : DownloaderOperation
{
internal PatchDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
internal ResourceDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
{
}
@@ -259,16 +259,16 @@ namespace YooAsset
/// <summary>
/// 创建空的下载器
/// </summary>
internal static PatchDownloaderOperation CreateEmptyDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
internal static ResourceDownloaderOperation CreateEmptyDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
}
public sealed class PatchUnpackerOperation : DownloaderOperation
public sealed class ResourceUnpackerOperation : DownloaderOperation
{
internal PatchUnpackerOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
internal ResourceUnpackerOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
{
}
@@ -276,10 +276,10 @@ namespace YooAsset
/// <summary>
/// 创建空的解压器
/// </summary>
internal static PatchUnpackerOperation CreateEmptyUnpacker(int upackingMaxNumber, int failedTryAgain, int timeout)
internal static ResourceUnpackerOperation CreateEmptyUnpacker(int upackingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
var operation = new ResourceUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
return operation;
}
}
@@ -26,14 +26,14 @@ namespace YooAsset
}
private readonly EditorSimulateModeImpl _impl;
private readonly string _simulateManifestPath;
private readonly string _simulateManifestFilePath;
private LoadEditorManifestOperation _loadEditorManifestOp;
private ESteps _steps = ESteps.None;
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulateManifestPath)
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulateManifestFilePath)
{
_impl = impl;
_simulateManifestPath = simulateManifestPath;
_simulateManifestFilePath = simulateManifestFilePath;
}
internal override void Start()
{
@@ -45,7 +45,7 @@ namespace YooAsset
{
if (_loadEditorManifestOp == null)
{
_loadEditorManifestOp = new LoadEditorManifestOperation(_simulateManifestPath);
_loadEditorManifestOp = new LoadEditorManifestOperation(_simulateManifestFilePath);
OperationSystem.StartOperation(_loadEditorManifestOp);
}
@@ -18,15 +18,15 @@ namespace YooAsset
}
private readonly BufferReader _buffer;
private int _patchAssetCount;
private int _patchBundleCount;
private int _packageAssetCount;
private int _packageBundleCount;
private int _progressTotalValue;
private ESteps _steps = ESteps.None;
/// <summary>
/// 解析的清单实例
/// </summary>
public PatchManifest Manifest { private set; get; }
public PackageManifest Manifest { private set; get; }
public DeserializeManifestOperation(byte[] binaryData)
{
@@ -55,7 +55,7 @@ namespace YooAsset
// 读取文件标记
uint fileSign = _buffer.ReadUInt32();
if (fileSign != YooAssetSettings.PatchManifestFileSign)
if (fileSign != YooAssetSettings.ManifestFileSign)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
@@ -65,16 +65,16 @@ namespace YooAsset
// 读取文件版本
string fileVersion = _buffer.ReadUTF8();
if (fileVersion != YooAssetSettings.PatchManifestFileVersion)
if (fileVersion != YooAssetSettings.ManifestFileVersion)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"The manifest file version are not compatible : {fileVersion} != {YooAssetSettings.PatchManifestFileVersion}";
Error = $"The manifest file version are not compatible : {fileVersion} != {YooAssetSettings.ManifestFileVersion}";
return;
}
// 读取文件头信息
Manifest = new PatchManifest();
Manifest = new PackageManifest();
Manifest.FileVersion = fileVersion;
Manifest.EnableAddressable = _buffer.ReadBool();
Manifest.OutputNameStyle = _buffer.ReadInt32();
@@ -86,38 +86,38 @@ namespace YooAsset
if (_steps == ESteps.PrepareAssetList)
{
_patchAssetCount = _buffer.ReadInt32();
Manifest.AssetList = new List<PatchAsset>(_patchAssetCount);
Manifest.AssetDic = new Dictionary<string, PatchAsset>(_patchAssetCount);
_progressTotalValue = _patchAssetCount;
_packageAssetCount = _buffer.ReadInt32();
Manifest.AssetList = new List<PackageAsset>(_packageAssetCount);
Manifest.AssetDic = new Dictionary<string, PackageAsset>(_packageAssetCount);
_progressTotalValue = _packageAssetCount;
_steps = ESteps.DeserializeAssetList;
}
if (_steps == ESteps.DeserializeAssetList)
{
while (_patchAssetCount > 0)
while (_packageAssetCount > 0)
{
var patchAsset = new PatchAsset();
patchAsset.Address = _buffer.ReadUTF8();
patchAsset.AssetPath = _buffer.ReadUTF8();
patchAsset.AssetTags = _buffer.ReadUTF8Array();
patchAsset.BundleID = _buffer.ReadInt32();
patchAsset.DependIDs = _buffer.ReadInt32Array();
Manifest.AssetList.Add(patchAsset);
var packageAsset = new PackageAsset();
packageAsset.Address = _buffer.ReadUTF8();
packageAsset.AssetPath = _buffer.ReadUTF8();
packageAsset.AssetTags = _buffer.ReadUTF8Array();
packageAsset.BundleID = _buffer.ReadInt32();
packageAsset.DependIDs = _buffer.ReadInt32Array();
Manifest.AssetList.Add(packageAsset);
// 注意:我们不允许原始路径存在重名
string assetPath = patchAsset.AssetPath;
string assetPath = packageAsset.AssetPath;
if (Manifest.AssetDic.ContainsKey(assetPath))
throw new System.Exception($"AssetPath have existed : {assetPath}");
else
Manifest.AssetDic.Add(assetPath, patchAsset);
Manifest.AssetDic.Add(assetPath, packageAsset);
_patchAssetCount--;
Progress = 1f - _patchAssetCount / _progressTotalValue;
_packageAssetCount--;
Progress = 1f - _packageAssetCount / _progressTotalValue;
if (OperationSystem.IsBusy)
break;
}
if (_patchAssetCount <= 0)
if (_packageAssetCount <= 0)
{
_steps = ESteps.PrepareBundleList;
}
@@ -125,37 +125,37 @@ namespace YooAsset
if (_steps == ESteps.PrepareBundleList)
{
_patchBundleCount = _buffer.ReadInt32();
Manifest.BundleList = new List<PatchBundle>(_patchBundleCount);
Manifest.BundleDic = new Dictionary<string, PatchBundle>(_patchBundleCount);
_progressTotalValue = _patchBundleCount;
_packageBundleCount = _buffer.ReadInt32();
Manifest.BundleList = new List<PackageBundle>(_packageBundleCount);
Manifest.BundleDic = new Dictionary<string, PackageBundle>(_packageBundleCount);
_progressTotalValue = _packageBundleCount;
_steps = ESteps.DeserializeBundleList;
}
if (_steps == ESteps.DeserializeBundleList)
{
while (_patchBundleCount > 0)
while (_packageBundleCount > 0)
{
var patchBundle = new PatchBundle();
patchBundle.BundleName = _buffer.ReadUTF8();
patchBundle.FileHash = _buffer.ReadUTF8();
patchBundle.FileCRC = _buffer.ReadUTF8();
patchBundle.FileSize = _buffer.ReadInt64();
patchBundle.IsRawFile = _buffer.ReadBool();
patchBundle.LoadMethod = _buffer.ReadByte();
patchBundle.Tags = _buffer.ReadUTF8Array();
patchBundle.ReferenceIDs = _buffer.ReadInt32Array();
Manifest.BundleList.Add(patchBundle);
var packageBundle = new PackageBundle();
packageBundle.BundleName = _buffer.ReadUTF8();
packageBundle.FileHash = _buffer.ReadUTF8();
packageBundle.FileCRC = _buffer.ReadUTF8();
packageBundle.FileSize = _buffer.ReadInt64();
packageBundle.IsRawFile = _buffer.ReadBool();
packageBundle.LoadMethod = _buffer.ReadByte();
packageBundle.Tags = _buffer.ReadUTF8Array();
packageBundle.ReferenceIDs = _buffer.ReadInt32Array();
Manifest.BundleList.Add(packageBundle);
patchBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
Manifest.BundleDic.Add(patchBundle.BundleName, patchBundle);
packageBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
Manifest.BundleDic.Add(packageBundle.BundleName, packageBundle);
_patchBundleCount--;
Progress = 1f - _patchBundleCount / _progressTotalValue;
_packageBundleCount--;
Progress = 1f - _packageBundleCount / _progressTotalValue;
if (OperationSystem.IsBusy)
break;
}
if (_patchBundleCount <= 0)
if (_packageBundleCount <= 0)
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
@@ -20,7 +20,7 @@ namespace YooAsset
/// <summary>
/// 加载的清单实例
/// </summary>
public PatchManifest Manifest { private set; get; }
public PackageManifest Manifest { private set; get; }
public LoadBuildinManifestOperation(string buildinPackageName, string buildinPackageVersion)
@@ -24,7 +24,7 @@ namespace YooAsset
/// <summary>
/// 加载的清单实例
/// </summary>
public PatchManifest Manifest { private set; get; }
public PackageManifest Manifest { private set; get; }
public LoadCacheManifestOperation(string packageName, string packageVersion)
@@ -19,7 +19,7 @@ namespace YooAsset
/// <summary>
/// 加载的清单实例
/// </summary>
public PatchManifest Manifest { private set; get; }
public PackageManifest Manifest { private set; get; }
public LoadEditorManifestOperation(string manifestFilePath)
@@ -4,57 +4,69 @@ using System.Collections.Generic;
namespace YooAsset
{
public abstract class PreDownloadPackageOperation : AsyncOperationBase
public abstract class PreDownloadContentOperation : AsyncOperationBase
{
/// <summary>
/// 创建补丁下载器,用于下载更新指定资源版本所有的资源包文件
/// 创建资源下载器,用于下载当前资源版本所有的资源包文件
/// </summary>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public virtual PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public virtual ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
/// 创建资源下载器,用于下载指定的资源标签关联的资源包文件
/// </summary>
/// <param name="tag">资源标签</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public virtual PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public virtual ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
/// 创建资源下载器,用于下载指定的资源标签列表关联的资源包文件
/// </summary>
/// <param name="tags">资源标签列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public virtual PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public virtual ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
/// </summary>
/// <param name="locations">资源定位列表</param>
/// <param name="location">资源定位地址</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public virtual PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public virtual ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
/// </summary>
/// <param name="locations">资源定位地址列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public virtual ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
}
public class EditorPlayModePreDownloadPackageOperation : PreDownloadPackageOperation
internal class EditorPlayModePreDownloadContentOperation : PreDownloadContentOperation
{
internal override void Start()
{
@@ -64,7 +76,7 @@ namespace YooAsset
{
}
}
public class OfflinePlayModePreDownloadPackageOperation : PreDownloadPackageOperation
internal class OfflinePlayModePreDownloadContentOperation : PreDownloadContentOperation
{
internal override void Start()
{
@@ -74,7 +86,7 @@ namespace YooAsset
{
}
}
public class HostPlayModePreDownloadPackageOperation : PreDownloadPackageOperation
internal class HostPlayModePreDownloadContentOperation : PreDownloadContentOperation
{
private enum ESteps
{
@@ -94,11 +106,11 @@ namespace YooAsset
private LoadCacheManifestOperation _tryLoadCacheManifestOp;
private LoadCacheManifestOperation _loadCacheManifestOp;
private DownloadManifestOperation _downloadManifestOp;
private PatchManifest _manifest;
private PackageManifest _manifest;
private ESteps _steps = ESteps.None;
internal HostPlayModePreDownloadPackageOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
internal HostPlayModePreDownloadContentOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
{
_impl = impl;
_packageName = packageName;
@@ -202,48 +214,64 @@ namespace YooAsset
}
}
public override PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public override ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
List<BundleInfo> downloadList = _impl.GetDownloadListByAll(_manifest);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
public override PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public override ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, new string[] { tag });
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
public override PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public override ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, tags);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
public override PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public override ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
List<AssetInfo> assetInfos = new List<AssetInfo>();
var assetInfo = _manifest.ConvertLocationToAssetInfo(location, null);
assetInfos.Add(assetInfo);
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray());
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
public override ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
@@ -254,7 +282,7 @@ namespace YooAsset
}
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray());
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
}
@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset
{
/// <summary>
/// 向远端请求并更新补丁清单
/// 向远端请求并更新清单
/// </summary>
public abstract class UpdatePackageManifestOperation : AsyncOperationBase
{