This commit is contained in:
azw 2023-11-07 05:53:32 +00:00
parent 022d4c5e5c
commit 6092bea2ba
2 changed files with 27 additions and 10 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:
{
@ -1043,10 +1046,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;
});
@ -1070,7 +1074,7 @@ void CallFuncBuff::RangeHoldBuff()
}
}
};
owner->room->xtimer.SetIntervalWpEx
auto check_timer = owner->room->xtimer.SetIntervalWpEx
(
SERVER_FRAME_RATE,
[this, context, on_enter, on_stay, on_leave, check_cb]
@ -1081,20 +1085,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] (const a8::Args& args) mutable
[this, clear_func] (const a8::Args& args) mutable
{
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);
}
}
}
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;
};