use a range instead of a start index
This commit is contained in:
parent
96479b84f9
commit
86e6b9534c
@ -15,6 +15,7 @@ use bevy_utils::{default, prelude::DebugName, TypeIdMap};
|
|||||||
use core::{
|
use core::{
|
||||||
any::{Any, TypeId},
|
any::{Any, TypeId},
|
||||||
fmt::{Debug, Write},
|
fmt::{Debug, Write},
|
||||||
|
ops::Range,
|
||||||
};
|
};
|
||||||
use fixedbitset::FixedBitSet;
|
use fixedbitset::FixedBitSet;
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
@ -765,21 +766,20 @@ enum UninitializedId {
|
|||||||
/// A system set's conditions that have not been initialized yet.
|
/// A system set's conditions that have not been initialized yet.
|
||||||
Set {
|
Set {
|
||||||
key: SystemSetKey,
|
key: SystemSetKey,
|
||||||
/// The index in [`SystemSets::conditions`] where the first
|
/// The range of indices in [`SystemSets::conditions`] that correspond
|
||||||
/// uninitialized condition is. All conditions after this index also
|
/// to conditions that have not been initialized yet.
|
||||||
/// still need to be initialized.
|
|
||||||
///
|
///
|
||||||
/// Conditions might be added multiple times to a system set (e.g. when
|
/// [`SystemSets::conditions`] for a given set may be appended to
|
||||||
/// `configure_sets` is called multiple times with the same set), so we
|
/// multiple times (e.g. when `configure_sets` is called multiple with
|
||||||
/// need to track where the newly added conditions start in the
|
/// the same set), so we need to track which conditions in that list
|
||||||
/// `conditions` list.
|
/// are newly added and not yet initialized.
|
||||||
///
|
///
|
||||||
/// Note: We don't need to do this for systems because calling
|
/// Note: We don't need to do this for systems because calling
|
||||||
/// `add_systems` multiple times with the same system results in
|
/// `add_systems` multiple times with the same system results in
|
||||||
/// multiple duplicates of that system in the graph, each with their own
|
/// multiple duplicates of that system in the graph, each with their own
|
||||||
/// separate list of conditions. That means all of a system's conditions
|
/// separate list of conditions. That means all of a system's conditions
|
||||||
/// are always initialized together.
|
/// are always initialized together.
|
||||||
first_uninit_condition: usize,
|
uninitialized_conditions: Range<usize>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1123,9 +1123,10 @@ impl ScheduleGraph {
|
|||||||
|
|
||||||
// system init has to be deferred (need `&mut World`)
|
// system init has to be deferred (need `&mut World`)
|
||||||
let system_set_conditions = self.system_sets.conditions.entry(key).unwrap().or_default();
|
let system_set_conditions = self.system_sets.conditions.entry(key).unwrap().or_default();
|
||||||
|
let start = system_set_conditions.len();
|
||||||
self.uninit.push(UninitializedId::Set {
|
self.uninit.push(UninitializedId::Set {
|
||||||
key,
|
key,
|
||||||
first_uninit_condition: system_set_conditions.len(),
|
uninitialized_conditions: start..(start + conditions.len()),
|
||||||
});
|
});
|
||||||
system_set_conditions.extend(conditions.into_iter().map(ConditionWithAccess::new));
|
system_set_conditions.extend(conditions.into_iter().map(ConditionWithAccess::new));
|
||||||
|
|
||||||
@ -1211,11 +1212,9 @@ impl ScheduleGraph {
|
|||||||
}
|
}
|
||||||
UninitializedId::Set {
|
UninitializedId::Set {
|
||||||
key,
|
key,
|
||||||
first_uninit_condition,
|
uninitialized_conditions,
|
||||||
} => {
|
} => {
|
||||||
for condition in self.system_sets.conditions[key]
|
for condition in &mut self.system_sets.conditions[key][uninitialized_conditions]
|
||||||
.iter_mut()
|
|
||||||
.skip(first_uninit_condition)
|
|
||||||
{
|
{
|
||||||
condition.access = condition.condition.initialize(world);
|
condition.access = condition.condition.initialize(world);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user