|
|
|
@ -12,8 +12,12 @@ impl Plugin for IntroPlugin {
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>())
|
|
|
|
.run_if(resource_exists::<tweak::GameTweaks>())
|
|
|
|
.run_if(run_once()),
|
|
|
|
.run_if(run_once()),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.add_systems(OnEnter(GameState::Intro), (activate::<Intro>, start_intro))
|
|
|
|
.add_systems(OnEnter(GameState::Intro), manage_intro)
|
|
|
|
.add_systems(OnExit(GameState::Intro), deactivate::<Intro>)
|
|
|
|
.add_systems(OnExit(GameState::Intro), deactivate::<Intro>)
|
|
|
|
|
|
|
|
.add_systems(
|
|
|
|
|
|
|
|
Update,
|
|
|
|
|
|
|
|
manage_intro.run_if(any_component_removed::<ui::TextScrollAnimation>()),
|
|
|
|
|
|
|
|
)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
Update,
|
|
|
|
Update,
|
|
|
|
// Started when the TextScrollAnimation component is added to the parent entity
|
|
|
|
// Started when the TextScrollAnimation component is added to the parent entity
|
|
|
|
@ -65,8 +69,8 @@ fn init_intro_text(
|
|
|
|
height: Val::Percent(100.0),
|
|
|
|
height: Val::Percent(100.0),
|
|
|
|
justify_content: JustifyContent::Center,
|
|
|
|
justify_content: JustifyContent::Center,
|
|
|
|
align_items: AlignItems::Center,
|
|
|
|
align_items: AlignItems::Center,
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
|
|
|
|
position_type: PositionType::Absolute,
|
|
|
|
position_type: PositionType::Absolute,
|
|
|
|
|
|
|
|
padding: UiRect::all(Val::Px(50.0)),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
background_color: Color::NONE.into(),
|
|
|
|
background_color: Color::NONE.into(),
|
|
|
|
@ -81,14 +85,11 @@ fn init_intro_text(
|
|
|
|
Intro,
|
|
|
|
Intro,
|
|
|
|
NodeBundle {
|
|
|
|
NodeBundle {
|
|
|
|
style: Style {
|
|
|
|
style: Style {
|
|
|
|
width: Val::Percent(100.0),
|
|
|
|
position_type: PositionType::Absolute,
|
|
|
|
justify_content: JustifyContent::Center,
|
|
|
|
padding: UiRect::all(Val::Px(25.0)),
|
|
|
|
align_content: AlignContent::Center,
|
|
|
|
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
|
|
|
|
align_items: AlignItems::Center,
|
|
|
|
|
|
|
|
justify_items: JustifyItems::Center,
|
|
|
|
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
visibility: Visibility::Hidden,
|
|
|
|
background_color: Color::hex(&background_hex).unwrap().into(),
|
|
|
|
background_color: Color::hex(&background_hex).unwrap().into(),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -97,14 +98,6 @@ fn init_intro_text(
|
|
|
|
parent.spawn((
|
|
|
|
parent.spawn((
|
|
|
|
Intro,
|
|
|
|
Intro,
|
|
|
|
TextBundle {
|
|
|
|
TextBundle {
|
|
|
|
style: Style {
|
|
|
|
|
|
|
|
// position_type: PositionType::Absolute,
|
|
|
|
|
|
|
|
top: Val::Px(0.0),
|
|
|
|
|
|
|
|
left: Val::Px(0.0),
|
|
|
|
|
|
|
|
justify_self: JustifySelf::Center,
|
|
|
|
|
|
|
|
align_self: AlignSelf::Center,
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
text: Text {
|
|
|
|
text: Text {
|
|
|
|
sections: text
|
|
|
|
sections: text
|
|
|
|
.chars()
|
|
|
|
.chars()
|
|
|
|
@ -129,13 +122,16 @@ fn init_intro_text(
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn start_intro(
|
|
|
|
fn manage_intro(
|
|
|
|
// Hack, this way of "finding" the Node with our animated Text is precarious
|
|
|
|
// Hack, this way of "finding" the root Node containing our paragraphs is precarious
|
|
|
|
query: Query<Entity, (With<Node>, With<Intro>, With<Children>, Without<Parent>)>,
|
|
|
|
query: Query<Entity, (With<Node>, With<Intro>, Without<Parent>)>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
query.iter().for_each(|e| {
|
|
|
|
query.iter().for_each(|e| {
|
|
|
|
commands.entity(e).insert(ui::TextScrollAnimation);
|
|
|
|
commands
|
|
|
|
|
|
|
|
.entity(e)
|
|
|
|
|
|
|
|
.insert(ui::TextScrollAnimation)
|
|
|
|
|
|
|
|
.insert(Visibility::Inherited);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -143,9 +139,11 @@ fn manage_scroll_text_animation(
|
|
|
|
roots: Query<Entity, With<ui::TextScrollAnimation>>,
|
|
|
|
roots: Query<Entity, With<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>,
|
|
|
|
children: Query<&Children>,
|
|
|
|
children: Query<&Children>,
|
|
|
|
time: Res<Time>,
|
|
|
|
time: Res<Time>,
|
|
|
|
framecount: Res<FrameCount>,
|
|
|
|
framecount: Res<FrameCount>,
|
|
|
|
|
|
|
|
mut next_state: ResMut<NextState<GameState>>,
|
|
|
|
mut curr: Local<Option<Entity>>,
|
|
|
|
mut curr: Local<Option<Entity>>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
@ -164,6 +162,9 @@ fn manage_scroll_text_animation(
|
|
|
|
if curr.is_some() {
|
|
|
|
if curr.is_some() {
|
|
|
|
// Hide the last active entity
|
|
|
|
// Hide the last active entity
|
|
|
|
if let Some(e) = *curr {
|
|
|
|
if let Some(e) = *curr {
|
|
|
|
|
|
|
|
let p = parents.get(e).unwrap();
|
|
|
|
|
|
|
|
commands.entity(p.get()).insert(Visibility::Hidden);
|
|
|
|
|
|
|
|
|
|
|
|
commands.entity(e).insert(Visibility::Hidden);
|
|
|
|
commands.entity(e).insert(Visibility::Hidden);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Locate the last entity we were operating with
|
|
|
|
// Locate the last entity we were operating with
|
|
|
|
@ -186,6 +187,7 @@ fn manage_scroll_text_animation(
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
commands.entity(r).remove::<ui::TextScrollAnimation>();
|
|
|
|
commands.entity(r).remove::<ui::TextScrollAnimation>();
|
|
|
|
|
|
|
|
next_state.set(GameState::Play);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -197,6 +199,7 @@ fn scroll_text(
|
|
|
|
tweaks: Res<Assets<tweak::Tweaks>>,
|
|
|
|
tweaks: Res<Assets<tweak::Tweaks>>,
|
|
|
|
time: Res<Time>,
|
|
|
|
time: Res<Time>,
|
|
|
|
keys: Res<Input<KeyCode>>,
|
|
|
|
keys: Res<Input<KeyCode>>,
|
|
|
|
|
|
|
|
parents: Query<&Parent>,
|
|
|
|
mut commands: Commands,
|
|
|
|
mut commands: Commands,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
let tweak = tweaks.get(tweaks_file.handle.clone()).expect("Load tweaks");
|
|
|
|
let tweak = tweaks.get(tweaks_file.handle.clone()).expect("Load tweaks");
|
|
|
|
@ -207,6 +210,10 @@ fn scroll_text(
|
|
|
|
|
|
|
|
|
|
|
|
// If the animation just started, make visible
|
|
|
|
// If the animation just started, make visible
|
|
|
|
if text_scroll.progress == 0 {
|
|
|
|
if text_scroll.progress == 0 {
|
|
|
|
|
|
|
|
let p = parents.get(entity).unwrap();
|
|
|
|
|
|
|
|
commands.entity(p.get()).insert(Visibility::Inherited);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Make the text visible as well
|
|
|
|
*vis = Visibility::Inherited;
|
|
|
|
*vis = Visibility::Inherited;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|