pub struct Bookkeeping {
pub component_map: HashMap<TypeId, ComponentId>,
pub component_name_map: HashMap<String, TypeId>,
pub components: Vec<Component>,
pub archetypes: Vec<Archetype>,
pub entities: EntityStore,
pub exact_archetype: HashMap<Vec<ComponentId>, ArchetypeId>,
}Expand description
A struct concerned with the nitty gritty of archetype and component management
Fields§
§component_map: HashMap<TypeId, ComponentId>maps TypeId to ComponentId
for relationships only the Origin Relationship ID is returned
to get the ID for the target use .flip_target()
component_name_map: HashMap<String, TypeId>§components: Vec<Component>Indexed by ComponentId
archetypes: Vec<Archetype>Indexed by ArchetypeId
entities: EntityStoreIndexed by EntityId
exact_archetype: HashMap<Vec<ComponentId>, ArchetypeId>maps to the Archetype which has all the components in the vec and just those
Implementations§
Source§impl Bookkeeping
impl Bookkeeping
pub fn new() -> Self
pub fn is_alive(&self, e: Entity) -> bool
pub fn create(&mut self) -> Entity
pub fn create_deferred(&self) -> Entity
pub fn realize_deferred(&mut self)
pub fn ensure_alive(&mut self, id: EntityId) -> Entity
pub fn get_component_id(&self, tid: TypeId) -> Option<ComponentId>
pub fn get_component_id_unchecked(&self, tid: TypeId) -> ComponentId
pub fn get_component(&self, e: Entity, cid: ComponentId) -> *const u8
pub fn get_component_opt(&self, e: Entity, cid: ComponentId) -> Option<*mut u8>
Sourcepub fn get_component_opt_unchecked(
&self,
e: EntityId,
cid: ComponentId,
) -> Option<*mut u8>
pub fn get_component_opt_unchecked( &self, e: EntityId, cid: ComponentId, ) -> Option<*mut u8>
Does not check if the Entity for the EntityID is alive.
pub fn has_component(&self, e: Entity, cid: ComponentId) -> bool
Sourcepub fn remove_component(&mut self, e: Entity, cid: ComponentId)
pub fn remove_component(&mut self, e: Entity, cid: ComponentId)
Works for normal components and ZSTs
pub fn matching_archetypes( &self, with: &[ComponentId], without: &[ComponentId], ) -> Vec<ArchetypeId>
pub fn destroy(&mut self, e: Entity)
pub fn add_relation(&mut self, cid: ComponentId, from: Entity, to: Entity)
pub fn remove_relation(&mut self, cid: ComponentId, from: Entity, to: Entity)
pub fn has_relation( &self, origin_cid: ComponentId, from: Entity, to: Entity, ) -> bool
Sourcepub fn relation_partners(
&self,
relation_cid: ComponentId,
e: Entity,
) -> Option<impl Iterator<Item = Entity> + use<'_>>
pub fn relation_partners( &self, relation_cid: ComponentId, e: Entity, ) -> Option<impl Iterator<Item = Entity> + use<'_>>
Returns all directly related partners DOES NOT follow transitive relations
Auto Trait Implementations§
impl !Freeze for Bookkeeping
impl !RefUnwindSafe for Bookkeeping
impl !Send for Bookkeeping
impl !Sync for Bookkeeping
impl Unpin for Bookkeeping
impl UnwindSafe for Bookkeeping
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more