55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using VoxelEngine.World.Blocks;
|
|
using VoxelEngine.World.WorldGen;
|
|
using Xunit;
|
|
|
|
namespace VoxelEngine.Tests.WorldGen;
|
|
|
|
public class BiomeMapTests
|
|
{
|
|
private static (BiomeMap map, BiomeRegistry biomes) Build(int seed = 42)
|
|
{
|
|
var blocks = new BlockRegistry();
|
|
var biomes = new BiomeRegistry(seed, blocks);
|
|
var noise = new NoiseSource(seed);
|
|
var cells = new VoronoiCells(seed, 96f);
|
|
return (new BiomeMap(noise, cells, biomes), biomes);
|
|
}
|
|
|
|
[Fact]
|
|
public void Classify_HighElevation_IsMountains()
|
|
{
|
|
var (_, biomes) = Build();
|
|
Assert.Same(biomes.Mountains, BiomeMap.Classify(0f, 0.5f, 0f, biomes));
|
|
}
|
|
|
|
[Fact]
|
|
public void Classify_HotLowElevation_IsDesert()
|
|
{
|
|
var (_, biomes) = Build();
|
|
Assert.Same(biomes.Desert, BiomeMap.Classify(0.5f, 0f, 0f, biomes));
|
|
}
|
|
|
|
[Fact]
|
|
public void Classify_TemperateWooded_IsForest()
|
|
{
|
|
var (_, biomes) = Build();
|
|
Assert.Same(biomes.Forest, BiomeMap.Classify(0f, 0f, 0.5f, biomes));
|
|
}
|
|
|
|
[Fact]
|
|
public void Classify_ColdLow_IsPlains()
|
|
{
|
|
var (_, biomes) = Build();
|
|
Assert.Same(biomes.Plains, BiomeMap.Classify(-0.9f, 0f, 0f, biomes));
|
|
}
|
|
|
|
[Fact]
|
|
public void BiomeAt_IsConstantWithinACell()
|
|
{
|
|
var (map, _) = Build();
|
|
IBiome a = map.BiomeAt(500f, 500f);
|
|
IBiome b = map.BiomeAt(500.01f, 500.01f); // same cell
|
|
Assert.Same(a, b);
|
|
}
|
|
}
|