-- HousingDecorGuide/Core/HDG_RoomShapeAtlas.lua
-- Pure data: room shape identifier → atlas element name, footprint, door anchors.
-- Footprint is in canvas cells (not Blizzard's internal grid units). Default door
-- anchor is the midpoint of each occupied side; renderer uses these as line
-- start/end points and as orb positions for unoccupied doors.

local _, privateDB = ...
local M = {}

-- shape ID → { atlas, cells = {w, h}, doors = {N|E|S|W} }
-- Atlas names verified against DevTools/atlas/data/UiTextureAtlasElement.csv.
-- NOTE: Blizzard misspells "Octogon" (Octagon). Atlas names use the misspelling.
local SHAPES = {
    closet_xs        = { atlas = "Layout_Closet_XS_Icon",                 cells = {1, 1}, doors = {"N","S"} },
    square_xs        = { atlas = "Layout_Square_XS_Icon",                 cells = {1, 1}, doors = {"N","E","S","W"} },
    square_s         = { atlas = "Layout_Square_S_Icon",                  cells = {2, 2}, doors = {"N","E","S","W"} },
    square_m         = { atlas = "Layout_Square_M_Icon",                  cells = {3, 3}, doors = {"N","E","S","W"} },
    square_l         = { atlas = "Layout_Square_L_Icon",                  cells = {4, 4}, doors = {"N","E","S","W"} },
    octagon_s        = { atlas = "Layout_Octogon_S_Icon",                 cells = {2, 2}, doors = {"N","E","S","W"} },
    octagon_m        = { atlas = "Layout_Octogon_M_Icon",                 cells = {3, 3}, doors = {"N","E","S","W"} },
    octagon_l        = { atlas = "Layout_Octogon_L_Icon",                 cells = {4, 4}, doors = {"N","E","S","W"} },
    l_shape          = { atlas = "Layout_L-Shape_S_Icon",                 cells = {2, 2}, doors = {"E","W"} },
    t_shape          = { atlas = "Layout_T-Shape_S_Icon",                 cells = {2, 2}, doors = {"N","E","W"} },
    cross_shape      = { atlas = "Layout_Cross_S_Icon",                   cells = {3, 3}, doors = {"N","E","S","W"} },
    hallway          = { atlas = "Layout_Hallway_S_Icon",                 cells = {2, 1}, doors = {"E","W"} },
    tall_room        = { atlas = "Layout_TallRoom_S_Icon",                cells = {2, 2}, doors = {"N","E","S","W"} },
    staircase        = { atlas = "Layout_Staircase_S_Icon",               cells = {2, 2}, doors = {"N","S"} },
    staircase_mirror = { atlas = "Layout_Staircase_Mirrored_S_Icon",      cells = {2, 2}, doors = {"N","S"} },
    circle_evening   = { atlas = "Full_Layout_Artisinal_Garden_Evening",  cells = {3, 3}, doors = {"N"} },
    circle_daylight  = { atlas = "Full_Layout_Artisinal_Garden_Daylight", cells = {3, 3}, doors = {"N"} },
    -- Fallback for Entry-shaped rooms — render as a small square
    entry            = { atlas = "Layout_Square_XS_Icon",                 cells = {1, 1}, doors = {"N"} },
}

function M.GetShape(shapeID)
    return SHAPES[shapeID]
end

function M.GetAtlas(shapeID)
    local s = SHAPES[shapeID]
    return s and s.atlas
end

function M.GetCells(shapeID)
    local s = SHAPES[shapeID]
    return s and s.cells or { 1, 1 }
end

function M.GetDoors(shapeID)
    local s = SHAPES[shapeID]
    return s and s.doors or {}
end

function M.IsKnown(shapeID)
    return SHAPES[shapeID] ~= nil
end

if privateDB then privateDB.HDG_RoomShapeAtlas = M end
return M
