diff options
author | HampusM <hampus@hampusmat.com> | 2024-04-06 12:30:49 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-04-06 13:44:26 +0200 |
commit | 519a73f83848ea668fe79895e6643cff4c5c51be (patch) | |
tree | 23e52eac67f80241f4efe590a05c17d489d48a2b /ecs/src/lib.rs | |
parent | 3e6d04be56e910f77048442a3c744298ef856ca1 (diff) |
feat(ecs): add stopping event loop
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r-- | ecs/src/lib.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index 339a314..fc97d42 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -26,6 +26,7 @@ use crate::type_name::TypeName; pub mod actions; pub mod component; pub mod event; +pub mod flags; pub mod lock; pub mod system; pub mod tuple; @@ -166,6 +167,16 @@ impl World } self.perform_queued_actions(); + + let flags = self + .data + .flags + .read_nonblock() + .expect("Failed to aquire lock to flags"); + + if flags.stop { + break; + } } } @@ -187,11 +198,26 @@ impl World } #[derive(Debug, Default)] +struct WorldFlags +{ + stop: bool, +} + +impl TypeName for WorldFlags +{ + fn type_name(&self) -> &'static str + { + type_name::<Self>() + } +} + +#[derive(Debug, Default)] pub struct WorldData { events: HashMap<EventId, Vec<usize>>, component_storage: Arc<Lock<ComponentStorage>>, action_queue: Lock<ActionQueue>, + flags: Lock<WorldFlags>, } #[derive(Debug, Default)] |