当前位置: 首页>>代码示例>>C++>>正文


C++ BranchTask::SetCurrentTask方法代码示例

本文整理汇总了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;
    }
开发者ID:xfw5,项目名称:behaviac,代码行数:94,代码来源:behaviortree_task.cpp


注:本文中的BranchTask::SetCurrentTask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。