Make fields and methods pub

This commit is contained in:
SeanOMik 2023-12-16 11:36:49 -05:00
parent 68a2868478
commit 1ab79fae83
Signed by: SeanOMik
GPG Key ID: 568F326C7EB33ACB
3 changed files with 17 additions and 13 deletions

View File

@ -201,10 +201,10 @@ impl ArchetypeId {
} }
pub struct Archetype { pub struct Archetype {
pub(crate) id: ArchetypeId, pub id: ArchetypeId,
pub(crate) entities: HashMap<Entity, ArchetypeEntityId>, pub(crate) entities: HashMap<Entity, ArchetypeEntityId>,
pub(crate) columns: Vec<ComponentColumn>, pub(crate) columns: Vec<ComponentColumn>,
capacity: usize, pub capacity: usize,
} }
/// The default capacity of the columns /// The default capacity of the columns
@ -285,14 +285,14 @@ impl Archetype {
} }
/// Returns a boolean indicating whether this archetype can store the TypeIds given /// Returns a boolean indicating whether this archetype can store the TypeIds given
pub(crate) fn is_archetype_for(&self, types: &Vec<DynTypeId>) -> bool { pub fn is_archetype_for(&self, types: &Vec<DynTypeId>) -> bool {
if types.len() == self.columns.len() { if types.len() == self.columns.len() {
self.columns.iter().all(|c| types.contains(&c.info.type_id)) self.columns.iter().all(|c| types.contains(&c.info.type_id))
} else { false } } else { false }
} }
/// Returns a boolean indicating whether this archetype has a column for `comp_type` /// 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) self.columns.iter().any(|c| comp_type == c.info.type_id)
} }
@ -386,6 +386,10 @@ impl Archetype {
//self.remove_entity(entity); //self.remove_entity(entity);
} }
pub fn entities(&self) -> &HashMap<Entity, ArchetypeEntityId> {
&self.entities
}
} }
#[cfg(test)] #[cfg(test)]

View File

@ -22,8 +22,8 @@ impl DynamicType {
/// Currently it can only fetch from archetypes, later it will be able to fetch dynamic /// 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. /// resources as well. Its meant to be a single Fetcher for all dynamic types.
pub struct FetchDynamicType<'a> { pub struct FetchDynamicType<'a> {
col: &'a ComponentColumn, pub col: &'a ComponentColumn,
info: ComponentInfo, pub info: ComponentInfo,
} }
impl<'a> Fetch<'a> for FetchDynamicType<'a> { 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) 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) let col = archetype.columns.iter().find(|c| c.info.type_id == self.info.type_id)
.expect("You ignored 'can_visit_archetype'!"); .expect("You ignored 'can_visit_archetype'!");

View File

@ -43,11 +43,11 @@ impl<'a> IntoIterator for DynamicView<'a> {
pub struct DynamicViewIter<'a> { pub struct DynamicViewIter<'a> {
pub world: &'a World, pub world: &'a World,
queries: Vec<QueryDynamicType>, pub queries: Vec<QueryDynamicType>,
fetchers: Vec<FetchDynamicType<'a>>, pub fetchers: Vec<FetchDynamicType<'a>>,
archetypes: Vec<&'a Archetype>, pub archetypes: Vec<&'a Archetype>,
next_archetype: usize, pub next_archetype: usize,
component_indices: Range<u64>, pub component_indices: Range<u64>,
} }
impl<'a> Iterator for DynamicViewIter<'a> { impl<'a> Iterator for DynamicViewIter<'a> {