veloren/common/src/terrain/mod.rs

66 lines
1.3 KiB
Rust
Raw Normal View History

2019-01-02 19:22:01 +00:00
pub mod biome;
pub mod block;
pub mod chonk;
pub mod structure;
2019-01-02 19:22:01 +00:00
2019-01-15 15:13:11 +00:00
// Reexports
pub use self::{
biome::BiomeKind,
block::{Block, BlockKind},
structure::Structure,
};
2019-01-15 15:13:11 +00:00
use crate::{vol::VolSize, volumes::vol_map_2d::VolMap2d};
use serde_derive::{Deserialize, Serialize};
use vek::*;
2019-01-02 19:22:01 +00:00
2019-01-15 15:13:11 +00:00
// TerrainChunkSize
2019-01-02 19:22:01 +00:00
#[derive(Debug, Clone, Serialize, Deserialize)]
2019-01-15 15:13:11 +00:00
pub struct TerrainChunkSize;
2019-01-02 19:22:01 +00:00
2019-01-15 15:13:11 +00:00
impl VolSize for TerrainChunkSize {
const SIZE: Vec3<u32> = Vec3 {
x: 32,
y: 32,
z: std::i32::MAX as u32,
};
2019-01-02 19:22:01 +00:00
}
2019-01-15 15:13:11 +00:00
// TerrainChunkMeta
2019-01-02 19:22:01 +00:00
#[derive(Debug, Clone, Serialize, Deserialize)]
2019-01-15 15:13:11 +00:00
pub struct TerrainChunkMeta {
2019-06-11 18:39:25 +00:00
name: Option<String>,
2019-01-02 19:22:01 +00:00
biome: BiomeKind,
}
2019-01-15 15:13:11 +00:00
impl TerrainChunkMeta {
2019-06-11 18:39:25 +00:00
pub fn new(name: Option<String>, biome: BiomeKind) -> Self {
2019-06-15 10:36:26 +00:00
Self { name, biome }
2019-06-11 18:39:25 +00:00
}
2019-01-15 15:13:11 +00:00
pub fn void() -> Self {
Self {
2019-06-11 18:39:25 +00:00
name: None,
2019-01-15 15:13:11 +00:00
biome: BiomeKind::Void,
}
}
2019-06-11 18:39:25 +00:00
pub fn name(&self) -> &str {
self.name
.as_ref()
.map(|s| s.as_str())
.unwrap_or("Wilderness")
}
pub fn biome(&self) -> BiomeKind {
self.biome
}
2019-01-15 15:13:11 +00:00
}
// Terrain type aliases
2019-01-02 19:22:01 +00:00
pub type TerrainChunk = chonk::Chonk; //Chunk<Block, TerrainChunkSize, TerrainChunkMeta>;
pub type TerrainMap = VolMap2d<TerrainChunk, TerrainChunkSize>;