From 519a0ce022c8ac8adc137e50d1d8aecbf77b4ca9 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 29 Jul 2024 13:21:41 +0200 Subject: feat(ecs): add fn to prepare world without using the event_loop fn --- ecs/src/lib.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'ecs') diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index 95519c9..741b555 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -176,17 +176,25 @@ impl World } } - /// A event loop which runs until a stop is issued with [`Flags::stop`]. - /// - /// # Panics - /// Will panic if a internal lock cannot be acquired. - pub fn event_loop(&self) + /// Prepares the world. Should be called before manually emitting events and after + /// creating entities, registering systems & adding extensions. You do not need to + /// call this function if you use [`event_loop`]. + pub fn prepare(&self) { self.data .component_storage .write_nonblock() .expect("Failed to acquire read-write component storage lock") .make_archetype_lookup_entries(); + } + + /// A event loop which runs until a stop is issued with [`Flags::stop`]. + /// + /// # Panics + /// Will panic if a internal lock cannot be acquired. + pub fn event_loop(&self) + { + self.prepare(); let event_seq = EventSeq::ids(); -- cgit v1.2.3-18-g5258