This commit is contained in:
aozhiwei 2023-10-31 14:30:26 +08:00
parent 7762d7974c
commit 3f0357a46c
2 changed files with 12 additions and 3 deletions

View File

@ -76,6 +76,10 @@ bool BaseAgent::PreEnterCoroutine(int co_id, behaviac::EBTStatus& status)
return false;
}
auto& co = itr->second;
if (co->IsAbort()) {
status = behaviac::BT_FAILURE;
return true;
}
if (co->status != behaviac::BT_RUNNING) {
abort();
}
@ -174,5 +178,8 @@ int BaseAgent::DeltaTime(int time)
void BaseAgent::AbortCoroutine(int co_id)
{
auto itr = coroutines_hash_.find(co_id);
if (itr != coroutines_hash_.end()) {
itr->second->Abort(GetRoom()->GetFrameNo());
}
}

View File

@ -23,6 +23,8 @@
#include "mt/Equip.h"
#include "mt/Skill.h"
#include "behaviac_generated/types/internal/behaviac_customized_types.h"
HeroAgent::HeroAgent():BaseAgent()
{
current_target_agent = behaviac::Agent::Create<TargetAgent>();
@ -493,7 +495,7 @@ behaviac::EBTStatus HeroAgent::CoMoveMasterRaycast()
behaviac::EBTStatus HeroAgent::CoFindPath(const glm::vec3& pos)
{
PRE_ENTER_COROUTINE();
PRE_ENTER_COROUTINE_EX(kCoFindPath);
auto context = MAKE_BTCONTEXT
(
bool find_ok = false;
@ -527,7 +529,7 @@ behaviac::EBTStatus HeroAgent::CoFindPath(const glm::vec3& pos)
behaviac::EBTStatus HeroAgent::CoFindPathEx(const glm::vec3& pos, float distance)
{
PRE_ENTER_COROUTINE();
PRE_ENTER_COROUTINE_EX(kCoFindPathEx);
auto context = MAKE_BTCONTEXT
(
bool find_ok = false;