修复地雷伤害问题
This commit is contained in:
parent
f61e029f61
commit
2e7e015c6a
@ -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) {
|
||||
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();
|
||||
if (obstacle->meta->i->damage_dia() > 0.01f &&
|
||||
obstacle->meta->i->damage() > 0.01f) {
|
||||
obstacle->Explosion(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -125,31 +125,35 @@ 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);
|
||||
}
|
||||
if (TestCollision(hum)) {
|
||||
objects.insert(hum);
|
||||
}
|
||||
for (Entity* entity : grid->entity_list) {
|
||||
switch (entity->entity_type) {
|
||||
case ET_Obstacle:
|
||||
case ET_Building:
|
||||
{
|
||||
if (TestCollision(entity)) {
|
||||
objects.insert(entity);
|
||||
}
|
||||
}
|
||||
for (Entity* entity : grid->entity_list) {
|
||||
switch (entity->entity_type) {
|
||||
case ET_Obstacle:
|
||||
case ET_Building:
|
||||
{
|
||||
if (entity != this && TestCollision(entity)) {
|
||||
objects.insert(entity);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}//end for
|
||||
}
|
||||
@ -196,5 +200,8 @@ void Obstacle::Explosion(Bullet* bullet)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (self_collider_) {
|
||||
self_collider_->rad = old_rad;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user