feat : remove delivery file system

Host Play Mode 移除了DeliveryFileSystemParameters
pull/332/merge
何冠峰 2024-12-11 18:43:15 +08:00
parent a91cbee50c
commit bf1e3da298
4 changed files with 60 additions and 110 deletions

View File

@ -220,7 +220,6 @@ namespace YooAsset
public class HostPlayModeParameters : InitializeParameters
{
public FileSystemParameters BuildinFileSystemParameters;
public FileSystemParameters DeliveryFileSystemParameters;
public FileSystemParameters CacheFileSystemParameters;
}

View File

@ -171,9 +171,9 @@ namespace YooAsset
private enum ESteps
{
None,
CreateFileSystem,
CreateBuildinFileSystem,
InitBuildinFileSystem,
InitDeliveryFileSystem,
CreateCacheFileSystem,
InitCacheFileSystem,
Done,
}
@ -181,7 +181,6 @@ namespace YooAsset
private readonly HostPlayModeImpl _impl;
private readonly HostPlayModeParameters _parameters;
private FSInitializeFileSystemOperation _initBuildinFileSystemOp;
private FSInitializeFileSystemOperation _initDeliveryFileSystemOp;
private FSInitializeFileSystemOperation _initCacheFileSystemOp;
private ESteps _steps = ESteps.None;
@ -192,25 +191,21 @@ namespace YooAsset
}
internal override void InternalOnStart()
{
_steps = ESteps.CreateFileSystem;
_steps = ESteps.CreateBuildinFileSystem;
}
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.CreateFileSystem)
if (_steps == ESteps.CreateBuildinFileSystem)
{
if (_parameters.CacheFileSystemParameters == null)
if (_parameters.BuildinFileSystemParameters == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Cache file system parameters is null";
_steps = ESteps.CreateCacheFileSystem;
return;
}
if (_parameters.BuildinFileSystemParameters != null)
{
_impl.BuildinFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.BuildinFileSystemParameters);
if (_impl.BuildinFileSystem == null)
{
@ -219,20 +214,41 @@ namespace YooAsset
Error = "Failed to create buildin file system";
return;
}
_steps = ESteps.InitBuildinFileSystem;
}
if (_parameters.DeliveryFileSystemParameters != null)
if (_steps == ESteps.InitBuildinFileSystem)
{
_impl.DeliveryFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.DeliveryFileSystemParameters);
if (_impl.DeliveryFileSystem == null)
if (_initBuildinFileSystemOp == null)
_initBuildinFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
Progress = _initBuildinFileSystemOp.Progress;
if (_initBuildinFileSystemOp.IsDone == false)
return;
if (_initBuildinFileSystemOp.Status == EOperationStatus.Succeed)
{
_steps = ESteps.CreateCacheFileSystem;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Failed to create delivery file system";
return;
Error = _initBuildinFileSystemOp.Error;
}
}
if (_steps == ESteps.CreateCacheFileSystem)
{
if (_parameters.CacheFileSystemParameters == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Cache file system parameters is null";
return;
}
_impl.CacheFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.CacheFileSystemParameters);
if (_impl.CacheFileSystem == null)
{
@ -242,63 +258,7 @@ namespace YooAsset
return;
}
_steps = ESteps.InitBuildinFileSystem;
}
if (_steps == ESteps.InitBuildinFileSystem)
{
// 注意:内置文件系统可以为空
if (_impl.BuildinFileSystem == null)
{
_steps = ESteps.InitDeliveryFileSystem;
return;
}
if (_initBuildinFileSystemOp == null)
_initBuildinFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
Progress = _initBuildinFileSystemOp.Progress;
if (_initBuildinFileSystemOp.IsDone == false)
return;
if (_initBuildinFileSystemOp.Status == EOperationStatus.Succeed)
{
_steps = ESteps.InitDeliveryFileSystem;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _initBuildinFileSystemOp.Error;
}
}
if (_steps == ESteps.InitDeliveryFileSystem)
{
// 注意:分发文件系统可以为空
if (_impl.DeliveryFileSystem == null)
{
_steps = ESteps.InitCacheFileSystem;
return;
}
Progress = _initDeliveryFileSystemOp.Progress;
if (_initDeliveryFileSystemOp == null)
_initDeliveryFileSystemOp = _impl.DeliveryFileSystem.InitializeFileSystemAsync();
if (_initDeliveryFileSystemOp.IsDone == false)
return;
if (_initDeliveryFileSystemOp.Status == EOperationStatus.Succeed)
{
_steps = ESteps.InitCacheFileSystem;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _initDeliveryFileSystemOp.Error;
}
}
if (_steps == ESteps.InitCacheFileSystem)
@ -445,7 +405,7 @@ namespace YooAsset
if (_steps == ESteps.CheckResult)
{
if(_impl.WebServerFileSystem == null && _impl.WebRemoteFileSystem == null)
if (_impl.WebServerFileSystem == null && _impl.WebRemoteFileSystem == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;

View File

@ -225,7 +225,7 @@ namespace YooAsset
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
}
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(_manifest, _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(_manifest, _impl.BuildinFileSystem, _impl.CacheFileSystem);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
@ -237,7 +237,7 @@ namespace YooAsset
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
}
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, new string[] { tag }, _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, new string[] { tag }, _impl.BuildinFileSystem, _impl.CacheFileSystem);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
@ -249,7 +249,7 @@ namespace YooAsset
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
}
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, tags, _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, tags, _impl.BuildinFileSystem, _impl.CacheFileSystem);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
@ -265,7 +265,7 @@ namespace YooAsset
var assetInfo = _manifest.ConvertLocationToAssetInfo(location, null);
assetInfos.Add(assetInfo);
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.CacheFileSystem);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
@ -284,7 +284,7 @@ namespace YooAsset
assetInfos.Add(assetInfo);
}
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.CacheFileSystem);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}

View File

@ -8,7 +8,6 @@ namespace YooAsset
{
public readonly string PackageName;
public IFileSystem BuildinFileSystem { set; get; } //可以为空!
public IFileSystem DeliveryFileSystem { set; get; } //可以为空!
public IFileSystem CacheFileSystem { set; get; }
@ -35,9 +34,6 @@ namespace YooAsset
if (BuildinFileSystem != null)
BuildinFileSystem.OnUpdate();
if (DeliveryFileSystem != null)
DeliveryFileSystem.OnUpdate();
if (CacheFileSystem != null)
CacheFileSystem.OnUpdate();
}
@ -63,50 +59,50 @@ namespace YooAsset
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
{
var operation = new ClearAllBundleFilesImplOperation(this, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
var operation = new ClearAllBundleFilesImplOperation(this, BuildinFileSystem, CacheFileSystem, null);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
{
var operation = new ClearUnusedBundleFilesImplOperation(this, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
var operation = new ClearUnusedBundleFilesImplOperation(this, BuildinFileSystem, CacheFileSystem, null);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, BuildinFileSystem, CacheFileSystem);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, BuildinFileSystem, CacheFileSystem);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, BuildinFileSystem, CacheFileSystem);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, BuildinFileSystem, CacheFileSystem);
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation;
}
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, BuildinFileSystem, CacheFileSystem);
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation;
}
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, BuildinFileSystem, CacheFileSystem);
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
return operation;
}
@ -123,11 +119,6 @@ namespace YooAsset
BundleInfo bundleInfo = new BundleInfo(BuildinFileSystem, packageBundle);
return bundleInfo;
}
if (DeliveryFileSystem != null && DeliveryFileSystem.Belong(packageBundle))
{
BundleInfo bundleInfo = new BundleInfo(DeliveryFileSystem, packageBundle);
return bundleInfo;
}
if (CacheFileSystem.Belong(packageBundle))
{
BundleInfo bundleInfo = new BundleInfo(CacheFileSystem, packageBundle);