修复地雷伤害问题

This commit is contained in:
aozhiwei 2019-05-08 15:43:55 +08:00
parent f61e029f61
commit 2e7e015c6a
2 changed files with 29 additions and 22 deletions

View File

@ -131,14 +131,14 @@ void Bullet::OnHit(std::set<Entity*>& objects)
obstacle->dead = obstacle->health <= 0.01f;
obstacle->dead_frameno = room->frame_no;
if (obstacle->dead) {
obstacle->ClearColliders();
room->ScatterDrop(obstacle->pos, obstacle->meta->i->drop());
}
obstacle->BroadcastFullState();
if (obstacle->meta->i->damage_dia() > 0.01f &&
obstacle->meta->i->damage() > 0.01f) {
obstacle->Explosion(this);
}
obstacle->ClearColliders();
room->ScatterDrop(obstacle->pos, obstacle->meta->i->drop());
}
obstacle->BroadcastFullState();
}
}
break;

View File

@ -125,12 +125,17 @@ ColliderComponent* Obstacle::GetBoxBound()
void Obstacle::Explosion(Bullet* bullet)
{
float old_rad = self_collider_->rad;
if (self_collider_) {
self_collider_->rad = meta->i->damage_dia();
}
if (meta->i->damage_dia() > 0.01f &&
meta->i->damage() > 0.01f) {
std::set<Entity*> objects;
std::set<GridCell*> grid_list;
room->grid_service.GetAllCellsByXy(pos.x, pos.y, grid_list);
for (auto& grid : grid_list) {
for (Human* hum: grid->human_list) {
{
if (TestCollision(hum)) {
objects.insert(hum);
}
@ -140,7 +145,7 @@ void Obstacle::Explosion(Bullet* bullet)
case ET_Obstacle:
case ET_Building:
{
if (TestCollision(entity)) {
if (entity != this && TestCollision(entity)) {
objects.insert(entity);
}
}
@ -150,7 +155,6 @@ void Obstacle::Explosion(Bullet* bullet)
}
break;
}
}
}//end for
}
Vector2D bomb_pos = pos;
@ -197,4 +201,7 @@ void Obstacle::Explosion(Bullet* bullet)
}
}
}
if (self_collider_) {
self_collider_->rad = old_rad;
}
}