Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions crates/bevy_ecs/src/schedule/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub type BoxedCondition<In = ()> = Box<dyn ReadOnlySystem<In = In, Out = bool>>;
/// # app.run(&mut world);
/// # assert!(world.resource::<DidRun>().0);
pub trait SystemCondition<Marker, In: SystemInput = ()>:
sealed::SystemCondition<Marker, In>
IntoSystem<In, bool, Marker, System: ReadOnlySystem>
{
/// Returns a new run condition that only returns `true`
/// if both this one and the passed `and` return `true`.
Expand Down Expand Up @@ -373,30 +373,10 @@ pub trait SystemCondition<Marker, In: SystemInput = ()>:
}

impl<Marker, In: SystemInput, F> SystemCondition<Marker, In> for F where
F: sealed::SystemCondition<Marker, In>
F: IntoSystem<In, bool, Marker, System: ReadOnlySystem>
{
}

mod sealed {
use crate::system::{IntoSystem, ReadOnlySystem, SystemInput};

pub trait SystemCondition<Marker, In: SystemInput>:
IntoSystem<In, bool, Marker, System = Self::ReadOnlySystem>
{
// This associated type is necessary to let the compiler
// know that `Self::System` is `ReadOnlySystem`.
type ReadOnlySystem: ReadOnlySystem<In = In, Out = bool>;
}

impl<Marker, In: SystemInput, F> SystemCondition<Marker, In> for F
where
F: IntoSystem<In, bool, Marker>,
F::System: ReadOnlySystem,
{
type ReadOnlySystem = F::System;
}
}

/// A collection of [run conditions](SystemCondition) that may be useful in any bevy app.
pub mod common_conditions {
use super::{NotSystem, SystemCondition};
Expand Down