From ae19a96844df4e2eedd13791f914b989f2ee3059 Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Sun, 18 Feb 2024 22:22:11 -0800 Subject: [PATCH] Working better, but not intro -> game animation is missing the game just pops into existance, no bueno. --- assets/martian.tweak.toml | 2 -- src/display3d.rs | 8 ++++--- src/intro.rs | 47 ++++++++++++++++++++++----------------- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/assets/martian.tweak.toml b/assets/martian.tweak.toml index e721177..8e2ae6a 100644 --- a/assets/martian.tweak.toml +++ b/assets/martian.tweak.toml @@ -87,14 +87,12 @@ objective = [ ] ownership = [ """ -> When player or AI moves a piece across the canal, This here line is called the canal. And blow me down if she aint a beaut! See herein lies the kicker of Martian warfare: You control any and only the pieces on your side of the canal. When you move a piece across the canal, your opponent assumes control over it. """, "Keep playing and try to score some points!", ] promotions = [ """ -> When player has either no drones or no Queens Oh and one last thing: real nerds occasionally employ the field promotions strategy. Here's how it works: If you control no drones, you may combine two pawns to make a drone. Similarly, if you control no Queens, you may combine two drones to make a queen. """, ] diff --git a/src/display3d.rs b/src/display3d.rs index d5ac6fa..5d6ddf1 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -83,9 +83,11 @@ impl Plugin for Display3dPlugin { ), setup_capture_piece.run_if(any_component_changed::>), capture_piece.run_if(any_with_component::()), - skip_animation.run_if(|keys: Res>| -> bool { - keys.just_pressed(KeyCode::Return) - }), + skip_animation + .run_if(|keys: Res>| -> bool { + keys.just_pressed(KeyCode::Return) + }) + .run_if(in_state(GameState::Play)), ), ) .add_systems( diff --git a/src/intro.rs b/src/intro.rs index a30c6e1..229ddc1 100644 --- a/src/intro.rs +++ b/src/intro.rs @@ -12,8 +12,12 @@ impl Plugin for IntroPlugin { .run_if(resource_exists::()) .run_if(run_once()), ) - .add_systems(OnEnter(GameState::Intro), (activate::, start_intro)) + .add_systems(OnEnter(GameState::Intro), manage_intro) .add_systems(OnExit(GameState::Intro), deactivate::) + .add_systems( + Update, + manage_intro.run_if(any_component_removed::()), + ) .add_systems( Update, // Started when the TextScrollAnimation component is added to the parent entity @@ -65,8 +69,8 @@ fn init_intro_text( height: Val::Percent(100.0), justify_content: JustifyContent::Center, align_items: AlignItems::Center, - flex_direction: FlexDirection::Column, position_type: PositionType::Absolute, + padding: UiRect::all(Val::Px(50.0)), ..default() }, background_color: Color::NONE.into(), @@ -81,14 +85,11 @@ fn init_intro_text( Intro, NodeBundle { style: Style { - width: Val::Percent(100.0), - justify_content: JustifyContent::Center, - align_content: AlignContent::Center, - flex_direction: FlexDirection::Column, - align_items: AlignItems::Center, - justify_items: JustifyItems::Center, + position_type: PositionType::Absolute, + padding: UiRect::all(Val::Px(25.0)), ..default() }, + visibility: Visibility::Hidden, background_color: Color::hex(&background_hex).unwrap().into(), ..default() }, @@ -97,14 +98,6 @@ fn init_intro_text( parent.spawn(( Intro, 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 { sections: text .chars() @@ -129,13 +122,16 @@ fn init_intro_text( }); } -fn start_intro( - // Hack, this way of "finding" the Node with our animated Text is precarious - query: Query, With, With, Without)>, +fn manage_intro( + // Hack, this way of "finding" the root Node containing our paragraphs is precarious + query: Query, With, Without)>, mut commands: Commands, ) { 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>, texts: Query, With)>, animated_texts: Query<&ui::TextScroll>, + parents: Query<&Parent>, children: Query<&Children>, time: Res