public BehaviourJob CreateAndAddChildJob(IEnumerator co) { var j = new BehaviourJob(co, false); AddChildJob(j); return(j); }
private IEnumerator DoWork() { while (IsRunning) { if (IsPaused) { yield return(null); } else { if (coroutine.MoveNext()) { yield return(coroutine.Current); } else { if (null != childJobStack && childJobStack.Count > 0) { BehaviourJob childJob = childJobStack.Pop(); coroutine = childJob.coroutine; } else { isRunning = false; } } } } OnComplete?.Invoke(isJobKilled); yield return(null); }
public void AddChildJob(BehaviourJob j) { if (null == childJobStack) { childJobStack = new Stack <BehaviourJob>(); } childJobStack.Push(j); }
// Update is called once per frame void Update() { if (timer >= lifeTime) { if (!isFadeOut) { isFadeOut = true; fadeOutJob = BehaviourJob.Make(IFadeOut(), true); } } else { timer += Time.deltaTime; } }
public void RemoveChildJob(BehaviourJob childJob) { if (childJobStack.Contains(childJob)) { var childStack = new Stack <BehaviourJob>(childJobStack.Count - 1); var allCurChildren = childJobStack.ToArray(); Array.Reverse(allCurChildren); for (int i = 0; i < allCurChildren.Length; i++) { var j = allCurChildren[i]; if (j != childJob) { childStack.Push(j); } } childJobStack = childStack; } }
private void Start() { trapTrigger = GetComponent <Collider>(); moveJob = BehaviourJob.Make(IMoveTrack(), true); }