This commit is contained in:
aozhiwei 2023-10-31 14:22:44 +08:00
parent c1651a92dc
commit 7762d7974c
3 changed files with 20 additions and 1 deletions

View File

@ -9,7 +9,16 @@
#include "btcontext.h"
#define PRE_ENTER_COROUTINE() \
const int co_id = __LINE__; \
const int co_id = 1000 + __LINE__; \
{ \
behaviac::EBTStatus status; \
if (PreEnterCoroutine(co_id, status)) { \
return status; \
} \
}
#define PRE_ENTER_COROUTINE_EX(ID) \
const int co_id = ID; \
{ \
behaviac::EBTStatus status; \
if (PreEnterCoroutine(co_id, status)) { \

View File

@ -6,3 +6,9 @@
#include "base_agent.h"
#include "btcontext.h"
#include "btevent.h"
void BtCoroutine::Abort(long long frameno)
{
is_abort_ = true;
abort_frameno = frameno;
}

View File

@ -13,6 +13,7 @@ class BtCoroutine
long long sleep_end_frameno = 0;
int sleep_time = 0;
list_head entry;
long long abort_frameno = 0;
behaviac::EBTStatus status = behaviac::BT_RUNNING;
BtCoroutine(std::shared_ptr<BtContext> context, int id, const char* name)
@ -26,10 +27,13 @@ class BtCoroutine
const char* GetName() const { return name_; }
auto GetContext() { return context_; }
int GetId() { return id_; }
bool IsAbort() { return is_abort_; }
void Abort(long long frameno);
private:
std::shared_ptr<BtContext> context_;
const char* name_ = nullptr;
int id_ = 0;
bool is_abort_ = false;
};