--- @class TileAtlasData
--- @field atlas love.Image
--- @field quad love.Quad
local tileAtlasData = {}
tileAtlasData.__index = tileAtlasData

-----------------------------------------------------------------

--- @class Tile
--- @field atlasData TileAtlasData
--- @field position Vec3
--- @field walkable boolean
local tile = {
    walkable = true
}
tile.__index = tile

--- TODO: сделать как love.graphics.draw несколько сигнатур у функции
--- @param atlasData TileAtlasData
local function new(atlasData)
    return setmetatable({
        atlasData = setmetatable(atlasData, tileAtlasData)
    }, tile)
end

function tile:draw()
    love.graphics.draw(self.atlasData.atlas, self.atlasData.quad, self.position.x,
        self.position.y,
        nil, 1 / 32, 1 / 32)
end

--- @param values table
--- @return Tile
function tile:copyWith(values)
    for k, v in pairs(self) do
        values[k] = v
    end
    return setmetatable(values, tile)
end

--- @param quad love.Quad
--- @param isClip boolean
local function fromQuad(quad, isClip)
    return setmetatable({
        isClip = isClip,
        quad = quad
    })
end

return { new = new }
