summaryrefslogtreecommitdiff
path: root/ecs/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-06-16 19:30:27 +0200
committerHampusM <hampus@hampusmat.com>2024-06-16 19:51:59 +0200
commit61ce6ce0a603384b07ede2d149f6ec0542a2d03e (patch)
tree4786c775787e7fa493b7918599056c8c566981f9 /ecs/src/lib.rs
parenta7c9b0a9dfe5051a60763e123df47f4c16052e32 (diff)
fix(ecs): update archetype lookups when entity is spawned with Actions
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r--ecs/src/lib.rs29
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);
}