remove SystemSetNode, replace it with inherent functions
This commit is contained in:
parent
f1eace62f0
commit
d0fa5cb036
@ -659,29 +659,6 @@ impl Dag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A [`SystemSet`] with metadata, stored in a [`ScheduleGraph`].
|
|
||||||
struct SystemSetNode {
|
|
||||||
inner: InternedSystemSet,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SystemSetNode {
|
|
||||||
pub fn new(set: InternedSystemSet) -> Self {
|
|
||||||
Self { inner: set }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn name(&self) -> String {
|
|
||||||
format!("{:?}", &self.inner)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_system_type(&self) -> bool {
|
|
||||||
self.inner.system_type().is_some()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_anonymous(&self) -> bool {
|
|
||||||
self.inner.is_anonymous()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A [`SystemWithAccess`] stored in a [`ScheduleGraph`].
|
/// A [`SystemWithAccess`] stored in a [`ScheduleGraph`].
|
||||||
pub struct SystemNode {
|
pub struct SystemNode {
|
||||||
inner: Option<SystemWithAccess>,
|
inner: Option<SystemWithAccess>,
|
||||||
@ -785,7 +762,7 @@ enum UninitializedId {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct SystemSets {
|
struct SystemSets {
|
||||||
/// List of system sets in the schedule
|
/// List of system sets in the schedule
|
||||||
sets: SlotMap<SystemSetKey, SystemSetNode>,
|
sets: SlotMap<SystemSetKey, InternedSystemSet>,
|
||||||
/// List of conditions for each system set, in the same order as `system_sets`
|
/// List of conditions for each system set, in the same order as `system_sets`
|
||||||
conditions: SecondaryMap<SystemSetKey, Vec<ConditionWithAccess>>,
|
conditions: SecondaryMap<SystemSetKey, Vec<ConditionWithAccess>>,
|
||||||
/// Map from system set to node id
|
/// Map from system set to node id
|
||||||
@ -795,7 +772,7 @@ struct SystemSets {
|
|||||||
impl SystemSets {
|
impl SystemSets {
|
||||||
fn get_or_add_set(&mut self, set: InternedSystemSet) -> SystemSetKey {
|
fn get_or_add_set(&mut self, set: InternedSystemSet) -> SystemSetKey {
|
||||||
*self.ids.entry(set).or_insert_with(|| {
|
*self.ids.entry(set).or_insert_with(|| {
|
||||||
let key = self.sets.insert(SystemSetNode::new(set));
|
let key = self.sets.insert(set);
|
||||||
self.conditions.insert(key, Vec::new());
|
self.conditions.insert(key, Vec::new());
|
||||||
key
|
key
|
||||||
})
|
})
|
||||||
@ -875,7 +852,7 @@ impl ScheduleGraph {
|
|||||||
|
|
||||||
/// Returns the set at the given [`NodeId`], if it exists.
|
/// Returns the set at the given [`NodeId`], if it exists.
|
||||||
pub fn get_set_at(&self, key: SystemSetKey) -> Option<&dyn SystemSet> {
|
pub fn get_set_at(&self, key: SystemSetKey) -> Option<&dyn SystemSet> {
|
||||||
self.system_sets.sets.get(key).map(|set| &*set.inner)
|
self.system_sets.sets.get(key).map(|set| &**set)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the set at the given [`NodeId`].
|
/// Returns the set at the given [`NodeId`].
|
||||||
@ -917,10 +894,9 @@ impl ScheduleGraph {
|
|||||||
pub fn system_sets(
|
pub fn system_sets(
|
||||||
&self,
|
&self,
|
||||||
) -> impl Iterator<Item = (SystemSetKey, &dyn SystemSet, &[ConditionWithAccess])> {
|
) -> impl Iterator<Item = (SystemSetKey, &dyn SystemSet, &[ConditionWithAccess])> {
|
||||||
self.system_sets.sets.iter().filter_map(|(key, set_node)| {
|
self.system_sets.sets.iter().filter_map(|(key, set)| {
|
||||||
let set = &*set_node.inner;
|
|
||||||
let conditions = self.system_sets.conditions.get(key)?.as_slice();
|
let conditions = self.system_sets.conditions.get(key)?.as_slice();
|
||||||
Some((key, set, conditions))
|
Some((key, &**set, conditions))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1704,7 +1680,7 @@ impl ScheduleGraph {
|
|||||||
if set.is_anonymous() {
|
if set.is_anonymous() {
|
||||||
self.anonymous_set_name(id)
|
self.anonymous_set_name(id)
|
||||||
} else {
|
} else {
|
||||||
set.name()
|
set.debug_name()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use alloc::boxed::Box;
|
use alloc::{boxed::Box, format, string::String};
|
||||||
use bevy_utils::prelude::DebugName;
|
use bevy_utils::prelude::DebugName;
|
||||||
use core::{
|
use core::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
@ -175,6 +175,18 @@ define_label!(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl dyn SystemSet {
|
||||||
|
/// Returns the name of this system set for debugging purposes.
|
||||||
|
pub fn debug_name(&self) -> String {
|
||||||
|
format!("{self:?}")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if this system set is a [`SystemTypeSet`].
|
||||||
|
pub fn is_system_type(&self) -> bool {
|
||||||
|
self.system_type().is_some()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A shorthand for `Interned<dyn SystemSet>`.
|
/// A shorthand for `Interned<dyn SystemSet>`.
|
||||||
pub type InternedSystemSet = Interned<dyn SystemSet>;
|
pub type InternedSystemSet = Interned<dyn SystemSet>;
|
||||||
/// A shorthand for `Interned<dyn ScheduleLabel>`.
|
/// A shorthand for `Interned<dyn ScheduleLabel>`.
|
||||||
|
Loading…
Reference in New Issue
Block a user