Fixing refill times

This commit is contained in:
Zoe Roux
2021-05-31 17:00:46 +02:00
parent 43bd781175
commit 8009c0619b
2 changed files with 5 additions and 7 deletions
@@ -22,7 +22,7 @@ namespace BBM
//! @brief The max number of bomb that this entity can have.
unsigned int maxBombCount = 3;
//! @brief The number of seconds of each refill. This variable is used to reset the nextBombRefill value.
std::chrono::nanoseconds refillRate = 5000ns;
std::chrono::nanoseconds refillRate = 5000ms;
//! @brief The number of nanosecond before the next bomb refill.
std::chrono::nanoseconds nextBombRefill = refillRate;
@@ -36,18 +36,16 @@ namespace BBM
auto &position = entity.getComponent<PositionComponent>();
auto &controllable = entity.getComponent<ControllableComponent>();
if (controllable.bomb && holder.bombCount > 0) {
holder.bombCount--;
this->_spawnBomb(position.position);
}
if (holder.bombCount < holder.maxBombCount) {
holder.nextBombRefill -= dtime;
if (holder.nextBombRefill <= 0ns) {
holder.nextBombRefill = holder.refillRate;
holder.bombCount++;
std::cout << "Count: " << holder.bombCount << std::endl;
}
}
if (controllable.bomb && holder.bombCount > 0) {
holder.bombCount--;
std::cout << "Now" << std::endl;
this->_spawnBomb(position.position);
}
}
}