MapGen: Fixed map mirroring. Added an isometric grid map
This commit is contained in:
@@ -355,17 +355,34 @@ end
|
||||
---@param category MapGen.Layer.Category Category indicating what will be generated by peaks.
|
||||
---@param groups? table<string, number> Groups that will be added to all peaks.
|
||||
function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category, groups)
|
||||
if scale < 2 then
|
||||
error('The map scale should not be less than 2.')
|
||||
end
|
||||
|
||||
local modPath = core.get_modpath(core.get_current_modname())
|
||||
local peaks = ff2luat(modPath .. '/textures/maps/' .. map)
|
||||
|
||||
---@type {h:integer, w:integer}
|
||||
local mapSize = peaks.size
|
||||
peaks.size = nil
|
||||
|
||||
zeroPos.x = zeroPos.x + mathRound(mapSize.w/2)
|
||||
zeroPos.y = zeroPos.y + mathRound(mapSize.h/2)
|
||||
|
||||
local x, z
|
||||
|
||||
for color, peaksPos in pairs(peaks) do
|
||||
for _, peakPos in ipairs(peaksPos) do
|
||||
x, z = (peakPos.x - zeroPos.x - 1) * scale, (peakPos.y - zeroPos.y - 1) * -scale
|
||||
|
||||
-- Converting a rectangular grid into an isometric-like one.
|
||||
if peakPos.y % 2 == 1 then
|
||||
x = x + (scale/2)
|
||||
end
|
||||
|
||||
---@type MapGen.PeakDef
|
||||
local def = {
|
||||
pos = vector.new((peakPos.x - zeroPos.x - 1) * scale, 0, (peakPos.y - zeroPos.y - 1) * scale),
|
||||
pos = vector.new(x, 0, z),
|
||||
color = color,
|
||||
groups = groups,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user