2020-02-26 21:43:31 +00:00
|
|
|
mod settlement;
|
2019-08-23 19:56:21 +00:00
|
|
|
|
|
|
|
// Reexports
|
2020-02-26 21:43:31 +00:00
|
|
|
pub use self::settlement::Settlement;
|
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 {
|
2020-02-09 21:56:52 +00:00
|
|
|
pub fn radius(&self) -> f32 {
|
|
|
|
match self {
|
|
|
|
Site::Settlement(settlement) => settlement.radius(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-07 22:19:25 +00:00
|
|
|
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),
|
|
|
|
) {
|
2020-02-08 19:58:42 +00:00
|
|
|
match self {
|
|
|
|
Site::Settlement(settlement) => settlement.apply_to(wpos2d, zcaches, vol),
|
|
|
|
}
|
2020-02-08 11:38:44 +00:00
|
|
|
}
|
2020-02-07 22:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Settlement> for Site {
|
|
|
|
fn from(settlement: Settlement) -> Self { Site::Settlement(Arc::new(settlement)) }
|
|
|
|
}
|