diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 083f70bd77..56755b9a0a 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -234,6 +234,11 @@ impl Schedule { &self.graph } + /// Returns a mutable reference to the [`ScheduleGraph`]. + pub fn graph_mut(&mut self) -> &mut ScheduleGraph { + &mut self.graph + } + /// Iterates the change ticks of all systems in the schedule and clamps any older than /// [`MAX_CHANGE_AGE`](crate::change_detection::MAX_CHANGE_AGE). /// This prevents overflow and thus prevents false positives. @@ -377,6 +382,7 @@ pub struct ScheduleGraph { ambiguous_with: UnGraphMap, ambiguous_with_flattened: UnGraphMap, ambiguous_with_all: HashSet, + conflicting_systems: Vec<(NodeId, NodeId, Vec)>, changed: bool, settings: ScheduleBuildSettings, default_base_set: Option, @@ -398,6 +404,7 @@ impl ScheduleGraph { ambiguous_with: UnGraphMap::new(), ambiguous_with_flattened: UnGraphMap::new(), ambiguous_with_all: HashSet::new(), + conflicting_systems: Vec::new(), changed: false, settings: default(), default_base_set: None, @@ -500,6 +507,14 @@ impl ScheduleGraph { &self.dependency } + /// Returns the list of systems that conflict with each other, i.e. have ambiguities in their access. + /// + /// If the `Vec` is empty, the systems conflict on [`World`] access. + /// Must be called after [`ScheduleGraph::build_schedule`] to be non-empty. + pub fn conflicting_systems(&self) -> &[(NodeId, NodeId, Vec)] { + &self.conflicting_systems + } + fn add_systems

(&mut self, systems: impl IntoSystemConfigs

) { let SystemConfigs { systems, chained } = systems.into_configs(); let mut system_iter = systems.into_iter(); @@ -1149,6 +1164,7 @@ impl ScheduleGraph { return Err(ScheduleBuildError::Ambiguity); } } + self.conflicting_systems = conflicting_systems; // build the schedule let dg_system_ids = self.dependency_flattened.topsort.clone();