bool BehaviorTask::onenter_action(Agent* pAgent) { this->m_node->InstantiatePars(pAgent); bool bResult = this->CheckPreconditions(pAgent, false); if (bResult) { bResult = this->onenter(pAgent); if (!bResult) { return false; } else { #if !BEHAVIAC_RELEASE //BEHAVIAC_PROFILE_DEBUGBLOCK("Debug", true); CHECK_BREAKPOINT(pAgent, this->m_node, "enter", bResult ? EAR_success : EAR_failure); #endif } } return bResult; }
bool State::UpdateTransitions(Agent* pAgent, const BehaviorNode* node, const behaviac::vector<Transition*>* transitions, int& nextStateId, EBTStatus result) { BEHAVIAC_UNUSED_VAR(node); bool bTransitioned = false; if (transitions && transitions->size() > 0) { for (uint32_t i = 0; i < transitions->size(); ++i) { Transition* transition = (*transitions)[i]; if (transition->Evaluate(pAgent, result)) { nextStateId = transition->GetTargetStateId(); BEHAVIAC_ASSERT(nextStateId != -1); //transition actions transition->ApplyEffects(pAgent, Effector::E_BOTH); #if !BEHAVIAC_RELEASE if (Config::IsLoggingOrSocketing()) { CHECK_BREAKPOINT(pAgent, node, "transition", EAR_none); } #endif bTransitioned = true; break; } } } return bTransitioned; }
void BehaviorTask::onexit_action(Agent* pAgent, EBTStatus status) { this->onexit(pAgent, status); if (this->m_node != 0) { Effector::EPhase phase = Effector::E_SUCCESS; if (status == BT_FAILURE) { phase = Effector::E_FAILURE; } else { BEHAVIAC_ASSERT(status == BT_SUCCESS); } this->m_node->ApplyEffects(pAgent, (BehaviorNode::EPhase)phase); this->m_node->UnInstantiatePars(pAgent); } #if !BEHAVIAC_RELEASE if (Config::IsLoggingOrSocketing()) { //BEHAVIAC_PROFILE_DEBUGBLOCK("Debug", true); if (status == BT_SUCCESS) { CHECK_BREAKPOINT(pAgent, this->m_node, "exit", EAR_success); } else { CHECK_BREAKPOINT(pAgent, this->m_node, "exit", EAR_failure); } } #endif }