Allow biome pos restrictions

pull/2/head
Bram van den Heuvel 2024-04-30 12:15:58 +02:00 committed by Bram
parent 1392ff483d
commit 24f164fc6c
1 changed files with 18 additions and 14 deletions

View File

@ -366,16 +366,18 @@ function internal.clean_shape_def(def)
end end
-- Get the most nearby cave biome -- Get the most nearby cave biome
function internal.closest_cave_biome(heat, humidity) function internal.closest_cave_biome(heat, humidity, pos)
local biome = internal.default_biome() local biome = internal.default_biome()
local d = internal.biome_def_distance(biome, heat, humidity) local d = internal.biome_def_distance(biome, heat, humidity)
for _, def in pairs(noordstar_caves.registered_biomes) do for _, def in pairs(noordstar_caves.registered_biomes) do
local new_d = internal.biome_def_distance(def, heat, humidity) if internal.is_valid_pos(pos, def.minp, def.maxp) then
local new_d = internal.biome_def_distance(def, heat, humidity)
if new_d <= d then if new_d <= d then
biome = def biome = def
d = new_d d = new_d
end
end end
end end
@ -383,16 +385,18 @@ function internal.closest_cave_biome(heat, humidity)
end end
-- Get the most nearby cave shape -- Get the most nearby cave shape
function internal.closest_cave_shape(cnct, vrtcl) function internal.closest_cave_shape(cnct, vrtcl, y)
local shape = internal.default_shape() local shape = internal.default_shape()
local d = internal.shape_def_distance(shape, cnct, vrtcl) local d = internal.shape_def_distance(shape, cnct, vrtcl)
for key, def in pairs(noordstar_caves.registered_shapes) do for key, def in pairs(noordstar_caves.registered_shapes) do
local new_d = internal.shape_def_distance(def, cnct, vrtcl) if def.y_min <= y and y <= def.y_max then
local new_d = internal.shape_def_distance(def, cnct, vrtcl)
if new_d <= d then if new_d <= d then
shape = def shape = def
d = new_d d = new_d
end
end end
end end
@ -516,7 +520,7 @@ function internal.flat_from_cave_bools(minp, maxp)
local cnct = connectivity:get_index(i) local cnct = connectivity:get_index(i)
local vrtcl = verticality:get_index(i) local vrtcl = verticality:get_index(i)
local def = internal.closest_cave_shape(cnct, vrtcl) local def = internal.closest_cave_shape(cnct, vrtcl, pos.y)
return def.name return def.name
end) end)
@ -735,7 +739,7 @@ function internal.generate_caves(data, minp, maxp)
local heat = heat_points:get_index(i) local heat = heat_points:get_index(i)
local humidity = humidity_points:get_index(i) local humidity = humidity_points:get_index(i)
local def = internal.closest_cave_biome(heat, humidity) local def = internal.closest_cave_biome(heat, humidity, pos)
if nt == internal.node_types.floor then if nt == internal.node_types.floor then
place(def.node_floor) place(def.node_floor)