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(crate) id: ArchetypeId,
pub id: ArchetypeId,
pub(crate) entities: HashMap<Entity, ArchetypeEntityId>,
pub(crate) columns: Vec<ComponentColumn>,
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<DynTypeId>) -> bool {
pub fn is_archetype_for(&self, types: &Vec<DynTypeId>) -> 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<Entity, ArchetypeEntityId> {
&self.entities
}
}
#[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
/// 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'!");

View File

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