This commit is contained in:
aozhiwei 2023-04-05 14:27:48 +08:00
parent fa5bee011c
commit f936461640
3 changed files with 4 additions and 11 deletions

View File

@ -75,9 +75,6 @@ behaviac::EBTStatus AndroidAgent::DoRandomWalk()
[this, context] () [this, context] ()
{ {
if (GetOwner()->GetMovement()->GetPathSize() <= 0) { if (GetOwner()->GetMovement()->GetPathSize() <= 0) {
if (!context->handler.expired()) {
GetOwner()->GetTrigger()->RemoveEventHandler(context->handler);
}
return behaviac::BT_SUCCESS; return behaviac::BT_SUCCESS;
} else { } else {
return behaviac::BT_RUNNING; return behaviac::BT_RUNNING;
@ -123,6 +120,7 @@ behaviac::EBTStatus AndroidAgent::DoRandomShot()
); );
context->owner = GetOwner()->GetWeakPtrRef(); context->owner = GetOwner()->GetWeakPtrRef();
context->last_frameno = GetOwenr()->room->GetFrameNo();
context->handler = GetOwner()->GetTrigger()->AddListener context->handler = GetOwner()->GetTrigger()->AddListener
( (
kAttacked, kAttacked,
@ -200,7 +198,7 @@ behaviac::EBTStatus AndroidAgent::DoAttack()
context->owner = GetOwner()->GetWeakPtrRef(); context->owner = GetOwner()->GetWeakPtrRef();
context->last_frameno = GetOwner()->room->GetFrameNo(); context->last_frameno = GetOwner()->room->GetFrameNo();
auto co = std::make_shared<BtCoroutine>(context, "CoAttack"); auto co = std::make_shared<BtCoroutine>(context, "CoAttack");
co->runing_cb = co->runing_cb =
[this, context] () [this, context] ()
{ {
@ -248,6 +246,7 @@ behaviac::EBTStatus AndroidAgent::DoPursuit()
context->target = enemy->GetWeakPtrRef(); context->target = enemy->GetWeakPtrRef();
context->last_frameno = GetOwner()->room->GetFrameNo(); context->last_frameno = GetOwner()->room->GetFrameNo();
context->last_pursuit_frameno = GetOwner()->room->GetFrameNo(); context->last_pursuit_frameno = GetOwner()->room->GetFrameNo();
#if 0
context->handler = GetOwner()->GetTrigger()->AddListener context->handler = GetOwner()->GetTrigger()->AddListener
( (
kAttacked, kAttacked,
@ -268,6 +267,7 @@ behaviac::EBTStatus AndroidAgent::DoPursuit()
context->owner.Get()->GetTrigger()->RemoveEventHandler(context->handler); context->owner.Get()->GetTrigger()->RemoveEventHandler(context->handler);
} }
}); });
#endif
auto co = std::make_shared<BtCoroutine>(context, "CoPursuit"); auto co = std::make_shared<BtCoroutine>(context, "CoPursuit");
co->runing_cb = co->runing_cb =

View File

@ -22,11 +22,6 @@ HeroAgent::~HeroAgent()
{ {
} }
State_e HeroAgent::GetState()
{
return kPreBattle;
}
behaviac::EBTStatus HeroAgent::DoRandomWalk() behaviac::EBTStatus HeroAgent::DoRandomWalk()
{ {
if (status_ == behaviac::BT_RUNNING) { if (status_ == behaviac::BT_RUNNING) {

View File

@ -12,8 +12,6 @@ public:
BEHAVIAC_DECLARE_AGENTTYPE(HeroAgent, BaseAgent) BEHAVIAC_DECLARE_AGENTTYPE(HeroAgent, BaseAgent)
State_e GetState();
behaviac::EBTStatus DoRandomWalk(); behaviac::EBTStatus DoRandomWalk();
behaviac::EBTStatus DoRandomShot(); behaviac::EBTStatus DoRandomShot();
behaviac::EBTStatus DoAttack(); behaviac::EBTStatus DoAttack();