veloren/world/src/generator/mod.rs

35 lines
779 B
Rust
Raw Normal View History

mod town;
// Reexports
2019-08-23 21:33:14 +00:00
pub use self::town::{TownGen, TownState};
2019-08-24 13:23:42 +00:00
use crate::{column::ColumnSample, util::Sampler};
use common::terrain::Block;
use vek::*;
2019-08-28 18:32:44 +00:00
#[derive(Copy, Clone, Debug)]
pub struct SpawnRules {
pub trees: bool,
}
impl Default for SpawnRules {
fn default() -> Self {
Self { trees: true }
}
}
impl SpawnRules {
pub fn and(self, other: Self) -> Self {
Self {
trees: self.trees && other.trees,
}
}
}
2019-08-23 21:33:14 +00:00
pub trait Generator<'a, T: 'a>:
2019-08-24 22:57:55 +00:00
Sampler<'a, Index = (&'a T, Vec3<i32>, &'a ColumnSample<'a>, f32), Sample = Option<Block>>
2019-08-23 21:33:14 +00:00
{
2019-08-24 13:23:42 +00:00
fn get_z_limits(&self, state: &'a T, wpos: Vec2<i32>, sample: &ColumnSample) -> (f32, f32);
2019-08-28 18:32:44 +00:00
fn spawn_rules(&self, town: &'a TownState, wpos: Vec2<i32>) -> SpawnRules;
2019-08-23 21:33:14 +00:00
}