using System; using UnityEngine; namespace QFramework { internal class NextOperationAction : IAction { public System.Action OnFinished { get; set; } private NextOperationAction() { } private static readonly SimpleObjectPool mPool = new SimpleObjectPool(() => new NextOperationAction(), null, 10); public static NextOperationAction Allocate( System.Action OnFinished = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.Deinited = false; retNode.Reset(); retNode.OnFinished = OnFinished; return retNode; } public ulong ActionID { get; set; } public ActionStatus Status { get; set; } public void OnStart() { TypeEventSystem.Global.Send(); } public void OnExecute(float dt) { this.Finish(); 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; } } }