This commit is contained in:
azw 2023-11-07 05:54:51 +00:00
commit 76f55d1748
2 changed files with 26 additions and 11 deletions

View File

@ -187,6 +187,9 @@ void CallFuncBuff::Activate()
void CallFuncBuff::Deactivate()
{
if (deactivate_cb_) {
deactivate_cb_();
}
switch ((BuffCallFunc_e)meta->_int_buff_param1) {
case BuffCallFunc_e::kAddMinorMode:
{
@ -1044,10 +1047,11 @@ void CallFuncBuff::RangeHoldBuff()
std::set<Creature*> hit_humans;
owner->room->TraverseAliveHumanList
(
[this, range] (Human* hum)
[this, range, &hit_humans] (Human* hum) mutable
{
if (Collision::CheckCC(owner, owner->GetRadius(),
hum, range)) {
hit_humans.insert(hum);
}
return true;
});
@ -1082,22 +1086,32 @@ void CallFuncBuff::RangeHoldBuff()
}
},
&owner->xtimer_attacher);
auto clear_func =
[this, context, check_timer] () mutable
{
owner->room->xtimer.Delete(check_timer);
for (auto& pair : context->in_human_infos) {
for (int buff_uniid : pair.second.buff_uniids) {
if (pair.second.c.Get()) {
pair.second.c.Get()->RemoveBuffByUniId(buff_uniid);
}
}
}
context->in_human_infos.clear();
};
{
event_handlers_.push_back(owner->GetTrigger()->AddListener
(
kDieEvent,
[this, context, check_timer] (const a8::Args& args) mutable
[this, clear_func] (const a8::Args& args) mutable
{
owner->room->xtimer.Delete(check_timer);
for (auto& pair : context->in_human_infos) {
for (int buff_uniid : pair.second.buff_uniids) {
if (pair.second.c.Get()) {
pair.second.c.Get()->RemoveBuffByUniId(buff_uniid);
}
}
}
context->in_human_infos.clear();
clear_func();
}
));
deactivate_cb_ =
[this, clear_func] () mutable
{
clear_func();
};
}
}

View File

@ -66,4 +66,5 @@ class CallFuncBuff : public Buff
float hold_param2_ = 0.0;
Weapon* hold_weapon_ = nullptr;
std::function<void()> deactivate_cb_ = nullptr;
};