So I cobbled together a system that waits for the game map to generate in a background task but I have some doubts.
- What used to be a startup system now keeps running but effectively only runs once. Can I express this better?
- It just looks kinda funky
This is how the start of the system goes where I'm wrangling the Task.
if generate_map_task.is_empty() {
return;
}
let (task_entity, mut task) = generate_map_task.single_mut();
let mapprototype = match future::block_on(future::poll_once(&mut task.0)) {
Some(Ok(result)) => {
commands.entity(task_entity).despawn();
result
}
Some(Err(e)) => {
error!("something went wrong: {}", e);
commands.entity(task_entity).despawn();
return;
}
None => return,
};
Full context: https://github.com/keis/explore-game/commit/8f1bc48a6996371629299b1d202bdf189b47f518