修复子弹地图边界问题

This commit is contained in:
aozhiwei 2020-08-05 14:35:15 +08:00
parent abf4d4ef70
commit 79be580f3d
2 changed files with 46 additions and 36 deletions

View File

@ -209,10 +209,30 @@ void Bullet::MapServiceUpdate()
if (IsBomb()) {
ProcBomb();
} else {
Check(distance);
if (!later_removed_) {
room->RemoveObjectLater(this);
}
}
} else {
room->grid_service->MoveBullet(this);
Check(distance);
}
}
float Bullet::GetAtk()
{
float atk = gun_meta->i->atk() +
(gun_upgrade_meta ? gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_Atk) : 0);
if (player->IsAndroid()) {
Android* android = (Android*)player;
atk *= android->ai->GetAttackRate();
}
return atk;
}
void Bullet::Check(float distance)
{
std::set<Entity*> objects;
TouchAllLayerHumanList
(
@ -245,19 +265,7 @@ void Bullet::MapServiceUpdate()
OnHit(objects);
}
room->RemoveObjectLater(this);
}
later_removed_ = true;
}
}
}
float Bullet::GetAtk()
{
float atk = gun_meta->i->atk() +
(gun_upgrade_meta ? gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_Atk) : 0);
if (player->IsAndroid()) {
Android* android = (Android*)player;
atk *= android->ai->GetAttackRate();
}
return atk;
}

View File

@ -43,9 +43,11 @@ protected:
bool IsBomb();
inline void MapServiceUpdate();
float GetAtk();
void Check(float distance);
private:
CircleCollider* self_collider_ = nullptr;
bool later_removed_ = false;
friend class EntityFactory;
};