Fix bt::conditional node: proper assert handling & child nodes starting
This commit is contained in:
parent
6d4abb7c03
commit
89cbbaeeef
1 changed files with 25 additions and 14 deletions
|
|
@ -34,6 +34,8 @@ namespace psemek::bt
|
|||
}
|
||||
|
||||
status update(Time dt, Args ... args) override
|
||||
{
|
||||
try
|
||||
{
|
||||
if (condition_result_)
|
||||
{
|
||||
|
|
@ -49,12 +51,21 @@ namespace psemek::bt
|
|||
if (auto finished = std::get_if<typename node_type::finished>(&result))
|
||||
{
|
||||
condition_result_ = finished->result;
|
||||
if (*condition_result_)
|
||||
true_branch_->start(args...);
|
||||
else
|
||||
false_branch_->start(args...);
|
||||
return running{};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
catch (assertion_failed_exception const &)
|
||||
{
|
||||
return finished{false};
|
||||
}
|
||||
}
|
||||
|
||||
bool event(Event const & event, Args ... args) override
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue