1
This commit is contained in:
parent
c1651a92dc
commit
7762d7974c
@ -9,7 +9,16 @@
|
|||||||
#include "btcontext.h"
|
#include "btcontext.h"
|
||||||
|
|
||||||
#define PRE_ENTER_COROUTINE() \
|
#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; \
|
behaviac::EBTStatus status; \
|
||||||
if (PreEnterCoroutine(co_id, status)) { \
|
if (PreEnterCoroutine(co_id, status)) { \
|
||||||
|
@ -6,3 +6,9 @@
|
|||||||
#include "base_agent.h"
|
#include "base_agent.h"
|
||||||
#include "btcontext.h"
|
#include "btcontext.h"
|
||||||
#include "btevent.h"
|
#include "btevent.h"
|
||||||
|
|
||||||
|
void BtCoroutine::Abort(long long frameno)
|
||||||
|
{
|
||||||
|
is_abort_ = true;
|
||||||
|
abort_frameno = frameno;
|
||||||
|
}
|
||||||
|
@ -13,6 +13,7 @@ class BtCoroutine
|
|||||||
long long sleep_end_frameno = 0;
|
long long sleep_end_frameno = 0;
|
||||||
int sleep_time = 0;
|
int sleep_time = 0;
|
||||||
list_head entry;
|
list_head entry;
|
||||||
|
long long abort_frameno = 0;
|
||||||
behaviac::EBTStatus status = behaviac::BT_RUNNING;
|
behaviac::EBTStatus status = behaviac::BT_RUNNING;
|
||||||
|
|
||||||
BtCoroutine(std::shared_ptr<BtContext> context, int id, const char* name)
|
BtCoroutine(std::shared_ptr<BtContext> context, int id, const char* name)
|
||||||
@ -26,10 +27,13 @@ class BtCoroutine
|
|||||||
const char* GetName() const { return name_; }
|
const char* GetName() const { return name_; }
|
||||||
auto GetContext() { return context_; }
|
auto GetContext() { return context_; }
|
||||||
int GetId() { return id_; }
|
int GetId() { return id_; }
|
||||||
|
bool IsAbort() { return is_abort_; }
|
||||||
|
void Abort(long long frameno);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<BtContext> context_;
|
std::shared_ptr<BtContext> context_;
|
||||||
const char* name_ = nullptr;
|
const char* name_ = nullptr;
|
||||||
int id_ = 0;
|
int id_ = 0;
|
||||||
|
bool is_abort_ = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user