// bullet.hpp - Clase para projectils de la ship
// © 1999 Visente i Sergi (versión Pascal)
// © 2025 Port a C++20 con SDL3

#pragma once
#include <SDL3/SDL.h>

#include <cstdint>

#include "core/defaults.hpp"
#include "core/entities/entity.hpp"
#include "core/types.hpp"

class Bullet : public Entities::Entity {
    public:
        Bullet()
            : Entity(nullptr) {}
        Bullet(Rendering::Renderer* renderer);

        void init() override;
        void disparar(const Vec2& position, float angle, uint8_t owner_id);
        void update(float delta_time) override;
        void postUpdate(float delta_time) override;
        void draw() const override;

        // Override: Interfaz de Entity
        [[nodiscard]] auto isActive() const -> bool override { return esta_; }

        // Override: Interfaz de colisión (gameplay-level: PLAYAREA bounds-check)
        [[nodiscard]] auto getCollisionRadius() const -> float override {
            return Defaults::Entities::BULLET_RADIUS;
        }
        [[nodiscard]] auto isCollidable() const -> bool override {
            return esta_ && grace_timer_ <= 0.0F;
        }

        // Getters (API pública sin cambios)
        [[nodiscard]] auto esta_activa() const -> bool { return esta_; }
        [[nodiscard]] auto getOwnerId() const -> uint8_t { return owner_id_; }
        [[nodiscard]] auto getGraceTimer() const -> float { return grace_timer_; }
        void desactivar();

    private:
        // Miembros específicos de Bullet (heredados: renderer_, shape_, center_, angle_, brightness_, body_)
        bool esta_;
        uint8_t owner_id_;   // 0=P1, 1=P2
        float grace_timer_;  // Grace period timer (0.0 = vulnerable)
};
