diff --git a/lyra-ecs/src/archetype.rs b/lyra-ecs/src/archetype.rs index fc43fe4..a63ea7a 100644 --- a/lyra-ecs/src/archetype.rs +++ b/lyra-ecs/src/archetype.rs @@ -201,10 +201,10 @@ impl ArchetypeId { } pub struct Archetype { - pub(crate) id: ArchetypeId, + pub id: ArchetypeId, pub(crate) entities: HashMap, pub(crate) columns: Vec, - capacity: usize, + pub capacity: usize, } /// The default capacity of the columns @@ -285,14 +285,14 @@ impl Archetype { } /// Returns a boolean indicating whether this archetype can store the TypeIds given - pub(crate) fn is_archetype_for(&self, types: &Vec) -> bool { + pub fn is_archetype_for(&self, types: &Vec) -> bool { if types.len() == self.columns.len() { self.columns.iter().all(|c| types.contains(&c.info.type_id)) } else { false } } /// Returns a boolean indicating whether this archetype has a column for `comp_type` - pub(crate) fn has_column(&self, comp_type: DynTypeId) -> bool { + pub fn has_column(&self, comp_type: DynTypeId) -> bool { self.columns.iter().any(|c| comp_type == c.info.type_id) } @@ -386,6 +386,10 @@ impl Archetype { //self.remove_entity(entity); } + + pub fn entities(&self) -> &HashMap { + &self.entities + } } #[cfg(test)] diff --git a/lyra-ecs/src/query/dynamic/mod.rs b/lyra-ecs/src/query/dynamic/mod.rs index 65d7f3c..ee5e6c3 100644 --- a/lyra-ecs/src/query/dynamic/mod.rs +++ b/lyra-ecs/src/query/dynamic/mod.rs @@ -22,8 +22,8 @@ impl DynamicType { /// Currently it can only fetch from archetypes, later it will be able to fetch dynamic /// resources as well. Its meant to be a single Fetcher for all dynamic types. pub struct FetchDynamicType<'a> { - col: &'a ComponentColumn, - info: ComponentInfo, + pub col: &'a ComponentColumn, + pub info: ComponentInfo, } impl<'a> Fetch<'a> for FetchDynamicType<'a> { @@ -60,11 +60,11 @@ impl QueryDynamicType { } } - fn can_visit_archetype(&self, archetype: &crate::archetype::Archetype) -> bool { + pub fn can_visit_archetype(&self, archetype: &crate::archetype::Archetype) -> bool { archetype.has_column(self.info.type_id) } - unsafe fn fetch<'a>(&self, _world: &'a World, _arch_id: crate::archetype::ArchetypeId, archetype: &'a crate::archetype::Archetype) -> FetchDynamicType<'a> { + pub unsafe fn fetch<'a>(&self, _world: &'a World, _arch_id: crate::archetype::ArchetypeId, archetype: &'a crate::archetype::Archetype) -> FetchDynamicType<'a> { let col = archetype.columns.iter().find(|c| c.info.type_id == self.info.type_id) .expect("You ignored 'can_visit_archetype'!"); diff --git a/lyra-ecs/src/query/dynamic/view.rs b/lyra-ecs/src/query/dynamic/view.rs index 6a314c4..0f0c47d 100644 --- a/lyra-ecs/src/query/dynamic/view.rs +++ b/lyra-ecs/src/query/dynamic/view.rs @@ -43,11 +43,11 @@ impl<'a> IntoIterator for DynamicView<'a> { pub struct DynamicViewIter<'a> { pub world: &'a World, - queries: Vec, - fetchers: Vec>, - archetypes: Vec<&'a Archetype>, - next_archetype: usize, - component_indices: Range, + pub queries: Vec, + pub fetchers: Vec>, + pub archetypes: Vec<&'a Archetype>, + pub next_archetype: usize, + pub component_indices: Range, } impl<'a> Iterator for DynamicViewIter<'a> {