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,11 +366,12 @@ function internal.clean_shape_def(def)
end
-- 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 d = internal.biome_def_distance(biome, heat, humidity)
for _, def in pairs(noordstar_caves.registered_biomes) do
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
@ -378,16 +379,18 @@ function internal.closest_cave_biome(heat, humidity)
d = new_d
end
end
end
return biome
end
-- 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 d = internal.shape_def_distance(shape, cnct, vrtcl)
for key, def in pairs(noordstar_caves.registered_shapes) do
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
@ -395,6 +398,7 @@ function internal.closest_cave_shape(cnct, vrtcl)
d = new_d
end
end
end
return shape
end
@ -516,7 +520,7 @@ function internal.flat_from_cave_bools(minp, maxp)
local cnct = connectivity: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
end)
@ -735,7 +739,7 @@ function internal.generate_caves(data, minp, maxp)
local heat = heat_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
place(def.node_floor)