Skip to main content

World

Struct World 

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

Sammlung aller Entitäten und ihrer Komponenten.

Implementations§

Source§

impl World

Source

pub fn new() -> Self

Source

pub fn spawn(&mut self) -> Entity

Neue Entität ohne Komponenten.

Source

pub fn despawn(&mut self, entity: Entity) -> bool

Entfernt die Entität samt allen Komponenten; false für bereits tote oder unbekannte Handles.

Source

pub fn alive(&self, entity: Entity) -> bool

Ist das Handle noch aktuell (von keiner neueren Entität abgelöst)?

Source

pub fn entities(&self) -> Vec<Entity>

Alle lebenden Entitäten in Speicherfolge.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn insert<T: Component>( &mut self, entity: Entity, component: T, ) -> Option<T>

Setzt die Komponente und gibt die vorherige zurück; None bei toter Entität.

Source

pub fn get<T: Component>(&self, entity: Entity) -> Option<&T>

Source

pub fn get_mut<T: Component>(&mut self, entity: Entity) -> Option<&mut T>

Source

pub fn remove<T: Component>(&mut self, entity: Entity) -> Option<T>

Entfernt die Komponente und gibt ihren Wert zurück.

Source

pub fn has<T: Component>(&self, entity: Entity) -> bool

Source

pub fn count<T: Component>(&self) -> usize

Wie viele Entitäten tragen diese Komponente?

Source

pub fn for_each<T: Component>(&self, f: impl FnMut(Entity, &T))

Iteriert alle Entitäten mit T (unveränderlich).

Source

pub fn for_each_mut<T: Component>(&mut self, f: impl FnMut(Entity, &mut T))

Iteriert alle Entitäten mit T (ändernd).

Source

pub fn for_each_pair<A: Component, B: Component>( &mut self, f: impl FnMut(Entity, &mut A, &mut B), )

Join über zwei Komponenten; die kleinere Tabelle treibt.

Die beiden Typen müssen verschieden sein (debug_assert).

Trait Implementations§

Source§

impl Default for World

Source§

fn default() -> World

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for World

§

impl !Sync for World

§

impl !UnwindSafe for World

§

impl Freeze for World

§

impl Send for World

§

impl Unpin for World

§

impl UnsafeUnpin for World

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.