steel_core/chunk/
status.rs1use wincode::{SchemaRead, SchemaWrite};
4
5use super::heightmap::HeightmapType;
6
7#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, SchemaWrite, SchemaRead)]
9pub enum ChunkStatus {
10 Empty,
12 StructureStarts,
14 StructureReferences,
16 Biomes,
18 Terrain,
20 Features,
22 InitializeLight,
24 Light,
26 Spawn,
28 Full,
30}
31
32impl ChunkStatus {
33 #[must_use]
35 pub const fn get_index(self) -> usize {
36 self as usize
37 }
38
39 #[must_use]
41 pub const fn from_index(index: usize) -> Option<Self> {
42 match index {
43 0 => Some(Self::Empty),
44 1 => Some(Self::StructureStarts),
45 2 => Some(Self::StructureReferences),
46 3 => Some(Self::Biomes),
47 4 => Some(Self::Terrain),
48 5 => Some(Self::Features),
49 6 => Some(Self::InitializeLight),
50 7 => Some(Self::Light),
51 8 => Some(Self::Spawn),
52 9 => Some(Self::Full),
53 _ => None,
54 }
55 }
56
57 #[must_use]
59 pub const fn next(self) -> Option<Self> {
60 match self {
61 Self::Empty => Some(Self::StructureStarts),
62 Self::StructureStarts => Some(Self::StructureReferences),
63 Self::StructureReferences => Some(Self::Biomes),
64 Self::Biomes => Some(Self::Terrain),
65 Self::Terrain => Some(Self::Features),
66 Self::Features => Some(Self::InitializeLight),
67 Self::InitializeLight => Some(Self::Light),
68 Self::Light => Some(Self::Spawn),
69 Self::Spawn => Some(Self::Full),
70 Self::Full => None,
71 }
72 }
73
74 #[must_use]
76 pub const fn parent(self) -> Option<Self> {
77 match self {
78 Self::Empty => None,
79 Self::StructureStarts => Some(Self::Empty),
80 Self::StructureReferences => Some(Self::StructureStarts),
81 Self::Biomes => Some(Self::StructureReferences),
82 Self::Terrain => Some(Self::Biomes),
83 Self::Features => Some(Self::Terrain),
84 Self::InitializeLight => Some(Self::Features),
85 Self::Light => Some(Self::InitializeLight),
86 Self::Spawn => Some(Self::Light),
87 Self::Full => Some(Self::Spawn),
88 }
89 }
90
91 #[must_use]
96 pub const fn heightmaps_after(self) -> &'static [HeightmapType] {
97 match self {
98 Self::Empty | Self::StructureStarts | Self::StructureReferences | Self::Biomes => {
99 HeightmapType::worldgen_types()
100 }
101 Self::Terrain
102 | Self::Features
103 | Self::InitializeLight
104 | Self::Light
105 | Self::Spawn
106 | Self::Full => HeightmapType::final_types(),
107 }
108 }
109}