Files
impostor/inc/map/map.manager.lua
Zsolt Tasnadi 76964f872d
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
docs
2026-02-22 00:30:12 +01:00

47 lines
1016 B
Lua

-- Manages game maps.
local _maps = {}
--- Gets all registered maps as an array.
-- @return table An array of registered map data.
function Map.get_maps_array()
local maps_array = {}
for _, map_data in pairs(_maps) do
table.insert(maps_array, map_data)
end
return maps_array
end
--- Registers a map definition.
-- @param map_data table The map data table.
function Map.register(map_data)
if _maps[map_data.id] then
trace("Warning: Overwriting map with id: " .. map_data.id)
end
_maps[map_data.id] = map_data
end
--- Gets a map by ID.
-- @param map_id string The ID of the map.
-- @return table The map data table or nil.
function Map.get_by_id(map_id)
return _maps[map_id]
end
--- Draws a map.
-- @param map_id string The ID of the map to draw.
function Map.draw(map_id)
local map_data = Map.get_by_id(map_id)
if not map_data then
return
end
map(
map_data.from_x,
map_data.from_y,
map_data.width,
map_data.height,
map_data.to_x,
map_data.to_y
)
end