1
This commit is contained in:
parent
f936461640
commit
56eab70fe4
@ -120,7 +120,7 @@ behaviac::EBTStatus AndroidAgent::DoRandomShot()
|
|||||||
);
|
);
|
||||||
|
|
||||||
context->owner = GetOwner()->GetWeakPtrRef();
|
context->owner = GetOwner()->GetWeakPtrRef();
|
||||||
context->last_frameno = GetOwenr()->room->GetFrameNo();
|
context->last_frameno = GetOwner()->room->GetFrameNo();
|
||||||
context->handler = GetOwner()->GetTrigger()->AddListener
|
context->handler = GetOwner()->GetTrigger()->AddListener
|
||||||
(
|
(
|
||||||
kAttacked,
|
kAttacked,
|
||||||
|
@ -73,9 +73,6 @@ behaviac::EBTStatus HeroAgent::DoRandomWalk()
|
|||||||
[this, context] ()
|
[this, context] ()
|
||||||
{
|
{
|
||||||
if (GetOwner()->GetMovement()->GetPathSize() <= 0) {
|
if (GetOwner()->GetMovement()->GetPathSize() <= 0) {
|
||||||
if (!context->handler.expired()) {
|
|
||||||
GetOwner()->GetTrigger()->RemoveEventHandler(context->handler);
|
|
||||||
}
|
|
||||||
return behaviac::BT_SUCCESS;
|
return behaviac::BT_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
return behaviac::BT_RUNNING;
|
return behaviac::BT_RUNNING;
|
||||||
@ -121,6 +118,7 @@ behaviac::EBTStatus HeroAgent::DoRandomShot()
|
|||||||
);
|
);
|
||||||
|
|
||||||
context->owner = GetOwner()->GetWeakPtrRef();
|
context->owner = GetOwner()->GetWeakPtrRef();
|
||||||
|
context->last_frameno = GetOwner()->room->GetFrameNo();
|
||||||
context->handler = GetOwner()->GetTrigger()->AddListener
|
context->handler = GetOwner()->GetTrigger()->AddListener
|
||||||
(
|
(
|
||||||
kAttacked,
|
kAttacked,
|
||||||
@ -325,37 +323,14 @@ behaviac::EBTStatus HeroAgent::DoPursuit()
|
|||||||
(
|
(
|
||||||
CreatureWeakPtr owner;
|
CreatureWeakPtr owner;
|
||||||
CreatureWeakPtr target;
|
CreatureWeakPtr target;
|
||||||
CreatureWeakPtr last_attacker;
|
|
||||||
long long last_attacked_frameno = 0;
|
|
||||||
long long last_frameno = 0;
|
long long last_frameno = 0;
|
||||||
long long last_pursuit_frameno = 0;
|
long long last_pursuit_frameno = 0;
|
||||||
std::weak_ptr<EventHandlerPtr> handler;
|
|
||||||
);
|
);
|
||||||
|
|
||||||
context->owner = GetOwner()->GetWeakPtrRef();
|
context->owner = GetOwner()->GetWeakPtrRef();
|
||||||
context->target = enemy->GetWeakPtrRef();
|
context->target = enemy->GetWeakPtrRef();
|
||||||
context->last_frameno = GetOwner()->room->GetFrameNo();
|
context->last_frameno = GetOwner()->room->GetFrameNo();
|
||||||
context->last_pursuit_frameno = GetOwner()->room->GetFrameNo();
|
context->last_pursuit_frameno = GetOwner()->room->GetFrameNo();
|
||||||
context->handler = GetOwner()->GetTrigger()->AddListener
|
|
||||||
(
|
|
||||||
kAttacked,
|
|
||||||
[context_wp = context->GetWp()] (const a8::Args& args)
|
|
||||||
{
|
|
||||||
if (context_wp.expired()) {
|
|
||||||
auto context = context_wp.lock();
|
|
||||||
Creature* c = args.Get<Creature*>(0);
|
|
||||||
context->last_attacker = c->GetWeakPtrRef();
|
|
||||||
context->last_attacked_frameno = c->room->GetFrameNo();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
context->_destory_cb =
|
|
||||||
(
|
|
||||||
[context = context.get()] ()
|
|
||||||
{
|
|
||||||
if (context->owner.Get()) {
|
|
||||||
context->owner.Get()->GetTrigger()->RemoveEventHandler(context->handler);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
auto co = std::make_shared<BtCoroutine>(context, "CoPursuit");
|
auto co = std::make_shared<BtCoroutine>(context, "CoPursuit");
|
||||||
co->runing_cb =
|
co->runing_cb =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user