Bookkeeping

Struct Bookkeeping 

Source
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: EntityStore

Indexed 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

Source

pub fn new() -> Self

Source

pub fn is_alive(&self, e: Entity) -> bool

Source

pub fn create(&mut self) -> Entity

Source

pub fn create_deferred(&self) -> Entity

Source

pub fn realize_deferred(&mut self)

Source

pub fn ensure_alive(&mut self, id: EntityId) -> Entity

Source

pub fn get_component_id(&self, tid: TypeId) -> Option<ComponentId>

Source

pub fn get_component_id_unchecked(&self, tid: TypeId) -> ComponentId

Source

pub fn get_component(&self, e: Entity, cid: ComponentId) -> *const u8

Source

pub fn get_component_opt(&self, e: Entity, cid: ComponentId) -> Option<*mut u8>

Source

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.

Source

pub fn has_component(&self, e: Entity, cid: ComponentId) -> bool

Source

pub fn remove_component(&mut self, e: Entity, cid: ComponentId)

Works for normal components and ZSTs

Source

pub fn matching_archetypes( &self, with: &[ComponentId], without: &[ComponentId], ) -> Vec<ArchetypeId>

Source

pub fn destroy(&mut self, e: Entity)

Source

pub fn add_relation(&mut self, cid: ComponentId, from: Entity, to: Entity)

Source

pub fn remove_relation(&mut self, cid: ComponentId, from: Entity, to: Entity)

Source

pub fn has_relation( &self, origin_cid: ComponentId, from: Entity, to: Entity, ) -> bool

Source

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

Source

pub fn relation_pairs(&self, tid: TypeId) -> Vec<(Entity, Entity)>

Returns all directly related pairs DOES NOT follow transitive relations

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.