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


C++ BranchTask类代码示例

本文整理汇总了C++中BranchTask的典型用法代码示例。如果您正苦于以下问题:C++ BranchTask类的具体用法?C++ BranchTask怎么用?C++ BranchTask使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BranchTask类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BEHAVIAC_ASSERT

    bool BranchTask::oneventCurrentNode(Agent* pAgent, const char* eventName)
    {
        BEHAVIAC_ASSERT(this->m_currentTask);

        EBTStatus s = this->m_currentTask->GetStatus();
        BEHAVIAC_UNUSED_VAR(s);

        BEHAVIAC_ASSERT(s == BT_RUNNING && this->m_node->HasEvents());

        bool bGoOn = this->m_currentTask->onevent(pAgent, eventName);

        //give the handling back to parents
        if (bGoOn)
        {
            BranchTask* parentBranch = this->m_currentTask->GetParent();

            //back track the parents until the branch
            while (parentBranch && parentBranch != this)
            {
                BEHAVIAC_ASSERT(parentBranch->GetStatus() == BT_RUNNING);

                bGoOn = parentBranch->onevent(pAgent, eventName);

                if (!bGoOn)
                {
                    return false;
                }

                parentBranch = parentBranch->GetParent();
            }
        }

        return bGoOn;
    }
开发者ID:xfw5,项目名称:behaviac,代码行数:34,代码来源:behaviortree_task.cpp

示例2: CheckParentUpdatePreconditions

	bool BehaviorTask::CheckParentUpdatePreconditions(Agent* pAgent)
	{
		bool bValid = true;

		if (this->m_bHasManagingParent)
		{
			bool bHasManagingParent = false;
			const int kMaxParentsCount = 512;
			int parentsCount = 0;
			BehaviorTask* parents[kMaxParentsCount];

			BranchTask* parentBranch = this->GetParent();

			parents[parentsCount++] = this;

			//back track the parents until the managing branch
			while (parentBranch != 0)
			{
				BEHAVIAC_ASSERT(parentsCount < kMaxParentsCount, "weird tree!");

				parents[parentsCount++] = parentBranch;

				if (parentBranch->GetCurrentTask() == this)
				{
					//BEHAVIAC_ASSERT(parentBranch->GetNode()->IsManagingChildrenAsSubTrees());

					bHasManagingParent = true;
					break;
				}

				parentBranch = parentBranch->GetParent();
			}

			if (bHasManagingParent)
			{
				for (int i = parentsCount - 1; i >= 0; --i)
				{
					BehaviorTask* pb = parents[i];

					bValid = pb->CheckPreconditions(pAgent, true);

					if (!bValid)
					{
						break;
					}
				}
			}
		}
		else
		{
			bValid = this->CheckPreconditions(pAgent, true);
		}

		return bValid;
	}
开发者ID:haolly,项目名称:behaviac,代码行数:55,代码来源:behaviortree_task.cpp

示例3: while

    BranchTask* BehaviorTask::GetParentBranch()
    {
        BehaviorTask* pTopNode = this->m_parent;

        while (pTopNode)
        {
            BranchTask* pBranch = BranchTask::DynamicCast(pTopNode);

            if (pBranch && pBranch->isContinueTicking())
            {
                return pBranch;
            }

            pTopNode = pTopNode->m_parent;
        }

        return 0;
    }
开发者ID:xfw5,项目名称:behaviac,代码行数:18,代码来源:behaviortree_task.cpp

示例4: FormatString

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