1
This commit is contained in:
parent
7ed35b47e8
commit
1a230fccab
@ -17,6 +17,7 @@ Android::Android():Human()
|
|||||||
if (!agent_) {
|
if (!agent_) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
agent_->SetOwner(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Android::~Android()
|
Android::~Android()
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
#include "android_agent.h"
|
#include "android_agent.h"
|
||||||
|
#include "android.h"
|
||||||
|
#include "room.h"
|
||||||
|
|
||||||
AndroidAgent::AndroidAgent()
|
AndroidAgent::AndroidAgent()
|
||||||
{
|
{
|
||||||
@ -14,5 +16,26 @@ AndroidAgent::~AndroidAgent()
|
|||||||
|
|
||||||
behaviac::EBTStatus AndroidAgent::DoIdle(int time)
|
behaviac::EBTStatus AndroidAgent::DoIdle(int time)
|
||||||
{
|
{
|
||||||
|
if (status_ == behaviac::BT_RUNNING) {
|
||||||
|
return status_runing_cb_();
|
||||||
|
}
|
||||||
|
xtimer_list* timer = GetOwner()->room->xtimer.AddDeadLineTimerAndAttach
|
||||||
|
(
|
||||||
|
time / FRAME_RATE_MS,
|
||||||
|
a8::XParams(),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
},
|
||||||
|
&GetOwner()->xtimer_attacher.timer_list_);
|
||||||
|
std::weak_ptr<a8::XTimerPtr> timer_ptr = GetOwner()->room->xtimer.GetTimerPtr(timer);
|
||||||
|
status_runing_cb_ =
|
||||||
|
[timer_ptr] ()
|
||||||
|
{
|
||||||
|
if (timer_ptr.lock()) {
|
||||||
|
return behaviac::BT_RUNNING;
|
||||||
|
} else {
|
||||||
|
return behaviac::BT_SUCCESS;
|
||||||
|
}
|
||||||
|
};
|
||||||
return behaviac::BT_RUNNING;
|
return behaviac::BT_RUNNING;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "behaviac_headers.h"
|
#include "behaviac_headers.h"
|
||||||
|
|
||||||
|
class Android;
|
||||||
class AndroidAgent : public behaviac::Agent
|
class AndroidAgent : public behaviac::Agent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -12,6 +13,13 @@ public:
|
|||||||
BEHAVIAC_DECLARE_AGENTTYPE(AndroidAgent, behaviac::Agent)
|
BEHAVIAC_DECLARE_AGENTTYPE(AndroidAgent, behaviac::Agent)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void SetOwner(Android* owner) { owner_ = owner; };
|
||||||
|
Android* GetOwner() { return owner_; };
|
||||||
|
|
||||||
behaviac::EBTStatus DoIdle(int time);
|
behaviac::EBTStatus DoIdle(int time);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Android* owner_ = nullptr;
|
||||||
|
behaviac::EBTStatus status_= behaviac::BT_SUCCESS;
|
||||||
|
std::function<behaviac::EBTStatus()> status_runing_cb_;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user