[][src]Struct kudo::World

pub struct World { /* fields omitted */ }

The world holds all components and associated entities.

Implementations

impl World[src]

pub fn new() -> Self[src]

Create the world.

pub fn spawn(&mut self, b: impl ComponentBundle) -> Entity[src]

Spawn an entity with components passed in through a tuple. Multiple components can be passed in through the tuple.

Example

let mut world = World::new();
let entity = world.spawn((456, true));

pub fn despawn(&mut self, entity: Entity) -> Result<(), NoSuchEntity>[src]

Remove an entity and all its components from the world. An error is returned if the entity does not exist.

pub fn get_component_mut<T: 'static>(
    &mut self,
    entity: Entity
) -> Result<&mut T, ComponentError>
[src]

Gets mutable access to a single component on an Entity.

pub fn remove_component<T: 'static>(
    &mut self,
    entity: Entity
) -> Result<T, ComponentError>
[src]

Remove a single component from an entity. If successful the component is returned.

Example

let mut world = World::new();
let entity = world.spawn((456, true));
let b = world.remove_component::<bool>(entity).unwrap();

pub fn add_component<T: 'static + Send + Sync>(
    &mut self,
    entity: Entity,
    t: T
) -> Result<(), NoSuchEntity>
[src]

Adds a component to an entity. If the component already exists its data will be replaced.

pub fn query<'world_borrow, T: QueryParams>(
    &'world_borrow self
) -> Result<Query<'_, T>, ComponentAlreadyBorrowed>
[src]

Get a query from the world.

Example

let query = world.query<(&bool, &String)>();

Auto Trait Implementations

impl !RefUnwindSafe for World

impl Send for World

impl Sync for World

impl Unpin for World

impl !UnwindSafe for World

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.