This commit is contained in:
aozhiwei 2023-06-23 19:37:25 +08:00
parent 53d0553d40
commit 07e56b7e59
4 changed files with 17 additions and 11 deletions

View File

@ -109,7 +109,7 @@ behaviac::EBTStatus BaseAgent::StartCoroutine(std::shared_ptr<BtCoroutine> corou
#ifdef DEBUG
last_status_ = behaviac::BT_INVALID;
status_frameno_ = GetOwner()->room->GetFrameNo();
status_name_ = coroutine_->name;
status_name_ = coroutine_->GetName();
#endif
status_ = behaviac::BT_RUNNING;
return status_;

View File

@ -27,7 +27,7 @@ namespace a8
}
}
struct BtCoroutine;
class BtCoroutine;
class Creature;
class BaseAgent : public behaviac::Agent
{

View File

@ -9,8 +9,8 @@
bool BtCoroutine::HasEvent()
{
if (!context->events.empty()) {
auto event = context->events.at(context->events.size() - 1);
if (!context_->events.empty()) {
auto event = context_->events.at(context_->events.size() - 1);
return event->HasEvent();
}
return false;
@ -18,8 +18,8 @@ bool BtCoroutine::HasEvent()
void BtCoroutine::FireEvent(BaseAgent* agent)
{
if (!context->events.empty()) {
auto event = context->events.at(context->events.size() - 1);
if (!context_->events.empty()) {
auto event = context_->events.at(context_->events.size() - 1);
if (event->HasEvent()) {
event->FireEvent(agent);
}

View File

@ -5,20 +5,26 @@
struct BtContext;
class BaseAgent;
struct BtCoroutine
class BtCoroutine
{
std::shared_ptr<BtContext> context;
const char* name = nullptr;
public:
std::function<behaviac::EBTStatus()> runing_cb;
long long sleep_end_frameno = 0;
int sleep_time = 0;
BtCoroutine(std::shared_ptr<BtContext> context, const char* name)
{
this->context = context;
this->name = name;
this->context_ = context;
this->name_ = name;
}
bool HasEvent();
void FireEvent(BaseAgent* agent);
const char* GetName() const { return name_; }
private:
std::shared_ptr<BtContext> context_;
const char* name_ = nullptr;
};