feat(entities): migrar bullet a data/entities/bullet/bullet.yaml

This commit is contained in:
2026-05-25 11:42:43 +02:00
parent 5fb6c68df4
commit bea844d51e
12 changed files with 306 additions and 107 deletions
+12 -10
View File
@@ -6,10 +6,12 @@
#include <cstdint>
#include "core/defaults.hpp"
#include "core/entities/entity.hpp"
#include "core/types.hpp"
// Forward declaration — la definició completa s'inclou només al .cpp.
struct BulletConfig;
class Bullet : public Entities::Entity {
public:
Bullet()
@@ -25,25 +27,25 @@ class Bullet : public Entities::Entity {
// Override: Interfaz de Entity
[[nodiscard]] auto isActive() const -> bool override { return is_active_; }
// Override: Interfaz de colisión (gameplay-level: PLAYAREA bounds-check)
[[nodiscard]] auto getCollisionRadius() const -> float override {
return Defaults::Entities::BULLET_RADIUS;
}
// Override: Interfaz de colisión (radi derivat al ctor des del shape).
[[nodiscard]] auto getCollisionRadius() const -> float override { return collision_radius_; }
[[nodiscard]] auto isCollidable() const -> bool override {
return is_active_;
}
// Configuració associada (vàlida des del ctor — la bala l'agafa del BulletRegistry).
[[nodiscard]] auto getConfig() const -> const BulletConfig& { return *config_; }
// Getters (API pública sin cambios)
[[nodiscard]] auto getOwnerId() const -> uint8_t { return owner_id_; }
// Posició al final del frame anterior, per a CCD segment-vs-cercle.
[[nodiscard]] auto getPrevPosition() const -> const Vec2& { return prev_position_; }
void desactivar();
private:
// Miembros específicos de Bullet (heredados: renderer_, shape_, center_, angle_, brightness_, body_).
// Inicializados en la declaración para que tanto el ctor por defecto como el que toma renderer
// dejen el objeto en estado coherente (proyectil inactivo, sin owner).
const BulletConfig* config_{nullptr}; // apunta al BulletRegistry; vàlid post-ctor
float collision_radius_{0.0F}; // derivat: shape.bounding_radius × scale × collision_factor
bool is_active_{false};
uint8_t owner_id_{0}; // 0=P1, 1=P2
Vec2 prev_position_{}; // Posició al final del frame anterior (per a swept collision)
Vec2 prev_position_{}; // posició al final del frame anterior (swept CCD)
};