Exemplo n.º 1
0
 public override void OnBehaviorEnded(Behavior behavior, Behavior.Status status)
 {
     // Modify the current world state due to the previous action
     // We already have a reference to the current action so
     // don't really use the behavior here (it wouldn't know its
     // part of a stateful action anyway)
     this.state.Merge(currentAction.effects);
     ContinuePlan();
 }
Exemplo n.º 2
0
 public override void OnBehaviorEnded(Behavior behavior, Behavior.Status status)
 {
     stack.RemoveLast();
     //Trace.Script($"Removing {behavior}");
     if (stack.Empty())
     {
         this.OnReset();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Update the next active behavior.
        /// </summary>
        /// <returns></returns>
        public bool Step()
        {
            IBehavior current = _activeBehaviors.GrabFirst();

            if (current == null)
            {
                return(false);
            }

            Behavior.Status result = current.Tick();

            if (result == Behavior.Status.Running)
            {
                _activeBehaviors.AddLast(current);
            }

            return(true);
        }
Exemplo n.º 4
0
 public abstract void OnBehaviorEnded(Behavior behavior, Behavior.Status status);
Exemplo n.º 5
0
 /// <summary>
 /// Called when a suspended <see cref="IBehavior"/> has terminated.
 /// Removes it from <see cref="_suspendedBehaviors"/>.
 /// </summary>
 /// <param name="behavior">The suspended behavior that has been terminated.</param>
 /// <param name="status">The status the <paramref name="behavior"/> has terminated with.</param>
 private void OnSuspendedBehaviourTerminated(IBehavior behavior, Behavior.Status status)
 {
     _suspendedBehaviors.Remove(behavior);
     behavior.Terminated -= OnSuspendedBehaviourTerminated;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Stop the <paramref name="behavior"/>.
 /// </summary>
 /// <param name="behavior">The <see cref="IBehavior"/> we want to stop.</param>
 /// <param name="status">The status to stop the behavior with.</param>
 public void StopBehaviour(IBehavior behavior, Behavior.Status status)
 {
     behavior.Terminate(status);
     _activeBehaviors.Remove(behavior);
 }