From 3f0357a46c7475cbbdd9ec2c26b521c7edaa396a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 31 Oct 2023 14:30:26 +0800 Subject: [PATCH] 1 --- server/gameserver/base_agent.cc | 9 ++++++++- server/gameserver/hero_agent.cc | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/server/gameserver/base_agent.cc b/server/gameserver/base_agent.cc index 3bc2976c..4eddfdd4 100644 --- a/server/gameserver/base_agent.cc +++ b/server/gameserver/base_agent.cc @@ -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()); + } } diff --git a/server/gameserver/hero_agent.cc b/server/gameserver/hero_agent.cc index 7efb9151..fff4fbfa 100644 --- a/server/gameserver/hero_agent.cc +++ b/server/gameserver/hero_agent.cc @@ -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(); @@ -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;