pub struct ObserverWithCondition<E: Event, B: Bundle, M, S: IntoObserverSystem<E, B, M>> { /* private fields */ }Expand description
An observer system with run conditions that preserves event type information.
This type is returned by ObserverSystemExt::run_if
and allows entity.observe(system.run_if(cond)) to work with compile-time
verification that the event implements EntityEvent.
Implementations§
Source§impl<E: Event, B: Bundle, M, S: IntoObserverSystem<E, B, M>> ObserverWithCondition<E, B, M, S>
impl<E: Event, B: Bundle, M, S: IntoObserverSystem<E, B, M>> ObserverWithCondition<E, B, M, S>
Sourcepub fn run_if<C, CM>(self, condition: C) -> Selfwhere
C: SystemCondition<CM>,
pub fn run_if<C, CM>(self, condition: C) -> Selfwhere
C: SystemCondition<CM>,
Adds another run condition to this observer.
All conditions must return true for the observer to run (AND semantics).
Note: Chained .run_if() calls do not short-circuit — all conditions
run every time to maintain correct change detection ticks. If you need
short-circuit behavior, use .run_if(a.and(b)), but be aware this may cause
stale Changed<T> detection if the second condition is frequently skipped.
§Example
world.add_observer(
on_event
.run_if(|a: Res<CondA>| a.0)
.run_if(|b: Res<CondB>| b.0)
);Auto Trait Implementations§
impl<E, B, M, S> !RefUnwindSafe for ObserverWithCondition<E, B, M, S>
impl<E, B, M, S> !UnwindSafe for ObserverWithCondition<E, B, M, S>
impl<E, B, M, S> Freeze for ObserverWithCondition<E, B, M, S>where
S: Freeze,
impl<E, B, M, S> Send for ObserverWithCondition<E, B, M, S>
impl<E, B, M, S> Sync for ObserverWithCondition<E, B, M, S>where
S: Sync,
impl<E, B, M, S> Unpin for ObserverWithCondition<E, B, M, S>where
S: Unpin,
impl<E, B, M, S> UnsafeUnpin for ObserverWithCondition<E, B, M, S>where
S: UnsafeUnpin,
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
impl<T> ConditionalSend for Twhere
T: Send,
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<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.