1
This commit is contained in:
parent
e56e22232b
commit
4cd9e474f2
@ -333,20 +333,14 @@ behaviac::EBTStatus HeroAgent::CoIdle(int min_val, int max_val)
|
||||
}
|
||||
auto context = MAKE_BTCONTEXT
|
||||
(
|
||||
a8::XTimerWp timer_ptr;
|
||||
int time = 0;
|
||||
);
|
||||
context->timer_ptr = owner_->room->xtimer.SetTimeoutWpEx
|
||||
(
|
||||
a8::RandEx(min_val, max_val) / FRAME_RATE_MS,
|
||||
[] (int event, const a8::Args* args)
|
||||
{
|
||||
},
|
||||
&owner_->xtimer_attacher);
|
||||
context->time = a8::RandEx(min_val, max_val);
|
||||
auto co = std::make_shared<BtCoroutine>(context, "CoIdle");
|
||||
co->runing_cb =
|
||||
[this, context] ()
|
||||
{
|
||||
if (!context->timer_ptr.expired()) {
|
||||
if (GetRoom()->GetFrameNo() - context->frameno < context->time) {
|
||||
return behaviac::BT_RUNNING;
|
||||
} else {
|
||||
return behaviac::BT_SUCCESS;
|
||||
|
@ -9,10 +9,12 @@ class Context : public BtContext \
|
||||
{public: \
|
||||
__VA_ARGS__; \
|
||||
std::function<void()> _destory_cb; \
|
||||
long long frameno = 0; \
|
||||
~Context() { if (_destory_cb) { _destory_cb(); };}; \
|
||||
}; \
|
||||
auto context = std::make_shared<Context>(); \
|
||||
context->SetOwner(owner); \
|
||||
context->frameno = owner.Get()->room->GetFrameNo(); \
|
||||
return context; \
|
||||
}(owner_->GetWeakPtrRef(), this)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user