This commit is contained in:
aozhiwei 2023-10-14 15:26:46 +08:00
parent 5bcc347518
commit 35fc38d388

View File

@ -344,37 +344,205 @@ behaviac::EBTStatus HeroAgent::CoIdle(int min_val, int max_val)
behaviac::EBTStatus HeroAgent::CoMoveCurrentTargetRaycast()
{
abort();
if (status_ == behaviac::BT_RUNNING) {
return DoRunningCb();
}
auto context = MAKE_BTCONTEXT
(
a8::XTimerWp timer_ptr;
);
context->timer_ptr = owner_->room->xtimer.SetTimeoutWpEx
(
1000 / FRAME_RATE_MS,
[] (int event, const a8::Args* args)
{
},
&owner_->xtimer_attacher);
auto co = std::make_shared<BtCoroutine>(context, "CoMoveCurrentTargetRaycast");
co->runing_cb =
[this, context] ()
{
if (!context->timer_ptr.expired()) {
return behaviac::BT_RUNNING;
} else {
return behaviac::BT_SUCCESS;
}
};
return StartCoroutine(co);
}
behaviac::EBTStatus HeroAgent::CoShotCurrentTargetRaycast()
{
abort();
if (status_ == behaviac::BT_RUNNING) {
return DoRunningCb();
}
auto context = MAKE_BTCONTEXT
(
a8::XTimerWp timer_ptr;
);
context->timer_ptr = owner_->room->xtimer.SetTimeoutWpEx
(
1000 / FRAME_RATE_MS,
[] (int event, const a8::Args* args)
{
},
&owner_->xtimer_attacher);
auto co = std::make_shared<BtCoroutine>(context, "CoShotCurrentTargetRaycast");
co->runing_cb =
[this, context] ()
{
if (!context->timer_ptr.expired()) {
return behaviac::BT_RUNNING;
} else {
return behaviac::BT_SUCCESS;
}
};
return StartCoroutine(co);
}
behaviac::EBTStatus HeroAgent::CoMoveMasterRaycast()
{
abort();
if (status_ == behaviac::BT_RUNNING) {
return DoRunningCb();
}
auto context = MAKE_BTCONTEXT
(
a8::XTimerWp timer_ptr;
);
context->timer_ptr = owner_->room->xtimer.SetTimeoutWpEx
(
1000 / FRAME_RATE_MS,
[] (int event, const a8::Args* args)
{
},
&owner_->xtimer_attacher);
auto co = std::make_shared<BtCoroutine>(context, "CoMoveMasterRaycast");
co->runing_cb =
[this, context] ()
{
if (!context->timer_ptr.expired()) {
return behaviac::BT_RUNNING;
} else {
return behaviac::BT_SUCCESS;
}
};
return StartCoroutine(co);
}
behaviac::EBTStatus HeroAgent::CoFindPath(const glm::vec3& pos)
{
abort();
if (status_ == behaviac::BT_RUNNING) {
return DoRunningCb();
}
auto context = MAKE_BTCONTEXT
(
a8::XTimerWp timer_ptr;
);
context->timer_ptr = owner_->room->xtimer.SetTimeoutWpEx
(
1000 / FRAME_RATE_MS,
[] (int event, const a8::Args* args)
{
},
&owner_->xtimer_attacher);
auto co = std::make_shared<BtCoroutine>(context, "CoFindPath");
co->runing_cb =
[this, context] ()
{
if (!context->timer_ptr.expired()) {
return behaviac::BT_RUNNING;
} else {
return behaviac::BT_SUCCESS;
}
};
return StartCoroutine(co);
}
behaviac::EBTStatus HeroAgent::CoFindPathEx(const glm::vec3& pos, float distance)
{
abort();
if (status_ == behaviac::BT_RUNNING) {
return DoRunningCb();
}
auto context = MAKE_BTCONTEXT
(
a8::XTimerWp timer_ptr;
);
context->timer_ptr = owner_->room->xtimer.SetTimeoutWpEx
(
1000 / FRAME_RATE_MS,
[] (int event, const a8::Args* args)
{
},
&owner_->xtimer_attacher);
auto co = std::make_shared<BtCoroutine>(context, "CoFindPathEx");
co->runing_cb =
[this, context] ()
{
if (!context->timer_ptr.expired()) {
return behaviac::BT_RUNNING;
} else {
return behaviac::BT_SUCCESS;
}
};
return StartCoroutine(co);
}
behaviac::EBTStatus HeroAgent::CoStartMove(float distance)
{
abort();
if (status_ == behaviac::BT_RUNNING) {
return DoRunningCb();
}
auto context = MAKE_BTCONTEXT
(
a8::XTimerWp timer_ptr;
);
context->timer_ptr = owner_->room->xtimer.SetTimeoutWpEx
(
1000 / FRAME_RATE_MS,
[] (int event, const a8::Args* args)
{
},
&owner_->xtimer_attacher);
auto co = std::make_shared<BtCoroutine>(context, "CoStartMove");
co->runing_cb =
[this, context] ()
{
if (!context->timer_ptr.expired()) {
return behaviac::BT_RUNNING;
} else {
return behaviac::BT_SUCCESS;
}
};
return StartCoroutine(co);
}
behaviac::EBTStatus HeroAgent::CoSleep(int time)
{
abort();
if (status_ == behaviac::BT_RUNNING) {
return DoRunningCb();
}
auto context = MAKE_BTCONTEXT
(
a8::XTimerWp timer_ptr;
);
context->timer_ptr = owner_->room->xtimer.SetTimeoutWpEx
(
1000 / FRAME_RATE_MS,
[] (int event, const a8::Args* args)
{
},
&owner_->xtimer_attacher);
auto co = std::make_shared<BtCoroutine>(context, "CoSleep");
co->runing_cb =
[this, context] ()
{
if (!context->timer_ptr.expired()) {
return behaviac::BT_RUNNING;
} else {
return behaviac::BT_SUCCESS;
}
};
return StartCoroutine(co);
}
Room* HeroAgent::GetRoom()