diff options
Diffstat (limited to 'ecs/src/actions.rs')
-rw-r--r-- | ecs/src/actions.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ecs/src/actions.rs b/ecs/src/actions.rs index ea4837a..a5aaf0c 100644 --- a/ecs/src/actions.rs +++ b/ecs/src/actions.rs @@ -26,6 +26,20 @@ impl<'world> Actions<'world> .expect("Failed to aquire read-write action queue lock") .push(Action::Spawn(components.into_vec())); } + + /// Adds stopping the loop in [`Engine::event_loop`] at the next oppertune time to the + /// action queue. + /// + /// # Panics + /// Will panic if a mutable internal lock cannot be acquired. + pub fn stop(&mut self) + { + self.world_data + .action_queue + .write_nonblock() + .expect("Failed to aquire read-write action queue lock") + .push(Action::Stop); + } } unsafe impl<'world> SystemParam<'world> for Actions<'world> @@ -66,6 +80,7 @@ unsafe impl<'world> SystemParam<'world> for Actions<'world> pub(crate) enum Action { Spawn(Vec<Box<dyn Component>>), + Stop, } struct Comparable; |