Struct legion::systems::CommandBuffer[][src]

pub struct CommandBuffer { /* fields omitted */ }

A command buffer used to queue mutable changes to the world from a system. This buffer is automatically flushed and refreshed at the beginning of every frame by Schedule. If Schedule is not used, then the user needs to manually flush it by performing CommandBuffer::flush.

Examples

Inserting an entity using the CommandBuffer:

let mut command_buffer = CommandBuffer::new(&world);
let entity = command_buffer.push(());

command_buffer.add_component(entity, Position(123.0));
command_buffer.remove(entity);

command_buffer.flush(&mut world, &mut resources);

Implementations

impl CommandBuffer[src]

pub fn new(world: &World) -> Self[src]

Constructs an empty command buffer.

pub fn world(&self) -> WorldId[src]

Gets the ID of the world this command buffer belongs to.

pub fn flush(&mut self, world: &mut World, resources: &mut Resources)[src]

Flushes this command buffer, draining all stored commands and writing them to the world.

Command flushes are performed in a FIFO manner, allowing for reliable, linear commands being executed in the order they were provided.

pub fn exec_mut<F>(&mut self, f: F) where
    F: 'static + Fn(&mut World, &mut Resources) + Send + Sync
[src]

Executes an arbitrary closure against the mutable world, allowing for queued exclusive access to the world.

pub fn push<T>(&mut self, components: T) -> Entity where
    Option<T>: 'static + IntoComponentSource,
    <Option<T> as IntoComponentSource>::Source: KnownLength + Send + Sync
[src]

Queues the insertion of a single entity into the world.

pub fn extend<T>(&mut self, components: T) -> &[Entity]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
where
    T: 'static + IntoComponentSource,
    <T as IntoComponentSource>::Source: KnownLength + Send + Sync
[src]

Queues the insertion of new entities into the world.

pub fn remove(&mut self, entity: Entity)[src]

Queues the deletion of an entity in the command buffer.

pub fn add_component<C: Component>(&mut self, entity: Entity, component: C)[src]

Queues the addition of a component from an entity in the command buffer.

pub fn remove_component<C: Component>(&mut self, entity: Entity)[src]

Queues the removal of a component from an entity in the command buffer.

pub fn len(&self) -> usize[src]

Returns the current number of commands already queued in this CommandBuffer instance.

pub fn is_empty(&self) -> bool[src]

Returns true if this CommandBuffer is currently empty and contains no writers.

Auto Trait Implementations

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> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

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

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

impl<T> Pointable for T

type Init = T

The type for initializers.

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.