Struct specs::world::LazyBuilder

source ·
pub struct LazyBuilder<'a> {
    pub entity: Entity,
    pub lazy: &'a LazyUpdate,
}
Expand description

Like EntityBuilder, but inserts the component lazily, meaning on maintain. If you need those components to exist immediately, you have to insert them into the storages yourself.

Fields§

§entity: Entity

The entity that we’re inserting components for.

§lazy: &'a LazyUpdate

The lazy update reference.

Trait Implementations§

source§

impl<'a> Builder for LazyBuilder<'a>

source§

fn with<C>(self, component: C) -> Selfwhere C: Send + Sync + Component,

Inserts a component using LazyUpdate.

If a component was already associated with the entity, it will overwrite the previous component.

source§

fn build(self) -> Entity

Finishes the building and returns the built entity. Please note that no component is associated to this entity until you call World::maintain.

source§

fn maybe_with<C: Component + Send + Sync>(self, c: Option<C>) -> Selfwhere Self: Sized,

Convenience method that calls self.with(component) if Some(component) is provided Read more
source§

impl<'a> MarkedBuilder for LazyBuilder<'a>

source§

fn marked<M>(self) -> Selfwhere M: Marker,

Add a Marker to the entity by fetching the associated allocator.

This will be applied on the next world.maintain().

Examples
use specs::{
    prelude::*,
    saveload::{MarkedBuilder, SimpleMarker, SimpleMarkerAllocator},
};

struct NetworkSync;

let mut world = World::new();
world.register::<SimpleMarker<NetworkSync>>();
world.insert(SimpleMarkerAllocator::<NetworkSync>::new());

let my_entity = lazy
    .create_entity(&entities)
    /* .with(Component1) */
    .marked::<SimpleMarker<NetworkSync>>()
    .build();
Panics

Panics during world.maintain() in case there’s no allocator added to the World.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for LazyBuilder<'a>

§

impl<'a> Send for LazyBuilder<'a>

§

impl<'a> Sync for LazyBuilder<'a>

§

impl<'a> Unpin for LazyBuilder<'a>

§

impl<'a> !UnwindSafe for LazyBuilder<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> Event for Twhere T: Send + Sync + 'static,

source§

impl<T> Resource for Twhere T: Any + Send + Sync,