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(); }
public override void OnBehaviorEnded(Behavior behavior, Behavior.Status status) { stack.RemoveLast(); //Trace.Script($"Removing {behavior}"); if (stack.Empty()) { this.OnReset(); } }
/// <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); }
public abstract void OnBehaviorEnded(Behavior behavior, Behavior.Status status);
/// <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; }
/// <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); }