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>
impl<'a> ActionEncoder<'a>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if attached action buffer is empty.
That is, no actions were recorded.
Sourcepub fn allocate(&self) -> EntityLoc<'_>
pub fn allocate(&self) -> EntityLoc<'_>
Allocates new entity id that can be used with following actions.
Sourcepub fn spawn_one<T>(&mut self, component: T) -> EntityLoc<'_>
pub fn spawn_one<T>(&mut self, component: T) -> EntityLoc<'_>
Allocates new entity id and encodes an action to insert bundle to the entity.
Sourcepub fn spawn<B>(&mut self, bundle: B) -> EntityLoc<'_>where
B: DynamicComponentBundle + Send + 'static,
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.
Sourcepub fn spawn_external<B>(&mut self, bundle: B) -> EntityLoc<'_>where
B: DynamicBundle + Send + 'static,
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.
Sourcepub fn spawn_batch<I>(&mut self, bundles: I) -> SpawnBatch<'_, I> ⓘ
pub fn spawn_batch<I>(&mut self, bundles: I) -> SpawnBatch<'_, I> ⓘ
Returns an iterator which encodes action to spawn and yield entities using bundles yielded from provided bundles iterator.
Sourcepub fn spawn_external_batch<I>(&mut self, bundles: I) -> SpawnBatch<'_, I> ⓘ
pub fn spawn_external_batch<I>(&mut self, bundles: I) -> SpawnBatch<'_, I> ⓘ
Returns an iterator which encodes action to spawn and yield entities using bundles yielded from provided bundles iterator.
Sourcepub fn despawn_batch(&mut self, entities: impl IntoIterator<Item = EntityId>)
pub fn despawn_batch(&mut self, entities: impl IntoIterator<Item = EntityId>)
Encodes an action to despawn entities in batch.
Sourcepub fn insert<T>(&mut self, entity: impl Entity, component: T)
pub fn insert<T>(&mut self, entity: impl Entity, component: T)
Encodes an action to insert component to the specified entity.
Sourcepub fn insert_external<T>(&mut self, entity: impl Entity, component: T)where
T: Send + 'static,
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.
Sourcepub fn with<F, T>(&mut self, entity: impl Entity, f: F)
pub fn with<F, T>(&mut self, entity: impl Entity, f: F)
Encodes an action to insert component to the specified entity.
Sourcepub fn with_external<F, T>(&mut self, entity: impl Entity, f: F)
pub fn with_external<F, T>(&mut self, entity: impl Entity, f: F)
Encodes an action to insert component to the specified entity.
Sourcepub fn insert_bundle<B>(&mut self, entity: impl Entity, bundle: B)where
B: DynamicComponentBundle + Send + 'static,
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.
Sourcepub fn insert_external_bundle<B>(&mut self, entity: impl Entity, bundle: B)where
B: DynamicBundle + Send + 'static,
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.
Sourcepub fn with_bundle<B>(&mut self, entity: impl Entity, bundle: B)where
B: DynamicComponentBundle + Send + 'static,
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.
Sourcepub fn with_external_bundle<B>(&mut self, entity: impl Entity, bundle: B)where
B: DynamicBundle + Send + 'static,
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.
Sourcepub fn drop<T>(&mut self, entity: impl Entity)where
T: 'static,
pub fn drop<T>(&mut self, entity: impl Entity)where
T: 'static,
Encodes an action to drop component from specified entity.
Sourcepub fn drop_batch<T>(&mut self, entities: impl IntoIterator<Item = EntityId>)where
T: 'static,
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.
Sourcepub fn drop_erased(&mut self, entity: impl Entity, ty: TypeId)
pub fn drop_erased(&mut self, entity: impl Entity, ty: TypeId)
Encodes an action to drop component from specified entity.
Sourcepub fn drop_erased_batch(
&mut self,
entities: impl IntoIterator<Item = EntityId>,
ty: TypeId,
)
pub fn drop_erased_batch( &mut self, entities: impl IntoIterator<Item = EntityId>, ty: TypeId, )
Encodes an action to drop component from entities in batch.
Sourcepub fn drop_bundle<B>(&mut self, entity: impl Entity)where
B: Bundle,
pub fn drop_bundle<B>(&mut self, entity: impl Entity)where
B: Bundle,
Encodes an action to drop bundle of components from specified entity.
Sourcepub fn insert_relation<R>(
&mut self,
origin: impl Entity,
relation: R,
target: impl Entity,
)
pub fn insert_relation<R>( &mut self, origin: impl Entity, relation: R, target: impl Entity, )
Encodes an action to add relation between two entities to the World.
Sourcepub fn drop_relation<R>(&mut self, origin: EntityId, target: EntityId)where
R: Relation,
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.
Sourcepub fn insert_resource<T>(&mut self, resource: T)where
T: Send + 'static,
pub fn insert_resource<T>(&mut self, resource: T)where
T: Send + 'static,
Encodes action to insert resource instance.
Sourcepub fn drop_resource<T: 'static>(&mut self)
pub fn drop_resource<T: 'static>(&mut self)
Encodes an action to drop resource instance.
Sourcepub fn closure(&mut self, fun: impl FnOnce(&mut World) + Send + 'static)
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.
Sourcepub fn reborrow(&mut self) -> ActionEncoder<'_>
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<'_>
impl FnArg for ActionEncoder<'_>
Source§type State = ActionEncoderState
type State = ActionEncoderState
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<'de, F, T> Deserialize<'de, As<F>> for T
impl<'de, F, T> Deserialize<'de, As<F>> for T
Source§fn deserialize(deserializer: Deserializer<'de>) -> Result<T, DeserializeError>
fn deserialize(deserializer: Deserializer<'de>) -> Result<T, DeserializeError>
Source§fn deserialize_in_place(
&mut self,
deserializer: Deserializer<'de>,
) -> Result<(), DeserializeError>
fn deserialize_in_place( &mut self, deserializer: Deserializer<'de>, ) -> Result<(), DeserializeError>
self with data from the input. Read moreSource§impl<'de, F, T> Deserialize<'de, Ref<F>> for T
impl<'de, F, T> Deserialize<'de, Ref<F>> for T
Source§fn deserialize(de: Deserializer<'de>) -> Result<T, DeserializeError>
fn deserialize(de: Deserializer<'de>) -> Result<T, DeserializeError>
Source§fn deserialize_in_place(
&mut self,
de: Deserializer<'de>,
) -> Result<(), DeserializeError>
fn deserialize_in_place( &mut self, de: Deserializer<'de>, ) -> Result<(), DeserializeError>
self with data from the input. Read moreSource§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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