mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
yoo2.2,9
yoo2.2,9
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
@@ -10,52 +6,70 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public abstract class InitializationOperation : AsyncOperationBase
|
||||
{
|
||||
public string PackageVersion { protected set; get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟模式的初始化操作
|
||||
/// 编辑器下模拟模式
|
||||
/// </summary>
|
||||
internal sealed class EditorSimulateModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadEditorManifest,
|
||||
CreateFileSystem,
|
||||
InitFileSystem,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly EditorSimulateModeImpl _impl;
|
||||
private readonly string _simulateManifestFilePath;
|
||||
private LoadEditorManifestOperation _loadEditorManifestOp;
|
||||
private readonly EditorSimulateModeParameters _parameters;
|
||||
private FSInitializeFileSystemOperation _initFileSystemOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulateManifestFilePath)
|
||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, EditorSimulateModeParameters parameters)
|
||||
{
|
||||
_impl = impl;
|
||||
_simulateManifestFilePath = simulateManifestFilePath;
|
||||
_parameters = parameters;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.LoadEditorManifest;
|
||||
_steps = ESteps.CreateFileSystem;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.LoadEditorManifest)
|
||||
if (_steps == ESteps.CreateFileSystem)
|
||||
{
|
||||
if (_loadEditorManifestOp == null)
|
||||
if (_parameters.EditorFileSystemParameters == null)
|
||||
{
|
||||
_loadEditorManifestOp = new LoadEditorManifestOperation(_impl.PackageName, _simulateManifestFilePath);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _loadEditorManifestOp);
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Editor file system parameters is null";
|
||||
return;
|
||||
}
|
||||
|
||||
if (_loadEditorManifestOp.IsDone == false)
|
||||
_impl.EditorFileSystem = _parameters.EditorFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.EditorFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create editor file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitFileSystem)
|
||||
{
|
||||
if (_initFileSystemOp == null)
|
||||
_initFileSystemOp = _impl.EditorFileSystem.InitializeFileSystemAsync();
|
||||
|
||||
Progress = _initFileSystemOp.Progress;
|
||||
if (_initFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadEditorManifestOp.Status == EOperationStatus.Succeed)
|
||||
if (_initFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
PackageVersion = _loadEditorManifestOp.Manifest.PackageVersion;
|
||||
_impl.ActiveManifest = _loadEditorManifestOp.Manifest;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
@@ -63,443 +77,346 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadEditorManifestOp.Error;
|
||||
Error = _initFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线运行模式的初始化操作
|
||||
/// 离线运行模式
|
||||
/// </summary>
|
||||
internal sealed class OfflinePlayModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
QueryBuildinPackageVersion,
|
||||
LoadBuildinManifest,
|
||||
PackageCaching,
|
||||
CreateFileSystem,
|
||||
InitFileSystem,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly OfflinePlayModeImpl _impl;
|
||||
private QueryBuildinPackageVersionOperation _queryBuildinPackageVersionOp;
|
||||
private LoadBuildinManifestOperation _loadBuildinManifestOp;
|
||||
private PackageCachingOperation _cachingOperation;
|
||||
private readonly OfflinePlayModeParameters _parameters;
|
||||
private FSInitializeFileSystemOperation _initFileSystemOp;
|
||||
private FSRequestPackageVersionOperation _requestPackageVersionOp;
|
||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal OfflinePlayModeInitializationOperation(OfflinePlayModeImpl impl)
|
||||
internal OfflinePlayModeInitializationOperation(OfflinePlayModeImpl impl, OfflinePlayModeParameters parameters)
|
||||
{
|
||||
_impl = impl;
|
||||
_parameters = parameters;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.QueryBuildinPackageVersion;
|
||||
_steps = ESteps.CreateFileSystem;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.QueryBuildinPackageVersion)
|
||||
if (_steps == ESteps.CreateFileSystem)
|
||||
{
|
||||
if (_queryBuildinPackageVersionOp == null)
|
||||
{
|
||||
_queryBuildinPackageVersionOp = new QueryBuildinPackageVersionOperation(_impl.Persistent);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _queryBuildinPackageVersionOp);
|
||||
}
|
||||
|
||||
if (_queryBuildinPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_queryBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadBuildinManifest;
|
||||
}
|
||||
else
|
||||
if (_parameters.BuildinFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _queryBuildinPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadBuildinManifest)
|
||||
{
|
||||
if (_loadBuildinManifestOp == null)
|
||||
{
|
||||
_loadBuildinManifestOp = new LoadBuildinManifestOperation(_impl.Persistent, _queryBuildinPackageVersionOp.PackageVersion);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _loadBuildinManifestOp);
|
||||
}
|
||||
|
||||
Progress = _loadBuildinManifestOp.Progress;
|
||||
if (_loadBuildinManifestOp.IsDone == false)
|
||||
Error = "Buildin file system parameters is null";
|
||||
return;
|
||||
|
||||
if (_loadBuildinManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
PackageVersion = _loadBuildinManifestOp.Manifest.PackageVersion;
|
||||
_impl.ActiveManifest = _loadBuildinManifestOp.Manifest;
|
||||
_steps = ESteps.PackageCaching;
|
||||
}
|
||||
else
|
||||
|
||||
_impl.BuildinFileSystem = _parameters.BuildinFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.BuildinFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadBuildinManifestOp.Error;
|
||||
Error = "Failed to create buildin file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.PackageCaching)
|
||||
if (_steps == ESteps.InitFileSystem)
|
||||
{
|
||||
if (_cachingOperation == null)
|
||||
{
|
||||
_cachingOperation = new PackageCachingOperation(_impl.Persistent, _impl.Cache);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _cachingOperation);
|
||||
}
|
||||
if (_initFileSystemOp == null)
|
||||
_initFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
|
||||
|
||||
Progress = _cachingOperation.Progress;
|
||||
if (_cachingOperation.IsDone)
|
||||
Progress = _initFileSystemOp.Progress;
|
||||
if (_initFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 联机运行模式的初始化操作
|
||||
/// 注意:优先从沙盒里加载清单,如果沙盒里不存在就尝试把内置清单拷贝到沙盒并加载该清单。
|
||||
/// 联机运行模式
|
||||
/// </summary>
|
||||
internal sealed class HostPlayModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CheckAppFootPrint,
|
||||
QueryCachePackageVersion,
|
||||
TryLoadCacheManifest,
|
||||
QueryBuildinPackageVersion,
|
||||
UnpackBuildinManifest,
|
||||
LoadBuildinManifest,
|
||||
PackageCaching,
|
||||
CreateBuildinFileSystem,
|
||||
InitBuildinFileSystem,
|
||||
CreateCacheFileSystem,
|
||||
InitCacheFileSystem,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private QueryBuildinPackageVersionOperation _queryBuildinPackageVersionOp;
|
||||
private QueryCachePackageVersionOperation _queryCachePackageVersionOp;
|
||||
private UnpackBuildinManifestOperation _unpackBuildinManifestOp;
|
||||
private LoadBuildinManifestOperation _loadBuildinManifestOp;
|
||||
private LoadCacheManifestOperation _loadCacheManifestOp;
|
||||
private PackageCachingOperation _cachingOperation;
|
||||
private readonly HostPlayModeParameters _parameters;
|
||||
private FSInitializeFileSystemOperation _initBuildinFileSystemOp;
|
||||
private FSInitializeFileSystemOperation _initCacheFileSystemOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl)
|
||||
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl, HostPlayModeParameters parameters)
|
||||
{
|
||||
_impl = impl;
|
||||
_parameters = parameters;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.CheckAppFootPrint;
|
||||
_steps = ESteps.CreateBuildinFileSystem;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CheckAppFootPrint)
|
||||
if (_steps == ESteps.CreateBuildinFileSystem)
|
||||
{
|
||||
var appFootPrint = new AppFootPrint(_impl.Persistent);
|
||||
appFootPrint.Load(_impl.PackageName);
|
||||
|
||||
// 如果水印发生变化,则说明覆盖安装后首次打开游戏
|
||||
if (appFootPrint.IsDirty())
|
||||
if (_parameters.BuildinFileSystemParameters == null)
|
||||
{
|
||||
_impl.Persistent.DeleteSandboxManifestFilesFolder();
|
||||
appFootPrint.Coverage(_impl.PackageName);
|
||||
YooLogger.Log("Delete manifest files when application foot print dirty !");
|
||||
_steps = ESteps.CreateCacheFileSystem;
|
||||
return;
|
||||
}
|
||||
_steps = ESteps.QueryCachePackageVersion;
|
||||
|
||||
_impl.BuildinFileSystem = _parameters.BuildinFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.BuildinFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create buildin file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitBuildinFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.QueryCachePackageVersion)
|
||||
if (_steps == ESteps.InitBuildinFileSystem)
|
||||
{
|
||||
if (_queryCachePackageVersionOp == null)
|
||||
{
|
||||
_queryCachePackageVersionOp = new QueryCachePackageVersionOperation(_impl.Persistent);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _queryCachePackageVersionOp);
|
||||
}
|
||||
if (_initBuildinFileSystemOp == null)
|
||||
_initBuildinFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
|
||||
|
||||
if (_queryCachePackageVersionOp.IsDone == false)
|
||||
Progress = _initBuildinFileSystemOp.Progress;
|
||||
if (_initBuildinFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_queryCachePackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
if (_initBuildinFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.TryLoadCacheManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.QueryBuildinPackageVersion;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.TryLoadCacheManifest)
|
||||
{
|
||||
if (_loadCacheManifestOp == null)
|
||||
{
|
||||
_loadCacheManifestOp = new LoadCacheManifestOperation(_impl.Persistent, _queryCachePackageVersionOp.PackageVersion);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _loadCacheManifestOp);
|
||||
}
|
||||
|
||||
if (_loadCacheManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadCacheManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
PackageVersion = _loadCacheManifestOp.Manifest.PackageVersion;
|
||||
_impl.ActiveManifest = _loadCacheManifestOp.Manifest;
|
||||
_steps = ESteps.PackageCaching;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.QueryBuildinPackageVersion;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.QueryBuildinPackageVersion)
|
||||
{
|
||||
if (_queryBuildinPackageVersionOp == null)
|
||||
{
|
||||
_queryBuildinPackageVersionOp = new QueryBuildinPackageVersionOperation(_impl.Persistent);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _queryBuildinPackageVersionOp);
|
||||
}
|
||||
|
||||
if (_queryBuildinPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_queryBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.UnpackBuildinManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 注意:为了兼容MOD模式,初始化动态新增的包裹的时候,如果内置清单不存在也不需要报错!
|
||||
_steps = ESteps.PackageCaching;
|
||||
string error = _queryBuildinPackageVersionOp.Error;
|
||||
YooLogger.Log($"Failed to load buildin package version file : {error}");
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.UnpackBuildinManifest)
|
||||
{
|
||||
if (_unpackBuildinManifestOp == null)
|
||||
{
|
||||
_unpackBuildinManifestOp = new UnpackBuildinManifestOperation(_impl.Persistent, _queryBuildinPackageVersionOp.PackageVersion);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _unpackBuildinManifestOp);
|
||||
}
|
||||
|
||||
if (_unpackBuildinManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_unpackBuildinManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadBuildinManifest;
|
||||
_steps = ESteps.CreateCacheFileSystem;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _unpackBuildinManifestOp.Error;
|
||||
Error = _initBuildinFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadBuildinManifest)
|
||||
if (_steps == ESteps.CreateCacheFileSystem)
|
||||
{
|
||||
if (_loadBuildinManifestOp == null)
|
||||
{
|
||||
_loadBuildinManifestOp = new LoadBuildinManifestOperation(_impl.Persistent, _queryBuildinPackageVersionOp.PackageVersion);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _loadBuildinManifestOp);
|
||||
}
|
||||
|
||||
Progress = _loadBuildinManifestOp.Progress;
|
||||
if (_loadBuildinManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadBuildinManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
PackageVersion = _loadBuildinManifestOp.Manifest.PackageVersion;
|
||||
_impl.ActiveManifest = _loadBuildinManifestOp.Manifest;
|
||||
_impl.FlushManifestVersionFile(); //注意:解压内置清单并加载成功后保存该清单版本。
|
||||
_steps = ESteps.PackageCaching;
|
||||
}
|
||||
else
|
||||
if (_parameters.CacheFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadBuildinManifestOp.Error;
|
||||
Error = "Cache file system parameters is null";
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.CacheFileSystem = _parameters.CacheFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.CacheFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create cache file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitCacheFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.PackageCaching)
|
||||
if (_steps == ESteps.InitCacheFileSystem)
|
||||
{
|
||||
if (_cachingOperation == null)
|
||||
{
|
||||
_cachingOperation = new PackageCachingOperation(_impl.Persistent, _impl.Cache);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _cachingOperation);
|
||||
}
|
||||
if (_initCacheFileSystemOp == null)
|
||||
_initCacheFileSystemOp = _impl.CacheFileSystem.InitializeFileSystemAsync();
|
||||
|
||||
Progress = _cachingOperation.Progress;
|
||||
if (_cachingOperation.IsDone)
|
||||
Progress = _initCacheFileSystemOp.Progress;
|
||||
if (_initCacheFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initCacheFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initCacheFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WebGL运行模式的初始化操作
|
||||
/// WebGL运行模式
|
||||
/// </summary>
|
||||
internal sealed class WebPlayModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
QueryWebPackageVersion,
|
||||
LoadWebManifest,
|
||||
CreateWebServerFileSystem,
|
||||
InitWebServerFileSystem,
|
||||
CreateWebRemoteFileSystem,
|
||||
InitWebRemoteFileSystem,
|
||||
CheckResult,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly WebPlayModeImpl _impl;
|
||||
private QueryBuildinPackageVersionOperation _queryWebPackageVersionOp;
|
||||
private LoadBuildinManifestOperation _loadWebManifestOp;
|
||||
private readonly WebPlayModeParameters _parameters;
|
||||
private FSInitializeFileSystemOperation _initWebServerFileSystemOp;
|
||||
private FSInitializeFileSystemOperation _initWebRemoteFileSystemOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal WebPlayModeInitializationOperation(WebPlayModeImpl impl)
|
||||
internal WebPlayModeInitializationOperation(WebPlayModeImpl impl, WebPlayModeParameters parameters)
|
||||
{
|
||||
_impl = impl;
|
||||
_parameters = parameters;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.QueryWebPackageVersion;
|
||||
_steps = ESteps.CreateWebServerFileSystem;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.QueryWebPackageVersion)
|
||||
if (_steps == ESteps.CreateWebServerFileSystem)
|
||||
{
|
||||
if (_queryWebPackageVersionOp == null)
|
||||
if (_parameters.WebServerFileSystemParameters == null)
|
||||
{
|
||||
_queryWebPackageVersionOp = new QueryBuildinPackageVersionOperation(_impl.Persistent);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _queryWebPackageVersionOp);
|
||||
}
|
||||
|
||||
if (_queryWebPackageVersionOp.IsDone == false)
|
||||
_steps = ESteps.CreateWebRemoteFileSystem;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_queryWebPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
_impl.WebServerFileSystem = _parameters.WebServerFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.WebServerFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.LoadWebManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 注意:WebGL平台可能因为网络的原因会导致请求失败。如果内置清单不存在或者超时也不需要报错!
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
string error = _queryWebPackageVersionOp.Error;
|
||||
YooLogger.Log($"Failed to load web package version file : {error}");
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create web server file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitWebServerFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadWebManifest)
|
||||
if (_steps == ESteps.InitWebServerFileSystem)
|
||||
{
|
||||
if (_loadWebManifestOp == null)
|
||||
{
|
||||
_loadWebManifestOp = new LoadBuildinManifestOperation(_impl.Persistent, _queryWebPackageVersionOp.PackageVersion);
|
||||
OperationSystem.StartOperation(_impl.PackageName, _loadWebManifestOp);
|
||||
}
|
||||
if (_initWebServerFileSystemOp == null)
|
||||
_initWebServerFileSystemOp = _impl.WebServerFileSystem.InitializeFileSystemAsync();
|
||||
|
||||
Progress = _loadWebManifestOp.Progress;
|
||||
if (_loadWebManifestOp.IsDone == false)
|
||||
Progress = _initWebServerFileSystemOp.Progress;
|
||||
if (_initWebServerFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadWebManifestOp.Status == EOperationStatus.Succeed)
|
||||
if (_initWebServerFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
PackageVersion = _loadWebManifestOp.Manifest.PackageVersion;
|
||||
_impl.ActiveManifest = _loadWebManifestOp.Manifest;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
_steps = ESteps.CreateWebRemoteFileSystem;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadWebManifestOp.Error;
|
||||
Error = _initWebServerFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CreateWebRemoteFileSystem)
|
||||
{
|
||||
if (_parameters.WebRemoteFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.CheckResult;
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.WebRemoteFileSystem = _parameters.WebRemoteFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.WebRemoteFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create web remote file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitWebRemoteFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitWebRemoteFileSystem)
|
||||
{
|
||||
if (_initWebRemoteFileSystemOp == null)
|
||||
_initWebRemoteFileSystemOp = _impl.WebRemoteFileSystem.InitializeFileSystemAsync();
|
||||
|
||||
Progress = _initWebRemoteFileSystemOp.Progress;
|
||||
if (_initWebRemoteFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initWebRemoteFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CheckResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initWebRemoteFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckResult)
|
||||
{
|
||||
if (_impl.WebServerFileSystem == null && _impl.WebRemoteFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Not found any file system !";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用程序水印
|
||||
/// </summary>
|
||||
internal class AppFootPrint
|
||||
{
|
||||
private PersistentManager _persistent;
|
||||
private string _footPrint;
|
||||
|
||||
public AppFootPrint(PersistentManager persistent)
|
||||
{
|
||||
_persistent = persistent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取应用程序水印
|
||||
/// </summary>
|
||||
public void Load(string packageName)
|
||||
{
|
||||
string footPrintFilePath = _persistent.SandboxAppFootPrintFilePath;
|
||||
if (File.Exists(footPrintFilePath))
|
||||
{
|
||||
_footPrint = FileUtility.ReadAllText(footPrintFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Coverage(packageName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测水印是否发生变化
|
||||
/// </summary>
|
||||
public bool IsDirty()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return _footPrint != Application.version;
|
||||
#else
|
||||
return _footPrint != Application.buildGUID;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 覆盖掉水印
|
||||
/// </summary>
|
||||
public void Coverage(string packageName)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
_footPrint = Application.version;
|
||||
#else
|
||||
_footPrint = Application.buildGUID;
|
||||
#endif
|
||||
string footPrintFilePath = _persistent.SandboxAppFootPrintFilePath;
|
||||
FileUtility.WriteAllText(footPrintFilePath, _footPrint);
|
||||
YooLogger.Log($"Save application foot print : {_footPrint}");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user