Esempio n. 1
0
        protected void SetParent(RoutineBase newParent)
        {
            if (parent == newParent)
            {
                return;
            }

            if (parent != null)
            {
                Assert.IsTrue(parent.children.Contains(this));
                parent.children.Remove(this);
            }

            parent = newParent;

            if (newParent != null)
            {
                manager = parent.manager;
                newParent.children.Add(this);
            }
            else
            {
                manager = null;
            }
        }
Esempio n. 2
0
 protected virtual void Reset()
 {
     Stop();
     state = State.NotStarted;
     if (stateMachine != null)
     {
         stateMachinePool.Release(stateMachine);
         stateMachine = null;
     }
     parent  = null;
     manager = null;
 }
Esempio n. 3
0
        private static void CollectAwaitingRoutines(RoutineBase routine, List <RoutineBase> awaitingRoutines)
        {
            var isAwaiting = true;

            foreach (var child in routine.children)
            {
                if (child.IsRunning)
                {
                    isAwaiting = false;
                    CollectAwaitingRoutines(child, awaitingRoutines);
                }
            }
            if (isAwaiting)
            {
                awaitingRoutines.Add(routine);
            }
        }
Esempio n. 4
0
 private void Setup(bool yield, RoutineBase parent)
 {
     id = nextId++;
     SetParent(parent);
     state = yield ? State.Running : State.NotStarted;
 }
Esempio n. 5
0
 /// <summary> Release routine back to pool. </summary>
 public static void Release(RoutineBase routine)
 {
     routine.Reset();
     pool.Release(routine);
 }