update operation system

pull/189/head
hevinci 2023-10-10 12:17:01 +08:00
parent b3a135e1a2
commit 5d9ef12577
29 changed files with 106 additions and 97 deletions

View File

@ -26,11 +26,11 @@ namespace YooAsset
{
_cache = cache;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.GetAllCacheFiles;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -28,11 +28,11 @@ namespace YooAsset
_package = package;
_cache = cache;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.GetUnusedCacheFiles;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -31,12 +31,12 @@ namespace YooAsset
_persistent = persistent;
_cache = cache;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.Prepare;
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -48,12 +48,12 @@ namespace YooAsset
_cache = cache;
_waitingList = elements;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.InitVerify;
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
@ -175,12 +175,12 @@ namespace YooAsset
_cache = cache;
_waitingList = elements;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.InitVerify;
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -41,11 +41,11 @@ namespace YooAsset
{
_element = element;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.VerifyFile;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
@ -110,11 +110,11 @@ namespace YooAsset
{
_element = element;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.VerifyFile;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -26,11 +26,11 @@ namespace YooAsset
_persistent = persistent;
_cache = cache;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.FindCacheFiles;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -112,7 +112,7 @@ namespace YooAsset
if (_steps == ESteps.WaitingVerifyTempFile)
{
if (WaitForAsyncComplete)
_verifyFileOp.Update();
_verifyFileOp.InternalOnUpdate();
if (_verifyFileOp.IsDone == false)
return;

View File

@ -76,23 +76,18 @@ namespace YooAsset
}
}
internal abstract void Start();
internal abstract void Update();
internal virtual void Abort() { }
internal abstract void InternalOnStart();
internal abstract void InternalOnUpdate();
internal virtual void InternalOnAbort() { }
internal void SetPackageName(string packageName)
{
PackageName = packageName;
}
internal void SetAbort()
internal void SetStart()
{
if (IsDone == false)
{
Status = EOperationStatus.Failed;
Error = "user abort";
YooLogger.Warning($"Async operaiton has been abort : {this.GetType().Name}");
Abort();
}
Status = EOperationStatus.Processing;
InternalOnStart();
}
internal void SetFinish()
{
@ -101,10 +96,15 @@ namespace YooAsset
if (_taskCompletionSource != null)
_taskCompletionSource.TrySetResult(null);
}
internal void SetStart()
internal void SetAbort()
{
Status = EOperationStatus.Processing;
Start();
if (IsDone == false)
{
Status = EOperationStatus.Failed;
Error = "user abort";
YooLogger.Warning($"Async operaiton has been abort : {this.GetType().Name}");
InternalOnAbort();
}
}
/// <summary>

View File

@ -3,14 +3,18 @@ namespace YooAsset
{
public abstract class GameAsyncOperation : AsyncOperationBase
{
internal override void Start()
internal override void InternalOnStart()
{
OnStart();
}
internal override void Update()
internal override void InternalOnUpdate()
{
OnUpdate();
}
internal override void InternalOnAbort()
{
OnAbort();
}
/// <summary>
/// 异步操作开始
@ -22,6 +26,11 @@ namespace YooAsset
/// </summary>
protected abstract void OnUpdate();
/// <summary>
/// 异步操作终止
/// </summary>
protected abstract void OnAbort();
/// <summary>
/// 异步操作系统是否繁忙
/// </summary>

View File

@ -60,7 +60,7 @@ namespace YooAsset
var operation = _operations[i];
if (operation.IsDone == false)
operation.Update();
operation.InternalOnUpdate();
if (operation.IsDone)
{

View File

@ -34,11 +34,11 @@ namespace YooAsset
_parent = parent;
_worldPositionStays = worldPositionStays;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.Clone;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
@ -93,7 +93,7 @@ namespace YooAsset
if (_steps == ESteps.Done)
return;
_handle.WaitForAsyncComplete();
Update();
InternalOnUpdate();
}
internal static GameObject InstantiateInternal(UnityEngine.Object assetObject, bool setPositionAndRotation, Vector3 position, Quaternion rotation, Transform parent, bool worldPositionStays)

View File

@ -36,7 +36,7 @@ namespace YooAsset
_flag = EFlag.Normal;
_scene = scene;
}
internal override void Start()
internal override void InternalOnStart()
{
if (_flag == EFlag.Normal)
{
@ -52,7 +52,7 @@ namespace YooAsset
throw new System.NotImplementedException(_flag.ToString());
}
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -98,12 +98,12 @@ namespace YooAsset
// 统计下载信息
CalculatDownloaderInfo();
}
internal override void Start()
internal override void InternalOnStart()
{
YooLogger.Log($"Begine to download : {TotalDownloadCount} files and {TotalDownloadBytes} bytes");
_steps = ESteps.Check;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -35,11 +35,11 @@ namespace YooAsset
_impl = impl;
_simulateManifestFilePath = simulateManifestFilePath;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.LoadEditorManifest;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.LoadEditorManifest)
{
@ -93,11 +93,11 @@ namespace YooAsset
{
_impl = impl;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.QueryBuildinPackageVersion;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
@ -201,11 +201,11 @@ namespace YooAsset
{
_impl = impl;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.CheckAppFootPrint;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
@ -382,11 +382,11 @@ namespace YooAsset
{
_impl = impl;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.QueryWebPackageVersion;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -32,11 +32,11 @@ namespace YooAsset
{
_buffer = new BufferReader(binaryData);
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.DeserializeFileHeader;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -27,12 +27,12 @@ namespace YooAsset
_packageVersion = packageVersion;
_timeout = timeout;
}
internal override void Start()
internal override void InternalOnStart()
{
_requestCount = RequestHelper.GetRequestFailedCount(_persistent.PackageName, nameof(DownloadManifestOperation));
_steps = ESteps.DownloadPackageHashFile;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -28,11 +28,11 @@ namespace YooAsset
_persistent = persistent;
_buildinPackageVersion = buildinPackageVersion;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.LoadBuildinManifest;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -32,11 +32,11 @@ namespace YooAsset
_persistent = persistent;
_packageVersion = packageVersion;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.QueryCachePackageHash;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -28,11 +28,11 @@ namespace YooAsset
_packageName = packageName;
_manifestFilePath = manifestFilePath;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.LoadEditorManifest;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -37,12 +37,12 @@ namespace YooAsset
_packageVersion = packageVersion;
_timeout = timeout;
}
internal override void Start()
internal override void InternalOnStart()
{
_requestCount = RequestHelper.GetRequestFailedCount(_packageName, nameof(LoadRemoteManifestOperation));
_steps = ESteps.DownloadPackageHashFile;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -24,11 +24,11 @@ namespace YooAsset
{
_persistent = persistent;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.LoadBuildinPackageVersionFile;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -26,11 +26,11 @@ namespace YooAsset
_persistent = persistent;
_packageVersion = packageVersion;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.LoadCachePackageHashFile;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -24,11 +24,11 @@ namespace YooAsset
{
_persistent = persistent;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.LoadCachePackageVersionFile;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -31,12 +31,12 @@ namespace YooAsset
_packageVersion = packageVersion;
_timeout = timeout;
}
internal override void Start()
internal override void InternalOnStart()
{
_requestCount = RequestHelper.GetRequestFailedCount(_packageName, nameof(QueryRemotePackageHashOperation));
_steps = ESteps.DownloadPackageHash;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -31,12 +31,12 @@ namespace YooAsset
_appendTimeTicks = appendTimeTicks;
_timeout = timeout;
}
internal override void Start()
internal override void InternalOnStart()
{
_requestCount = RequestHelper.GetRequestFailedCount(_packageName, nameof(QueryRemotePackageVersionOperation));
_steps = ESteps.DownloadPackageVersion;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -22,11 +22,11 @@ namespace YooAsset
_persistent = persistent;
_buildinPackageVersion = buildinPackageVersion;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.UnpackManifestHashFile;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -59,11 +59,11 @@ namespace YooAsset
{
_impl = impl;
}
internal override void Start()
internal override void InternalOnStart()
{
Status = EOperationStatus.Succeed;
}
internal override void Update()
internal override void InternalOnUpdate()
{
}
@ -96,11 +96,11 @@ namespace YooAsset
{
_impl = impl;
}
internal override void Start()
internal override void InternalOnStart()
{
Status = EOperationStatus.Succeed;
}
internal override void Update()
internal override void InternalOnUpdate()
{
}
@ -154,11 +154,11 @@ namespace YooAsset
_packageVersion = packageVersion;
_timeout = timeout;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.CheckActiveManifest;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
@ -331,11 +331,11 @@ namespace YooAsset
{
_impl = impl;
}
internal override void Start()
internal override void InternalOnStart()
{
Status = EOperationStatus.Succeed;
}
internal override void Update()
internal override void InternalOnUpdate()
{
}

View File

@ -23,11 +23,11 @@ namespace YooAsset
public EditorPlayModeUpdatePackageManifestOperation()
{
}
internal override void Start()
internal override void InternalOnStart()
{
Status = EOperationStatus.Succeed;
}
internal override void Update()
internal override void InternalOnUpdate()
{
}
}
@ -40,11 +40,11 @@ namespace YooAsset
public OfflinePlayModeUpdatePackageManifestOperation()
{
}
internal override void Start()
internal override void InternalOnStart()
{
Status = EOperationStatus.Succeed;
}
internal override void Update()
internal override void InternalOnUpdate()
{
}
}
@ -84,11 +84,11 @@ namespace YooAsset
_autoSaveVersion = autoSaveVersion;
_timeout = timeout;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.CheckParams;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
@ -229,11 +229,11 @@ namespace YooAsset
_packageVersion = packageVersion;
_timeout = timeout;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.CheckParams;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;

View File

@ -20,11 +20,11 @@ namespace YooAsset
/// </summary>
internal sealed class EditorPlayModeUpdatePackageVersionOperation : UpdatePackageVersionOperation
{
internal override void Start()
internal override void InternalOnStart()
{
Status = EOperationStatus.Succeed;
}
internal override void Update()
internal override void InternalOnUpdate()
{
}
}
@ -34,11 +34,11 @@ namespace YooAsset
/// </summary>
internal sealed class OfflinePlayModeUpdatePackageVersionOperation : UpdatePackageVersionOperation
{
internal override void Start()
internal override void InternalOnStart()
{
Status = EOperationStatus.Succeed;
}
internal override void Update()
internal override void InternalOnUpdate()
{
}
}
@ -67,11 +67,11 @@ namespace YooAsset
_appendTimeTicks = appendTimeTicks;
_timeout = timeout;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.QueryRemotePackageVersion;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
@ -127,11 +127,11 @@ namespace YooAsset
_appendTimeTicks = appendTimeTicks;
_timeout = timeout;
}
internal override void Start()
internal override void InternalOnStart()
{
_steps = ESteps.QueryRemotePackageVersion;
}
internal override void Update()
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;