summaryrefslogtreecommitdiff
path: root/ecs/src/component
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/component')
-rw-r--r--ecs/src/component/storage.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/ecs/src/component/storage.rs b/ecs/src/component/storage.rs
index ffd682e..54fa834 100644
--- a/ecs/src/component/storage.rs
+++ b/ecs/src/component/storage.rs
@@ -79,6 +79,27 @@ impl Storage
self.archetypes.get(archetype_index)
}
+ pub fn remove_entity(&mut self, entity_uid: Uid)
+ {
+ let Some(archetype_id) = self.entity_archetype_lookup.get(&entity_uid) else {
+ return;
+ };
+
+ let Some(archetype_index) =
+ self.find_archetype_index_with_entity(*archetype_id, entity_uid)
+ else {
+ return;
+ };
+
+ let Some(archetype) = self.archetypes.get_mut(archetype_index) else {
+ return;
+ };
+
+ archetype.take_entity(entity_uid);
+
+ self.entity_archetype_lookup.remove(&entity_uid);
+ }
+
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
pub fn push_entity(
&mut self,