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,
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ local land2 = {
|
||||
local land3 = {
|
||||
offset = 40,
|
||||
scale = 20,
|
||||
spread = {x = 45, y = 20, z = 45},
|
||||
spread = {x = 5, y = 40, z = 5},
|
||||
seed = 472,
|
||||
octaves = 3,
|
||||
persistence = 0.3,
|
||||
@@ -171,9 +171,9 @@ for _, c in ipairs({'landscape', 'temp', 'humidity'}) do
|
||||
})--]]
|
||||
end
|
||||
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 100,{x=3, y=3}, 'landscape')
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 150,{x=3, y=3}, 'temp')
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 200,{x=3, y=3}, 'humidity')
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 100,{x=0, y=0}, 'landscape')
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 150,{x=0, y=0}, 'temp')
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 200,{x=0, y=0}, 'humidity')
|
||||
|
||||
-- [[
|
||||
mapGenerator:registerCavern('midgard', 'cavern1', {
|
||||
|
||||
Reference in New Issue
Block a user