waiting for previous chunk loading before doing next
This commit is contained in:
@@ -22,6 +22,7 @@ pub struct World {
|
||||
data: WorldData,
|
||||
loader: ChunkLoader,
|
||||
chunks: HashMap<Vector3<i32>, WorldChunk>,
|
||||
busy: u32
|
||||
}
|
||||
|
||||
impl World {
|
||||
@@ -31,18 +32,24 @@ impl World {
|
||||
data: WorldData { name: name.clone(), ..Default::default() },
|
||||
loader: ChunkLoader::new(name.clone()),
|
||||
chunks: HashMap::new(),
|
||||
busy: 0,
|
||||
};
|
||||
instance.load_metadata();
|
||||
instance.save_all();
|
||||
instance
|
||||
}
|
||||
|
||||
pub fn is_busy(&self) -> bool {
|
||||
self.busy > 0
|
||||
}
|
||||
|
||||
/*
|
||||
* Receives loaded chunks from ChunkLoader
|
||||
*/
|
||||
pub fn update(&mut self) {
|
||||
for (pos, chunk) in self.loader.receive() {
|
||||
self.chunks.insert(pos, chunk);
|
||||
self.busy -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +58,7 @@ impl World {
|
||||
*/
|
||||
pub fn load_chunk(&mut self, pos: Vector3<i32>) {
|
||||
self.loader.load(pos);
|
||||
self.busy += 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user