linter
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#include "bullet_manager.hpp"
|
||||
|
||||
#include <algorithm> // Para remove_if
|
||||
#include <utility>
|
||||
|
||||
#include "bullet.hpp" // Para Bullet
|
||||
#include "param.hpp" // Para param
|
||||
#include "player.hpp" // Para Player
|
||||
#include "param.hpp" // Para Param, ParamGame, param
|
||||
#include "utils.hpp" // Para Circle, Zone
|
||||
|
||||
// Constructor
|
||||
BulletManager::BulletManager()
|
||||
@@ -12,10 +13,10 @@ BulletManager::BulletManager()
|
||||
}
|
||||
|
||||
// Actualiza el estado de todas las balas
|
||||
void BulletManager::update(float deltaTime) {
|
||||
void BulletManager::update(float delta_time) {
|
||||
for (auto& bullet : bullets_) {
|
||||
if (bullet->isEnabled()) {
|
||||
processBulletUpdate(bullet, deltaTime);
|
||||
processBulletUpdate(bullet, delta_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,14 +37,9 @@ void BulletManager::createBullet(int x, int y, Bullet::Type type, Bullet::Color
|
||||
|
||||
// Libera balas que ya no están habilitadas
|
||||
void BulletManager::freeBullets() {
|
||||
if (!bullets_.empty()) {
|
||||
// Elimina las balas deshabilitadas del vector
|
||||
bullets_.erase(
|
||||
std::remove_if(bullets_.begin(), bullets_.end(), [](const std::shared_ptr<Bullet>& bullet) {
|
||||
return !bullet->isEnabled();
|
||||
}),
|
||||
bullets_.end());
|
||||
}
|
||||
std::erase_if(bullets_, [](const std::shared_ptr<Bullet>& bullet) {
|
||||
return !bullet->isEnabled();
|
||||
});
|
||||
}
|
||||
|
||||
// Elimina todas las balas
|
||||
@@ -72,24 +68,24 @@ void BulletManager::checkCollisions() {
|
||||
|
||||
// Establece el callback para colisión con Tabe
|
||||
void BulletManager::setTabeCollisionCallback(CollisionCallback callback) {
|
||||
tabe_collision_callback_ = callback;
|
||||
tabe_collision_callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
// Establece el callback para colisión con globos
|
||||
void BulletManager::setBalloonCollisionCallback(CollisionCallback callback) {
|
||||
balloon_collision_callback_ = callback;
|
||||
balloon_collision_callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
// Establece el callback para balas fuera de límites
|
||||
void BulletManager::setOutOfBoundsCallback(OutOfBoundsCallback callback) {
|
||||
out_of_bounds_callback_ = callback;
|
||||
out_of_bounds_callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
// --- Métodos privados ---
|
||||
|
||||
// Procesa la actualización individual de una bala
|
||||
void BulletManager::processBulletUpdate(const std::shared_ptr<Bullet>& bullet, float deltaTime) {
|
||||
auto status = bullet->update(deltaTime);
|
||||
void BulletManager::processBulletUpdate(const std::shared_ptr<Bullet>& bullet, float delta_time) {
|
||||
auto status = bullet->update(delta_time);
|
||||
|
||||
// Si la bala salió de los límites, llama al callback
|
||||
if (status == Bullet::MoveStatus::OUT && out_of_bounds_callback_) {
|
||||
@@ -98,7 +94,7 @@ void BulletManager::processBulletUpdate(const std::shared_ptr<Bullet>& bullet, f
|
||||
}
|
||||
|
||||
// Verifica si la bala está fuera de los límites del área de juego
|
||||
auto BulletManager::isBulletOutOfBounds(const std::shared_ptr<Bullet>& bullet) -> bool {
|
||||
auto BulletManager::isBulletOutOfBounds(const std::shared_ptr<Bullet>& bullet) const -> bool {
|
||||
auto collider = bullet->getCollider();
|
||||
|
||||
return (collider.x < play_area_.x ||
|
||||
|
||||
Reference in New Issue
Block a user