本文整理汇总了C++中BranchTask::SetCurrentTask方法的典型用法代码示例。如果您正苦于以下问题:C++ BranchTask::SetCurrentTask方法的具体用法?C++ BranchTask::SetCurrentTask怎么用?C++ BranchTask::SetCurrentTask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BranchTask
的用法示例。
在下文中一共展示了BranchTask::SetCurrentTask方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
EBTStatus BehaviorTask::exec(Agent* pAgent, EBTStatus childStatus)
{
#if BEHAVIAC_ENABLE_PROFILING
#if 1
const char* classStr = (this->m_node ? this->m_node->GetClassNameString().c_str() : "BT");
int nodeId = (this->m_node ? this->m_node->GetId() : -1);
behaviac::string taskClassid = FormatString("%s[%i]", classStr, nodeId);
AutoProfileBlockSend profiler_block(Profiler::GetInstance(), taskClassid, pAgent);
#else
const char* classStr = (this->m_node ? this->m_node->GetClassNameString().c_str() : "BT");
BEHAVIAC_PROFILE(classStr);
#endif
#endif//#if BEHAVIAC_ENABLE_PROFILING
BEHAVIAC_ASSERT(!this->m_node || this->m_node->IsValid(pAgent, this),
FormatString("Agent In BT:%s while the Agent used for: %s", this->m_node->m_agentType.c_str(), pAgent->GetClassTypeName()));
bool bEnterResult = false;
if (this->m_status == BT_RUNNING)
{
bEnterResult = true;
}
else
{
//reset it to invalid when it was success/failure
this->m_status = BT_INVALID;
bEnterResult = this->onenter_action(pAgent);
}
if (bEnterResult)
{
#if !BEHAVIAC_RELEASE
if (Config::IsLoggingOrSocketing())
{
string btStr = BehaviorTask::GetTickInfo(pAgent, this, "update");
//empty btStr is for internal BehaviorTreeTask
if (!StringUtils::IsNullOrEmpty(btStr.c_str()))
{
LogManager::GetInstance()->Log(pAgent, btStr.c_str(), EAR_none, ELM_tick);
}
}
#endif
bool bValid = true;
int _tempPrecndCount = this->m_node != 0 ? this->m_node->PreconditionsCount() : 0;
if (_tempPrecndCount > 0)
{
bValid = this->m_node->CheckPreconditions(pAgent, true);
}
if (bValid)
{
this->m_status = this->update_current(pAgent, childStatus);
}
else
{
this->m_status = BT_FAILURE;
}
if (this->m_status != BT_RUNNING)
{
//clear it
this->onexit_action(pAgent, this->m_status);
//this node is possibly ticked by its parent or by the topBranch who records it as currrent node
//so, we can't here reset the topBranch's current node
}
else
{
BranchTask* tree = this->GetTopManageBranchTask();
if (tree != 0)
{
tree->SetCurrentTask(this);
}
}
}
else
{
this->m_status = BT_FAILURE;
}
return this->m_status;
}