#pragma once

#include "core/defaults.hpp"

// Aliases utilitzats per simplificar lectures freqüents de Defaults::

namespace Constants {
    // Límits de objectes
    constexpr int MAX_ORNIS = Defaults::Entities::MAX_ORNIS;
    constexpr int MAX_BULLETS = Defaults::Entities::MAX_BULLETS;

    // Matemàtiques
    constexpr float PI = Defaults::Math::PI;

    // Helpers per comprovar límits de zone
    inline auto isInPlayArea(float x, float y) -> bool {
        const SDL_FPoint POINT = {x, y};
        return SDL_PointInRectFloat(&POINT, &Defaults::Zones::PLAYAREA);
    }

    inline void getPlayAreaBounds(float& min_x, float& max_x, float& min_y, float& max_y) {
        const auto& zone = Defaults::Zones::PLAYAREA;
        min_x = zone.x;
        max_x = zone.x + zone.w;
        min_y = zone.y;
        max_y = zone.y + zone.h;
    }

    // Obtenir límits segurs (compensant radius de l'entidad)
    inline void getSafePlayAreaBounds(float radius, float& min_x, float& max_x, float& min_y, float& max_y) {
        const auto& zone = Defaults::Zones::PLAYAREA;
        constexpr float SAFETY_MARGIN = 10.0F;  // Safety margin

        min_x = zone.x + radius + SAFETY_MARGIN;
        max_x = zone.x + zone.w - radius - SAFETY_MARGIN;
        min_y = zone.y + radius + SAFETY_MARGIN;
        max_y = zone.y + zone.h - radius - SAFETY_MARGIN;
    }

    // Obtenir centro de l'àrea de juego
    inline void getPlayAreaCenter(float& center_x, float& center_y) {
        const auto& zone = Defaults::Zones::PLAYAREA;
        center_x = zone.x + (zone.w / 2.0F);
        center_y = zone.y + (zone.h / 2.0F);
    }
}  // namespace Constants
