EBTStatus PlannerTaskReference::update(Agent* pAgent, EBTStatus childStatus) { BEHAVIAC_UNUSED_VAR(childStatus); BEHAVIAC_ASSERT(ReferencedBehavior::DynamicCast(this->m_node) != 0); //BEHAVIAC_ASSERT(this->m_node is ReferencedBehavior); ReferencedBehavior* pNode = (ReferencedBehavior*)this->m_node; //ReferencedBehavior pNode = this->m_node as ReferencedBehavior; BEHAVIAC_ASSERT(pNode != NULL); EBTStatus status = BT_RUNNING; //pNode->SetTaskParams(pAgent); if (pNode->RootTaskNode() == NULL) { status = this->m_subTree->exec(pAgent); } else { #if !BEHAVIAC_RELEASE if (!_logged) { pAgent->LogJumpTree(pNode->GetReferencedTree()); _logged = true; } #endif BEHAVIAC_ASSERT(this->m_children.size() == 1); BehaviorTask* c = this->m_children[0]; status = c->exec(pAgent); } return status; }
bool PlannerTaskReference::onenter(Agent* pAgent) { BEHAVIAC_UNUSED_VAR(pAgent); BEHAVIAC_ASSERT(ReferencedBehavior::DynamicCast(this->m_node) != 0); ReferencedBehavior* pNode = (ReferencedBehavior*)this->m_node; BEHAVIAC_UNUSED_VAR(pNode); BEHAVIAC_ASSERT(pNode != NULL); #if !BEHAVIAC_RELEASE _logged = false; #endif pNode->SetTaskParams(pAgent); this->m_subTree = Workspace::GetInstance()->CreateBehaviorTreeTask(pNode->GetReferencedTree()); return true; }
void PlannerTaskReference::onexit(Agent* pAgent, EBTStatus status) { BEHAVIAC_UNUSED_VAR(pAgent); BEHAVIAC_UNUSED_VAR(status); BEHAVIAC_ASSERT(ReferencedBehavior::DynamicCast(this->m_node) != 0); ReferencedBehavior* pNode = (ReferencedBehavior*)this->m_node; BEHAVIAC_UNUSED_VAR(pNode); BEHAVIAC_ASSERT(pNode != NULL); this->m_subTree = 0; #if !BEHAVIAC_RELEASE pAgent->LogReturnTree(pNode->GetReferencedTree()); #endif BEHAVIAC_ASSERT(this->currentState != NULL); this->currentState->Pop(); this->currentState = 0; }