This commit is contained in:
aozhiwei 2022-10-01 09:03:16 +08:00
parent 8433dd75a9
commit c2586b87e9
3 changed files with 21 additions and 23 deletions

View File

@ -682,28 +682,26 @@ int Creature::TryAddBuff(Creature* caster, int buff_id)
return -1;
}
void Creature::TryDelayAddBuff(Creature* caster, int buff_id, int time)
std::weak_ptr<a8::XTimerPtr> Creature::TryDelayAddBuff(Creature* caster, int buff_id, int time)
{
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(buff_id);
if (buff_meta) {
room->xtimer.AddDeadLineTimerAndAttach
(
time / FRAME_RATE_MS,
a8::XParams()
.SetSender(this)
.SetParam1(caster->GetUniId())
.SetParam2(buff_id),
[] (const a8::XParams& param)
{
Creature* c = (Creature*)param.sender.GetUserData();
Entity* e = c->room->GetEntityByUniId(param.param1);
if (e->IsCreature(c->room) && !c->IsDead(c->room)) {
c->TryAddBuff((Creature*)e, param.param2);
}
},
&xtimer_attacher.timer_list_
);
}
xtimer_list* timer = room->xtimer.AddDeadLineTimerAndAttach
(
time / FRAME_RATE_MS,
a8::XParams()
.SetSender(this)
.SetParam1(caster->GetUniId())
.SetParam2(buff_id),
[] (const a8::XParams& param)
{
Creature* c = (Creature*)param.sender.GetUserData();
Entity* e = c->room->GetEntityByUniId(param.param1);
if (e->IsCreature(c->room) && !c->IsDead(c->room)) {
c->TryAddBuff((Creature*)e, param.param2);
}
},
&xtimer_attacher.timer_list_
);
return room->xtimer.GetTimerPtr(timer);
}
int Creature::TryAddBuffWithTarget(Creature* caster, int buff_id)

View File

@ -136,7 +136,7 @@ class Creature : public MoveableEntity
bool no_check_immune = false);
bool IsImmuneBuffEffect(int buff_effect);
int MustBeAddBuff(Creature* caster, int buff_id);
void TryDelayAddBuff(Creature* caster, int buff_id, int time);
std::weak_ptr<a8::XTimerPtr> TryDelayAddBuff(Creature* caster, int buff_id, int time);
int TryAddBuff(Creature* caster, int buff_id);
int TryAddBuffWithTarget(Creature* caster, int buff_id);
void RemoveBuffById(int buff_id);

@ -1 +1 @@
Subproject commit feaf1958a808725df7a2b0ede65c2733965064cd
Subproject commit cf4607dd902bcca2ec8e849b51a1968ffb2dc0ca