File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,9 @@ NodeStatus WhileDoElseNode::tick()
2929{
3030 const size_t children_count = children_nodes_.size ();
3131
32- if (children_count != 3 )
32+ if (children_count != 2 && children_count != 3 )
3333 {
34- throw std::logic_error (" WhileDoElse must have 3 children" );
34+ throw std::logic_error (" WhileDoElseNode must have either 2 or 3 children" );
3535 }
3636
3737 setStatus (NodeStatus::RUNNING);
@@ -47,13 +47,23 @@ NodeStatus WhileDoElseNode::tick()
4747
4848 if (condition_status == NodeStatus::SUCCESS)
4949 {
50- haltChild (2 );
50+ if (children_count == 3 )
51+ {
52+ haltChild (2 );
53+ }
5154 status = children_nodes_[1 ]->executeTick ();
5255 }
5356 else if (condition_status == NodeStatus::FAILURE)
5457 {
55- haltChild (1 );
56- status = children_nodes_[2 ]->executeTick ();
58+ if (children_count == 3 )
59+ {
60+ haltChild (1 );
61+ status = children_nodes_[2 ]->executeTick ();
62+ }
63+ else if (children_count == 2 )
64+ {
65+ status = NodeStatus::FAILURE;
66+ }
5767 }
5868
5969 if (status == NodeStatus::RUNNING)
You can’t perform that action at this time.
0 commit comments