diff options
author | 2024-10-11 16:03:43 -0400 | |
---|---|---|
committer | 2024-10-11 16:03:43 -0400 | |
commit | 535436e2e9164f9880e507d7057a8cdbf261608e (patch) | |
tree | db370db8e0caea99a9e6e3c501c7ea7e3b6dd708 /src/systems.rs | |
parent | ebc3ccfea4027a3eb0c80f6a3d64b6425d32d1ef (diff) | |
parent | 16c1574e400d73198713336e18975ff37ab78290 (diff) |
Merge pull request #1 from exvacuum/navigation
Navigation
Diffstat (limited to 'src/systems.rs')
-rw-r--r-- | src/systems.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/systems.rs b/src/systems.rs new file mode 100644 index 0000000..ac5f667 --- /dev/null +++ b/src/systems.rs @@ -0,0 +1,14 @@ +use bevy::{prelude::{Commands, ResMut}, tasks::{block_on, futures_lite::future}}; + +use crate::resources::DirworldTasks; + +pub fn remove_completed_tasks(mut commands: Commands, mut tasks: ResMut<DirworldTasks>) { + tasks.retain(|_, task| { + if task.is_finished() { + if let Some(Some(mut command_queue)) = block_on(future::poll_once(&mut *task)) { + commands.append(&mut command_queue); + } + } + !task.is_finished() + }); +} |