2022-05-10 11:36:44 +00:00
|
|
|
use crate::{terrain::TerrainChunkSize, vol::RectVolSize};
|
|
|
|
use serde::{Deserialize, Serialize};
|
2022-05-08 23:53:19 +00:00
|
|
|
use strum::EnumIter;
|
2022-05-10 11:36:44 +00:00
|
|
|
use vek::*;
|
2022-05-08 23:53:19 +00:00
|
|
|
|
|
|
|
// In chunks
|
2022-05-09 00:15:18 +00:00
|
|
|
pub const ZONE_SIZE: u32 = 32;
|
2022-05-08 23:53:19 +00:00
|
|
|
|
2022-05-09 09:28:32 +00:00
|
|
|
bitflags::bitflags! {
|
2023-05-10 08:33:01 +00:00
|
|
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
2024-03-23 17:22:44 +00:00
|
|
|
pub struct InstFlags: u8 {
|
2023-10-17 15:14:09 +00:00
|
|
|
const SNOW_COVERED = 0b00000001;
|
2024-03-22 17:59:14 +00:00
|
|
|
const GLOW = 0b00000010;
|
2022-05-09 09:28:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-08 23:53:19 +00:00
|
|
|
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug, Serialize, Deserialize, EnumIter)]
|
|
|
|
#[repr(u16)]
|
|
|
|
pub enum ObjectKind {
|
2024-03-22 17:59:14 +00:00
|
|
|
GenericTree,
|
2022-05-09 08:25:36 +00:00
|
|
|
Pine,
|
2022-12-31 15:32:56 +00:00
|
|
|
Dead,
|
2022-05-10 18:19:46 +00:00
|
|
|
House,
|
2022-05-10 19:30:48 +00:00
|
|
|
GiantTree,
|
2024-03-22 18:01:09 +00:00
|
|
|
Mangrove,
|
|
|
|
Acacia,
|
|
|
|
Birch,
|
|
|
|
Redwood,
|
|
|
|
Baobab,
|
|
|
|
Frostpine,
|
|
|
|
Haniwa,
|
|
|
|
Desert,
|
|
|
|
Palm,
|
|
|
|
Arena,
|
2024-03-26 21:32:48 +00:00
|
|
|
SavannahHut,
|
|
|
|
SavannahPit,
|
2024-03-27 01:37:58 +00:00
|
|
|
TerracottaPalace,
|
|
|
|
TerracottaHouse,
|
|
|
|
TerracottaYard,
|
2024-03-27 13:39:11 +00:00
|
|
|
AirshipDock,
|
|
|
|
CoastalHouse,
|
|
|
|
CoastalWorkshop,
|
2022-05-08 23:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
pub struct Object {
|
|
|
|
pub kind: ObjectKind,
|
2022-05-10 18:19:46 +00:00
|
|
|
pub pos: Vec3<i16>,
|
2024-03-23 17:22:44 +00:00
|
|
|
pub flags: InstFlags,
|
2024-03-22 17:59:14 +00:00
|
|
|
pub color: Rgb<u8>,
|
2022-05-08 23:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
pub struct Zone {
|
|
|
|
pub objects: Vec<Object>,
|
|
|
|
}
|
|
|
|
|
2022-05-10 11:36:44 +00:00
|
|
|
pub fn to_wpos(wpos: i32) -> i32 { wpos * (TerrainChunkSize::RECT_SIZE.x * ZONE_SIZE) as i32 }
|
2022-05-08 23:53:19 +00:00
|
|
|
|
|
|
|
pub fn from_wpos(zone_pos: i32) -> i32 {
|
2022-05-09 12:51:04 +00:00
|
|
|
zone_pos.div_euclid((TerrainChunkSize::RECT_SIZE.x * ZONE_SIZE) as i32)
|
2022-05-08 23:53:19 +00:00
|
|
|
}
|