77 lines
1.8 KiB
C#
77 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace QFramework
|
|
{
|
|
internal class OperationChangeAction : IAction
|
|
{
|
|
|
|
public System.Action OnFinished { get; set; }
|
|
|
|
|
|
private OperationChangeAction()
|
|
{
|
|
}
|
|
|
|
private static readonly SimpleObjectPool<OperationChangeAction> mPool =
|
|
new SimpleObjectPool<OperationChangeAction>(() => new OperationChangeAction(), null, 10);
|
|
|
|
Dictionary<string, string> datas;
|
|
public static OperationChangeAction Allocate(Dictionary<string, string> datas, System.Action OnFinished = null)
|
|
{
|
|
var retNode = mPool.Allocate();
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
|
retNode.Deinited = false;
|
|
retNode.Reset();
|
|
retNode.datas = datas;
|
|
retNode.OnFinished = OnFinished;
|
|
return retNode;
|
|
}
|
|
|
|
|
|
public ulong ActionID { get; set; }
|
|
public ActionStatus Status { get; set; }
|
|
|
|
public void OnStart()
|
|
{
|
|
}
|
|
|
|
public void OnExecute(float dt)
|
|
{
|
|
this.Finish();
|
|
if (datas.ContainsKey("name"))
|
|
{
|
|
Debug.Log("OperationChangeAction" + "????");
|
|
OperationController.Instance.ChangeOperation(datas["name"]);
|
|
}
|
|
OnFinished?.Invoke();
|
|
}
|
|
|
|
public void OnFinish()
|
|
{
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
Status = ActionStatus.NotStart;
|
|
Paused = false;
|
|
}
|
|
|
|
public bool Paused { get; set; }
|
|
|
|
public void Deinit()
|
|
{
|
|
if (!Deinited)
|
|
{
|
|
OnFinished = null;
|
|
Deinited = true;
|
|
mPool.Recycle(this);
|
|
}
|
|
}
|
|
|
|
public bool Deinited { get; set; }
|
|
}
|
|
|
|
|
|
} |