From 294f3b82ef39c99d39d14c0ffc09012c5253c1e5 Mon Sep 17 00:00:00 2001 From: MDietermann Date: Sun, 31 May 2026 21:51:57 +0200 Subject: [PATCH] feat: add WorldConstants, SurfacePalette and IBiome contract --- World/WorldGen/IBiome.cs | 17 +++++++++++++++++ World/WorldGen/SurfacePalette.cs | 7 +++++++ World/WorldGen/WorldConstants.cs | 10 ++++++++++ 3 files changed, 34 insertions(+) create mode 100644 World/WorldGen/IBiome.cs create mode 100644 World/WorldGen/SurfacePalette.cs create mode 100644 World/WorldGen/WorldConstants.cs diff --git a/World/WorldGen/IBiome.cs b/World/WorldGen/IBiome.cs new file mode 100644 index 0000000..6b573cc --- /dev/null +++ b/World/WorldGen/IBiome.cs @@ -0,0 +1,17 @@ +using VoxelEngine.World.Blocks; + +namespace VoxelEngine.World.WorldGen; + +public interface IBiome +{ + string Name { get; } + + // Absolute target surface height at the column (continuous, pre-rounding). + float SampleHeight(NoiseSource noise, float worldX, float worldZ); + + SurfacePalette Surface { get; } + + // Surface block for a given height; lets biomes vary the top by altitude + // (e.g. Mountains use Snow above the snow line). Defaults to Surface.Top. + IBlock TopBlock(int worldY); +} diff --git a/World/WorldGen/SurfacePalette.cs b/World/WorldGen/SurfacePalette.cs new file mode 100644 index 0000000..5c6a908 --- /dev/null +++ b/World/WorldGen/SurfacePalette.cs @@ -0,0 +1,7 @@ +using VoxelEngine.World.Blocks; + +namespace VoxelEngine.World.WorldGen; + +// Surface block layering for a biome: the top block, the filler band below it, +// and the deep "under" block (stone). Filler depth is fixed at 3 blocks. +public readonly record struct SurfacePalette(IBlock Top, IBlock Filler, IBlock Under); diff --git a/World/WorldGen/WorldConstants.cs b/World/WorldGen/WorldConstants.cs new file mode 100644 index 0000000..5bf055a --- /dev/null +++ b/World/WorldGen/WorldConstants.cs @@ -0,0 +1,10 @@ +using VoxelChunk = VoxelEngine.World.Chunk.Chunk; + +namespace VoxelEngine.World.WorldGen; + +public static class WorldConstants +{ + public const int WorldHeightChunks = 8; + public const int WorldHeight = WorldConstants.WorldHeightChunks * VoxelChunk.Size; // 128 + public const int SeaLevel = 64; +}