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 Noise,
20 Surface,
22 Carvers,
24 Features,
26 InitializeLight,
28 Light,
30 Spawn,
32 Full,
34}
35
36impl ChunkStatus {
37 #[must_use]
39 pub const fn get_index(self) -> usize {
40 self as usize
41 }
42
43 #[must_use]
45 pub const fn from_index(index: usize) -> Option<Self> {
46 match index {
47 0 => Some(Self::Empty),
48 1 => Some(Self::StructureStarts),
49 2 => Some(Self::StructureReferences),
50 3 => Some(Self::Biomes),
51 4 => Some(Self::Noise),
52 5 => Some(Self::Surface),
53 6 => Some(Self::Carvers),
54 7 => Some(Self::Features),
55 8 => Some(Self::InitializeLight),
56 9 => Some(Self::Light),
57 10 => Some(Self::Spawn),
58 11 => Some(Self::Full),
59 _ => None,
60 }
61 }
62
63 #[must_use]
65 pub const fn next(self) -> Option<Self> {
66 match self {
67 Self::Empty => Some(Self::StructureStarts),
68 Self::StructureStarts => Some(Self::StructureReferences),
69 Self::StructureReferences => Some(Self::Biomes),
70 Self::Biomes => Some(Self::Noise),
71 Self::Noise => Some(Self::Surface),
72 Self::Surface => Some(Self::Carvers),
73 Self::Carvers => Some(Self::Features),
74 Self::Features => Some(Self::InitializeLight),
75 Self::InitializeLight => Some(Self::Light),
76 Self::Light => Some(Self::Spawn),
77 Self::Spawn => Some(Self::Full),
78 Self::Full => None,
79 }
80 }
81
82 #[must_use]
84 pub const fn parent(self) -> Option<Self> {
85 match self {
86 Self::Empty => None,
87 Self::StructureStarts => Some(Self::Empty),
88 Self::StructureReferences => Some(Self::StructureStarts),
89 Self::Biomes => Some(Self::StructureReferences),
90 Self::Noise => Some(Self::Biomes),
91 Self::Surface => Some(Self::Noise),
92 Self::Carvers => Some(Self::Surface),
93 Self::Features => Some(Self::Carvers),
94 Self::InitializeLight => Some(Self::Features),
95 Self::Light => Some(Self::InitializeLight),
96 Self::Spawn => Some(Self::Light),
97 Self::Full => Some(Self::Spawn),
98 }
99 }
100
101 #[must_use]
106 pub const fn heightmaps_after(self) -> &'static [HeightmapType] {
107 match self {
108 Self::Empty
109 | Self::StructureStarts
110 | Self::StructureReferences
111 | Self::Biomes
112 | Self::Noise
113 | Self::Surface => HeightmapType::worldgen_types(),
114 Self::Carvers
115 | Self::Features
116 | Self::InitializeLight
117 | Self::Light
118 | Self::Spawn
119 | Self::Full => HeightmapType::final_types(),
120 }
121 }
122}