|
|
|
@ -14,7 +14,10 @@ impl Plugin for IntroPlugin {
|
|
|
|
.run_if(run_once()),
|
|
|
|
.run_if(run_once()),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.add_systems(OnEnter(GameState::Intro), manage_intro)
|
|
|
|
.add_systems(OnEnter(GameState::Intro), manage_intro)
|
|
|
|
.add_systems(OnExit(GameState::Intro), (deactivate::<Intro>, cleanup_intro))
|
|
|
|
.add_systems(
|
|
|
|
|
|
|
|
OnExit(GameState::Intro),
|
|
|
|
|
|
|
|
(deactivate::<Intro>, cleanup_intro),
|
|
|
|
|
|
|
|
)
|
|
|
|
// All of these run during GameState::Intro
|
|
|
|
// All of these run during GameState::Intro
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
Update,
|
|
|
|
Update,
|
|
|
|
@ -23,15 +26,18 @@ impl Plugin for IntroPlugin {
|
|
|
|
manage_intro.run_if(any_component_removed::<ui::TextScrollAnimation>()),
|
|
|
|
manage_intro.run_if(any_component_removed::<ui::TextScrollAnimation>()),
|
|
|
|
// Started when the TextScrollAnimation component is added to the parent entity
|
|
|
|
// Started when the TextScrollAnimation component is added to the parent entity
|
|
|
|
// Updated for as long as there is scrolling text
|
|
|
|
// Updated for as long as there is scrolling text
|
|
|
|
manage_scroll_text_animation
|
|
|
|
manage_scroll_text_animation.run_if(
|
|
|
|
.run_if(any_component_added::<ui::TextScrollAnimation>.or_else(
|
|
|
|
any_component_added::<ui::TextScrollAnimation>.or_else(
|
|
|
|
|keys: Res<Input<KeyCode>>| -> bool { keys.just_pressed(KeyCode::Return) },
|
|
|
|
|keys: Res<Input<KeyCode>>| -> bool {
|
|
|
|
)),
|
|
|
|
keys.just_pressed(KeyCode::Return)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
// Play intro manages playing the intro of each individual paragraph
|
|
|
|
// Play intro manages playing the intro of each individual paragraph
|
|
|
|
// Runs every time the TextScroll component (managed by manage_scroll_text_animation) is updated
|
|
|
|
// Runs every time the TextScroll component (managed by manage_scroll_text_animation) is updated
|
|
|
|
scroll_text
|
|
|
|
scroll_text.run_if(any_with_component::<ui::TextScroll>()),
|
|
|
|
.run_if(any_with_component::<ui::TextScroll>()),
|
|
|
|
)
|
|
|
|
).run_if(in_state(GameState::Intro))
|
|
|
|
.run_if(in_state(GameState::Intro)),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -144,7 +150,11 @@ fn cleanup_intro(
|
|
|
|
info!("Cleaning up intro");
|
|
|
|
info!("Cleaning up intro");
|
|
|
|
|
|
|
|
|
|
|
|
query.iter().for_each(|e| {
|
|
|
|
query.iter().for_each(|e| {
|
|
|
|
commands.entity(e).remove::<ui::TextScrollAnimation>().remove::<ui::TextScroll>().insert(Visibility::Hidden);
|
|
|
|
commands
|
|
|
|
|
|
|
|
.entity(e)
|
|
|
|
|
|
|
|
.remove::<ui::TextScrollAnimation>()
|
|
|
|
|
|
|
|
.remove::<ui::TextScroll>()
|
|
|
|
|
|
|
|
.insert(Visibility::Hidden);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -166,7 +176,13 @@ fn cleanup_intro(
|
|
|
|
struct CurrentIntroParagraph(Option<Entity>);
|
|
|
|
struct CurrentIntroParagraph(Option<Entity>);
|
|
|
|
|
|
|
|
|
|
|
|
fn manage_scroll_text_animation(
|
|
|
|
fn manage_scroll_text_animation(
|
|
|
|
roots: Query<Entity, Or<(With<ui::TextScrollAnimation>, Added<ui::TextScrollAnimation>)>>,
|
|
|
|
roots: Query<
|
|
|
|
|
|
|
|
Entity,
|
|
|
|
|
|
|
|
Or<(
|
|
|
|
|
|
|
|
With<ui::TextScrollAnimation>,
|
|
|
|
|
|
|
|
Added<ui::TextScrollAnimation>,
|
|
|
|
|
|
|
|
)>,
|
|
|
|
|
|
|
|
>,
|
|
|
|
texts: Query<Entity, (With<Text>, With<Intro>)>,
|
|
|
|
texts: Query<Entity, (With<Text>, With<Intro>)>,
|
|
|
|
animated_texts: Query<&ui::TextScroll>,
|
|
|
|
animated_texts: Query<&ui::TextScroll>,
|
|
|
|
parents: Query<&Parent>,
|
|
|
|
parents: Query<&Parent>,
|
|
|
|
|