Added Superflat implementation.
This commit is contained in:
1 parent
9149e82508
commit
43c724dec7
3 files changed
+56
-2
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
pub mod superflat;
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
use crate::{
|
||||||
|
biome::Biome,
|
||||||
|
block::BlockId,
|
||||||
|
coordinates::{BlockCoordinates, XZBlockCoordinates},
|
||||||
|
world_gen::{
|
||||||
|
generator::{BiomeGenerator, GeneratorInit, TerrainGenerator},
|
||||||
|
generic_generator::GenericGenerator,
|
||||||
|
Seed,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub type SuperflatGenerator = GenericGenerator<SuperflatBiomeGenerator, SuperflatTerrainGenerator>;
|
||||||
|
|
||||||
|
pub(crate) struct SuperflatBiomeGenerator {}
|
||||||
|
|
||||||
|
impl GeneratorInit for SuperflatBiomeGenerator {
|
||||||
|
fn new(_: Seed) -> Self {
|
||||||
|
Self {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BiomeGenerator for SuperflatBiomeGenerator {
|
||||||
|
// TODO make generic over Biome and allow changing the Biome in the config.
|
||||||
|
fn generate_biome(&self, _: XZBlockCoordinates) -> Biome {
|
||||||
|
Biome::Plains
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct SuperflatTerrainGenerator {}
|
||||||
|
|
||||||
|
impl GeneratorInit for SuperflatTerrainGenerator {
|
||||||
|
fn new(_: Seed) -> Self {
|
||||||
|
Self {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TerrainGenerator for SuperflatTerrainGenerator {
|
||||||
|
// TODO allow specifying which blocks should be at which height in the config.
|
||||||
|
fn generate_block(&self, at: BlockCoordinates, _: Biome) -> BlockId {
|
||||||
|
match *at.y {
|
||||||
|
-64 => BlockId::from_id(79), // Bedrock
|
||||||
|
-63..=-62 => BlockId::from_id(10), // Dirt
|
||||||
|
-61 => BlockId::from_id(9), // Grass
|
||||||
|
_ => BlockId::AIR,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,16 @@
|
|||||||
mod generator;
|
mod generator;
|
||||||
mod generic_generator;
|
mod generic_generator;
|
||||||
|
mod implementations;
|
||||||
mod seed;
|
mod seed;
|
||||||
|
|
||||||
pub use generator::WorldGenerator;
|
pub use generator::WorldGenerator;
|
||||||
pub use seed::Seed;
|
pub use seed::Seed;
|
||||||
|
|
||||||
|
use generator::GeneratorInit;
|
||||||
|
use implementations::superflat::SuperflatGenerator;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn get_world_gen(_: Seed) -> Box<dyn WorldGenerator> {
|
pub fn get_world_gen(seed: Seed) -> Box<dyn WorldGenerator> {
|
||||||
todo!()
|
// TODO decide which WorldGenerator to pick based on config.
|
||||||
|
Box::new(SuperflatGenerator::new(seed))
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user