move test caves to base:demo
This commit is contained in:
parent
5966ca5617
commit
c022e11c3b
@ -1,3 +1,13 @@
|
||||
-- Get entry-point and filename from `entry-point:filename` path
|
||||
-- // TODO: move to stdmin
|
||||
function parse_path(path)
|
||||
local index = string.find(path, ':')
|
||||
if index == nil then
|
||||
error("invalid path syntax (':' missing)")
|
||||
end
|
||||
return string.sub(path, 1, index-1), string.sub(path, index+1, -1)
|
||||
end
|
||||
|
||||
local _, dir = parse_path(__DIR__)
|
||||
ores = file.read_combined_list(dir.."/ores.json")
|
||||
|
||||
@ -26,6 +36,17 @@ end
|
||||
function place_structures(x, z, w, d, seed, hmap, chunk_height)
|
||||
local placements = {}
|
||||
place_ores(placements, x, z, w, d, seed, hmap, chunk_height)
|
||||
|
||||
if math.random() < 0.1 then -- generate caves
|
||||
local sy = math.random() * (chunk_height / 2)
|
||||
local ey = math.random() * (chunk_height / 2)
|
||||
local sx = x + math.random() * 20 - 10
|
||||
local ex = x + math.random() * 20 - 10
|
||||
local sz = z + math.random() * 20 - 10
|
||||
local ez = z + math.random() * 20 - 10
|
||||
table.insert(placements,
|
||||
{":line", 0, {sx - 10, sy, sz - 10}, {ex + 10, ey, ez + 10}, 3})
|
||||
end
|
||||
return placements
|
||||
end
|
||||
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
-- TODO: delete this file after caves complete implementation
|
||||
|
||||
function generate_heightmap(x, y, w, h, seed, s)
|
||||
local map = Heightmap(w, h)
|
||||
map:add(0.25)
|
||||
return map
|
||||
end
|
||||
|
||||
|
||||
function place_structures(x, z, w, d, seed, hmap, chunk_height)
|
||||
local placements = {}
|
||||
do
|
||||
local sy = math.random() * (chunk_height / 4)
|
||||
local ey = math.random() * (chunk_height / 4)
|
||||
local sx = x + math.random() * 20 - 10
|
||||
local ex = x + math.random() * 20 - 10
|
||||
local sz = z + math.random() * 20 - 10
|
||||
local ez = z + math.random() * 20 - 10
|
||||
table.insert(placements,
|
||||
{":line", 0, {sx - 10, sy, sz - 10}, {ex + 10, ey, ez + 10}, 3})
|
||||
end
|
||||
return placements
|
||||
end
|
||||
@ -341,7 +341,13 @@ void WorldGenerator::generate(voxel* voxels, int chunkX, int chunkZ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
generateLines(prototype, voxels, chunkX, chunkZ);
|
||||
generateStructures(prototype, voxels, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
void WorldGenerator::generateStructures(
|
||||
const ChunkPrototype& prototype, voxel* voxels, int chunkX, int chunkZ
|
||||
) {
|
||||
for (const auto& placement : prototype.structures) {
|
||||
if (placement.structure < 0 || placement.structure >= def.structures.size()) {
|
||||
logger.error() << "invalid structure index " << placement.structure;
|
||||
@ -380,7 +386,6 @@ void WorldGenerator::generate(voxel* voxels, int chunkX, int chunkZ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
generateLines(prototype, voxels, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
void WorldGenerator::generateLines(
|
||||
|
||||
@ -80,6 +80,9 @@ class WorldGenerator {
|
||||
void generateLines(
|
||||
const ChunkPrototype& prototype, voxel* voxels, int x, int z
|
||||
);
|
||||
void generateStructures(
|
||||
const ChunkPrototype& prototype, voxel* voxels, int x, int z
|
||||
);
|
||||
public:
|
||||
WorldGenerator(
|
||||
const GeneratorDef& def,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user