Created
October 31, 2018 13:52
-
-
Save Telzhaak/0dd8a2714b29ae95c500f4ed0dc426de to your computer and use it in GitHub Desktop.
My use-case for resource loading in a system.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct DeSavegameSystem; | |
impl<'a> System<'a> for DeSavegameSystem { | |
type SystemData = ( | |
Option<Write<'a, GameSessionData>>, | |
Option<Read<'a, SavegamePaths>>, | |
); | |
fn run(&mut self,( | |
session_data, | |
paths, | |
): Self::SystemData, | |
) { | |
match (session_data, paths) { | |
(Some(mut session_data), Some(paths)) => { | |
match GameSessionData::load(&paths){ | |
Ok(data) => { | |
let mut buffer = session_data.deref_mut(); | |
*buffer = data; | |
}, | |
Err(e) => { | |
error!("Error loading savegame data at {:?}: {:?}", paths.savegame_file_path.clone(), e); | |
} | |
} | |
}, | |
(None, Some(paths)) => { | |
match GameSessionData::load(&paths){ | |
Ok(data) => { | |
/* | |
let mut buffer = session_data; | |
buffer = Some(data); | |
*/ | |
error!("Found savegame data at {:?}, but cannot add resource from inside system.", paths.savegame_file_path.clone()); | |
}, | |
Err(e) => { | |
error!("Error loading savegame data at {:?}: {:?}", paths.savegame_file_path.clone(), e); | |
} | |
} | |
}, | |
_ => { | |
error!("| SavegamePaths not found."); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment