mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-22 14:58:44 -06:00
wip
This commit is contained in:
parent
2c86971d18
commit
2bc0231f22
|
@ -7,10 +7,23 @@ mod thread;
|
||||||
|
|
||||||
use chunk::{Chunk, CHUNK_SIZE};
|
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 struct World {
|
||||||
pub chunks: HashMap<IVec2, Chunk>
|
pub chunks: HashMap<IVec2, Chunk>
|
||||||
}
|
}
|
||||||
impl World {
|
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 {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
chunks: HashMap::new()
|
chunks: HashMap::new()
|
||||||
|
|
Loading…
Reference in a new issue