本文整理汇总了C++中BehaviorTask::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ BehaviorTask::reset方法的具体用法?C++ BehaviorTask::reset怎么用?C++ BehaviorTask::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BehaviorTask
的用法示例。
在下文中一共展示了BehaviorTask::reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
EBTStatus SelectorLoopTask::update(Agent* pAgent, EBTStatus childStatus)
{
BEHAVIAC_UNUSED_VAR(pAgent);
BEHAVIAC_UNUSED_VAR(childStatus);
//checking the preconditions and take the first action tree
uint32_t index = (uint32_t)-1;
for (uint32_t i = 0; i < this->m_children.size(); ++i)
{
WithPreconditionTask* pSubTree = (WithPreconditionTask*)this->m_children[i];
BEHAVIAC_ASSERT(WithPreconditionTask::DynamicCast(pSubTree));
BehaviorTask* pPrecondTree = pSubTree->PreconditionNode();
EBTStatus status = pPrecondTree->exec(pAgent);
if (status == BT_SUCCESS)
{
index = i;
break;
}
}
//clean up the current ticking action tree
if (index != (uint32_t)-1)
{
if (this->m_activeChildIndex != CompositeTask::InvalidChildIndex)
{
WithPreconditionTask* pCurrentSubTree = (WithPreconditionTask*)this->m_children[this->m_activeChildIndex];
BEHAVIAC_ASSERT(WithPreconditionTask::DynamicCast(pCurrentSubTree));
BehaviorTask* pCurrentActionTree = pCurrentSubTree->Action();
WithPreconditionTask* pSubTree = (WithPreconditionTask*)this->m_children[index];
BEHAVIAC_ASSERT(WithPreconditionTask::DynamicCast(pSubTree));
BehaviorTask* pActionTree = pSubTree->Action();
if (pCurrentActionTree != pActionTree)
{
pCurrentActionTree->abort(pAgent);
pCurrentSubTree->abort(pAgent);
this->m_activeChildIndex = index;
}
}
for (uint32_t i = 0; i < this->m_children.size(); ++i)
{
WithPreconditionTask* pSubTree = (WithPreconditionTask*)this->m_children[i];
BEHAVIAC_ASSERT(WithPreconditionTask::DynamicCast(pSubTree));
//dummy ticking so that the designer knows it is updating
EBTStatus statusDummy = pSubTree->exec(pAgent);
BEHAVIAC_ASSERT(statusDummy == BT_RUNNING);
BEHAVIAC_UNUSED_VAR(statusDummy);
//when i < index, the precondition is failure, so to continue
if (i < index)
{
continue;
}
if (i > index)
{
BehaviorTask* pPreconditionTree = pSubTree->PreconditionNode();
EBTStatus status = pPreconditionTree->exec(pAgent);
//to search for the first one whose precondition is success
if (status != BT_SUCCESS)
{
continue;
}
}
BehaviorTask* pActionTree = pSubTree->Action();
EBTStatus status = pActionTree->exec(pAgent);
if (status == BT_RUNNING)
{
this->m_activeChildIndex = index;
}
else
{
pActionTree->reset(pAgent);
if (status == BT_FAILURE || status == BT_INVALID)
{
//THE ACTION failed, to try the next one
continue;
}
}
BEHAVIAC_ASSERT(status == BT_RUNNING || status == BT_SUCCESS);
return status;
}
//.........这里部分代码省略.........