Function bevy::prelude::resource_exists_and_equals

pub fn resource_exists_and_equals<T>(value: T) -> impl FnMut(Option<Res<'_, T>>)
where T: Resource + PartialEq,
Expand description

Generates a Condition-satisfying closure that returns true if the resource exists and is equal to value.

The condition will return false if the resource does not exist.


    // `resource_exists_and_equals` will only return true
    // if the given resource exists and equals the given value

fn my_system(mut counter: ResMut<Counter>) {
    counter.0 += 1;

// `Counter` hasn't been added so `my_system` can't run world);

// `Counter` is `0` so `my_system` can run world);
assert_eq!(world.resource::<Counter>().0, 1);

// `Counter` is no longer `0` so `my_system` won't run world);
assert_eq!(world.resource::<Counter>().0, 1);