refactor the runtime code
重构了运行时代码,支持全新的文件系统。
This commit is contained in:
@@ -10,14 +10,12 @@ namespace YooAsset
|
||||
// 用户请求的回调
|
||||
private Action<AsyncOperationBase> _callback;
|
||||
|
||||
// 所属包裹
|
||||
private string _packageName = null;
|
||||
|
||||
// 是否已经完成
|
||||
internal bool IsFinish = false;
|
||||
|
||||
/// <summary>
|
||||
/// 所属包裹
|
||||
/// </summary>
|
||||
public string PackageName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 优先级
|
||||
/// </summary>
|
||||
@@ -88,9 +86,13 @@ namespace YooAsset
|
||||
internal abstract void InternalOnUpdate();
|
||||
internal virtual void InternalOnAbort() { }
|
||||
|
||||
internal string GetPackageName()
|
||||
{
|
||||
return _packageName;
|
||||
}
|
||||
internal void SetPackageName(string packageName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
_packageName = packageName;
|
||||
}
|
||||
internal void SetStart()
|
||||
{
|
||||
@@ -116,11 +118,19 @@ namespace YooAsset
|
||||
{
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "user abort";
|
||||
YooLogger.Warning($"Async operaiton has been abort : {this.GetType().Name}");
|
||||
YooLogger.Warning($"Async operaiton {this.GetType().Name} has been abort !");
|
||||
InternalOnAbort();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 等待异步执行完毕
|
||||
/// </summary>
|
||||
public virtual void WaitForAsyncComplete()
|
||||
{
|
||||
throw new System.NotImplementedException(this.GetType().Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空完成回调
|
||||
/// </summary>
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace YooAsset
|
||||
// 终止临时队列里的任务
|
||||
foreach (var operation in _newList)
|
||||
{
|
||||
if (operation.PackageName == packageName)
|
||||
if (operation.GetPackageName() == packageName)
|
||||
{
|
||||
operation.SetAbort();
|
||||
}
|
||||
@@ -121,7 +121,7 @@ namespace YooAsset
|
||||
// 终止正在进行的任务
|
||||
foreach (var operation in _operations)
|
||||
{
|
||||
if (operation.PackageName == packageName)
|
||||
if (operation.GetPackageName() == packageName)
|
||||
{
|
||||
operation.SetAbort();
|
||||
}
|
||||
@@ -137,14 +137,5 @@ namespace YooAsset
|
||||
operation.SetPackageName(packageName);
|
||||
operation.SetStart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始处理异步操作类
|
||||
/// </summary>
|
||||
public static void StartOperation(AsyncOperationBase operation)
|
||||
{
|
||||
_newList.Add(operation);
|
||||
operation.SetStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user