#pragma once

#include <cmath>

#include "adapters/unity/bindings/UnityTypes.h"

namespace ta::adapters::eft::aimbot::shot_policy
{
    [[nodiscard]] inline bool is_finite(const ta::adapters::unity::vector3& value) noexcept
    {
        return std::isfinite(value.x) && std::isfinite(value.y) && std::isfinite(value.z);
    }

    /// Enhanced-style magic bullet behavior: spawn the local projectile at the
    /// selected target and send it downward through the target collider.
    [[nodiscard]] inline bool relocate_projectile(const bool has_target,
                                                   const ta::adapters::unity::vector3& target,
                                                   ta::adapters::unity::vector3& shot_position,
                                                   ta::adapters::unity::vector3& shot_direction,
                                                   ta::adapters::unity::vector3& fireport_position) noexcept
    {
        if (!has_target || !is_finite(target))
            return false;

        shot_position = target;
        fireport_position = target;
        shot_direction = {0.0f, -1.0f, 0.0f};
        return true;
    }
}
