2020-02-06 22:32:26 +00:00
|
|
|
pub mod settlement;
|
2019-08-23 19:56:21 +00:00
|
|
|
mod town;
|
|
|
|
|
|
|
|
// Reexports
|
2020-02-07 22:19:25 +00:00
|
|
|
pub use self::{
|
|
|
|
settlement::Settlement,
|
|
|
|
town::{TownGen, TownState},
|
|
|
|
};
|
2019-08-23 19:56:21 +00:00
|
|
|
|
2020-02-08 11:38:44 +00:00
|
|
|
use crate::{
|
|
|
|
block::ZCache,
|
|
|
|
column::ColumnSample,
|
|
|
|
util::{Grid, Sampler},
|
|
|
|
};
|
|
|
|
use common::{
|
|
|
|
terrain::Block,
|
|
|
|
vol::{BaseVol, WriteVol},
|
|
|
|
};
|
2020-02-07 22:19:25 +00:00
|
|
|
use std::sync::Arc;
|
2019-08-23 19:56:21 +00:00
|
|
|
use vek::*;
|
|
|
|
|
2020-02-07 22:19:25 +00:00
|
|
|
#[derive(Clone)]
|
|
|
|
pub enum Site {
|
|
|
|
Settlement(Arc<Settlement>),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Site {
|
|
|
|
pub fn get_surface(&self, wpos: Vec2<i32>) -> Option<Block> {
|
|
|
|
match self {
|
|
|
|
Site::Settlement(settlement) => settlement.get_surface(wpos),
|
|
|
|
}
|
|
|
|
}
|
2020-02-08 11:38:44 +00:00
|
|
|
|
|
|
|
pub fn apply_to(
|
|
|
|
&self,
|
|
|
|
wpos2d: Vec2<i32>,
|
|
|
|
zcaches: &Grid<Option<ZCache>>,
|
|
|
|
vol: &mut (impl BaseVol<Vox = Block> + WriteVol),
|
|
|
|
) {
|
|
|
|
// TODO
|
|
|
|
}
|
2020-02-07 22:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Settlement> for Site {
|
|
|
|
fn from(settlement: Settlement) -> Self { Site::Settlement(Arc::new(settlement)) }
|
|
|
|
}
|
|
|
|
|
2019-08-28 18:32:44 +00:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
|
|
|
pub struct SpawnRules {
|
|
|
|
pub trees: bool,
|
2019-09-25 12:00:00 +00:00
|
|
|
pub cliffs: bool,
|
2019-08-28 18:32:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for SpawnRules {
|
|
|
|
fn default() -> Self {
|
2019-09-25 12:00:00 +00:00
|
|
|
Self {
|
|
|
|
trees: true,
|
|
|
|
cliffs: true,
|
|
|
|
}
|
2019-08-28 18:32:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl SpawnRules {
|
|
|
|
pub fn and(self, other: Self) -> Self {
|
|
|
|
Self {
|
|
|
|
trees: self.trees && other.trees,
|
2019-09-25 12:00:00 +00:00
|
|
|
cliffs: self.cliffs && other.cliffs,
|
2019-08-28 18:32:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|