This commit is contained in:
aozhiwei 2022-12-07 11:35:33 +08:00
parent a1a027b0c8
commit 9d2738630c
4 changed files with 21 additions and 10 deletions

View File

@ -104,11 +104,7 @@ void Android::InternalUpdate(int delta_time)
#endif
Global::Instance()->verify_set_pos = 0;
}
behaviac::EBTStatus status = f8::BtMgr::Instance()->BtExec(agent_);
#ifdef DEBUG
{
}
#endif
f8::BtMgr::Instance()->BtExec(agent_);
}
void Android::GiveEquip()

View File

@ -21,7 +21,7 @@ State_e AndroidAgent::GetState()
behaviac::EBTStatus AndroidAgent::DoIdle(int min_time, int max_time)
{
if (status_ == behaviac::BT_RUNNING) {
return status_runing_cb_();
return DoRunningCb();
}
int idle_time = a8::RandEx(min_time, max_time);
xtimer_list* timer = GetOwner()->room->xtimer.AddDeadLineTimerAndAttach
@ -50,7 +50,7 @@ behaviac::EBTStatus AndroidAgent::DoIdle(int min_time, int max_time)
behaviac::EBTStatus AndroidAgent::DoRandomWalk()
{
if (status_ == behaviac::BT_RUNNING) {
return status_runing_cb_();
return DoRunningCb();
}
a8::Vec2 dir = GetOwner()->GetMoveDir();
@ -113,7 +113,7 @@ behaviac::EBTStatus AndroidAgent::DoRandomShot()
behaviac::EBTStatus AndroidAgent::DoAttack()
{
if (status_ == behaviac::BT_RUNNING) {
return status_runing_cb_();
return DoRunningCb();
}
Human* enemy = GetOwner()->room->FindEnemy(GetOwner()->AsHuman());
if (!enemy) {
@ -152,7 +152,7 @@ behaviac::EBTStatus AndroidAgent::DoAttack()
behaviac::EBTStatus AndroidAgent::DoPursuit()
{
if (status_ == behaviac::BT_RUNNING) {
return status_runing_cb_();
return DoRunningCb();
}
Human* enemy = GetOwner()->room->FindEnemy(GetOwner()->AsHuman());
if (!enemy) {

View File

@ -17,3 +17,15 @@ bool BaseAgent::IsGameOver()
{
return GetOwner()->room->IsGameOver();
}
behaviac::EBTStatus BaseAgent::DoRunningCb()
{
if (status_ != behaviac::BT_RUNNING) {
abort();
}
status_ = status_runing_cb_();
if (status_ != behaviac::BT_RUNNING) {
status_runing_cb_ = nullptr;
}
return status_;
}

View File

@ -15,10 +15,13 @@ public:
bool IsGameOver();
public:
public:
void SetOwner(Creature* owner) { owner_ = owner; };
Creature* GetOwner() { return owner_; };
protected:
behaviac::EBTStatus DoRunningCb();
protected:
behaviac::EBTStatus status_= behaviac::BT_SUCCESS;
std::function<behaviac::EBTStatus()> status_runing_cb_;