pub struct BlockDef { /* private fields */ }Expand description
Contains a Block and can be stored in a Universe.
Together with Primitive::Indirect, this allows mutation of a block definition such
that all its existing usages follow.
To perform such a mutation, use BlockDefTransaction.
Additionally, it caches the results of block evaluation to improve performance.
Note that this cache only updates when the owning Universe is being stepped, or when
a direct mutation to this BlockDef is performed, not when the contained Block
sends a change notification.
Implementations§
Source§impl BlockDef
impl BlockDef
Sourcepub fn new(read_ticket: ReadTicket<'_>, block: Block) -> Self
pub fn new(read_ticket: ReadTicket<'_>, block: Block) -> Self
Constructs a new BlockDef that stores the given block (which may be replaced
in the future).
Sourcepub fn block(&self) -> &Block
pub fn block(&self) -> &Block
Returns the current block value.
Note that if you wish to get the EvaluatedBlock result, you should obtain the cached
value by calling BlockDef.evaluate(), or by using a Primitive::Indirect,
not by calling .block().evaluate(), which is not cached.
Sourcepub fn evaluate(
&self,
read_ticket: ReadTicket<'_>,
) -> Result<EvaluatedBlock, EvalBlockError>
pub fn evaluate( &self, read_ticket: ReadTicket<'_>, ) -> Result<EvaluatedBlock, EvalBlockError>
Returns the current cached evaluation of the current block value.
This returns the same success or error as Block::from(handle_to_self).evaluate() would,
not the same as .block().evaluate() would.
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for BlockDef
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for BlockDef
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl Component for BlockDef
Required Components: [BlockDefNextValue].
impl Component for BlockDef
Required Components: [BlockDefNextValue].
A component’s Required Components are inserted whenever it is inserted. Note that this will also insert the required components of the required components, recursively, in depth-first order.
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
requiree: ComponentId,
components: &mut ComponentsRegistrator<'_>,
required_components: &mut RequiredComponents,
inheritance_depth: u16,
recursion_check_stack: &mut Vec<ComponentId>,
)
fn register_required_components( requiree: ComponentId, components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, inheritance_depth: u16, recursion_check_stack: &mut Vec<ComponentId>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn register_component_hooks(hooks: &mut ComponentHooks)
fn register_component_hooks(hooks: &mut ComponentHooks)
Component::on_add, etc.)ComponentHooks.Source§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreSource§impl Listen for BlockDef
Registers a listener for whenever the result of evaluation of this block definition changes.
Note that this only occurs when the owning Universe is being stepped.
impl Listen for BlockDef
Registers a listener for whenever the result of evaluation of this block definition changes.
Note that this only occurs when the owning Universe is being stepped.
Source§type Msg = BlockChange
type Msg = BlockChange
Source§type Listener = <Notifier<<BlockDef as Listen>::Msg, Arc<dyn Listener<<BlockDef as Listen>::Msg> + Sync + Send>> as Listen>::Listener
type Listener = <Notifier<<BlockDef as Listen>::Msg, Arc<dyn Listener<<BlockDef as Listen>::Msg> + Sync + Send>> as Listen>::Listener
Source§fn listen_raw(&self, listener: Self::Listener)
fn listen_raw(&self, listener: Self::Listener)
Source§impl Transactional for BlockDef
impl Transactional for BlockDef
Source§type Transaction = BlockDefTransaction
type Transaction = BlockDefTransaction
Self.Source§fn transact<'c, F, O>(
&mut self,
f: F,
) -> Result<O, ExecuteError<Self::Transaction>>where
F: FnOnce(&mut Self::Transaction, &Self) -> Result<O, <Self::Transaction as Merge>::Conflict>,
Self::Transaction: Transaction<Target = Self, Context<'c> = (), Output = NoOutput> + Default,
fn transact<'c, F, O>(
&mut self,
f: F,
) -> Result<O, ExecuteError<Self::Transaction>>where
F: FnOnce(&mut Self::Transaction, &Self) -> Result<O, <Self::Transaction as Merge>::Conflict>,
Self::Transaction: Transaction<Target = Self, Context<'c> = (), Output = NoOutput> + Default,
self,
equivalent to the following steps: Read moreSource§impl UTransactional for BlockDef
impl UTransactional for BlockDef
Source§fn bind(
target: Handle<Self>,
transaction: Self::Transaction,
) -> UniverseTransaction
fn bind( target: Handle<Self>, transaction: Self::Transaction, ) -> UniverseTransaction
Source§impl UniverseMember for BlockDef
impl UniverseMember for BlockDef
Source§impl VisitHandles for BlockDef
impl VisitHandles for BlockDef
Source§fn visit_handles(&self, visitor: &mut dyn HandleVisitor)
fn visit_handles(&self, visitor: &mut dyn HandleVisitor)
Auto Trait Implementations§
impl Freeze for BlockDef
impl !RefUnwindSafe for BlockDef
impl Send for BlockDef
impl Sync for BlockDef
impl Unpin for BlockDef
impl !UnwindSafe for BlockDef
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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ids: &mut impl FnMut(ComponentId), )
Source§fn register_required_components(
components: &mut ComponentsRegistrator<'_>,
required_components: &mut RequiredComponents,
)
fn register_required_components( components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, )
Bundle.Source§fn get_component_ids(
components: &Components,
ids: &mut impl FnMut(Option<ComponentId>),
)
fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components( self, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Source§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