1
This commit is contained in:
parent
ede5a65bfd
commit
f032cedb82
@ -24,7 +24,16 @@ bool BaseAgent::IsGameOver()
|
||||
|
||||
void BaseAgent::Exec()
|
||||
{
|
||||
last_exec_status_ = f8::BtMgr::Instance()->BtExec(this);
|
||||
behaviac::EBTStatus status = f8::BtMgr::Instance()->BtExec(this);
|
||||
if (status == behaviac::BT_RUNNING && event_cb_) {
|
||||
bool has_event = false;
|
||||
event_cb_(has_event);
|
||||
if (has_event) {
|
||||
status_= behaviac::BT_INVALID;
|
||||
runing_cb_ = nullptr;
|
||||
event_cb_(has_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseAgent::HasTarget(float range)
|
||||
@ -38,7 +47,7 @@ behaviac::EBTStatus BaseAgent::DoRunningCb()
|
||||
if (status_ != behaviac::BT_RUNNING) {
|
||||
abort();
|
||||
}
|
||||
status_ = status_runing_cb_();
|
||||
status_ = runing_cb_();
|
||||
#ifdef DEBUG
|
||||
if ((GetOwner()->room->GetFrameNo() - status_frameno_) % SERVER_FRAME_RATE == 0 ||
|
||||
last_status_ != status_) {
|
||||
@ -47,7 +56,7 @@ behaviac::EBTStatus BaseAgent::DoRunningCb()
|
||||
}
|
||||
#endif
|
||||
if (status_ != behaviac::BT_RUNNING) {
|
||||
status_runing_cb_ = nullptr;
|
||||
runing_cb_ = nullptr;
|
||||
}
|
||||
return status_;
|
||||
}
|
||||
@ -60,7 +69,7 @@ behaviac::EBTStatus BaseAgent::StartCoroutine(std::function<behaviac::EBTStatus(
|
||||
status_frameno_ = GetOwner()->room->GetFrameNo();
|
||||
status_name_ = name;
|
||||
#endif
|
||||
status_runing_cb_ = std::move(cb);
|
||||
runing_cb_ = std::move(cb);
|
||||
status_ = behaviac::BT_RUNNING;
|
||||
return status_;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ public:
|
||||
BEHAVIAC_DECLARE_AGENTTYPE(BaseAgent, behaviac::Agent)
|
||||
|
||||
void Exec();
|
||||
behaviac::EBTStatus GetLastExecStatus() { return last_exec_status_; };
|
||||
|
||||
bool IsGameOver();
|
||||
bool HasTarget(float range);
|
||||
@ -36,9 +35,9 @@ protected:
|
||||
long long status_frameno_ = 0;
|
||||
const char* status_name_ = nullptr;
|
||||
#endif
|
||||
behaviac::EBTStatus last_exec_status_ = behaviac::BT_INVALID;
|
||||
behaviac::EBTStatus status_= behaviac::BT_SUCCESS;
|
||||
std::function<behaviac::EBTStatus()> status_runing_cb_;
|
||||
std::function<behaviac::EBTStatus()> runing_cb_;
|
||||
std::function<bool(bool&)> event_cb_;
|
||||
|
||||
private:
|
||||
Creature* owner_ = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user