pub struct ObserverState { /* private fields */ }
Expand description
Contains Observer
information. This defines how a given observer behaves. It is the
“source of truth” for a given observer entity’s behavior.
Implementations§
Source§impl ObserverState
impl ObserverState
Sourcepub fn with_event(self, event: ComponentId) -> Self
pub fn with_event(self, event: ComponentId) -> Self
Observe the given event
. This will cause the Observer
to run whenever an event with the given ComponentId
is triggered.
Sourcepub fn with_events(self, events: impl IntoIterator<Item = ComponentId>) -> Self
pub fn with_events(self, events: impl IntoIterator<Item = ComponentId>) -> Self
Observe the given event list. This will cause the Observer
to run whenever an event with any of the given ComponentId
s
is triggered.
Sourcepub fn with_entities(self, entities: impl IntoIterator<Item = Entity>) -> Self
pub fn with_entities(self, entities: impl IntoIterator<Item = Entity>) -> Self
Sourcepub fn with_components(
self,
components: impl IntoIterator<Item = ComponentId>,
) -> Self
pub fn with_components( self, components: impl IntoIterator<Item = ComponentId>, ) -> Self
Observe the given ComponentId
list. This will cause the Observer
to run whenever the Event
is triggered
for any ComponentId
target in the list.
Trait Implementations§
Source§impl Component for ObserverState
impl Component for ObserverState
Source§const STORAGE_TYPE: StorageType = StorageType::SparseSet
const STORAGE_TYPE: StorageType = StorageType::SparseSet
A constant indicating the storage type used for this component.
Source§type Mutability = Mutable
type Mutability = Mutable
A marker type to assist Bevy with determining if this component is
mutable, or immutable. Mutable components will have [
Component<Mutability = Mutable>
],
while immutable components will instead have [Component<Mutability = Immutable>
]. Read moreSource§fn on_add() -> Option<ComponentHook>
fn on_add() -> Option<ComponentHook>
Source§fn on_remove() -> Option<ComponentHook>
fn on_remove() -> Option<ComponentHook>
Source§fn register_component_hooks(hooks: &mut ComponentHooks)
fn register_component_hooks(hooks: &mut ComponentHooks)
👎Deprecated since 0.16.0: Use the individual hook methods instead (e.g.,
Component::on_add
, etc.)Called when registering this component, allowing mutable access to its
ComponentHooks
.Source§fn on_insert() -> Option<ComponentHook>
fn on_insert() -> Option<ComponentHook>
Source§fn on_replace() -> Option<ComponentHook>
fn on_replace() -> Option<ComponentHook>
Source§fn on_despawn() -> Option<ComponentHook>
fn on_despawn() -> Option<ComponentHook>
Source§fn register_required_components(
_component_id: ComponentId,
_components: &mut ComponentsRegistrator<'_>,
_required_components: &mut RequiredComponents,
_inheritance_depth: u16,
_recursion_check_stack: &mut Vec<ComponentId>,
)
fn register_required_components( _component_id: ComponentId, _components: &mut ComponentsRegistrator<'_>, _required_components: &mut RequiredComponents, _inheritance_depth: u16, _recursion_check_stack: &mut Vec<ComponentId>, )
Registers required components.
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Called when registering this component, allowing to override clone function (or disable cloning altogether) for this component. Read more
Source§fn map_entities<E: EntityMapper>(_this: &mut Self, _mapper: &mut E)
fn map_entities<E: EntityMapper>(_this: &mut Self, _mapper: &mut E)
Maps the entities on this component using the given
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 moreAuto Trait Implementations§
impl Freeze for ObserverState
impl RefUnwindSafe for ObserverState
impl Send for ObserverState
impl Sync for ObserverState
impl Unpin for ObserverState
impl UnwindSafe for ObserverState
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
Mutably borrows from an owned value. Read more
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, )
Registers components that are required by the components in this
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.