1
This commit is contained in:
parent
f032cedb82
commit
67e48dd9a0
@ -37,13 +37,17 @@ behaviac::EBTStatus AndroidAgent::DoIdle(int min_time, int max_time)
|
||||
&GetOwner()->xtimer_attacher.timer_list_);
|
||||
std::weak_ptr<a8::XTimerPtr> timer_ptr = GetOwner()->room->xtimer.GetTimerPtr(timer);
|
||||
|
||||
std::shared_ptr<CreatureWeakPtr> last_attacker = std::make_shared<CreatureWeakPtr>();
|
||||
std::shared_ptr<long long> last_attacked_frameno = std::make_shared<long long>(0);
|
||||
std::weak_ptr<EventHandlerPtr> handler = GetOwner()->GetTrigger()->AddListener
|
||||
(
|
||||
kAttacked,
|
||||
[this] (const std::vector<std::any>& args)
|
||||
[this, last_attacker, last_attacked_frameno] (const std::vector<std::any>& args)
|
||||
{
|
||||
Creature* c = std::any_cast<Creature*>(args.at(0));
|
||||
FireEvent("OnAttacked", c->GetUniId(), c->room->GetFrameNo());
|
||||
*last_attacker = c->GetWeakPtrRef();
|
||||
*last_attacked_frameno = c->room->GetFrameNo();
|
||||
//FireEvent("OnAttacked", c->GetUniId(), c->room->GetFrameNo());
|
||||
});
|
||||
|
||||
return StartCoroutine
|
||||
@ -58,6 +62,10 @@ behaviac::EBTStatus AndroidAgent::DoIdle(int min_time, int max_time)
|
||||
}
|
||||
return behaviac::BT_SUCCESS;
|
||||
}
|
||||
},
|
||||
[this, last_attacker, last_attacked_frameno] (bool& has_event)
|
||||
{
|
||||
|
||||
},
|
||||
"CoIdle"
|
||||
);
|
||||
@ -100,6 +108,10 @@ behaviac::EBTStatus AndroidAgent::DoRandomWalk()
|
||||
} else {
|
||||
return behaviac::BT_RUNNING;
|
||||
}
|
||||
},
|
||||
[this] (bool& has_event)
|
||||
{
|
||||
|
||||
},
|
||||
"CoRandomWalk"
|
||||
);
|
||||
@ -146,6 +158,10 @@ behaviac::EBTStatus AndroidAgent::DoRandomShot()
|
||||
|
||||
return behaviac::BT_RUNNING;
|
||||
}
|
||||
},
|
||||
[this] (bool& has_event)
|
||||
{
|
||||
|
||||
},
|
||||
"CoRandomShot"
|
||||
);
|
||||
@ -184,6 +200,10 @@ behaviac::EBTStatus AndroidAgent::DoAttack()
|
||||
|
||||
return behaviac::BT_RUNNING;
|
||||
}
|
||||
},
|
||||
[this] (bool& has_event)
|
||||
{
|
||||
|
||||
},
|
||||
"CoAttack"
|
||||
);
|
||||
@ -246,6 +266,10 @@ behaviac::EBTStatus AndroidAgent::DoPursuit()
|
||||
}
|
||||
return behaviac::BT_RUNNING;
|
||||
}
|
||||
},
|
||||
[this] (bool& has_event)
|
||||
{
|
||||
|
||||
},
|
||||
"CoPursuit"
|
||||
);
|
||||
|
@ -62,6 +62,7 @@ behaviac::EBTStatus BaseAgent::DoRunningCb()
|
||||
}
|
||||
|
||||
behaviac::EBTStatus BaseAgent::StartCoroutine(std::function<behaviac::EBTStatus()> cb,
|
||||
std::function<void(bool&)> event_cb,
|
||||
const char* name)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@ -70,6 +71,7 @@ behaviac::EBTStatus BaseAgent::StartCoroutine(std::function<behaviac::EBTStatus(
|
||||
status_name_ = name;
|
||||
#endif
|
||||
runing_cb_ = std::move(cb);
|
||||
event_cb_ = std::move(event_cb);
|
||||
status_ = behaviac::BT_RUNNING;
|
||||
return status_;
|
||||
}
|
||||
@ -133,6 +135,10 @@ behaviac::EBTStatus BaseAgent::CoAttackTarget(int target_id)
|
||||
}
|
||||
}
|
||||
return behaviac::BT_RUNNING;
|
||||
},
|
||||
[this] (bool& has_event)
|
||||
{
|
||||
|
||||
},
|
||||
"CoAttackTarget"
|
||||
);
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
protected:
|
||||
behaviac::EBTStatus DoRunningCb();
|
||||
behaviac::EBTStatus StartCoroutine(std::function<behaviac::EBTStatus()> cb,
|
||||
std::function<void(bool&)> event_cb,
|
||||
const char* name);
|
||||
|
||||
protected:
|
||||
@ -37,7 +38,7 @@ protected:
|
||||
#endif
|
||||
behaviac::EBTStatus status_= behaviac::BT_SUCCESS;
|
||||
std::function<behaviac::EBTStatus()> runing_cb_;
|
||||
std::function<bool(bool&)> event_cb_;
|
||||
std::function<void(bool&)> event_cb_;
|
||||
|
||||
private:
|
||||
Creature* owner_ = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user