summaryrefslogtreecommitdiff
path: root/ecs/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-08-10 18:50:45 +0200
committerHampusM <hampus@hampusmat.com>2024-08-10 20:56:39 +0200
commit93f764e1003bb6f35b56b7b91a73ae0ca80282c9 (patch)
tree1765bd3ba2e61783e3477211eb84550726e0b7d9 /ecs/src/lib.rs
parentb4be1c1e9a7e69a86a5aa9be6699847edc2c8d0f (diff)
refactor(ecs): create archetype lookup entries on-the-go
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r--ecs/src/lib.rs33
1 files changed, 1 insertions, 32 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs
index 0da8b71..34d6b7b 100644
--- a/ecs/src/lib.rs
+++ b/ecs/src/lib.rs
@@ -94,8 +94,6 @@ impl World
) where
EventT: Event,
{
- system.prepare(&self.data);
-
self.systems.push(system.into_type_erased());
self.data
@@ -155,27 +153,12 @@ impl World
{
match action {
Action::Spawn(components) => {
- {
- let mut component_storage_lock =
- self.data.component_storage.write_nonblock().expect(
- "Failed to acquire read-write component storage lock",
- );
-
- component_storage_lock.push_entity(components);
- }
-
- for system in &self.systems {
- unsafe {
- system.prepare(&self.data);
- }
- }
-
let mut component_storage_lock =
self.data.component_storage.write_nonblock().expect(
"Failed to acquire read-write component storage lock",
);
- component_storage_lock.make_archetype_lookup_entries();
+ component_storage_lock.push_entity(components);
}
Action::Stop => {
self.stop.store(true, Ordering::Relaxed);
@@ -184,18 +167,6 @@ impl World
}
}
- /// 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`]. Before the
/// loop begins, [`StartEvent`] is emitted.
///
@@ -203,8 +174,6 @@ impl World
/// Will panic if a internal lock cannot be acquired.
pub fn event_loop<EventSeq: EventSequence>(&self)
{
- self.prepare();
-
self.emit(StartEvent);
let event_seq = EventSeq::ids();