1
This commit is contained in:
parent
56eab70fe4
commit
cb5f01beff
@ -210,58 +210,34 @@ behaviac::EBTStatus HeroAgent::DoAttack()
|
||||
context->target = enemy->GetWeakPtrRef();
|
||||
context->last_frameno = GetOwner()->room->GetFrameNo();
|
||||
|
||||
#if 0
|
||||
std::weak_ptr<EventHandlerPtr> handler;
|
||||
if (GetOwner()->AsHero()->master.Get()) {
|
||||
handler = GetOwner()->AsHero()->master.Get()->GetTrigger()->AddListener
|
||||
context->handler = GetOwner()->AsHero()->master.Get()->GetTrigger()->AddListener
|
||||
(
|
||||
kBulletHitEvent,
|
||||
[this, last_attacker, last_attacked_frameno] (const a8::Args& args)
|
||||
[context_wp = context->GetWp()] (const a8::Args& args)
|
||||
{
|
||||
Creature* c = args.Get<Creature*>(1);
|
||||
*last_attacker = c->GetWeakPtrRef();
|
||||
*last_attacked_frameno = c->room->GetFrameNo();
|
||||
if (!context_wp.expired()) {
|
||||
auto context = context_wp.lock();
|
||||
Creature* c = args.Get<Creature*>(1);
|
||||
context->last_attacker = c->GetWeakPtrRef();
|
||||
context->last_attacked_frameno = c->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();
|
||||
}
|
||||
});
|
||||
#endif
|
||||
#if 0
|
||||
context->_destory_cb =
|
||||
(
|
||||
[context = context.get()] ()
|
||||
{
|
||||
if (context->owner.Get()) {
|
||||
context->owner.Get()->GetTrigger()->RemoveEventHandler(context->handler);
|
||||
}
|
||||
});
|
||||
|
||||
auto holder = std::make_shared<a8::Holder>
|
||||
(
|
||||
[owner = GetOwner()->GetWeakPtrRef(), handler] (const a8::Args& args) mutable
|
||||
{
|
||||
if (!handler.expired() && owner.Get()) {
|
||||
if (owner.Get()->IsEntityType(ET_Hero)) {
|
||||
Hero* hero = (Hero*)owner.Get();
|
||||
if (!context->handler.expired() && context->owner.Get()) {
|
||||
if (context->owner.Get()->IsEntityType(ET_Hero)) {
|
||||
Hero* hero = (Hero*)context->owner.Get();
|
||||
if (hero->master.Get()) {
|
||||
hero->master.Get()->GetTrigger()->RemoveEventHandler(handler);
|
||||
hero->master.Get()->GetTrigger()->RemoveEventHandler(context->handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
#endif
|
||||
|
||||
auto co = std::make_shared<BtCoroutine>(context, "CoAttack");
|
||||
co->runing_cb =
|
||||
[this, context] ()
|
||||
|
Loading…
x
Reference in New Issue
Block a user