This commit is contained in:
griffi-gh 2023-01-16 21:01:34 +01:00
parent 2c86971d18
commit 2bc0231f22

View file

@ -7,10 +7,23 @@ mod thread;
use chunk::{Chunk, CHUNK_SIZE};
const POSITIVE_X_NEIGHBOR: usize = 0;
const NEGATIVE_X_NEIGHBOR: usize = 1;
const POSITIVE_Z_NEIGHBOR: usize = 2;
const NEGATIVE_Z_NEIGHBOR: usize = 3;
pub struct World {
pub chunks: HashMap<IVec2, Chunk>
}
impl World {
pub fn chunk_neighbors(&self, position: IVec2) -> [Option<&Chunk>; 4] {
[
self.chunks.get(&(position + IVec2::new(1, 0))),
self.chunks.get(&(position - IVec2::new(1, 0))),
self.chunks.get(&(position + IVec2::new(0, 1))),
self.chunks.get(&(position - IVec2::new(0, 1))),
]
}
pub fn new() -> Self {
Self {
chunks: HashMap::new()