Fixing multiple bombs at the same pos

This commit is contained in:
Zoe Roux
2021-06-17 14:00:30 +02:00
parent 4f782e9d75
commit fcb1c91044
+10 -5
View File
@@ -125,7 +125,7 @@ namespace BBM
}
this->_wal.getScene()->scheduleNewEntity("Bomb")
.addComponent<PositionComponent>(position.round())
.addComponent<PositionComponent>(position)
.addComponent<HealthComponent>(1, [](WAL::Entity &entity, WAL::Wal &wal) {
// the bomb explode when hit
entity.scheduleDeletion();
@@ -180,10 +180,6 @@ namespace BBM
auto &position = entity.get<PositionComponent>();
auto &controllable = entity.get<ControllableComponent>();
if (controllable.bomb && holder.bombCount > 0) {
holder.bombCount--;
this->_spawnBomb(position.position, holder);
}
if (holder.bombCount < holder.maxBombCount) {
holder.nextBombRefill -= dtime;
if (holder.nextBombRefill <= 0ns) {
@@ -191,5 +187,14 @@ namespace BBM
holder.bombCount++;
}
}
if (controllable.bomb && holder.bombCount > 0) {
auto spawnPos = position.position.round();
for (auto &[entity, pos, _] : this->_wal.getScene()->view<PositionComponent, BasicBombComponent>()) {
if (pos.position == spawnPos)
return;
}
holder.bombCount--;
this->_spawnBomb(spawnPos, holder);
}
}
}