mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
42 lines
936 B
Rust
42 lines
936 B
Rust
use crate::{terrain::TerrainChunkSize, vol::RectVolSize};
|
|
use serde::{Deserialize, Serialize};
|
|
use strum::EnumIter;
|
|
use vek::*;
|
|
|
|
// In chunks
|
|
pub const ZONE_SIZE: u32 = 32;
|
|
|
|
bitflags::bitflags! {
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct Flags: u8 {
|
|
const SNOW_COVERED = 0b00000001;
|
|
}
|
|
}
|
|
|
|
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug, Serialize, Deserialize, EnumIter)]
|
|
#[repr(u16)]
|
|
pub enum ObjectKind {
|
|
Oak,
|
|
Pine,
|
|
House,
|
|
GiantTree,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Object {
|
|
pub kind: ObjectKind,
|
|
pub pos: Vec3<i16>,
|
|
pub flags: Flags,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Zone {
|
|
pub objects: Vec<Object>,
|
|
}
|
|
|
|
pub fn to_wpos(wpos: i32) -> i32 { wpos * (TerrainChunkSize::RECT_SIZE.x * ZONE_SIZE) as i32 }
|
|
|
|
pub fn from_wpos(zone_pos: i32) -> i32 {
|
|
zone_pos.div_euclid((TerrainChunkSize::RECT_SIZE.x * ZONE_SIZE) as i32)
|
|
}
|