cargo fmt

main
Elijah C. Voigt 2 years ago
parent 207d691b2e
commit 7566ca1ca2

@ -13,13 +13,17 @@ impl Plugin for IntroPlugin {
.init_resource::<IntroProgress>()
.add_systems(OnEnter(GameState::Intro), activate::<Intro>)
.add_systems(OnExit(GameState::Intro), deactivate::<Intro>)
.add_systems(Update, manage_intro_progress
.run_if(in_state(GameState::Intro))
.run_if(not(resource_exists::<IntroPlayed>()))
.add_systems(
Update,
manage_intro_progress
.run_if(in_state(GameState::Intro))
.run_if(not(resource_exists::<IntroPlayed>())),
)
.add_systems(Update, play_intro
.run_if(in_state(GameState::Intro))
.run_if(resource_changed::<IntroProgress>())
.add_systems(
Update,
play_intro
.run_if(in_state(GameState::Intro))
.run_if(resource_changed::<IntroProgress>()),
)
// Continue to play state if the intro is done playing out
.add_systems(
@ -89,9 +93,9 @@ fn init_intro_text(
fn manage_intro_progress(
keys: Res<Input<KeyCode>>,
mut start: Local<u32>,
mut progress: ResMut<IntroProgress>,
mut progress: ResMut<IntroProgress>,
framecount: Res<FrameCount>,
mut commands: Commands,
mut commands: Commands,
tweaks_file: Res<tweak::GameTweaks>,
tweaks: Res<Assets<tweak::Tweaks>>,
) {
@ -103,12 +107,10 @@ fn manage_intro_progress(
// If the user hits 'return' set this to the end of the animation
if keys.just_pressed(KeyCode::Return) {
progress.0 = usize::MAX;
commands.insert_resource(IntroPlayed);
commands.insert_resource(IntroPlayed);
// Otherwise progress by N characters (1)
} else {
let tweak = tweaks
.get(tweaks_file.handle.clone())
.expect("Load tweaks");
let tweak = tweaks.get(tweaks_file.handle.clone()).expect("Load tweaks");
let rate = tweak.get::<u32>("intro_rate").expect("[intro] rate = #");
progress.0 = ((framecount.0 - *start) / rate) as usize;
@ -117,9 +119,9 @@ fn manage_intro_progress(
// Upon entering the Intro state, start the intro "animation"
fn play_intro(
mut text: Query<(&mut Text, &mut Visibility), With<Intro>>,
mut text: Query<(&mut Text, &mut Visibility), With<Intro>>,
progress: Res<IntroProgress>,
mut commands: Commands,
mut commands: Commands,
) {
// Iterate over all (one) text
text.iter_mut().for_each(|(mut t, mut v)| {
@ -133,9 +135,7 @@ fn play_intro(
.iter_mut()
.enumerate()
// Only operate on sections up to this point
.filter_map(|(i, s)| {
(i <= progress.0).then_some(s)
})
.filter_map(|(i, s)| (i <= progress.0).then_some(s))
// Set the alpha to 1.0 making it visible
.for_each(|s| {
s.style.color.set_a(1.0);

Loading…
Cancel
Save