#pragma once

#include <nlohmann/json.hpp>

namespace f::players
{
    bool get_data(int32_t idx, class c_cs_player_controller* player, class c_cs_player_pawn* player_pawn);
    void get_weapons(class c_cs_player_pawn* player_pawn);
    void get_active_weapon(class c_cs_player_pawn* player_pawn);
}

namespace f::bomb
{
    void get_carried_bomb(class c_base_entity* bomb);
    void get_planted_bomb(class c_planted_c4* planted_c4);
}

namespace f::grenades
{
    void get_grenade_info();
}

namespace f::dropped_weapons
{
    void get_dropped_weapons();
}

namespace f::roundinfo
{
    void get_round_info();
}

namespace f
{
    void run();
    void get_map();
    void get_player_info();
    void compute_team_stats();
    void handle_planted_bomb();

    // Frame counter for rate-limited scans
    inline int32_t m_frame_counter = 0;

    // Cached planted C4 pointer — read timers every frame via memory
    inline std::uintptr_t m_planted_c4_ptr = 0;

    // Last-known data buffers (so skipped frames still send valid data)
    inline nlohmann::json m_last_bomb = nlohmann::json::object();
    inline nlohmann::json m_last_grenades = nlohmann::json::array();
    inline nlohmann::json m_last_dropped_weapons = nlohmann::json::array();

    inline nlohmann::json m_data = {};
    inline nlohmann::json m_player_data = {};
    inline uint32_t m_bomb_idx = 0;
}
