Added Superflat implementation.
This commit is contained in:
parent
9149e82508
commit
43c724dec7
1
pumpkin-world/src/world_gen/implementations/mod.rs
Normal file
1
pumpkin-world/src/world_gen/implementations/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod superflat;
|
||||
48
pumpkin-world/src/world_gen/implementations/superflat.rs
Normal file
48
pumpkin-world/src/world_gen/implementations/superflat.rs
Normal file
@ -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 generic_generator;
|
||||
mod implementations;
|
||||
mod seed;
|
||||
|
||||
pub use generator::WorldGenerator;
|
||||
pub use seed::Seed;
|
||||
|
||||
use generator::GeneratorInit;
|
||||
use implementations::superflat::SuperflatGenerator;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_world_gen(_: Seed) -> Box<dyn WorldGenerator> {
|
||||
todo!()
|
||||
pub fn get_world_gen(seed: Seed) -> Box<dyn WorldGenerator> {
|
||||
// TODO decide which WorldGenerator to pick based on config.
|
||||
Box::new(SuperflatGenerator::new(seed))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user