This commit is contained in:
aozhiwei 2021-05-28 10:24:23 +08:00
parent 1bb875aa01
commit b712fd0edc
3 changed files with 37 additions and 2 deletions

View File

@ -415,8 +415,28 @@ void Buff::ProcTurnOver(Creature* caster)
//穿墙
} else {
owner->_UpdateMove(distance);
if (!meta->param2_int_list.empty()) {
}
if (!meta->param2_int_list.empty()) {
int time = 0;
float moved_distance = owner->GetPos().Distance(old_pos);
if (std::abs(moved_distance) > 0.01f) {
time = ((moved_distance / distance) * meta->param3) / FRAME_RATE_MS;
}
owner->room->xtimer.AddDeadLineTimerAndAttach
(
time,
a8::XParams()
.SetSender(owner)
.SetParam1(meta),
[] (const a8::XParams& param)
{
Creature* c = (Creature*)param.sender.GetUserData();
MetaData::Buff* buff_meta = (MetaData::Buff*)param.param1.GetUserData();
for (int buff_id : buff_meta->param2_int_list) {
c->TryAddBuff(c, buff_id);
}
},
&owner->xtimer_attacher.timer_list_
);
}
}

View File

@ -1796,3 +1796,17 @@ void Creature::AddHp(float hp)
}
}
bool Creature::TryMove(const a8::Vec2& target_pos, a8::Vec2& out_pos)
{
bool move_ok = false;
a8::Vec2 old_pos = GetPos();
out_pos = GetPos();
SetPos(target_pos);
if (CollisonDetection()) {
out_pos = target_pos;
move_ok = true;
} else {
}
return move_ok;
}

View File

@ -174,6 +174,7 @@ class Creature : public MoveableEntity
float GetHP();
float GetMaxHP();
void GetHitEnemys(std::set<Creature*>& enemys);
bool TryMove(const a8::Vec2& target_pos, a8::Vec2& out_pos);
private: