2024-07-05 19:29:34 +08:00
|
|
|
|
|
2024-07-04 20:36:26 +08:00
|
|
|
|
namespace YooAsset
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2024-07-05 19:29:34 +08:00
|
|
|
|
/// 模拟文件系统
|
2024-07-04 20:36:26 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class DefaultEditorFileSystem : IFileSystem
|
|
|
|
|
|
{
|
|
|
|
|
|
protected string _packageRoot;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 包裹名称
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string PackageName { private set; get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 文件访问权限
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public EFileAccess FileSystemAccess
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return EFileAccess.Read;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 文件根目录
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string FileRoot
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _packageRoot;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 文件数量
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int FileCount
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 自定义参数
|
|
|
|
|
|
/// <summary>
|
2024-07-05 15:10:07 +08:00
|
|
|
|
/// 自定义参数:模拟构建结果
|
2024-07-04 20:36:26 +08:00
|
|
|
|
/// </summary>
|
2024-07-05 15:10:07 +08:00
|
|
|
|
public SimulateBuildResult BuildResult { private set; get; } = null;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DefaultEditorFileSystem()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
|
|
|
|
|
{
|
|
|
|
|
|
var operation = new DEFSInitializeOperation(this);
|
|
|
|
|
|
OperationSystem.StartOperation(PackageName, operation);
|
|
|
|
|
|
return operation;
|
|
|
|
|
|
}
|
|
|
|
|
|
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(params object[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
var operation = new DEFSLoadPackageManifestOperation(this);
|
|
|
|
|
|
OperationSystem.StartOperation(PackageName, operation);
|
|
|
|
|
|
return operation;
|
|
|
|
|
|
}
|
|
|
|
|
|
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(params object[] args)
|
|
|
|
|
|
{
|
2024-07-05 15:10:07 +08:00
|
|
|
|
var operation = new DEFSRequestPackageVersionOperation(this);
|
|
|
|
|
|
OperationSystem.StartOperation(PackageName, operation);
|
|
|
|
|
|
return operation;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync(params object[] args)
|
|
|
|
|
|
{
|
2024-07-05 15:10:07 +08:00
|
|
|
|
var operation = new FSClearAllBundleFilesCompleteOperation();
|
2024-07-04 20:36:26 +08:00
|
|
|
|
OperationSystem.StartOperation(PackageName, operation);
|
|
|
|
|
|
return operation;
|
|
|
|
|
|
}
|
|
|
|
|
|
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(params object[] args)
|
|
|
|
|
|
{
|
2024-07-05 15:10:07 +08:00
|
|
|
|
var operation = new FSClearUnusedBundleFilesCompleteOperation();
|
2024-07-04 20:36:26 +08:00
|
|
|
|
OperationSystem.StartOperation(PackageName, operation);
|
|
|
|
|
|
return operation;
|
|
|
|
|
|
}
|
|
|
|
|
|
public virtual FSDownloadFileOperation DownloadFileAsync(params object[] args)
|
|
|
|
|
|
{
|
2024-07-05 15:10:07 +08:00
|
|
|
|
throw new System.NotImplementedException();
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
2024-07-05 19:29:34 +08:00
|
|
|
|
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
|
|
|
|
|
{
|
|
|
|
|
|
var operation = new DEFSLoadBundleOperation(this, bundle);
|
|
|
|
|
|
OperationSystem.StartOperation(PackageName, operation);
|
|
|
|
|
|
return operation;
|
|
|
|
|
|
}
|
|
|
|
|
|
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
2024-07-04 20:36:26 +08:00
|
|
|
|
|
|
|
|
|
|
public virtual void SetParameter(string name, object value)
|
|
|
|
|
|
{
|
2024-07-05 15:10:07 +08:00
|
|
|
|
if (name == "SIMULATE_BUILD_RESULT")
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
2024-07-05 15:10:07 +08:00
|
|
|
|
BuildResult = (SimulateBuildResult)value;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
YooLogger.Warning($"Invalid parameter : {name}");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public virtual void OnCreate(string packageName, string rootDirectory)
|
|
|
|
|
|
{
|
|
|
|
|
|
PackageName = packageName;
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(rootDirectory))
|
|
|
|
|
|
rootDirectory = GetDefaultRoot();
|
|
|
|
|
|
|
|
|
|
|
|
_packageRoot = PathUtility.Combine(rootDirectory, packageName);
|
|
|
|
|
|
}
|
|
|
|
|
|
public virtual void OnUpdate()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual bool Belong(PackageBundle bundle)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
public virtual bool Exists(PackageBundle bundle)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2024-07-05 19:29:34 +08:00
|
|
|
|
public virtual bool NeedDownload(PackageBundle bundle)
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2024-07-05 19:29:34 +08:00
|
|
|
|
public virtual bool NeedUnpack(PackageBundle bundle)
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2024-07-05 19:29:34 +08:00
|
|
|
|
public virtual bool NeedImport(PackageBundle bundle)
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 内部方法
|
|
|
|
|
|
protected string GetDefaultRoot()
|
|
|
|
|
|
{
|
|
|
|
|
|
return "Assets/";
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|