mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-22 11:58:21 -06:00
wip
This commit is contained in:
parent
2c86971d18
commit
2bc0231f22
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue