#pragma once

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <dirent.h>
#include <pthread.h>
#include <cfloat> // Added for FLT_MAX
#include <imgui.h>
#include <imgui_internal.h>
#include <Il2Cpp.h>
#include <Tools.h>
#include <Vector3.hpp>
#include <Color.h>
#include <Struct/main.h>
#include "obfuscate.h"
#include "Unity/unity.h"
#include "../CheatCode/Hacks/Class.h"
#include "../CheatCode/Hacks/Rect.h"
inline static int g_GlHeight, g_GlWidth;
#include "../CheatCode/Hacks/Bools.h"
#include <math.h>
#include <stdio.h>
typedef char PACKAGENAME;

// Master ESP colors
ImVec4 normalESPColor = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);  // White
ImVec4 knockedESPColor = ImVec4(1.0f, 0.0f, 0.0f, 1.0f); // Red

// Unified color selector
ImColor GetESPColor(bool isKnocked) {
    ImVec4 c = isKnocked ? knockedESPColor : normalESPColor;
    return ImColor(c.x * 255, c.y * 255, c.z * 255, c.w * 255);
}



        bool Line = true;
        bool Health = true;
        bool Distance = true;
        bool Target = true;
		bool box = true;
		
		
		
bool Enable = false;
bool Convidado = false;




bool isOutsideScreen(ImVec2 pos, ImVec2 screen) {
    if (pos.y < 0) {
        return true;
    }
    if (pos.x > screen.x) {
        return true;
    }
    if (pos.y > screen.y) {
        return true;
    }
    return pos.x < 0;
}

ImVec2 pushToScreenBorder(ImVec2 Pos, ImVec2 screen, int offset) {
    int x = (int) Pos.x;
    int y = (int) Pos.y;
    
    if (Pos.y < 0) {
        y = -offset;
    }
    
    if (Pos.x > screen.x) {
        x = (int) screen.x + offset;
    }
    
    if (Pos.y > screen.y) {
        y = (int) screen.y + offset;
    }
    
    if (Pos.x < 0) {
        x = -offset;
    }
    return ImVec2(x, y);
}

static float tm_alpha = 127 / 255.f;

void DrawCircleHealth(ImVec2 position, int health, int max_health, float radius) {
    float a_max = ((3.14159265359f * 2.0f));
    ImU32 healthColor = IM_COL32(45, 180, 45, 255);
    if (health <= (max_health * 0.6)) {
        healthColor = IM_COL32(180, 180, 45, 255);
    }
    if (health < (max_health * 0.3)) {
        healthColor = IM_COL32(180, 45, 45, 255);
    }
    ImGui::GetForegroundDrawList()->PathArcTo(position, radius, (-(a_max / 4.0f)) + (a_max / max_health) * (max_health - health), a_max - (a_max / 4.0f));
    ImGui::GetForegroundDrawList()->PathStroke(healthColor, ImDrawFlags_None, 4);
}



void drawText2(int x, int y, long color, const char *str, float size) {
        ImGui::GetBackgroundDrawList()->AddText(NULL, size, ImVec2(x, y), color, str);
    }


void DrawRectFilled(int x, int y, int w, int h, ImColor color) {
    ImGui::GetBackgroundDrawList()->AddRectFilled(ImVec2(x, y), ImVec2(x + w, y + h),
                                               color, 0, 0);
}


void DrawRectFilledHealth(int x, int y, int w, int h, ImVec4 color) {
    ImGui::GetBackgroundDrawList()->AddRectFilled(ImVec2(x, y), ImVec2(x + w, y + h),
                                               ImGui::ColorConvertFloat4ToU32(color), 0, 0);
}


void DrawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, int color, int T) {
    ImGui::GetBackgroundDrawList()->AddTriangleFilled(ImVec2(x1, y1), ImVec2(x2, y2), ImVec2(x3, y3),
                                                   color);
}
bool IsVisible(void * player){
    if(player != NULL) {
        void *hitObj = NULL;
        Vector3 cameraLocation = Transform_GetPosition(Component_GetTransform(Camera_main()));
        Vector3 headLocation = Transform_GetPosition(Component_GetTransform(Player_GetHeadCollider(player)));
            return !Physics_Raycast(cameraLocation, headLocation, 12, &hitObj);
    }
    return false;
}


void DrawHealths(Rect box, float entityHealth, float maxHealth, int TeamID, const char* name, long color) {
    float x = box.x - (140 - box.w) / 2;
    float y = box.y;
    char dis[20];
    // sprintf(dis, "%0.fM", d);

    char TeamText[20];
    sprintf(TeamText, "%d", (int)TeamID);
    ImVec4 HPColor = ImVec4{1, 1, 0, 127 / 255.f}; // Màu mặc định cho máu

    if (entityHealth < maxHealth) {
        float healthPercentage = entityHealth / maxHealth;

        if (healthPercentage < 0.3f) {
            HPColor = ImVec4{0.5f, 0.0f, 0.0f, 127 / 255.f}; // Màu đỏ cho máu thấp
        } else if (healthPercentage < 0.6f) {
            HPColor = ImVec4{1, 0, 0, 127 / 255.f}; // Màu cam cho máu trung bình
        }
    }

    tm_alpha = 100.f / 255.f;
    DrawRectFilled(x - strlen(name), y - 41, 120 + strlen(name) * 2, 20, color); // Đám mây nền cho tên người chơi
    tm_alpha = 255.f / 255.f;
    DrawRectFilled(x - strlen(name), box.y - 41, 25, 20, color);
    if (strlen(TeamText) < 2) {
        drawText2(x + 6 - strlen(name), box.y - 42, ImColor(255,255,255),
                       TeamText, 18.943);//队伍ID
    } else {
        drawText2(x - strlen(name), box.y - 42, ImColor(255,255,255),
                       TeamText, 18.943);//队伍ID
    }
    drawText2(x + 28 - strlen(name), y - 43,
                   ImColor(255,255,255), name, 18.943);//玩家名称
    float maxWidth = 120; // Độ dài tối đa của thanh máu
    float healthBarWidth = entityHealth * maxWidth / maxHealth; // Độ dài thanh máu dựa trên tỷ lệ máu hiện tại và máu tối đa
    DrawRectFilledHealth(x - maxWidth / 2, y - 18, healthBarWidth, 8, HPColor);// cập nhật vị trí và kích thước của thanh máu
    drawText2(x + 125 + strlen(name), y - 43, ImColor(255,255,255), dis,18.943);//距离显示
    DrawTriangle(box.x + box.w / 2 - 10, y - 8, box.x + box.w / 2 + 15 - 10, y - 8,
                 box.x + box.w / 2 - 2, y, ImColor(255,255,255), 1);//第一个左边 第二个右边 第三个底边
}


static float SetFieldOfView = 0, GetFieldOfView = 0;

void DroneView() {
    if (GetFieldOfView == 0) {
        GetFieldOfView = get_fieldOfView();
    }
    if (SetFieldOfView > 0 && GetFieldOfView != 0) {
        set_fieldOfView((float)GetFieldOfView + SetFieldOfView);
    }
    if (SetFieldOfView == 0 && GetFieldOfView != 0) {
        set_fieldOfView((float)GetFieldOfView);
    }
}

void *GetClosestEnemy() {
    float smallestAngle = FLT_MAX;
    void* targetEnemy = NULL;

    void* get_MatchGame = Curent_Match();
    void* LocalPlayer = GetLocalPlayer(get_MatchGame);

    if (LocalPlayer != NULL && get_MatchGame != NULL && Enable && get_MatchGame) {
        monoDictionary<uint8_t *, void **> *players = *(monoDictionary<uint8_t*, void **> **)((long)get_MatchGame + ListPlayer);
        Vector3 LocalPlayerPos = getPosition(LocalPlayer);
        Vector3 cameraForward = GetForward(Component_GetTransform(Camera_main()));
        
        for (int u = 0; u < players->getNumValues(); u++) {
            void* Player = players->getValues()[u]; 
            if (Player != NULL && !get_isLocalTeam(Player) && !get_IsDieing(Player) && get_isVisible(Player) && get_MaxHP(Player)) {    
                Vector3 PlayerPos = getPosition(Player);
                
                float distance = Vector3::Distance(LocalPlayerPos, PlayerPos);
                
                // For very close enemies (< 5 units), use distance-based targeting
                if (distance < 5.0f) {
                    // Close range: prioritize by distance instead of angle
                    if (distance < smallestAngle) {
                        smallestAngle = distance;
                        targetEnemy = Player;
                    }
                } else {
                    // Normal range: use angle-based targeting
                    Vector3 targetDirection = Vector3::Normalized(PlayerPos - LocalPlayerPos);
                    float angleInRadians = Vector3::Angle(cameraForward, targetDirection);
                    float angleInDegrees = angleInRadians * (180.0f / 3.14159f);
                    
                    // Check if enemy is within FOV angle
                    if (angleInDegrees <= Size) {
                        if (angleInDegrees < smallestAngle) {
                            smallestAngle = angleInDegrees;
                            targetEnemy = Player;
                        }
                    }
                }
            }
        }
    }
    return targetEnemy;
}

float (*get_deltaTime)();
float smoothSpeedAIM = 5; 
void *MyPlayer = NULL;
bool Drone;

const float RADAR_SIZE = 200.0f; // kích thước của radar
const ImVec2 RADAR_CENTER(100.0f, 100.0f); // tọa độ trung tâm của radar


   
float x,y;

   float enemy1 = 2.0f;


float aimSmoothness = 0.1f;

inline void DrawAIMBOT(float screenWidth, float screenHeight) {
     
}

inline void DrawESP(float screenWidth, float screenHeight) {
 ImDrawList*draw = ImGui::GetBackgroundDrawList();
    if (!draw) return;   
	
                          //  draw->AddCircle(ImVec2(screenWidth / 2, screenHeight / 2), Fov_Aim, ImColor(255, 255, 255), 0, 1.5f);
         
if (Aimbot) {
      
void* CurrentMatch = Curent_Match();
void* closestEnemy = GetClosestEnemy();
void* LocalPlayer = GetLocalPlayer(CurrentMatch);

if (closestEnemy != NULL && LocalPlayer != NULL && CurrentMatch != NULL) {
    Vector3 targetPosition;
    // Percentage-based targeting from leg to head (0-100%)
    Vector3 headPos = GetHeadPosition(closestEnemy);
    Vector3 bodyPos = getPosition(closestEnemy);
    
    // Ultra-fast tracking for precise headshots
    Vector3 currentEnemyPos = bodyPos;
    Vector3 currentHeadPos = headPos;
    Vector3 enemyVelocity = Vector3(0, 0, 0);
    Vector3 headVelocity = Vector3(0, 0, 0);
    
    if (lastEnemyPos.x != 0 || lastEnemyPos.y != 0 || lastEnemyPos.z != 0) {
        enemyVelocity = currentEnemyPos - lastEnemyPos;
        headVelocity = currentHeadPos - Vector3(lastEnemyPos.x, lastEnemyPos.y + (headPos.y - bodyPos.y), lastEnemyPos.z);
        float distance = Vector3::Distance(currentEnemyPos, lastEnemyPos);
        isTargetMoving = distance > 0.03f; // Ultra-sensitive movement detection
    }
    lastEnemyPos = currentEnemyPos;
    
    // Fast prediction with head-specific tracking
    Vector3 predictedHeadPos = headPos;
    if (isTargetMoving) {
        // Instant prediction for fast tracking
        float predictionTime = 0.05f; // Very fast prediction
        predictedHeadPos = headPos + (headVelocity * predictionTime);
    }
    
    // Direct head targeting with percentage precision
    Vector3 legPos = Vector3(bodyPos.x, bodyPos.y - 0.5f, bodyPos.z); // Leg position
    float fullHeight = predictedHeadPos.y - legPos.y;
    
    // Precise percentage: 0% = legs, 100% = exact head center
    float targetHeight = legPos.y + (headshotPercentage / 100.0f) * fullHeight;
    targetPosition = Vector3(predictedHeadPos.x, targetHeight, predictedHeadPos.z);
    Vector3 PlayerLocation = CameraMain(LocalPlayer);
    
    // Dynamic smoothing based on firing state and target movement
    Vector3 currentAim = GetForward(Component_GetTransform(Camera_main()));
    Vector3 targetDirection = Vector3::Normalized(targetPosition - PlayerLocation);
    
    // Adjust smoothing for fire mode and moving targets
    float smoothFactor = 0.6f; // Default smoothness
    bool IsFiring = get_IsFiring(LocalPlayer);
    
    if (IsFiring && isTargetMoving) {
        smoothFactor = 0.95f; // Ultra-fast responsiveness for firing at moving targets
    } else if (IsFiring) {
        smoothFactor = 0.88f; // Fast responsiveness for firing
    } else if (isTargetMoving) {
        smoothFactor = 0.82f; // Fast tracking for moving targets
    }
    
    Vector3 smoothDirection = Vector3::Lerp(currentAim, targetDirection, smoothFactor);
    Quaternion PlayerLook = GetRotationToLocation(PlayerLocation + smoothDirection * 100.0f, 0.0f, PlayerLocation);
    
    bool IsScopeOn = get_IsSighting(LocalPlayer);

    if (AimWhen == 0) {
        set_aim(LocalPlayer, PlayerLook);
    }
    else if (AimWhen == 1 && IsFiring) {
        set_aim(LocalPlayer, PlayerLook);
        lastAimTarget = targetPosition; // Store for resistance
    }
    else if (AimWhen == 2 && IsScopeOn) {
        set_aim(LocalPlayer, PlayerLook);
    }
}
}

           

    if (Enable) {   
        int totalEnemies = 0, totalBots = 0;
        void *current_Match = Curent_Match();      
        void* local_player = GetLocalPlayer(current_Match);    
      
            
        if (local_player != nullptr && current_Match != nullptr) {              
            monoDictionary<uint8_t *, void **> *players = *(monoDictionary<uint8_t*, void **> **)((long)current_Match +ListPlayer);
            void *camera = Camera_main();
            if (players != nullptr && camera != nullptr) {
                for(int u = 0; u < players->getNumValues(); u++) {                  
                    void* closestEnemy = players->getValues()[u];
                    if (closestEnemy != local_player && closestEnemy != nullptr && get_isVisible(closestEnemy) && !get_isLocalTeam(closestEnemy)) {
                        
                        
                    Vector3 Toepos = getPosition(closestEnemy);
                    Vector3 Toeposi = WorldToScreenPoint(camera, Vector3(Toepos.x, Toepos.y, Toepos.z));
                    if (Toeposi.z < 1) continue;
        
                    
                    
                    Vector3 HeadPos = getPosition(closestEnemy) + Vector3(0, 1.9f, 0);
                    Vector3 HeadPosition = WorldToScreenPoint(camera, Vector3(HeadPos.x, HeadPos.y, HeadPos.z));
                    if (HeadPosition.z < 1) continue;
        
                    
                    
     
		
		
                    
                    
                    
                    
        if (!HideFOV) {
            // Convert FOV degrees to screen radius for circle display
            float fovRadius = (Size / 180.0f) * (screenWidth / 4.0f);
            draw->AddCircle(ImVec2(screenWidth / 2, screenHeight / 2), fovRadius, ImColor(255,255,255), 0, 1.5f);
        }
                        
        float distance = Vector3::Distance(getPosition(local_player), Toepos);
        float Hight = abs(HeadPosition.y - Toeposi.y) * (1.2 / 1.1);
        float Width = Hight * 0.50f;
        Rect rect = Rect(HeadPosition.x - Width / 2.f, screenHeight - HeadPosition.y, Width, Hight);

		
		/*
                        // ESP Line
                           if (Line) {
    ImVec2 start = ImVec2(screenWidth / 2.0f, 10);
    ImVec2 end = ImVec2(rect.x + rect.w / 2.0f, rect.y + rect.h / 2.0f);
    bool isDown = get_IsDieing(closestEnemy);

    // Midpoint start ke 50% distance pe (line split)
    ImVec2 mid = ImVec2(
        start.x + (end.x - start.x) * 0.5f,
        start.y + (end.y - start.y) * 0.5f
    );

    static float hue = 0.0f;
    hue += 0.005f;
    if (hue > 1.0f) hue = 0.0f;

    // Upper part RGB
    ImColor rgbColor = ImColor::HSV(hue, 1.0f, 1.0f);
    // Lower part white or red if down
    ImColor lowerColor = isDown ? ImColor(255, 0, 0) : ImColor(255, 255, 255);

    // Draw thick lines
    draw->AddLine(start, mid, rgbColor, 5.0f);
    draw->AddLine(mid, end, lowerColor, 5.0f);

    // Label (agar chahiye toh)
    const char* label = isDown ? "" : "";
    ImVec2 textPos = ImVec2((start.x + end.x) / 2.0f, (start.y + end.y) / 2.0f - 10);
    draw->AddText(
        ImVec2(textPos.x - ImGui::CalcTextSize(label).x / 2.0f, textPos.y),
        lowerColor,
        label
    );
}
						*/
						
						
						
						
						
						if (Line) {
    // 🟢 Start point: screen ke top bilkul center se
    ImVec2 start = ImVec2(screenWidth / 2.0f, 0.0f);

    // 🔴 End point: box ke top center tak (just upar tak)
    ImVec2 end = ImVec2(rect.x + rect.w / 2.0f, rect.y);

    bool isDown = get_IsDieing(closestEnemy);

    // 🔵 Midpoint
    ImVec2 mid = ImVec2(
        start.x + (end.x - start.x) * 0.5f,
        start.y + (end.y - start.y) * 0.5f
    );

    static float hue = 0.0f;
    hue += 0.005f;
    if (hue > 1.0f) hue = 0.0f;

    // 🌈 Upper part rainbow
    ImColor rgbColor = ImColor::HSV(hue, 1.0f, 1.0f);
    // ⚪ Lower part (white / red if down)
    ImColor lowerColor = isDown ? ImColor(255, 0, 0) : ImColor(255, 255, 255);

    // ✏️ Line draw karna
    draw->AddLine(start, mid, rgbColor, 1.5f);
    draw->AddLine(mid, end, lowerColor, 1.5f);//esp line end

    const char* label = isDown ? "" : "";
    ImVec2 textPos = ImVec2((start.x + end.x) / 2.0f, (start.y + end.y) / 2.0f - 10);
    draw->AddText(
        ImVec2(textPos.x - ImGui::CalcTextSize(label).x / 2.0f, textPos.y),
        lowerColor,
        label
    );
}
						
						
     


if (box) {
    int x = rect.x;
    int y = rect.y;
    int w = rect.w;
    int h = rect.h;

    // 🌈 @MANIx999 हल्का pastel rainbow fill
    float t = ImGui::GetTime() * 0.8f; // speed control
    float rf = (sinf(t) * 0.5f + 0.5f) * 0.5f;   // soft fill color
    float gf = (sinf(t + 2.0f) * 0.5f + 0.5f) * 0.5f;
    float bf = (sinf(t + 4.0f) * 0.5f + 0.5f) * 0.5f;
    ImColor fillColor = ImColor(rf, gf, bf, 0.25f); // opacity 25%

    // ✨ Gradient fill (Top transparent → Bottom light rainbow)
    ImVec4 base = fillColor.Value;
    ImColor topColor = ImColor(ImVec4(base.x, base.y, base.z, 0.05f));
    ImColor bottomColor = ImColor(ImVec4(base.x, base.y, base.z, 0.25f));

    draw->AddRectFilledMultiColor(
        ImVec2(x, y),
        ImVec2(x + w, y + h),
        topColor, topColor,
        bottomColor, bottomColor
    );

    // 👿 अगर enemy dying है तो सिर्फ red border
    ImU32 boxColor = get_IsDieing(closestEnemy)
        ? ImColor(255, 0, 0, 255)
        : ImColor(
            (sinf(t) * 0.5f + 0.5f),        // full bright red
            (sinf(t + 2.0f) * 0.5f + 0.5f), // full bright green
            (sinf(t + 4.0f) * 0.5f + 0.5f), // full bright blue
            1.0f                            // full opacity
          );

    // 📏 Bright border (full brightness + 1.0f thickness)
    float borderThickness = 1.5f;
    draw->AddRect(ImVec2(x, y), ImVec2(x + w, y + h), boxColor, 0.0f, 0, borderThickness);
    draw->AddRect(ImVec2(x + 1, y + 1), ImVec2(x + w - 1, y + h - 1), boxColor, 0.0f, 0, borderThickness);
}


/*
===============================[ 𝗠𝗔𝗗𝗘 𝗕𝗬 @Gringoxp776 ]============================
===============================[ 𝗠𝗔𝗗𝗘 𝗕𝗬 @Gringoxp776 ]============================
===============================[ 𝗠𝗔𝗗𝗘 𝗕𝗬 @Gringoxp776 ]============================

===============================[ 𝗠𝗔𝗗𝗘 𝗕𝗬 @Gringoxp776 ]============================
===============================[ 𝗠𝗔𝗗𝗘 𝗕𝗬 @Gringoxp776 ]============================
===============================[ 𝗠𝗔𝗗𝗘 𝗕𝗬 @Gringoxp776 ]============================

===============================[ 𝗠𝗔𝗗𝗘 𝗕𝗬 @Gringoxp776 ]============================
===============================[ 𝗠𝗔𝗗𝗘 𝗕𝗬 @Gringoxp776 ]============================
===============================[ 𝗠𝗔𝗗𝗘 𝗕𝗬 @Gringoxp776 ]============================
*/

                        if (Target) { 
                            if (get_IsDieing(closestEnemy)) {            
                                if (Target) {  
                                    int xx = rect.x + rect.w + 2;
                                    int yy = rect.y;
                                    draw->AddRectFilled(ImVec2(xx, yy), ImVec2(xx + 5, yy + rect.h), ImColor(0, 0, 0, 255));        
                                    draw->AddRectFilled(ImVec2(xx + 1, yy + rect.h - (rect.h * ((float)GetHp(closestEnemy) / get_MaxHP(closestEnemy)))), ImVec2(xx + 4, yy + rect.h),die);      
                                }
                            }else {
                                long clr = ImColor(0,255,0,255);   

                                if (GetHp(closestEnemy) <= (get_MaxHP(closestEnemy) * 0.6)) {
                                    clr = ImColor(255, 255, 0, 255);
                                }

                                if (GetHp(closestEnemy) < (get_MaxHP(closestEnemy) * 0.3)) {
                                    clr = ImColor(255, 0, 0, 255);
                                }

                                int xx = rect.x + rect.w + 2;
                                int yy = rect.y;
                                draw->AddRectFilled(ImVec2(xx, yy), ImVec2(xx + 5, yy + rect.h), ImColor(0, 0, 0, 255));        
                                draw->AddRectFilled(ImVec2(xx + 1, yy + rect.h - (rect.h * ((float)GetHp(closestEnemy) / get_MaxHP(closestEnemy)))), ImVec2(xx + 4, yy + rect.h),clr);                       
                            }
                        }
				


						 if (Health) {
    monoString* Nick = get_NickName(closestEnemy);
    std::string names;

    if (Nick != nullptr) {
        int len = Nick->getLength();
        for (int i = 0; i < len; i++) {
            char c = get_Chars(Nick, i);
            names += (isascii(c) && isprint(c)) ? c : '?';
        }

        float smallSize = 12.0f;
        float scale = smallSize / ImGui::GetFontSize();

        ImVec2 baseNameSize = ImGui::CalcTextSize(names.c_str());
        ImVec2 nameSize = ImVec2(baseNameSize.x * scale, baseNameSize.y * scale);

        float nameX = rect.x + (rect.w / 2.0f) - (nameSize.x / 2.0f);
        float nameY = rect.y - nameSize.y - 5.0f;

        bool isKnocked = get_IsDieing(closestEnemy);

        // 🎨 Color: yellow if alive, red if knocked
        ImU32 textColor = isKnocked ? IM_COL32(255, 0, 0, 255) : IM_COL32(255, 255, 0, 255);
        ImU32 shadowColor = IM_COL32(0, 0, 0, 200);

        // 🔲 Shadow border
        for (int dx = -1; dx <= 1; dx++) {
            for (int dy = -1; dy <= 1; dy++) {
                if (dx != 0 || dy != 0)
                    draw->AddText(ImGui::GetFont(), smallSize, ImVec2(nameX + dx, nameY + dy), shadowColor, names.c_str());
            }
        }
        // ✨ Main text
        draw->AddText(ImGui::GetFont(), smallSize, ImVec2(nameX, nameY), textColor, names.c_str());
    }
	
	{
		
		
 ImDrawList* draw = ImGui::GetBackgroundDrawList();

if ((totalEnemies + totalBots) > 0) {  // ✅ Show only if any enemy exists
    // Text setup
    std::string topText = "ENEMIES: ";
    std::string enemiesCount = std::to_string(totalEnemies);
    std::string fullText = topText + enemiesCount;
    std::string icon = ICON_FA_EXCLAMATION_TRIANGLE;

    // Font size & padding
    float fontSize = 30.0f;
    float horizontalPadding = 20.0f;
    float verticalPadding = 10.0f;
    float spacing = 10.0f; // space between icon and text

    // Measure sizes
    ImVec2 iconSize = ImGui::CalcTextSize(icon.c_str());
    ImVec2 textSize = ImGui::CalcTextSize(fullText.c_str());
    float totalWidth = iconSize.x + spacing + textSize.x + (horizontalPadding * 2);
    float totalHeight = textSize.y + (verticalPadding * 2);

    // Center position (top of screen)
    ImVec2 pos(g_GlWidth / 2.0f - totalWidth / 2.0f, 65.0f);
    ImVec2 bgStart(pos.x, pos.y);
    ImVec2 bgEnd(pos.x + totalWidth, pos.y + totalHeight);

    // 🔥 Blink animation (sin wave pulse)
    static float time = 0.0f;
    time += ImGui::GetIO().DeltaTime * 3.0f;
    float pulse = (sinf(time) * 0.5f + 0.5f); // 0–1 oscillation

    // 🔹 Colors
    ImColor borderColor = ImColor(0, 180 + int(75 * pulse), 255, 255);
    ImColor iconColor   = ImColor(0, 180 + int(75 * pulse), 255, 255);
    ImColor textColor   = ImColor(255, 255, 0, 255);
    ImColor countColor  = ImColor(0, 200, 255, 255);

    // 🔹 Background (dark)
    draw->AddRectFilled(bgStart, bgEnd, ImColor(0, 0, 0, 230), 6.0f);
    // 🔹 Border
    draw->AddRect(bgStart, bgEnd, borderColor, 6.0f, 0, 3.0f);

    // 🔹 Icon position
    ImVec2 iconPos(bgStart.x + horizontalPadding, bgStart.y + verticalPadding / 2);
    draw->AddText(NULL, fontSize, iconPos, iconColor, icon.c_str());

    // 🔹 Text “ENEMIES: ”
    ImVec2 textPos(iconPos.x + iconSize.x + spacing, iconPos.y);
    draw->AddText(NULL, fontSize, textPos, textColor, "ENEMIES: ");

    // 🔹 Count (move slightly right for clarity)
    ImVec2 countPos(textPos.x + ImGui::CalcTextSize("ENEMIES: ").x, textPos.y);
    draw->AddText(NULL, fontSize, countPos, countColor, enemiesCount.c_str());
}





		if (Distance) {
    char distText[32];
    snprintf(distText, sizeof(distText), "%dm", (int)distance);

    float smallSize = 12.0f;
    float scale = smallSize / ImGui::GetFontSize();

    ImVec2 baseDistSize = ImGui::CalcTextSize(distText);
    ImVec2 distSize = ImVec2(baseDistSize.x * scale, baseDistSize.y * scale);

    float distX = rect.x + (rect.w / 2.0f) - (distSize.x / 2.0f);
    float distY = rect.y + rect.h + 5.0f;

    bool isKnocked = get_IsDieing(closestEnemy);

    // 🎨 Color: yellow if alive, red if knocked
    ImU32 textColor = isKnocked ? IM_COL32(255, 0, 0, 255) : IM_COL32(255, 255, 0, 255);
    ImU32 shadowColor = IM_COL32(0, 0, 0, 200);

    // 🔲 Shadow border
    for (int dx = -1; dx <= 1; dx++) {
        for (int dy = -1; dy <= 1; dy++) {
            if (dx != 0 || dy != 0)
                draw->AddText(ImGui::GetFont(), smallSize, ImVec2(distX + dx, distY + dy), shadowColor, distText);
        }
    }
    // ✨ Main text
    draw->AddText(ImGui::GetFont(), smallSize, ImVec2(distX, distY), textColor, distText);
}
						
    }
}
  }
  }}
                }
            }
        }                  
     // 		}
     //		}
    
    
    
    
    
    
    
 

    
    



     
     
 
bool(*Bypass)(void* bypass); 
bool _Bypass(void* bypass) { 
   return false;
}


