From 81d90ae83792172ddfe7514626d17797ed81e3be Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Mon, 20 May 2024 21:54:59 -0700 Subject: [PATCH] I dont hate this. --- src/display3d.rs | 18 +++++++++++++----- src/menu.rs | 10 +++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/display3d.rs b/src/display3d.rs index 32d9f99..f934a96 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -86,13 +86,21 @@ impl Plugin for Display3dPlugin { switch_sides .run_if(in_state(GameState::Play)) .run_if(state_changed::) - .run_if(in_state(ai::PlayState::Human)), + .run_if(in_state(ai::PlayState::Human)) + .run_if(any_component_added::() + .or_else(any_component_removed::()) + ), + // vantage point camera when playing against AI vantage_point .run_if(in_state(GameState::Play)) - .run_if(in_state(PlayState::AiBogo) - .and_then(in_state(TurnState(Side::B)).and_then(any_component_added::().or_else(any_component_removed::()))) - .or_else(in_state(PlayState::Human).and_then(not(state_changed::))) - ), + .run_if(in_state(PlayState::AiBogo).and_then(in_state(TurnState(Side::B)))) + .run_if(any_component_added::().or_else(any_component_removed::())), + // vantage point camera when playing against human + vantage_point + .run_if(in_state(GameState::Play)) + .run_if(in_state(PlayState::Human)) + .run_if(not(state_changed::)) + .run_if(any_component_added::().or_else(any_component_removed::())), update_pieces .run_if(resource_exists::) .run_if(in_state(GameState::Play)) diff --git a/src/menu.rs b/src/menu.rs index c138d77..5a740a7 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -206,7 +206,7 @@ fn init_play_menu( // Opponent button parent .spawn(( - ButtonAction(ai::PlayState::AiBogo), + ButtonAction(ai::PlayState::Human), ButtonBundle { style: Style { padding: UiRect::all(Val::Px(2.0)), @@ -224,7 +224,7 @@ fn init_play_menu( parent.spawn(TextBundle { text: Text { sections: vec![TextSection { - value: "Opponent: AI".into(), + value: "Human Opponent".into(), style: TextStyle { color: Color::WHITE, font_size: 12.0, @@ -388,7 +388,7 @@ fn handle_button_press( fn manage_ai_button( - mut curr: Res>, + curr: Res>, mut query: Query<(&mut ButtonAction, &Children)>, mut texts: Query<&mut Text>, ) { @@ -402,8 +402,8 @@ fn manage_ai_button( texts.get_mut(*c).iter_mut().for_each(|t| { t.sections.iter_mut().for_each(|s| { s.value = match ba.0 { - PlayState::AiBogo => "Opponent: AI".into(), - PlayState::Human => "Opponent: Human".into() + PlayState::AiBogo => "AI Opponent".into(), + PlayState::Human => "Human Opponent".into() } }); });