diff options
author | HampusM <hampus@hampusmat.com> | 2025-01-10 15:09:33 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-01-10 15:09:33 +0100 |
commit | ab2fa8a93de33ccb17ee1efd6f9b8858a8b79253 (patch) | |
tree | ae648720e075dd5862805ef7457748d417b18985 /ecs/src/component/storage.rs | |
parent | 49d954830c1872461b779847907328d50e4364e9 (diff) |
refactor(ecs): add struct for querying using component metadata
Diffstat (limited to 'ecs/src/component/storage.rs')
-rw-r--r-- | ecs/src/component/storage.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/ecs/src/component/storage.rs b/ecs/src/component/storage.rs index 4b7a6b4..5ce587f 100644 --- a/ecs/src/component/storage.rs +++ b/ecs/src/component/storage.rs @@ -14,7 +14,6 @@ use crate::component::{ }; use crate::type_name::TypeName; use crate::uid::Uid; -use crate::util::Sortable; use crate::EntityComponent; #[derive(Debug, Default)] @@ -27,22 +26,21 @@ pub struct Storage impl Storage { - pub fn iter_archetypes_with_comps<CompMetadataList>( + pub fn iter_archetypes_with_comps( &self, - mut comp_metadata_list: CompMetadataList, + comp_metadata: impl AsRef<[ComponentMetadata]>, ) -> ArchetypeRefIter<'_> - where - CompMetadataList: Sortable<Item = ComponentMetadata>, - CompMetadataList: AsRef<[ComponentMetadata]>, { - comp_metadata_list.sort_by_key_b(|metadata| metadata.id); + debug_assert!(comp_metadata + .as_ref() + .is_sorted_by_key(|metadata| metadata.id)); - let archetype_id = ArchetypeId::from_components_metadata(&comp_metadata_list); + let archetype_id = ArchetypeId::from_components_metadata(&comp_metadata); if !self.archetype_lookup.borrow().contains_key(&archetype_id) { self.archetype_lookup.borrow_mut().insert( archetype_id, - self.create_populated_archetype_lookup_entry(comp_metadata_list.as_ref()), + self.create_populated_archetype_lookup_entry(comp_metadata.as_ref()), ); } |