/// <summary> /// /// </summary> /// <param name="work">work的创建和销毁由外界处理</param> /// <param name="run"></param> /// <returns></returns> public void AddWork(IWork work, bool run = false) { if (work != null && !allWorks.Contains(work)) { allWorks.Add(work); if (run) { if (runningCount < runningWorks.Count) { runningWorks[runningCount++] = work; } else { runningWorks.Add(work); runningCount++; } work.Start(); (work as ITick).Tick(0); //有些需要立即生效 if (work.IsFinished()) { allWorks.Remove(work); runningWorks.Remove(work); runningCount--; } } } }
public virtual void Tick(float deltaTime) { if (state == ManagerState.BOOT_LOADING && (bootLoader == null || bootLoader.IsFinished())) { bootLoader = null; state = ManagerState.RUNNING; } OnTick(deltaTime); }
protected override WorkState CanChangeState(WorkState currentState) { if (currentState == WorkState.PLAYING && conditionSatisfied && (then == null || then.IsFinished())) { return(WorkState.FINISHED); } return(base.CanChangeState(currentState)); }