Struct ActionEncoder

Source
pub struct ActionEncoder<'a> { /* private fields */ }
Expand description

Encoder for actions that require mutable access to World, like spawning/despawning entities and inserting/removing/dropping components and relations.

Systems may declare ActionEncoder argument to record actions that will be executed later. Each system will get its own ActionEncoder instance, so no conflicts will be caused by this argument. In contract &mut World argument will cause system to conflict with all other systems, reducing parallelism.

Provided to component and relation hooks.

Implementations§

Source§

impl<'a> ActionEncoder<'a>

Source

pub fn is_empty(&self) -> bool

Returns true if attached action buffer is empty. That is, no actions were recorded.

Source

pub fn allocate(&self) -> EntityLoc<'_>

Allocates new entity id that can be used with following actions.

Source

pub fn spawn_one<T>(&mut self, component: T) -> EntityLoc<'_>
where T: Component + Send + 'static,

Allocates new entity id and encodes an action to insert bundle to the entity.

Source

pub fn spawn<B>(&mut self, bundle: B) -> EntityLoc<'_>
where B: DynamicComponentBundle + Send + 'static,

Allocates new entity id and encodes an action to insert bundle to the entity.

Source

pub fn spawn_external<B>(&mut self, bundle: B) -> EntityLoc<'_>
where B: DynamicBundle + Send + 'static,

Allocates new entity id and encodes an action to insert bundle to the entity.

Source

pub fn spawn_batch<I>(&mut self, bundles: I) -> SpawnBatch<'_, I>
where I: IntoIterator, I::Item: ComponentBundle + Send + 'static,

Returns an iterator which encodes action to spawn and yield entities using bundles yielded from provided bundles iterator.

Source

pub fn spawn_external_batch<I>(&mut self, bundles: I) -> SpawnBatch<'_, I>
where I: IntoIterator, I::Item: Bundle + Send + 'static,

Returns an iterator which encodes action to spawn and yield entities using bundles yielded from provided bundles iterator.

Source

pub fn despawn(&mut self, entity: impl Entity)

Encodes an action to despawn specified entity.

Source

pub fn despawn_batch(&mut self, entities: impl IntoIterator<Item = EntityId>)

Encodes an action to despawn entities in batch.

Source

pub fn insert<T>(&mut self, entity: impl Entity, component: T)
where T: Component + Send,

Encodes an action to insert component to the specified entity.

Source

pub fn insert_external<T>(&mut self, entity: impl Entity, component: T)
where T: Send + 'static,

Encodes an action to insert component to the specified entity.

Source

pub fn with<F, T>(&mut self, entity: impl Entity, f: F)
where F: FnOnce() -> T + Send + 'static, T: Component,

Encodes an action to insert component to the specified entity.

Source

pub fn with_external<F, T>(&mut self, entity: impl Entity, f: F)
where F: FnOnce() -> T + Send + 'static, T: 'static,

Encodes an action to insert component to the specified entity.

Source

pub fn insert_bundle<B>(&mut self, entity: impl Entity, bundle: B)
where B: DynamicComponentBundle + Send + 'static,

Encodes an action to insert components from bundle to the specified entity.

Source

pub fn insert_external_bundle<B>(&mut self, entity: impl Entity, bundle: B)
where B: DynamicBundle + Send + 'static,

Encodes an action to insert components from bundle to the specified entity.

Source

pub fn with_bundle<B>(&mut self, entity: impl Entity, bundle: B)
where B: DynamicComponentBundle + Send + 'static,

Encodes an action to insert components from bundle to the specified entity.

Source

pub fn with_external_bundle<B>(&mut self, entity: impl Entity, bundle: B)
where B: DynamicBundle + Send + 'static,

Encodes an action to insert components from bundle to the specified entity.

Source

pub fn drop<T>(&mut self, entity: impl Entity)
where T: 'static,

Encodes an action to drop component from specified entity.

Source

pub fn drop_batch<T>(&mut self, entities: impl IntoIterator<Item = EntityId>)
where T: 'static,

Encodes an action to drop component from entities in batch.

Source

pub fn drop_erased(&mut self, entity: impl Entity, ty: TypeId)

Encodes an action to drop component from specified entity.

Source

pub fn drop_erased_batch( &mut self, entities: impl IntoIterator<Item = EntityId>, ty: TypeId, )

Encodes an action to drop component from entities in batch.

Source

pub fn drop_bundle<B>(&mut self, entity: impl Entity)
where B: Bundle,

Encodes an action to drop bundle of components from specified entity.

Source

pub fn insert_relation<R>( &mut self, origin: impl Entity, relation: R, target: impl Entity, )
where R: Relation + Send,

Encodes an action to add relation between two entities to the World.

Source

pub fn drop_relation<R>(&mut self, origin: EntityId, target: EntityId)
where R: Relation,

Encodes an action to drop relation between two entities in the World.

Source

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

Checks if entity is alive.

Source

pub fn insert_resource<T>(&mut self, resource: T)
where T: Send + 'static,

Encodes action to insert resource instance.

Source

pub fn drop_resource<T: 'static>(&mut self)

Encodes an action to drop resource instance.

Source

pub fn closure(&mut self, fun: impl FnOnce(&mut World) + Send + 'static)

Encodes a custom action with a closure that takes reference to World and ActionEncoder that can be used to record new actions.

Source

pub fn reborrow(&mut self) -> ActionEncoder<'_>

Creates new ActionEncoder that records actions into the same ActionBuffer as this one.

Trait Implementations§

Source§

impl FnArg for ActionEncoder<'_>

Source§

type State = ActionEncoderState

State for an argument that is stored between calls to function-system.

Auto Trait Implementations§

§

impl<'a> Freeze for ActionEncoder<'a>

§

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

§

impl<'a> Send for ActionEncoder<'a>

§

impl<'a> !Sync for ActionEncoder<'a>

§

impl<'a> Unpin for ActionEncoder<'a>

§

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

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<'de, F, T> Deserialize<'de, As<F>> for T
where F: BareFormula + ?Sized, T: Deserialize<'de, F>,

Source§

fn deserialize(deserializer: Deserializer<'de>) -> Result<T, DeserializeError>

Deserializes value provided deserializer. Returns deserialized value and the number of bytes consumed from the and of input. Read more
Source§

fn deserialize_in_place( &mut self, deserializer: Deserializer<'de>, ) -> Result<(), DeserializeError>

Deserializes value in-place provided deserializer. Overwrites self with data from the input. Read more
Source§

impl<'de, F, T> Deserialize<'de, Ref<F>> for T
where F: BareFormula + ?Sized, T: Deserialize<'de, F> + ?Sized,

Source§

fn deserialize(de: Deserializer<'de>) -> Result<T, DeserializeError>

Deserializes value provided deserializer. Returns deserialized value and the number of bytes consumed from the and of input. Read more
Source§

fn deserialize_in_place( &mut self, de: Deserializer<'de>, ) -> Result<(), DeserializeError>

Deserializes value in-place provided deserializer. Overwrites self with data from the input. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<F, T> Serialize<As<F>> for T
where F: BareFormula + ?Sized, T: Serialize<F>,

Source§

fn serialize<B>( self, sizes: &mut Sizes, buffer: B, ) -> Result<(), <B as Buffer>::Error>
where B: Buffer,

Serializes self into the given buffer. heap specifies the size of the buffer’s heap occupied prior to this call. Read more
Source§

fn size_hint(&self) -> Option<Sizes>

Returns heap and stack sizes required to serialize self. If some sizes are returned they must be exact. Read more
Source§

impl<F, T> Serialize<Ref<F>> for T
where F: BareFormula + ?Sized, T: Serialize<F>,

Source§

fn serialize<B>( self, sizes: &mut Sizes, buffer: B, ) -> Result<(), <B as Buffer>::Error>
where B: Buffer,

Serializes self into the given buffer. heap specifies the size of the buffer’s heap occupied prior to this call. Read more
Source§

fn size_hint(&self) -> Option<Sizes>

Returns heap and stack sizes required to serialize self. If some sizes are returned they must be exact. Read more
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.