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()
29
29
{
30
30
const size_t children_count = children_nodes_.size ();
31
31
32
- if (children_count != 3 )
32
+ if (children_count != 2 && children_count != 3 )
33
33
{
34
- throw std::logic_error (" WhileDoElse must have 3 children" );
34
+ throw std::logic_error (" WhileDoElseNode must have either 2 or 3 children" );
35
35
}
36
36
37
37
setStatus (NodeStatus::RUNNING);
@@ -47,13 +47,23 @@ NodeStatus WhileDoElseNode::tick()
47
47
48
48
if (condition_status == NodeStatus::SUCCESS)
49
49
{
50
- haltChild (2 );
50
+ if (children_count == 3 )
51
+ {
52
+ haltChild (2 );
53
+ }
51
54
status = children_nodes_[1 ]->executeTick ();
52
55
}
53
56
else if (condition_status == NodeStatus::FAILURE)
54
57
{
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
+ }
57
67
}
58
68
59
69
if (status == NodeStatus::RUNNING)
You can’t perform that action at this time.
0 commit comments