Skip to content

Commit 39262e5

Browse files
committed
SystemNodeId, SystemSetNodeId
1 parent 53919c3 commit 39262e5

File tree

3 files changed

+163
-118
lines changed

3 files changed

+163
-118
lines changed

crates/bevy_ecs/src/schedule/executor/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ pub use self::single_threaded::SingleThreadedExecutor;
88

99
use fixedbitset::FixedBitSet;
1010

11-
use crate::{
12-
schedule::{BoxedCondition, NodeId},
13-
system::BoxedSystem,
14-
world::World,
15-
};
11+
use crate::schedule::graph_utils::{SystemNodeId, SystemSetNodeId};
12+
use crate::{schedule::BoxedCondition, system::BoxedSystem, world::World};
1613

1714
/// Types that can run a [`SystemSchedule`] on a [`World`].
1815
pub(super) trait SystemExecutor: Send + Sync {
@@ -53,8 +50,8 @@ pub struct SystemSchedule {
5350
pub(super) systems: Vec<BoxedSystem>,
5451
pub(super) system_conditions: Vec<Vec<BoxedCondition>>,
5552
pub(super) set_conditions: Vec<Vec<BoxedCondition>>,
56-
pub(super) system_ids: Vec<NodeId>,
57-
pub(super) set_ids: Vec<NodeId>,
53+
pub(super) system_ids: Vec<SystemNodeId>,
54+
pub(super) set_ids: Vec<SystemSetNodeId>,
5855
pub(super) system_dependencies: Vec<usize>,
5956
pub(super) system_dependents: Vec<Vec<usize>>,
6057
pub(super) sets_with_conditions_of_systems: Vec<FixedBitSet>,

crates/bevy_ecs/src/schedule/graph_utils.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,37 @@ use fixedbitset::FixedBitSet;
88

99
use crate::schedule::set::*;
1010

11+
/// Unique identifier for a system set stored in a [`ScheduleGraph`].
12+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
13+
pub struct SystemNodeId(pub usize);
14+
15+
/// Unique identifier for a system set stored in a [`ScheduleGraph`].
16+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
17+
pub struct SystemSetNodeId(pub usize);
18+
1119
/// Unique identifier for a system or system set stored in a [`ScheduleGraph`].
1220
///
1321
/// [`ScheduleGraph`]: super::ScheduleGraph
1422
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
1523
pub enum NodeId {
1624
/// Identifier for a system.
17-
System(usize),
25+
System(SystemNodeId),
1826
/// Identifier for a system set.
19-
Set(usize),
27+
Set(SystemSetNodeId),
2028
}
2129

2230
impl NodeId {
23-
/// Returns the internal integer value.
24-
pub(crate) fn index(&self) -> usize {
31+
pub(crate) fn system(&self) -> Option<SystemNodeId> {
32+
match self {
33+
NodeId::System(node) => Some(*node),
34+
NodeId::Set(_) => None,
35+
}
36+
}
37+
38+
pub(crate) fn set(&self) -> Option<SystemSetNodeId> {
2539
match self {
26-
NodeId::System(index) | NodeId::Set(index) => *index,
40+
NodeId::System(_) => None,
41+
NodeId::Set(node) => Some(*node),
2742
}
2843
}
2944

0 commit comments

Comments
 (0)