This commit is contained in:
aozhiwei 2023-04-04 15:36:17 +08:00
parent fb5ff4c375
commit 329d16df8a
2 changed files with 8 additions and 17 deletions

View File

@ -61,15 +61,8 @@ void CondAddBuff::Activate()
void CondAddBuff::Deactivate()
{
for (auto handler : handlers_) {
if (!handler.expired()) {
owner->GetTrigger()->RemoveEventHandler(handler);
}
}
handlers_.clear();
}
void CondAddBuff::ProcBulletHit()
{
const bool is_same_target = meta->_int_buff_param5 ? true : false;
@ -83,7 +76,7 @@ void CondAddBuff::ProcBulletHit()
long long last_hit_frameno = 0;
);
handlers_.push_back
event_handlers_.push_back
(
owner->GetTrigger()->AddListener
(
@ -128,7 +121,7 @@ void CondAddBuff::ProcBulletKill()
(
);
handlers_.push_back
event_handlers_.push_back
(
owner->GetTrigger()->AddListener
(
@ -217,7 +210,7 @@ void CondAddBuff::ProcDisengageBattle()
owner->room->xtimer.ResetTimer(timer);
};
handlers_.push_back
event_handlers_.push_back
(owner->GetTrigger()->AddListener
(
kReceiveDmgEvent,
@ -289,13 +282,13 @@ void CondAddBuff::ProcLimitTimeKillTarget()
}
}
});
handlers_.push_back(handler);
event_handlers_.push_back(handler);
context->watch_targets[target->GetUniId()] = std::make_tuple(timer_wp, handler);
}
}
};
handlers_.push_back
event_handlers_.push_back
(owner->GetTrigger()->AddListener
(
kAttackTargetEvent,
@ -311,7 +304,7 @@ void CondAddBuff::ProcReload()
std::vector<int> buffs;
);
handlers_.push_back
event_handlers_.push_back
(owner->GetTrigger()->AddListener
(
kStartReloadEvent,
@ -331,7 +324,7 @@ void CondAddBuff::ProcReload()
)
);
handlers_.push_back
event_handlers_.push_back
(owner->GetTrigger()->AddListener
(
kEndReloadEvent,
@ -349,7 +342,7 @@ void CondAddBuff::ProcReload()
void CondAddBuff::ProcShot()
{
handlers_.push_back
event_handlers_.push_back
(owner->GetTrigger()->AddListener
(
kShotEvent,

View File

@ -32,6 +32,4 @@ class CondAddBuff : public Buff
void ProcReload();
void ProcShot();
private:
std::vector<std::weak_ptr<EventHandlerPtr>> handlers_;
};