refactor : 重构代码
This commit is contained in:
+35
-33
@@ -129,12 +129,12 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 自定义参数:解密服务接口的实例类
|
||||
/// </summary>
|
||||
public IDecryptionServices DecryptionServices { private set; get; }
|
||||
public IBundleDecryptionServices BundleDecryptionServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:资源清单服务类
|
||||
/// </summary>
|
||||
public IManifestRestoreServices ManifestServices { private set; get; }
|
||||
public IManifestRestoreServices ManifestRestoreServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:拷贝内置文件接口的实例类
|
||||
@@ -161,7 +161,7 @@ namespace YooAsset
|
||||
var operation = new DCFSLoadPackageManifestOperation(this, options.PackageVersion, options.Timeout);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options)
|
||||
{
|
||||
if (options.ClearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
||||
{
|
||||
@@ -170,17 +170,17 @@ namespace YooAsset
|
||||
}
|
||||
else if (options.ClearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
||||
{
|
||||
var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest);
|
||||
var operation = new ClearUnusedCacheBundleFilesOperation(this, options.Manifest);
|
||||
return operation;
|
||||
}
|
||||
else if (options.ClearMode == EFileClearMode.ClearBundleFilesByLocations.ToString())
|
||||
{
|
||||
var operation = new ClearCacheBundleFilesByLocationsOperaiton(this, manifest, options.ClearParam);
|
||||
var operation = new ClearCacheBundleFilesByLocationsOperaiton(this, options.Manifest, options.ClearParam);
|
||||
return operation;
|
||||
}
|
||||
else if (options.ClearMode == EFileClearMode.ClearBundleFilesByTags.ToString())
|
||||
{
|
||||
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, options.ClearParam);
|
||||
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, options.Manifest, options.ClearParam);
|
||||
return operation;
|
||||
}
|
||||
else if (options.ClearMode == EFileClearMode.ClearAllManifestFiles.ToString())
|
||||
@@ -190,7 +190,7 @@ namespace YooAsset
|
||||
}
|
||||
else if (options.ClearMode == EFileClearMode.ClearUnusedManifestFiles.ToString())
|
||||
{
|
||||
var operation = new ClearUnusedCacheManifestFilesOperation(this, manifest);
|
||||
var operation = new ClearUnusedCacheManifestFilesOperation(this, options.Manifest);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
@@ -200,9 +200,10 @@ namespace YooAsset
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(DownloadFileOptions options)
|
||||
{
|
||||
// 获取下载地址
|
||||
PackageBundle bundle = options.Bundle;
|
||||
if (string.IsNullOrEmpty(options.ImportFilePath))
|
||||
{
|
||||
// 注意:如果是解压文件系统类,这里会返回本地内置文件的下载路径
|
||||
@@ -217,17 +218,18 @@ namespace YooAsset
|
||||
options.SetURL(mainURL, mainURL);
|
||||
}
|
||||
|
||||
var downloader = new DownloadPackageBundleOperation(this, bundle, options);
|
||||
var downloader = new DownloadPackageBundleOperation(this, options);
|
||||
return downloader;
|
||||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
public virtual FSLoadBundleOperation LoadBundleAsync(LoadBundleOptions options)
|
||||
{
|
||||
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
|
||||
PackageBundle bundle = options.Bundle;
|
||||
if (bundle.BundleType == (int)EBundleType.AssetBundle)
|
||||
{
|
||||
var operation = new DCFSLoadAssetBundleOperation(this, bundle);
|
||||
return operation;
|
||||
}
|
||||
else if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
|
||||
else if (bundle.BundleType == (int)EBundleType.RawBundle)
|
||||
{
|
||||
var operation = new DCFSLoadRawBundleOperation(this, bundle);
|
||||
return operation;
|
||||
@@ -315,13 +317,13 @@ namespace YooAsset
|
||||
{
|
||||
ResumeDownloadResponseCodes = (List<long>)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||
else if (name == FileSystemParametersDefine.BUNDLE_DECRYPTION_SERVICES)
|
||||
{
|
||||
DecryptionServices = (IDecryptionServices)value;
|
||||
BundleDecryptionServices = (IBundleDecryptionServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.MANIFEST_SERVICES)
|
||||
else if (name == FileSystemParametersDefine.MANIFEST_RESTORE_SERVICES)
|
||||
{
|
||||
ManifestServices = (IManifestRestoreServices)value;
|
||||
ManifestRestoreServices = (IManifestRestoreServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES)
|
||||
{
|
||||
@@ -403,20 +405,20 @@ namespace YooAsset
|
||||
|
||||
if (bundle.Encrypted)
|
||||
{
|
||||
if (DecryptionServices == null)
|
||||
if (BundleDecryptionServices == null)
|
||||
{
|
||||
YooLogger.Error($"The {nameof(IDecryptionServices)} is null !");
|
||||
YooLogger.Error($"The {nameof(IBundleDecryptionServices)} is null !");
|
||||
return null;
|
||||
}
|
||||
|
||||
string filePath = GetCacheBundleFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.ReadFileData(fileInfo);
|
||||
return BundleDecryptionServices.ReadFileData(bundleInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -431,20 +433,20 @@ namespace YooAsset
|
||||
|
||||
if (bundle.Encrypted)
|
||||
{
|
||||
if (DecryptionServices == null)
|
||||
if (BundleDecryptionServices == null)
|
||||
{
|
||||
YooLogger.Error($"The {nameof(IDecryptionServices)} is null !");
|
||||
YooLogger.Error($"The {nameof(IBundleDecryptionServices)} is null !");
|
||||
return null;
|
||||
}
|
||||
|
||||
string filePath = GetCacheBundleFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.ReadFileText(fileInfo);
|
||||
return BundleDecryptionServices.ReadFileText(bundleInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -649,46 +651,46 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 加载加密资源文件
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundle(PackageBundle bundle)
|
||||
public DecryptSyncResult LoadEncryptedBundleSync(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetCacheBundleFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.LoadAssetBundle(fileInfo);
|
||||
return BundleDecryptionServices.LoadAssetBundleSync(bundleInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载加密资源文件
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundleAsync(PackageBundle bundle)
|
||||
public DecryptAsyncResult LoadEncryptedBundleAsync(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetCacheBundleFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.LoadAssetBundleAsync(fileInfo);
|
||||
return BundleDecryptionServices.LoadAssetBundleAsync(bundleInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载加密资源文件
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundleFallback(PackageBundle bundle)
|
||||
public DecryptSyncResult LoadEncryptedBundleFallback(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetCacheBundleFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.LoadAssetBundleFallback(fileInfo);
|
||||
return BundleDecryptionServices.LoadAssetBundleFallback(bundleInfo);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
+9
-9
@@ -79,8 +79,8 @@ namespace YooAsset
|
||||
{
|
||||
if (_downloadFileOp == null)
|
||||
{
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
|
||||
DownloadFileOptions options = new DownloadFileOptions(_bundle, int.MaxValue);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(options);
|
||||
_downloadFileOp.StartOperation();
|
||||
AddChildOperation(_downloadFileOp);
|
||||
}
|
||||
@@ -127,11 +127,11 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
if (_fileSystem.DecryptionServices == null)
|
||||
if (_fileSystem.BundleDecryptionServices == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"The {nameof(IDecryptionServices)} is null !";
|
||||
Error = $"The {nameof(IBundleDecryptionServices)} is null !";
|
||||
YooLogger.Error(Error);
|
||||
return;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
var decryptResult = _fileSystem.LoadEncryptedAssetBundle(_bundle);
|
||||
var decryptResult = _fileSystem.LoadEncryptedBundleSync(_bundle);
|
||||
_assetBundle = decryptResult.Result;
|
||||
_managedStream = decryptResult.ManagedStream;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
var decryptResult = _fileSystem.LoadEncryptedAssetBundleAsync(_bundle);
|
||||
var decryptResult = _fileSystem.LoadEncryptedBundleAsync(_bundle);
|
||||
_createRequest = decryptResult.CreateRequest;
|
||||
_managedStream = decryptResult.ManagedStream;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
var decryptResult = _fileSystem.LoadEncryptedAssetBundleFallback(_bundle);
|
||||
var decryptResult = _fileSystem.LoadEncryptedBundleFallback(_bundle);
|
||||
_assetBundle = decryptResult.Result;
|
||||
if (_assetBundle != null)
|
||||
{
|
||||
@@ -348,8 +348,8 @@ namespace YooAsset
|
||||
{
|
||||
if (_downloadFileOp == null)
|
||||
{
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
|
||||
DownloadFileOptions options = new DownloadFileOptions(_bundle, int.MaxValue);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(options);
|
||||
_downloadFileOp.StartOperation();
|
||||
AddChildOperation(_downloadFileOp);
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ namespace YooAsset
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DownloadPackageBundleOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle)
|
||||
internal DownloadPackageBundleOperation(DefaultCacheFileSystem fileSystem, DownloadFileOptions options) : base(options.Bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_options = options;
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
if (ManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||
if (PackageManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_deserializer == null)
|
||||
{
|
||||
_deserializer = new DeserializeManifestOperation(_fileSystem.ManifestServices, _fileData);
|
||||
_deserializer = new DeserializeManifestOperation(_fileSystem.ManifestRestoreServices, _fileData);
|
||||
_deserializer.StartOperation();
|
||||
AddChildOperation(_deserializer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user