local GloveSizeX, GloveSizeY <const> = Glove:getSize()
local GloveOffX, GloveOffY <const> = GloveSizeX / 2, GloveSizeY / 2

---@param ball Point3d
---@param fielderX number
---@param fielderY number
---@return boolean isHoldingBall
local function drawFielderGlove(ball, fielderX, fielderY, flip)
    local distanceFromBall = utils.distanceBetweenZ(fielderX, fielderY, 0, ball.x, ball.y, ball.z)
    local shoulderX, shoulderY = fielderX + 10, fielderY - 5
    if distanceFromBall > 20 then
        Glove:draw(shoulderX, shoulderY, flip)
        return false
    else
        GloveHoldingBall:draw(ball.x - GloveOffX, ball.y - GloveOffY, flip)
        return true
    end
end

---@param playerSprites PlayerImageBundle
---@param ball Point3d
---@param x number
---@param y number
---@return boolean isHoldingBall
function drawFielder(playerSprites, ball, x, y, flip)
    playerSprites.smiling:draw(x, y - 20, flip)
    return drawFielderGlove(ball, x, y)
end
