public void Execute() { if (this.plan.Count > 0 && this.agent != null) { if (this.plan.Peek().IsComplete(agent)) { agent.OnCommandCompleted(this.agent.blackboard.worldState.ApplyAction(this.plan.Peek()).stateVariables, this.plan.Peek().actionType); this.plan.Pop(); } else { this.plan.Peek().Continue(agent); } } }