|
|
|
@ -13,13 +13,17 @@ impl Plugin for IntroPlugin {
|
|
|
|
.init_resource::<IntroProgress>()
|
|
|
|
.init_resource::<IntroProgress>()
|
|
|
|
.add_systems(OnEnter(GameState::Intro), activate::<Intro>)
|
|
|
|
.add_systems(OnEnter(GameState::Intro), activate::<Intro>)
|
|
|
|
.add_systems(OnExit(GameState::Intro), deactivate::<Intro>)
|
|
|
|
.add_systems(OnExit(GameState::Intro), deactivate::<Intro>)
|
|
|
|
.add_systems(Update, manage_intro_progress
|
|
|
|
.add_systems(
|
|
|
|
|
|
|
|
Update,
|
|
|
|
|
|
|
|
manage_intro_progress
|
|
|
|
.run_if(in_state(GameState::Intro))
|
|
|
|
.run_if(in_state(GameState::Intro))
|
|
|
|
.run_if(not(resource_exists::<IntroPlayed>()))
|
|
|
|
.run_if(not(resource_exists::<IntroPlayed>())),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.add_systems(Update, play_intro
|
|
|
|
.add_systems(
|
|
|
|
|
|
|
|
Update,
|
|
|
|
|
|
|
|
play_intro
|
|
|
|
.run_if(in_state(GameState::Intro))
|
|
|
|
.run_if(in_state(GameState::Intro))
|
|
|
|
.run_if(resource_changed::<IntroProgress>())
|
|
|
|
.run_if(resource_changed::<IntroProgress>()),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
// Continue to play state if the intro is done playing out
|
|
|
|
// Continue to play state if the intro is done playing out
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
@ -106,9 +110,7 @@ fn manage_intro_progress(
|
|
|
|
commands.insert_resource(IntroPlayed);
|
|
|
|
commands.insert_resource(IntroPlayed);
|
|
|
|
// Otherwise progress by N characters (1)
|
|
|
|
// Otherwise progress by N characters (1)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let tweak = tweaks
|
|
|
|
let tweak = tweaks.get(tweaks_file.handle.clone()).expect("Load tweaks");
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
|
|
|
|
.expect("Load tweaks");
|
|
|
|
|
|
|
|
let rate = tweak.get::<u32>("intro_rate").expect("[intro] rate = #");
|
|
|
|
let rate = tweak.get::<u32>("intro_rate").expect("[intro] rate = #");
|
|
|
|
|
|
|
|
|
|
|
|
progress.0 = ((framecount.0 - *start) / rate) as usize;
|
|
|
|
progress.0 = ((framecount.0 - *start) / rate) as usize;
|
|
|
|
@ -133,9 +135,7 @@ fn play_intro(
|
|
|
|
.iter_mut()
|
|
|
|
.iter_mut()
|
|
|
|
.enumerate()
|
|
|
|
.enumerate()
|
|
|
|
// Only operate on sections up to this point
|
|
|
|
// Only operate on sections up to this point
|
|
|
|
.filter_map(|(i, s)| {
|
|
|
|
.filter_map(|(i, s)| (i <= progress.0).then_some(s))
|
|
|
|
(i <= progress.0).then_some(s)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
// Set the alpha to 1.0 making it visible
|
|
|
|
// Set the alpha to 1.0 making it visible
|
|
|
|
.for_each(|s| {
|
|
|
|
.for_each(|s| {
|
|
|
|
s.style.color.set_a(1.0);
|
|
|
|
s.style.color.set_a(1.0);
|
|
|
|
|