update file system

This commit is contained in:
何冠峰
2024-07-05 15:10:07 +08:00
parent db8d09d0d6
commit 75511397d6
54 changed files with 510 additions and 1077 deletions
@@ -12,7 +12,6 @@ namespace YooAsset
{
protected string _packageRoot;
/// <summary>
/// 包裹名称
/// </summary>
@@ -53,9 +52,9 @@ namespace YooAsset
#region 自定义参数
/// <summary>
/// 自定义参数:模拟运行的资源清单文件路径
/// 自定义参数:模拟构建结果
/// </summary>
public string SimulateManifestFilePath { private set; get; } = string.Empty;
public SimulateBuildResult BuildResult { private set; get; } = null;
#endregion
@@ -76,33 +75,32 @@ namespace YooAsset
}
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(params object[] args)
{
throw new System.NotImplementedException();
var operation = new DEFSRequestPackageVersionOperation(this);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync(params object[] args)
{
var operation = new DEFSClearAllBundleFilesOperation(this);
var operation = new FSClearAllBundleFilesCompleteOperation();
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(params object[] args)
{
var operation = new DEFSClearUnusedBundleFilesOperation(this);
var operation = new FSClearUnusedBundleFilesCompleteOperation();
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
public virtual FSDownloadFileOperation DownloadFileAsync(params object[] args)
{
PackageBundle bundle = args[0] as PackageBundle;
var operation = new DEFSDownloadFileOperation(bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation;
throw new System.NotImplementedException();
}
public virtual void SetParameter(string name, object value)
{
if (name == "SIMULATE_MANIFEST_FILE_PATH")
if (name == "SIMULATE_BUILD_RESULT")
{
SimulateManifestFilePath = (string)value;
BuildResult = (SimulateBuildResult)value;
}
else
{
@@ -1,20 +0,0 @@
namespace YooAsset
{
internal sealed class DEFSClearAllBundleFilesOperation : FSClearAllBundleFilesOperation
{
private readonly DefaultEditorFileSystem _fileSystem;
internal DEFSClearAllBundleFilesOperation(DefaultEditorFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
internal override void InternalOnStart()
{
Status = EOperationStatus.Succeed;
}
internal override void InternalOnUpdate()
{
}
}
}
@@ -1,20 +0,0 @@
namespace YooAsset
{
internal sealed class DEFSClearUnusedBundleFilesOperation : FSClearUnusedBundleFilesOperation
{
private readonly DefaultEditorFileSystem _fileSystem;
internal DEFSClearUnusedBundleFilesOperation(DefaultEditorFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
internal override void InternalOnStart()
{
Status = EOperationStatus.Succeed;
}
internal override void InternalOnUpdate()
{
}
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1f86d3bce4381694b8c619ceda2e7309
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,17 +0,0 @@
namespace YooAsset
{
internal class DEFSDownloadFileOperation : FSDownloadFileOperation
{
internal DEFSDownloadFileOperation(PackageBundle bundle) : base(bundle)
{
}
internal override void InternalOnStart()
{
Status = EOperationStatus.Succeed;
}
internal override void InternalOnUpdate()
{
}
}
}
@@ -0,0 +1,57 @@
namespace YooAsset
{
internal class DEFSRequestPackageVersionOperation : FSRequestPackageVersionOperation
{
private enum ESteps
{
None,
GetPackageVersion,
Done,
}
private readonly DefaultEditorFileSystem _fileSystem;
private LoadEditorPackageVersionOperation _loadEditorPackageVersionOp;
private ESteps _steps = ESteps.None;
internal DEFSRequestPackageVersionOperation(DefaultEditorFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
internal override void InternalOnStart()
{
_steps = ESteps.GetPackageVersion;
}
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.GetPackageVersion)
{
if (_loadEditorPackageVersionOp == null)
{
_loadEditorPackageVersionOp = new LoadEditorPackageVersionOperation(_fileSystem);
OperationSystem.StartOperation(_fileSystem.PackageName, _loadEditorPackageVersionOp);
}
if (_loadEditorPackageVersionOp.IsDone == false)
return;
if (_loadEditorPackageVersionOp.Status == EOperationStatus.Succeed)
{
_steps = ESteps.Done;
PackageVersion = _loadEditorPackageVersionOp.PackageVersion;
Status = EOperationStatus.Succeed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _loadEditorPackageVersionOp.Error;
}
}
}
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 06a8abe71cf3fe64180ec076a79b4b66
guid: 47293048f9cde3f46a1b297f1c2e3373
MonoImporter:
externalObjects: {}
serializedVersion: 2
@@ -38,7 +38,7 @@ namespace YooAsset
if (_steps == ESteps.LoadFileData)
{
string manifestFilePath = _fileSystem.SimulateManifestFilePath;
string manifestFilePath = _fileSystem.BuildResult.PackageManifestFilePath;
if (File.Exists(manifestFilePath))
{
_steps = ESteps.LoadManifest;
@@ -48,7 +48,7 @@ namespace YooAsset
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Simulation manifest file not found : {manifestFilePath}";
Error = $"Simulation package manifest file not found : {manifestFilePath}";
}
}
@@ -0,0 +1,51 @@
using System.IO;
namespace YooAsset
{
internal class LoadEditorPackageVersionOperation : AsyncOperationBase
{
private enum ESteps
{
None,
LoadVersion,
Done,
}
private readonly DefaultEditorFileSystem _fileSystem;
private ESteps _steps = ESteps.None;
public string PackageVersion { private set; get; }
internal LoadEditorPackageVersionOperation(DefaultEditorFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
internal override void InternalOnStart()
{
_steps = ESteps.LoadVersion;
}
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.LoadVersion)
{
string versionFilePath = _fileSystem.BuildResult.PackageVersionFilePath;
if (File.Exists(versionFilePath))
{
_steps = ESteps.Done;
PackageVersion = FileUtility.ReadAllText(versionFilePath);
Status = EOperationStatus.Succeed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Simulation package version file not found : {versionFilePath}";
}
}
}
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: a16dae8497d54984daa95a3682a7beb4
guid: a4278d490ca87354ab63b0bece1fdab7
MonoImporter:
externalObjects: {}
serializedVersion: 2