mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-25 15:39:50 +00:00
Fixing multiple bombs at the same pos
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user