Expose cell_gid query for multi-atlas v2 maps

Adds M.cell_gid(layer_name, x, y, map_id) to read raw GID values from
named layers, enabling callers to decode atlas/tile/rotation from any
layer without going through tile_at().

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Axel Meyer
2026-05-21 15:43:02 +02:00
parent 6af36e9c6e
commit 880c67fef3

View File

@@ -438,6 +438,15 @@ function M.has_layer(layer_name, map_id)
return m.layers and m.layers[layer_name] ~= nil
end
function M.cell_gid(layer_name, x, y, map_id)
local id = map_id or current_map_id
if not id then error("maps.cell_gid: no current map") end
local m = map_registry[id]
if not m.layers or not m.layers[layer_name] then return 0 end
if x < 0 or x >= m.size.w or y < 0 or y >= m.size.h then return 0 end
return m.layers[layer_name].tiles[y * m.size.w + x + 1] or 0
end
function M.is_indoor(x, y, map_id)
local id = map_id or current_map_id
if not id then error("maps.is_indoor: no current map") end