Fix terrain not loading

Former-commit-id: f9279878ab051c6083c4a1f5125531fe79151fb8
This commit is contained in:
timokoesters 2019-05-20 01:00:31 +02:00
parent 36e890bbd8
commit f5751d65b1
5 changed files with 15 additions and 0 deletions

View File

@ -184,6 +184,11 @@ impl State {
self.ecs.read_resource::<TerrainMap>()
}
/// Get a writable reference to this state's terrain.
pub fn terrain_mut(&self) -> FetchMut<TerrainMap> {
self.ecs.write_resource::<TerrainMap>()
}
/// Insert the provided chunk into this state's terrain.
pub fn insert_chunk(&mut self, key: Vec2<i32>, chunk: TerrainChunk) {
if self

View File

@ -145,6 +145,10 @@ impl<V: BaseVol, S: VolSize> VolMap2d<V, S> {
self.chunks.get(&key)
}
pub fn clear(&mut self) {
self.chunks.clear();
}
pub fn remove(&mut self, key: Vec2<i32>) -> Option<Arc<V>> {
self.chunks.remove(&key)
}

View File

@ -45,6 +45,7 @@ impl PlayState for CharSelectionState {
fn play(&mut self, _: Direction, global_state: &mut GlobalState) -> PlayStateResult {
// Set up an fps clock.
let mut clock = Clock::new();
self.client.borrow_mut().state_mut().terrain_mut().clear();
while self.client.borrow().is_request_pending()
|| self.client.borrow().get_client_state() == Some(ClientState::Registered)

View File

@ -205,4 +205,8 @@ impl Terrain {
renderer.render_terrain_chunk(&chunk.model, globals, &chunk.locals);
}
}
pub fn clear(&mut self) {
self.chunks.clear();
}
}

View File

@ -115,6 +115,7 @@ impl PlayState for SessionState {
// Set up an fps clock.
let mut clock = Clock::new();
self.client.borrow_mut().state_mut().terrain_mut().clear();
// Load a few chunks. TODO: Remove this.
/*