1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use std::fmt;
use math;
pub mod ground;
pub mod chunk;
mod hex_pillar;
mod provider;
mod world;
pub use self::chunk::Chunk;
pub use self::ground::*;
pub use self::hex_pillar::*;
pub use self::provider::*;
pub use self::world::World;
pub const HEX_OUTER_RADIUS: f32 = 1.0;
pub const HEX_INNER_RADIUS: f32 = HEX_OUTER_RADIUS * (::math::SQRT_3 / 2.0);
pub const PILLAR_STEP_HEIGHT: f32 = 0.5;
pub const CHUNK_SIZE: u16 = 16;
pub type PillarIndexComponent = math::AxialType;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct PillarIndex(pub math::AxialPoint);
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct ChunkIndex(pub math::AxialPoint);
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
pub struct HeightType(pub u16);
impl HeightType {
pub fn from_units(n: u16) -> Self {
HeightType(n)
}
pub fn units(&self) -> u16 {
self.0
}
pub fn to_real(&self) -> f32 {
(self.0 as f32) * PILLAR_STEP_HEIGHT
}
pub fn from_real(number: f32) -> f32 {
number / PILLAR_STEP_HEIGHT
}
}
impl fmt::Debug for HeightType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "[{} -> {}]", self.0, self.to_real())
}
}