summaryrefslogtreecommitdiff
path: root/ecs/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-07-29 13:21:41 +0200
committerHampusM <hampus@hampusmat.com>2024-07-29 13:26:48 +0200
commit519a0ce022c8ac8adc137e50d1d8aecbf77b4ca9 (patch)
tree42e44d493a3f6cd01367f10792381748790edf34 /ecs/src
parent0bc0eeb94b9e5b4600dc84f8e2fcf686a58921df (diff)
feat(ecs): add fn to prepare world without using the event_loop fn
Diffstat (limited to 'ecs/src')
-rw-r--r--ecs/src/lib.rs18
1 files changed, 13 insertions, 5 deletions
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<EventSeq: EventSequence>(&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<EventSeq: EventSequence>(&self)
+ {
+ self.prepare();
let event_seq = EventSeq::ids();