add a function in here that prints out the current break accel class TimeToReachCalculatorv2 {
public:
    static float calculateTimeToReach(const PlayerData& player, const Vec& targetPos) {
        // Extract position and velocity
        Vec carPos = player.phys.pos;
        Vec carVel = player.phys.vel;

        // Calculate direction and distance to target
        Vec targetVector = targetPos - carPos;
        float initialDist = targetVector.Length() - CommonValues::BALL_RADIUS;
        float dist = RS_MAX(initialDist, 0.0f); // Prevent negative distances

        // Normalize direction
        Vec dirToTarget = (dist > 0.0f) ? targetVector.Normalized() : Vec{ 0.0f, 0.0f, 0.0f };

        // Velocity towards target
        float vel = carVel.Dot(dirToTarget);

        // Calculate rotation and surface times
        float rotTime = calculateRotationTime(player, targetPos);
        float timeToSurface = calculateTimeToReachAnySurface(player); // Time to land on the ground

        // If already within threshold, return 0
        if (dist <= DIST_REACH_THRESH) {
            return 0.0f;
        }

        // --------------------
        // Time to Reach in Air Only
        // --------------------
        float timeInAir = 0.0f;
        float curDistAir = dist;
        float curVelAir = vel;
        bool hasAppliedFlipAir = false;

        while (curDistAir > DIST_REACH_THRESH && timeInAir < FLT_MAX) {
            bool hasRotated = timeInAir >= rotTime;

            // Apply initial Flip Force once
            if (!hasAppliedFlipAir && curVelAir < MAX_TOTAL_SPEED) {
                curVelAir += FLIP_FORCE;
                hasAppliedFlipAir = true;
            }

            // Apply air-based accelerations
            if (curVelAir < 0.0f) {
                // Braking in air
                curVelAir += (AIR_ACCEL + BOOST_ACCEL_AIR * hasRotated) * STEP_INTERVAL;
            }
            else if (curVelAir < MAX_TOTAL_SPEED) {
                // Boosting in air
                curVelAir += (BOOST_ACCEL_AIR * hasRotated) * STEP_INTERVAL;
            }

            // Clamp velocity
            curVelAir = RS_CLAMP(curVelAir, 0.0f, MAX_TOTAL_SPEED);

            // Calculate potential distance covered in this step
            float potentialMove = curVelAir * STEP_INTERVAL;

            if (potentialMove >= (curDistAir - DIST_REACH_THRESH)) {
                // Calculate the exact time needed for the remaining distance
                float remainingDist = curDistAir - DIST_REACH_THRESH;
                if (curVelAir > 0.0f) {
                    float partialStep = remainingDist / curVelAir;
                    timeInAir += partialStep;
                }
                else {
                    // Cannot reach the target with zero velocity
                    timeInAir = FLT_MAX;
                }
                break;
            }
            else {
                // Normal step
                timeInAir += STEP_INTERVAL;
                curDistAir -= potentialMove;
            }
        }

        // --------------------
        // Time to Reach on Ground After Landing
        // --------------------
        float timeOnGround = 0.0f;
        float curDistGround = dist;
        float curVelGround = vel;
        bool hasAppliedFlipGround = false;

        while (curDistGround > DIST_REACH_THRESH && timeOnGround < FLT_MAX) {
            bool hasRotated = timeOnGround >= rotTime;

            // Apply initial Flip Force once
            if (!hasAppliedFlipGround && curVelGround < MAX_TOTAL_SPEED) {
                curVelGround += FLIP_FORCE;
                hasAppliedFlipGround = true;
            }

            // Apply ground-based accelerations
            if (curVelGround < 0.0f) {
                // Braking on ground
                curVelGround += (BRAKE_ACCEL + BOOST_ACCEL_GROUND * hasRotated) * STEP_INTERVAL;
            }
            else if (curVelGround < MAX_DRIVE_SPEED) {
                // Driving on ground
                curVelGround += (DRIVE_ACCEL + BOOST_ACCEL_GROUND * hasRotated) * STEP_INTERVAL;
            }
            else if (curVelGround < MAX_TOTAL_SPEED) {
                // Boosting on ground
                curVelGround += (BOOST_ACCEL_GROUND * hasRotated) * STEP_INTERVAL;
            }

            // Clamp velocity
            curVelGround = RS_CLAMP(curVelGround, 0.0f, MAX_TOTAL_SPEED);

            // Calculate potential distance covered in this step
            float potentialMove = curVelGround * STEP_INTERVAL;

            if (potentialMove >= (curDistGround - DIST_REACH_THRESH)) {
                // Calculate the exact time needed for the remaining distance
                float remainingDist = curDistGround - DIST_REACH_THRESH;
                if (curVelGround > 0.0f) {
                    float partialStep = remainingDist / curVelGround;
                    timeOnGround += partialStep;
                }
                else {
                    // Cannot reach the target with zero velocity
                    timeOnGround = FLT_MAX;
                }
                break;
            }
            else {
                // Normal step
                timeOnGround += STEP_INTERVAL;
                curDistGround -= potentialMove;
            }
        }

        // --------------------
        // Final Time Calculation
        // --------------------
        float totalAirTime = timeInAir;
        float totalGroundTime = timeToSurface + timeOnGround;

        // Handle invalid paths
        if (totalAirTime == FLT_MAX && totalGroundTime == FLT_MAX) {
            return FLT_MAX; // Indicate failure to reach the target
        }

        if (totalAirTime == FLT_MAX) {
            return totalGroundTime;
        }

        if (totalGroundTime == FLT_MAX) {
            return totalAirTime;
        }

        // Return the minimum of the two times
        return RS_MIN(totalAirTime, totalGroundTime);
    }

private:
    // Constants
    static constexpr float SIDE_WALL_X = 4096.0f;
    static constexpr float CLOSE_DISTANCE = 10.0f;
    static constexpr float NEAR_WALL_DISTANCE = 4077.0f;
    static constexpr float Z_THRESHOLD = 256.0f;
    static constexpr float EPSILON = 1e-3f;
    static constexpr float DIST_REACH_THRESH = 80.0f;
    static constexpr float STEP_INTERVAL = 1.0f / 60.0f;
    static constexpr float FLIP_FORCE = 495.0f;
    static constexpr float AIR_ACCEL = 133.334f;
    static constexpr float BOOST_ACCEL_AIR = 2116.666f;
    static constexpr float MAX_TOTAL_SPEED = 2300.0f;
    static constexpr float BRAKE_ACCEL = -3500.0f;
    static constexpr float BOOST_ACCEL_GROUND = 1983.332f;
    static constexpr float DRIVE_ACCEL = 1600.0f;
    static constexpr float MAX_DRIVE_SPEED = 1410.0f;
    static constexpr float GRAVITY_Z = -650.0f;
    static constexpr float BACK_WALL_Y = 5120.0f;
    static constexpr float NEG_BACK_WALL_Y = -5120.0f;
    static constexpr float MAX_BACKWALL_Y = 5100.0f;
    static constexpr float BOOST_ACCEL_POS = 1000.0f;
    static constexpr float BOOST_ACCEL_NEG = -1000.0f;
    static constexpr float FLOOR_Z = 18.0f;
    static constexpr float BOOST_ACCEL_DOWN = -1000.0f;
    static constexpr float MAX_TIME = 10.0f;
    static constexpr float JUMP_IMPULSE = 291.667f;
    static constexpr float GROUND_Z_THRESHOLD = 50.0f;


    static float calculateTimeToReachAir(const PlayerData& player, const Vec& targetPos) {
        Vec carPos = player.phys.pos;
        Vec carVel = player.phys.vel;
        Vec dirToTarget = (targetPos - carPos).Normalized();
        float dist = (targetPos - carPos).Length() - CommonValues::BALL_RADIUS;
        float vel = carVel.Dot(dirToTarget);
        float rotTime = calculateRotationTime(player, targetPos);

        float t = 0;
        for (float curDist = dist, curVel = vel; curDist > DIST_REACH_THRESH; t += STEP_INTERVAL, curDist -= curVel * STEP_INTERVAL) {
            bool hasRotated = t >= rotTime;

            if (curVel < MAX_TOTAL_SPEED && t == 0) {
                // Initial jump/dodge impulse
                curVel += JUMP_IMPULSE;
            }

            // Apply air acceleration and boost
            float accel = AIR_ACCEL + (hasRotated ? BOOST_ACCEL_AIR : 0);
            curVel += accel * STEP_INTERVAL;

            // Apply gravity (project it onto the direction to target)
            float gravityComponent = GRAVITY_Z * dirToTarget.z;
            curVel += gravityComponent * STEP_INTERVAL;

            if (curVel >= MAX_TOTAL_SPEED) {
                return t + (curDist / curVel);
            }
        }

        return t;
    }

    static float calculateTimeToSideWalls(const PlayerData& player) {
        const Vec& pos = player.phys.pos;
        const Vec& vel = player.phys.vel;

        float minTime = std::numeric_limits<float>::infinity();

        if (std::abs(pos.x) >= NEAR_WALL_DISTANCE && std::abs(pos.x) <= SIDE_WALL_X) {
            return 0.0f;
        }

        if (vel.x > EPSILON) {
            float a = 0.5f * DRIVE_ACCEL;
            float b = vel.x;
            float c = pos.x - SIDE_WALL_X;

            float discriminant = b * b - 4.0f * a * c;

            if (discriminant >= 0.0f) {
                float sqrtD = std::sqrt(discriminant);
                float t1 = (-b + sqrtD) / (2.0f * a);
                float t2 = (-b - sqrtD) / (2.0f * a);

                if (t1 > EPSILON && t1 < minTime) {
                    minTime = t1;
                }
                if (t2 > EPSILON && t2 < minTime) {
                    minTime = t2;
                }
            }
        }

        if (vel.x < -EPSILON) {
            float a = 0.5f * (-DRIVE_ACCEL);
            float b = vel.x;
            float c = pos.x + SIDE_WALL_X;

            float discriminant = b * b - 4.0f * a * c;

            if (discriminant >= 0.0f) {
                float sqrtD = std::sqrt(discriminant);
                float t1 = (-b + sqrtD) / (2.0f * a);
                float t2 = (-b - sqrtD) / (2.0f * a);

                if (t1 > EPSILON && t1 < minTime) {
                    minTime = t1;
                }
                if (t2 > EPSILON && t2 < minTime) {
                    minTime = t2;
                }
            }
        }

        return minTime;
    }

    static float calculateTimeToBackWalls(const PlayerData& player) {
        const Vec& pos = player.phys.pos;
        const Vec& vel = player.phys.vel;

        float minTime = std::numeric_limits<float>::infinity();

        if (pos.y >= MAX_BACKWALL_Y || pos.y <= -MAX_BACKWALL_Y) {
            return 0.0f;
        }

        if (pos.y >= BACK_WALL_Y || pos.y <= NEG_BACK_WALL_Y) {
            return 0.0f;
        }

        if (vel.y > EPSILON) {
            float a = 0.5f * BOOST_ACCEL_POS;
            float b = vel.y;
            float c = pos.y - BACK_WALL_Y;

            float discriminant = b * b - 4.0f * a * c;

            if (discriminant >= 0.0f) {
                float sqrtD = std::sqrt(discriminant);
                float t1 = (-b + sqrtD) / (2.0f * a);
                float t2 = (-b - sqrtD) / (2.0f * a);

                if (t1 > EPSILON && t1 < minTime) {
                    minTime = t1;
                }
                if (t2 > EPSILON && t2 < minTime) {
                    minTime = t2;
                }
            }
        }

        if (vel.y < -EPSILON) {
            float a = 0.5f * BOOST_ACCEL_NEG;
            float b = vel.y;
            float c = pos.y - NEG_BACK_WALL_Y;

            float discriminant = b * b - 4.0f * a * c;

            if (discriminant >= 0.0f) {
                float sqrtD = std::sqrt(discriminant);
                float t1 = (-b + sqrtD) / (2.0f * a);
                float t2 = (-b - sqrtD) / (2.0f * a);

                if (t1 > EPSILON && t1 < minTime) {
                    minTime = t1;
                }
                if (t2 > EPSILON && t2 < minTime) {
                    minTime = t2;
                }
            }
        }

        return minTime;
    }

    static float calculateTimeToFloor(const PlayerData& player) {
        const Vec& pos = player.phys.pos;
        const Vec& vel = player.phys.vel;

        if (pos.z <= FLOOR_Z) {
            return 0.0f;
        }

        float totalAccel = GRAVITY_Z + BOOST_ACCEL_DOWN;

        float a = 0.5f * totalAccel;
        float b = vel.z;
        float c = pos.z - FLOOR_Z;

        float discriminant = b * b - 4.0f * a * c;

        if (discriminant < 0.0f) {
            return std::numeric_limits<float>::infinity();
        }

        float sqrtD = std::sqrt(discriminant);
        float t1 = (-b - sqrtD) / (2.0f * a);
        float t2 = (-b + sqrtD) / (2.0f * a);

        float timeToFloor = std::numeric_limits<float>::infinity();

        if (t1 > 0.0f) {
            timeToFloor = t1;
        }
        if (t2 > 0.0f && t2 < timeToFloor) {
            timeToFloor = t2;
        }

        return timeToFloor;
    }

    

    static float calculateTimeToReachAnySurface(const PlayerData& player) {
        // Calculate individual times to each surface
        float timeToSideWalls = calculateTimeToSideWalls(player);
        // RG_LOG(timeToSideWalls); // Uncomment if logging is needed

        float timeToBackWalls = calculateTimeToBackWalls(player);
        //RG_LOG(timeToBackWalls); // Uncomment if logging is needed

        float timeToFloor = calculateTimeToFloor(player);
        // RG_LOG(timeToFloor); // Uncomment if logging is needed

        // Assign identifier variables for clarity
        float minTimeBetweenBackWallsAndFloor = RS_MIN(timeToBackWalls, timeToFloor);

        // Now find the minimum time among side walls and the previously computed minimum
        float minTime = RS_MIN(timeToSideWalls, minTimeBetweenBackWallsAndFloor);

        return minTime;
    }

    static float calculateRotationTime(const PlayerData& player, const Vec& targetPos) {
        constexpr float MAX_ANG_VEL = 5.5f * 0.9f;

        Vec playerPos = player.phys.pos;
        Vec playerForward = player.phys.rotMat.forward;
        Vec dirToTarget = (targetPos - playerPos).Normalized();
        float dotProduct = RS_CLAMP(playerForward.Dot(dirToTarget), -1.0f, 1.0f);
        float angleDiff = std::acos(dotProduct);

        return angleDiff / MAX_ANG_VEL;
    }
};