Archetypes

Struct Archetypes 

Source
pub struct Archetypes { /* private fields */ }
Expand description

Contains all the Archetypes and their metadata for a world.

This can be obtained in a handler by using the &Archetypes handler parameter.

world.add_handler(|_: Receiver<E>, archetypes: &Archetypes| {});

Implementations§

Source§

impl Archetypes

Source

pub fn empty(&self) -> &Archetype

Returns a reference to the empty archetype (The archetype with no components).

The empty archetype is always present, so this function is infallible.

Source

pub fn get(&self, idx: ArchetypeIdx) -> Option<&Archetype>

Gets a reference to the archetype identified by the given ArchetypeIdx. Returns None if the index is invalid.

Source

pub fn get_by_components( &self, components: &[ComponentIdx], ) -> Option<&Archetype>

Gets a reference to the archetype with the given set of components.

Returns None if there is no archetype with the given set of components or the given ComponentIdx slice is not sorted and deduplicated.

Source

pub fn iter(&self) -> impl Iterator<Item = &Archetype>

Returns an iterator over all archetypes in an arbitrary order.

Source

pub fn len(&self) -> usize

Returns a count of the archetypes.

Trait Implementations§

Source§

impl Debug for Archetypes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl HandlerParam for &Archetypes

Source§

type State = ()

Persistent data stored in the handler.
Source§

type This<'a> = &'a Archetypes

The type produced by this handler param. This must be the type of Self but with the lifetime of 'a.
Source§

fn init( _world: &mut World, _config: &mut HandlerConfig, ) -> Result<Self::State, InitError>

Initializes the handler using the input World and HandlerConfig. Read more
Source§

unsafe fn get<'a>( _state: &'a mut Self::State, _info: &'a HandlerInfo, _event_ptr: EventPtr<'a>, _target_location: EntityLocation, world: UnsafeWorldCell<'a>, ) -> Self::This<'a>

Obtains a new instance of the handler parameter. Read more
Source§

fn refresh_archetype(_state: &mut Self::State, _arch: &Archetype)

Refresh an archetype for this handler param. Called whenever Handler::refresh_archetype is called.
Source§

fn remove_archetype(_state: &mut Self::State, _arch: &Archetype)

Remove the given archetype for this handler param. Called whenever Handler::remove_archetype is called.
Source§

impl Index<ArchetypeIdx> for Archetypes

Source§

fn index(&self, index: ArchetypeIdx) -> &Self::Output

Panics if the index is invalid.

Source§

type Output = Archetype

The returned type after indexing.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.