#pragma once
inline void AimbotStart(void* myplayer)
{
    void* camera = GameFunctions::GetUnityCamera();
    if (myplayer && playerList.size() > 0 && camera)
    {
        void* closestEnemy = nullptr;
        float minDistance = 999999;
        for (int i = 0; i < playerList.size(); i++)
        {
            void* enemy = playerList[i];
            if (GameFunctions::isEnemyTo(myplayer, enemy) && !
GameFunctions::isDead(enemy))
            {
                void* myTransform = GameFunctions::GetTransform(myplayer);
                void* enemyTransform = GameFunctions::GetTransform(enemy);
                Vector3 myPos = GameFunctions::GetPosition(myTransform);
                Vector3 enemyPos = GameFunctions::GetPosition(enemyTransform);
                Quaternion myRotation = GameFunctions::get_rotation(myTransform);
                Vector3 enemyScreenPos = GameFunctions::WorldToScreenPoint(camera,
enemyPos, Mono);
                float distance = std::sqrt(pow(enemyPos.X - myPos.X, 2) +
pow(enemyPos.Y - myPos.Y, 2) + pow(enemyPos.Z - myPos.Z, 2));
                static const Vector3 forwardDir(0.0f, 0.0f, 1.0f);
                Vector3 playerForwardDirection = myRotation * forwardDir;
                float screenX = (float)Variables::resolutionX -
((float)Variables::resolutionX - enemyScreenPos.X);
                float screenY = ((float)Variables::resolutionY - enemyScreenPos.Y);
                float screenDistance2Middle2 = sqrt(pow((screenX -
(Variables::resolutionX / 2)), 2) + pow((screenY - (Variables::resolutionY / 2)),
2));
                if (Vector3::Dot(playerForwardDirection, enemyPos - myPos) > 0 &&
Vector3::Magnitude(enemyPos - myPos) < minDistance) // Check if enemy is in front
                {
                    if (Variables::EnableCircleFov)
                    {
                         if (screenDistance2Middle2 <= Variables::CircleFov)
                         {
                             minDistance = Vector3::Magnitude(distance);
                             closestEnemy = enemy;
                         }
                    }
                    else
                    {
                         minDistance = Vector3::Magnitude(distance);
                         closestEnemy = enemy;
                    }
                }
            }
        }
        if (closestEnemy != nullptr)
        {
            void* myTransform =
GameFunctions::GetTransform(GameFunctions::get_playerTransform(myplayer));
            void* closestEnemyTransform =
GameFunctions::GetTransform(closestEnemy);
            Vector3 closestEnemyPos =
GameFunctions::GetPosition(closestEnemyTransform);
            Vector3 enemyScreenPos = GameFunctions::WorldToScreenPoint(camera,
closestEnemyPos, Mono);
            Vector3 myPos =
GameFunctions::GetPosition(GameFunctions::GetTransform(myplayer));
            float distanceToClosestEnemy = Vector3::Magnitude(closestEnemyPos -
myPos);
            if (enemyScreenPos.Z >= 1 && distanceToClosestEnemy < minDistance)
            {
                void *CurrentCamera = GameFunctions::GetCurrentCamera();
                void* CurrentCamTransform =
GameFunctions::GetTransform(CurrentCamera);
                auto camPosition =
GameFunctions::GetPosition(GameFunctions::GetTransform(CurrentCamTransform));
                Vector3 targetEnemyVector =
GameFunctions::InverseTransformPoint(CurrentCamTransform, closestEnemyPos);
                float deltaYaw = (std::atan2(targetEnemyVector.Z,
targetEnemyVector.X)) * 180 / M_PI;
                float distanceVector = std::sqrt(targetEnemyVector.X *
targetEnemyVector.X + targetEnemyVector.Z * targetEnemyVector.Z);
                float pitchOffset = 0.60;
                float deltaPitch = (std::atan2(targetEnemyVector.Y + pitchOffset,
distanceVector)) * 180 / M_PI;
                bool isVisible = !Variables::EnableAimVis ||
GameFunctions::LineOfSight(closestEnemyPos, camPosition);
                if ((Variables::EnableShootcheck && GetAsyncKeyState(VK_LBUTTON) &
0x8000) || !Variables::EnableShootcheck)
                {
                     if (isVisible)
                     {
                         if (Variables::aimbotMode ==
Variables::AimbotMode::LookAtInGame)
                         {
                             GameFunctions::Rotate(CurrentCamTransform, -
(deltaPitch), 0, 0);
                             GameFunctions::Rotate(myTransform, 0, -(deltaYaw - 90),
0);
                         }
                     }
                }
            }
        }
    }
}