Skip to content

Commit ab109d1

Browse files
committed
Switch to named fields
1 parent 99788a5 commit ab109d1

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

crates/bevy_app/src/app.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,13 @@ impl App {
367367
continue;
368368
}
369369

370-
self.add_schedule(OnTransition(variant.clone(), second), Schedule::new());
370+
self.add_schedule(
371+
OnTransition {
372+
from: variant.clone(),
373+
to: second,
374+
},
375+
Schedule::new(),
376+
);
371377
}
372378
}
373379

crates/bevy_ecs/src/schedule/state.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ pub struct OnEnter<S: States>(pub S);
5555
pub struct OnExit<S: States>(pub S);
5656

5757
/// The label of a [`Schedule`](super::Schedule) that **only** runs whenever [`State<S>`]
58-
/// exits the first given state, AND enters the second given state.
58+
/// exits the `from` state, AND enters the `to` state.
5959
///
6060
/// Systems added to this schedule are always ran *after* [`OnExit`], and *before* [`OnEnter`].
6161
#[derive(ScheduleLabel, Clone, Debug, PartialEq, Eq, Hash)]
62-
pub struct OnTransition<S: States>(pub S, pub S);
62+
pub struct OnTransition<S: States> {
63+
/// The state being exited.
64+
pub from: S,
65+
/// The state being entered.
66+
pub to: S,
67+
}
6368

6469
/// A [`SystemSet`] that will run within `CoreSet::Update` when this state is active.
6570
///
@@ -113,7 +118,10 @@ pub fn apply_state_transition<S: States>(world: &mut World) {
113118

114119
let exited = mem::replace(&mut world.resource_mut::<State<S>>().0, entered.clone());
115120
world.run_schedule(OnExit(exited.clone()));
116-
world.run_schedule(OnTransition(exited, entered.clone()));
121+
world.run_schedule(OnTransition {
122+
from: exited,
123+
to: entered.clone(),
124+
});
117125
world.run_schedule(OnEnter(entered));
118126
}
119127
}

0 commit comments

Comments
 (0)