本文整理汇总了C++中BehaviorTask::GetNextStateId方法的典型用法代码示例。如果您正苦于以下问题:C++ BehaviorTask::GetNextStateId方法的具体用法?C++ BehaviorTask::GetNextStateId怎么用?C++ BehaviorTask::GetNextStateId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BehaviorTask
的用法示例。
在下文中一共展示了BehaviorTask::GetNextStateId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateFSM
EBTStatus FSMTask::UpdateFSM(Agent* pAgent, EBTStatus childStatus)
{
BEHAVIAC_ASSERT(this->m_node != 0);
BEHAVIAC_ASSERT(this->m_currentNodeId != -1);
EBTStatus status = childStatus;
bool bLoop = true;
#if !BEHAVIAC_RELEASE
const int kMaxCount = 10;
behaviac::map<int, int> state_update_count;
#endif//#if !BEHAVIAC_RELEASE
while (bLoop)
{
BehaviorTask* currentState = this->GetChildById(this->m_currentNodeId);
//BEHAVIAC_ASSERT(currentState->GetNextStateId() == -1, "m_nextStateId is not reset to -1 in onenter");
currentState->exec(pAgent);
if (StateTask::DynamicCast(currentState) != 0)
{
StateTask* pStateTask = (StateTask*)currentState;
if (pStateTask->IsEndState())
{
return BT_SUCCESS;
}
}
int nextStateId = currentState->GetNextStateId();
if (nextStateId < 0) // don't know why, the nextStateID might be -2147483648, so change the condition
{
//if not transitioned, don't go on next state, to exit
bLoop = false;
}
else
{
#if !BEHAVIAC_RELEASE
state_update_count[this->m_currentNodeId]++;
if (state_update_count[this->m_currentNodeId] > kMaxCount) {
behaviac::string treeName = GetParentTreeName(pAgent, this->GetNode());
BEHAVIAC_LOGERROR("%s might be updating an FSM('%s') endlessly, possibly a dead loop, please redesign it!", pAgent->GetName().c_str(), treeName.c_str());
BEHAVIAC_ASSERT(false);
}
#endif
//if transitioned, go on next state
this->m_currentNodeId = nextStateId;
}
}
return status;
}