summaryrefslogtreecommitdiff
path: root/ecs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs')
-rw-r--r--ecs/src/component/storage.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/ecs/src/component/storage.rs b/ecs/src/component/storage.rs
index f174ea9..237dd73 100644
--- a/ecs/src/component/storage.rs
+++ b/ecs/src/component/storage.rs
@@ -77,7 +77,7 @@ impl ComponentStorage
.join(", ")
);
- let archetypes_indices = self
+ let archetype_indices = self
.archetype_lookup
.entry(ArchetypeComponentsHash::new(
components
@@ -91,10 +91,16 @@ impl ComponentStorage
vec![self.archetypes.len() - 1]
});
+ if archetype_indices.is_empty() {
+ self.archetypes.push(Archetype::default());
+
+ archetype_indices.push(self.archetypes.len() - 1);
+ }
+
let archetype = self
.archetypes
.get_mut(
- archetypes_indices
+ archetype_indices
.first()
.copied()
.expect("No archetype index found"),