diff options
author | HampusM <hampus@hampusmat.com> | 2024-08-18 21:15:02 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-08-18 21:15:02 +0200 |
commit | adae9bb8a47071cae274886e777a51df54f27665 (patch) | |
tree | c9f9d9e53e3d00c12cd68a808445454d46f33131 /ecs/src/component | |
parent | ad238a5b3c49ec8e12463a43db9b3a726d1a7657 (diff) |
perf(ecs): make Relation get method use entity archetype lookup
Diffstat (limited to 'ecs/src/component')
-rw-r--r-- | ecs/src/component/storage.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ecs/src/component/storage.rs b/ecs/src/component/storage.rs index 5d9bb06..1bb7fb5 100644 --- a/ecs/src/component/storage.rs +++ b/ecs/src/component/storage.rs @@ -72,6 +72,16 @@ impl Storage self.iter_archetypes_by_lookup(&archetype_id) } + pub fn get_entity_archetype(&self, entity_uid: EntityUid) -> Option<&Archetype> + { + let archetype_id = self.entity_archetype_lookup.get(&entity_uid)?; + + let archetype_index = + self.find_archetype_index_with_entity(*archetype_id, entity_uid)?; + + self.archetypes.get(archetype_index) + } + #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] pub fn push_entity( &mut self, |