diff options
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r-- | ecs/src/lib.rs | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index e427150..42cdef3 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -142,12 +142,29 @@ impl World .drain(..) { match action { - Action::Spawn(components) => self - .data - .component_storage - .write_nonblock() - .expect("Failed to acquire read-write component storage lock") - .push_entity(components), + 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(); + } Action::Stop => { self.stop.store(true, Ordering::Relaxed); } |