Exemplo n.º 1
0
        /// <summary>
        /// Starts the child corresponding to the <see cref="CurrentChildIndex"/>.
        /// </summary>
        private void StartCurrentChild()
        {
            //Get the current child and subscribe to it's termination event.
            IBehavior currentChild = Children[CurrentChildIndex];

            currentChild.Terminated += OnCurrentChildTerminated;

            //Start.
            currentChild.StartBehaviour();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Called when the <paramref name="child"/> is terminated.
 /// </summary>
 /// <param name="child">The child.</param>
 /// <param name="status">The status that the <paramref name="child"/> terminated with.</param>
 protected override void OnChildTerminated(IBehavior child, Status status)
 {
     if (status == _repeatStatus)
     {
         child.StartBehaviour();
     }
     else
     {
         Terminate(status);
     }
 }
Exemplo n.º 3
0
        /// <inheritdoc />
        protected override void Initialize()
        {
            base.Initialize();

            // Initialize the collections of children.
            _activeChildren = new LinkedList <IBehavior>(Children);
            _successfulChildren.Clear();
            _failedChildren.Clear();

            //Start each child behaviour.
            for (int index = Children.Count - 1; index >= 0; index--)
            {
                IBehavior child = Children[index];
                child.Terminated += OnChildTerminated;
                child.StartBehaviour();
            }

            //Suspend.
            Suspend();
        }