Deduplicate ambiguity reporting code (#6149)

# Objective

Now that #6083 has been merged, we can clean up some ugly ambiguity detection code.

# Solution

Deduplicate code.
This commit is contained in:
JoJoJet 2022-10-03 16:57:31 +00:00
parent ac364e9e28
commit 8a268129f9

View File

@ -47,42 +47,16 @@ impl SystemOrderAmbiguity {
) -> Self { ) -> Self {
use SystemStageSegment::*; use SystemStageSegment::*;
// TODO: blocked on https://github.com/bevyengine/bevy/pull/4166 let systems = match segment {
// We can't grab the system container generically, because .parallel_systems() Parallel => stage.parallel_systems(),
// and the exclusive equivalent return a different type, ExclusiveAtStart => stage.exclusive_at_start_systems(),
// and SystemContainer is not object-safe ExclusiveBeforeCommands => stage.exclusive_before_commands_systems(),
let (system_a_name, system_b_name) = match segment { ExclusiveAtEnd => stage.exclusive_at_end_systems(),
Parallel => {
let system_container = stage.parallel_systems();
(
system_container[system_a_index].name(),
system_container[system_b_index].name(),
)
}
ExclusiveAtStart => {
let system_container = stage.exclusive_at_start_systems();
(
system_container[system_a_index].name(),
system_container[system_b_index].name(),
)
}
ExclusiveBeforeCommands => {
let system_container = stage.exclusive_before_commands_systems();
(
system_container[system_a_index].name(),
system_container[system_b_index].name(),
)
}
ExclusiveAtEnd => {
let system_container = stage.exclusive_at_end_systems();
(
system_container[system_a_index].name(),
system_container[system_b_index].name(),
)
}
}; };
let mut system_names = [
let mut system_names = [system_a_name.to_string(), system_b_name.to_string()]; systems[system_a_index].name().to_string(),
systems[system_b_index].name().to_string(),
];
system_names.sort(); system_names.sort();
let mut conflicts: Vec<_> = component_ids let mut conflicts: Vec<_> = component_ids