Struct legion::systems::CommandBuffer [−][src]
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]
F: 'static + Fn(&mut World, &mut Resources) + Send + Sync,
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]
Option<T>: 'static + IntoComponentSource,
<Option<T> as IntoComponentSource>::Source: KnownLength + Send + Sync,
Queues the insertion of a single entity into the world.
pub fn extend<T>(&mut self, components: T) -> &[Entity]ⓘ where
T: 'static + IntoComponentSource,
<T as IntoComponentSource>::Source: KnownLength + Send + Sync,
[src]
T: 'static + IntoComponentSource,
<T as IntoComponentSource>::Source: KnownLength + Send + Sync,
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
impl !RefUnwindSafe for CommandBuffer
impl Send for CommandBuffer
impl Sync for CommandBuffer
impl Unpin for CommandBuffer
impl !UnwindSafe for CommandBuffer
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
[src]
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
pub fn as_any(&self) -> &(dyn Any + 'static)
[src]
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> DowncastSync for T where
T: Send + Sync + Any,
[src]
T: Send + Sync + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,