MapGen: add draft tree generation

This commit is contained in:
Van
2026-06-14 21:01:38 +03:00
parent 9252cf429c
commit ce38f752f7
8 changed files with 470 additions and 213 deletions

Binary file not shown.

View File

@@ -40,7 +40,7 @@ dofile(core.get_modpath('smc__system__table')..'/init.lua')
-- TODO: пока что закоментировано, поскольку вызывает ошибку из-за global_step
-- Smc lib loader
-- dofile(core.get_modpath('smc__system__helper_lib')..'/init.lua')
Smc = {}
Smc = {isAsync = true}
dofile(core.get_modpath('smc__system__helper_lib')..'/src/Lib/color.lua')
---@type MapGen

View File

@@ -699,15 +699,18 @@ local ryeNoise
---@param mapGenerator MapGen
---@param nodeType MapGen.nodeType
---@param area VoxelArea
local function meadowPostProcessing(biome, mapGenerator, factors, data, data2, index, x, y, z, nodeType, area)
---@param voxelManip VoxelManip
local function meadowPostProcessing(biome, mapGenerator, factors, data, data2, index, x, y, z, nodeType, area, voxelManip)
if nodeType ~= 'TURF' then
return
end
local i = area:index(x,y+1,z)
if ryeNoise == nil then ryeNoise = core.get_value_noise(ryeNoiseParams) end
local value = ryeNoise:get_2d({x=x, y=z}) + math.random(0, 5)
local i = area:index(x,y+1,z)
if value > 8 then
data[i] = id('plants:rye')
@@ -737,11 +740,128 @@ mapGenerator:registerBiome('midgard', 'green_meadow', {
bottom = 'soils:humus',
},
soilHeight = 5,
postProcessing = meadowPostProcessing,
dataPostProcessing = meadowPostProcessing,
vmPostProcessing = function(self, mapGenerator, factors, voxelManip, x, y, z, nodeType, area)
if nodeType ~= 'TURF' then
return
end
if ryeNoise == nil then ryeNoise = core.get_value_noise(ryeNoiseParams) end
local value = ryeNoise:get_2d({x=x, y=z}) + math.random(0, 5)
if value > 8 then
if math.random(0, 10) > 9 then
---@type MapVector
local pos = v(x, y+1, z)
mapGenerator:getTree('test_tree'):placeOnVM(voxelManip, pos)
end
end
end
--generateRock = generateRock,
--generateTurf = generateTurf,
--generateSoil = generateSoil,
--postProcessing = postProcessing
})
mapGenerator:registerTree('test_tree', {
path = core.get_modpath(core.get_current_modname())..'/schems/test_tree.mts',
})
return mapGenerator
--[[
mapGenerator:registerCavern('midgard', 'test_cavern', {
noiseParams = {
baseNoise = {
offset = 0,
scale = 1,
spread = {x = 20000, y = 8, z = 8},
seed = 88005553535,
octaves = 2,
persistence = 0.6,
lacunarity = 2
},
xNoise = {
offset = 0,
scale = 10,
spread = {x = 50, y = 30, z = 30},
seed = 42,
octaves = 2,
persistence = 0.6,
lacunarity = 2
},
yNoise = {
offset = 0,
scale = 10,
spread = {x = 50, y = 10, z = 30},
seed = 34,
octaves = 2,
persistence = 0.6,
lacunarity = 2
},
zNoise = {
offset = 0,
scale = 10,
spread = {x = 50, y = 30, z = 30},
seed = 12,
octaves = 2,
persistence = 0.6,
lacunarity = 2
},
},
threshold = 0.9,
smoothDistance = 10,
maxY = 100,
minY = -500,
isEroded = true,
step = 100
})
mapGenerator:registerCavern('midgard', 'test_cavern2', {
noiseParams = {
baseNoise = {
offset = 0,
scale = 1,
spread = {x = 2000, y = 100, z = 100},
seed = 880055253535,
octaves = 2,
persistence = 0.6,
lacunarity = 2
},
xNoise = {
offset = 2,
scale = 2,
spread = {x = 100, y = 600, z = 600},
seed = 423,
octaves = 2,
persistence = 0.6,
lacunarity = 2
},
yNoise = {
offset = 2,
scale = 2,
spread = {x = 100, y = 600, z = 600},
seed = 342,
octaves = 2,
persistence = 0.6,
lacunarity = 2
},
zNoise = {
offset = 2,
scale = 2,
spread = {x = 100, y = 600, z = 600},
seed = 132,
octaves = 2,
persistence = 0.6,
lacunarity = 2
},
},
threshold = 0.9,
smoothDistance = 10,
maxY = 100,
minY = -500,
isEroded = true,
step = 100
})--]]