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 class HostPlayModeParameters : InitializeParameters
{ {
public FileSystemParameters BuildinFileSystemParameters; public FileSystemParameters BuildinFileSystemParameters;
public FileSystemParameters DeliveryFileSystemParameters;
public FileSystemParameters CacheFileSystemParameters; public FileSystemParameters CacheFileSystemParameters;
} }

View File

@ -171,9 +171,9 @@ namespace YooAsset
private enum ESteps private enum ESteps
{ {
None, None,
CreateFileSystem, CreateBuildinFileSystem,
InitBuildinFileSystem, InitBuildinFileSystem,
InitDeliveryFileSystem, CreateCacheFileSystem,
InitCacheFileSystem, InitCacheFileSystem,
Done, Done,
} }
@ -181,7 +181,6 @@ namespace YooAsset
private readonly HostPlayModeImpl _impl; private readonly HostPlayModeImpl _impl;
private readonly HostPlayModeParameters _parameters; private readonly HostPlayModeParameters _parameters;
private FSInitializeFileSystemOperation _initBuildinFileSystemOp; private FSInitializeFileSystemOperation _initBuildinFileSystemOp;
private FSInitializeFileSystemOperation _initDeliveryFileSystemOp;
private FSInitializeFileSystemOperation _initCacheFileSystemOp; private FSInitializeFileSystemOperation _initCacheFileSystemOp;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
@ -192,14 +191,55 @@ namespace YooAsset
} }
internal override void InternalOnStart() internal override void InternalOnStart()
{ {
_steps = ESteps.CreateFileSystem; _steps = ESteps.CreateBuildinFileSystem;
} }
internal override void InternalOnUpdate() internal override void InternalOnUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
if (_steps == ESteps.CreateFileSystem) if (_steps == ESteps.CreateBuildinFileSystem)
{
if (_parameters.BuildinFileSystemParameters == null)
{
_steps = ESteps.CreateCacheFileSystem;
return;
}
_impl.BuildinFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.BuildinFileSystemParameters);
if (_impl.BuildinFileSystem == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Failed to create buildin file system";
return;
}
_steps = ESteps.InitBuildinFileSystem;
}
if (_steps == ESteps.InitBuildinFileSystem)
{
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 = _initBuildinFileSystemOp.Error;
}
}
if (_steps == ESteps.CreateCacheFileSystem)
{ {
if (_parameters.CacheFileSystemParameters == null) if (_parameters.CacheFileSystemParameters == null)
{ {
@ -209,30 +249,6 @@ namespace YooAsset
return; return;
} }
if (_parameters.BuildinFileSystemParameters != null)
{
_impl.BuildinFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.BuildinFileSystemParameters);
if (_impl.BuildinFileSystem == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Failed to create buildin file system";
return;
}
}
if (_parameters.DeliveryFileSystemParameters != null)
{
_impl.DeliveryFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.DeliveryFileSystemParameters);
if (_impl.DeliveryFileSystem == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Failed to create delivery file system";
return;
}
}
_impl.CacheFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.CacheFileSystemParameters); _impl.CacheFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.CacheFileSystemParameters);
if (_impl.CacheFileSystem == null) if (_impl.CacheFileSystem == null)
{ {
@ -242,63 +258,7 @@ namespace YooAsset
return; return;
} }
_steps = ESteps.InitBuildinFileSystem; _steps = ESteps.InitCacheFileSystem;
}
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) if (_steps == ESteps.InitCacheFileSystem)
@ -445,7 +405,7 @@ namespace YooAsset
if (_steps == ESteps.CheckResult) if (_steps == ESteps.CheckResult)
{ {
if(_impl.WebServerFileSystem == null && _impl.WebRemoteFileSystem == null) if (_impl.WebServerFileSystem == null && _impl.WebRemoteFileSystem == null)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;

View File

@ -225,7 +225,7 @@ namespace YooAsset
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout); 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); var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
@ -237,7 +237,7 @@ namespace YooAsset
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout); 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); var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
@ -249,7 +249,7 @@ namespace YooAsset
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout); 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); var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
@ -265,7 +265,7 @@ namespace YooAsset
var assetInfo = _manifest.ConvertLocationToAssetInfo(location, null); var assetInfo = _manifest.ConvertLocationToAssetInfo(location, null);
assetInfos.Add(assetInfo); 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); var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
@ -284,7 +284,7 @@ namespace YooAsset
assetInfos.Add(assetInfo); 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); var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }

View File

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