feat: add Plains/Desert/Mountains/Forest biomes and registry
This commit is contained in:
46
VoxelEngine.Tests/WorldGen/BiomeTests.cs
Normal file
46
VoxelEngine.Tests/WorldGen/BiomeTests.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using VoxelEngine.World.Blocks;
|
||||
using VoxelEngine.World.WorldGen;
|
||||
using Xunit;
|
||||
|
||||
namespace VoxelEngine.Tests.WorldGen;
|
||||
|
||||
public class BiomeTests
|
||||
{
|
||||
[Fact]
|
||||
public void Desert_TopAndFiller_AreSand()
|
||||
{
|
||||
var blocks = new BlockRegistry();
|
||||
var biomes = new BiomeRegistry(42, blocks);
|
||||
Assert.Equal("Sand", biomes.Desert.Surface.Top.Name);
|
||||
Assert.Equal("Sand", biomes.Desert.Surface.Filler.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Mountains_UseSnowAboveSnowLine_StoneBelow()
|
||||
{
|
||||
var blocks = new BlockRegistry();
|
||||
var biomes = new BiomeRegistry(42, blocks);
|
||||
Assert.Equal("Stone", biomes.Mountains.TopBlock(70).Name);
|
||||
Assert.Equal("Snow Block", biomes.Mountains.TopBlock(120).Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Plains_TopBlock_IsGrass_RegardlessOfHeight()
|
||||
{
|
||||
var blocks = new BlockRegistry();
|
||||
var biomes = new BiomeRegistry(42, blocks);
|
||||
Assert.Equal("Grass", biomes.Plains.TopBlock(40).Name);
|
||||
Assert.Equal("Grass", biomes.Plains.TopBlock(120).Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SampleHeight_IsDeterministic()
|
||||
{
|
||||
var blocks = new BlockRegistry();
|
||||
var biomes = new BiomeRegistry(42, blocks);
|
||||
var noise = new NoiseSource(42);
|
||||
float h1 = biomes.Mountains.SampleHeight(noise, 100f, 200f);
|
||||
float h2 = biomes.Mountains.SampleHeight(noise, 100f, 200f);
|
||||
Assert.Equal(h1, h2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user