using System; using UnityEngine; using System.Collections.Generic; namespace SK.Framework { /// /// 抽象事件链 /// public abstract class AbstractActionChain : AbstractAction, IActionChain { protected MonoBehaviour executer; protected List cacheList; protected List invokeList; protected Func stopWhen; public bool IsPaused { get; protected set; } protected int loops = 1; public AbstractActionChain() { executer = ActionMaster.Instance; cacheList = new List(); invokeList = new List(); } public AbstractActionChain(MonoBehaviour executer) { this.executer = executer; cacheList = new List(); invokeList = new List(); } public IActionChain Append(IAction action) { cacheList.Add(action); invokeList.Add(action); return this; } public IActionChain StopWhen(Func predicate) { stopWhen = predicate; return this; } public IActionChain OnStop(Action action) { onCompleted = action; return this; } public IActionChain Begin() { ActionChain.Execute(this, executer); return this; } public void Pause() { IsPaused = true; } public void Resume() { IsPaused = false; } public void Stop() { isCompleted = true; } public IActionChain SetLoops(int loops) { this.loops = loops; return this; } } }