veloren/world/src/site2/plot.rs

56 lines
1.2 KiB
Rust
Raw Normal View History

2021-03-04 18:23:13 +00:00
mod castle;
pub mod dungeon;
2022-02-02 02:33:37 +00:00
mod giant_tree;
2021-12-14 20:45:48 +00:00
mod gnarling;
mod house;
2021-09-19 17:24:14 +00:00
mod workshop;
2022-02-02 02:33:37 +00:00
pub use self::{
2021-12-14 20:45:48 +00:00
castle::Castle, dungeon::Dungeon, giant_tree::GiantTree, gnarling::GnarlingFortification,
house::House, workshop::Workshop,
2022-02-02 02:33:37 +00:00
};
use super::*;
2021-02-04 12:47:46 +00:00
use crate::util::DHashSet;
2021-02-17 01:47:16 +00:00
use common::path::Path;
2021-02-06 23:53:25 +00:00
use vek::*;
2020-12-26 15:53:06 +00:00
pub struct Plot {
2021-02-17 01:47:16 +00:00
pub(crate) kind: PlotKind,
pub(crate) root_tile: Vec2<i32>,
pub(crate) tiles: DHashSet<Vec2<i32>>,
pub(crate) seed: u32,
2021-02-04 12:47:46 +00:00
}
impl Plot {
pub fn find_bounds(&self) -> Aabr<i32> {
self.tiles
.iter()
2021-02-06 23:53:25 +00:00
.fold(Aabr::new_empty(self.root_tile), |b, t| {
b.expanded_to_contain_point(*t)
})
2021-02-04 12:47:46 +00:00
}
2021-09-18 21:23:13 +00:00
pub fn z_range(&self) -> Option<Range<i32>> {
match &self.kind {
PlotKind::House(house) => Some(house.z_range()),
_ => None,
}
}
pub fn kind(&self) -> &PlotKind { &self.kind }
2021-09-18 15:24:56 +00:00
pub fn root_tile(&self) -> Vec2<i32> { self.root_tile }
2020-12-26 15:53:06 +00:00
}
pub enum PlotKind {
House(House),
2021-09-19 17:24:14 +00:00
Workshop(Workshop),
2021-02-17 01:47:16 +00:00
Plaza,
2021-03-04 18:23:13 +00:00
Castle(Castle),
2021-02-17 01:47:16 +00:00
Road(Path<Vec2<i32>>),
Dungeon(Dungeon),
2021-12-14 20:45:48 +00:00
Gnarling(GnarlingFortification),
2022-02-02 02:33:37 +00:00
GiantTree(GiantTree),
2020-12-26 15:53:06 +00:00
}