From a216c2fc0d7a1da415a0f40617a543ef4d380bb4 Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Thu, 16 Feb 2023 22:20:06 +0100 Subject: [PATCH 1/3] add Schedule::graph_mut --- crates/bevy_ecs/src/schedule/schedule.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 581f80f0086ad..80cc67e65516a 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. From 714c588a9673a03c871751c3313c432a3bef2fdc Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Thu, 2 Feb 2023 23:13:09 +0100 Subject: [PATCH 2/3] expose conflicting systems --- crates/bevy_ecs/src/schedule/schedule.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 80cc67e65516a..8b79ef2ce4d94 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -382,6 +382,7 @@ pub struct ScheduleGraph { ambiguous_with: UnGraphMap, ambiguous_with_flattened: UnGraphMap, ambiguous_with_all: HashSet, + pub conflicting_systems: Vec<(NodeId, NodeId, Vec)>, changed: bool, settings: ScheduleBuildSettings, default_base_set: Option, @@ -403,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, @@ -505,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(); @@ -1154,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(); From d0a210fe92ea4422c097b260cbe0d70a3fd8f31c Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Thu, 16 Feb 2023 23:05:00 +0100 Subject: [PATCH 3/3] make conflicting_systems field private --- crates/bevy_ecs/src/schedule/schedule.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 8b79ef2ce4d94..29138258b1ab3 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -382,7 +382,7 @@ pub struct ScheduleGraph { ambiguous_with: UnGraphMap, ambiguous_with_flattened: UnGraphMap, ambiguous_with_all: HashSet, - pub conflicting_systems: Vec<(NodeId, NodeId, Vec)>, + conflicting_systems: Vec<(NodeId, NodeId, Vec)>, changed: bool, settings: ScheduleBuildSettings, default_base_set: Option,