diff --git a/Cargo.lock b/Cargo.lock index 8997931..9fed945 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5055,7 +5055,7 @@ dependencies = [ [[package]] name = "turtle_time" -version = "0.7.3" +version = "0.8.0" dependencies = [ "bevy", "bevy-inspector-egui", diff --git a/Cargo.toml b/Cargo.toml index de973dc..d54b23a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "turtle_time" -version = "0.7.3" +version = "0.8.0" publish = false -authors = ["Mike Eder "] # ToDo: you are the author +authors = ["Mike Eder "] edition = "2021" exclude = ["dist", "build", "assets", "credits"] diff --git a/assets/textures/goose.png b/assets/textures/goose.png new file mode 100644 index 0000000..67af23f Binary files /dev/null and b/assets/textures/goose.png differ diff --git a/src/debug/components.rs b/src/debug/components.rs index 9d7d7b2..983a1de 100644 --- a/src/debug/components.rs +++ b/src/debug/components.rs @@ -15,5 +15,9 @@ pub struct ConsoleReady(pub bool); pub struct PeerInfo(pub String); +#[derive(Resource)] + +pub struct EdibleCount(pub usize); + #[derive(Resource)] pub struct ConsoleUpdateTimer(pub Timer); diff --git a/src/debug/console.rs b/src/debug/console.rs index ab4164a..cde8e97 100644 --- a/src/debug/console.rs +++ b/src/debug/console.rs @@ -1,4 +1,6 @@ -use super::components::{ConsoleReady, ConsoleText, ConsoleUI, ConsoleUpdateTimer, PeerInfo}; +use super::components::{ + ConsoleReady, ConsoleText, ConsoleUI, ConsoleUpdateTimer, EdibleCount, PeerInfo, +}; use crate::loading::FontAssets; use bevy::prelude::*; @@ -58,7 +60,12 @@ pub fn setup_ui(mut commands: Commands, font_assets: Res) { ..Default::default() }, visibility: Visibility::Hidden, - background_color: BackgroundColor(Color::BLACK), + background_color: BackgroundColor(Color::Rgba { + red: 0., + green: 0., + blue: 0., + alpha: 0.7, + }), ..Default::default() }) .with_children(|parent| { @@ -71,24 +78,14 @@ pub fn setup_ui(mut commands: Commands, font_assets: Res) { ..Default::default() }, text: Text { - sections: vec![ - TextSection { - value: "Peer Info: ".to_owned(), - style: TextStyle { - font: font_assets.fira_sans.clone(), - font_size: 15.0, - color: Color::GREEN, - }, + sections: vec![TextSection { + value: "".to_owned(), + style: TextStyle { + font: font_assets.fira_sans.clone(), + font_size: 15.0, + color: Color::GREEN, }, - TextSection { - value: "".to_owned(), - style: TextStyle { - font: font_assets.fira_sans.clone(), - font_size: 15.0, - color: Color::GREEN, - }, - }, - ], + }], ..Default::default() }, ..Default::default() @@ -100,14 +97,22 @@ pub fn setup_ui(mut commands: Commands, font_assets: Res) { .insert(ConsoleUI); commands.insert_resource(PeerInfo("".to_string())); + commands.insert_resource(EdibleCount(0)); commands.insert_resource(ConsoleUpdateTimer(Timer::from_seconds( 1.0, TimerMode::Repeating, ))) } -pub fn set_peer_info(peer_info: ResMut, mut query: Query<&mut Text, With>) { +pub fn update_console_text( + edible_count: ResMut, + peer_info: ResMut, + mut query: Query<&mut Text, With>, +) { for mut text in query.iter_mut() { - text.sections[1].value = peer_info.0.to_string(); + text.sections[0].value = format!( + "Edible count: {}\nPeer Info: \n{}", + edible_count.0, peer_info.0 + ); } } diff --git a/src/debug/plugin.rs b/src/debug/plugin.rs index 6c84e06..0569965 100644 --- a/src/debug/plugin.rs +++ b/src/debug/plugin.rs @@ -5,15 +5,16 @@ use bevy_inspector_egui::quick::WorldInspectorPlugin; use crate::{ menu::connect::LocalHandle, + npc::components::EdibleTarget, player::input::GGRSConfig, player::{ checksum::Checksum, - components::{EdibleSpawnTimer, Player, PlayerHealth}, + components::{Edible, EdibleSpawnTimer, Player, PlayerHealth}, }, AppState, GameState, }; -use super::components::{ConsoleReady, ConsoleUpdateTimer, PeerInfo}; +use super::components::{ConsoleReady, ConsoleUpdateTimer, EdibleCount, PeerInfo}; use super::console::*; pub struct DebugPlugin; @@ -25,6 +26,8 @@ impl Plugin for DebugPlugin { .register_type::() .register_type::() .register_type::() + .register_type::() + .register_type::() .register_type::() .register_type::() .register_type::(); @@ -39,12 +42,17 @@ impl Plugin for ConsolePlugin { app.add_system(setup_ui.in_schedule(OnExit(AppState::Loading))) .add_system(log_ggrs_events.in_set(OnUpdate(GameState::Playing))) .add_system(open_console) - .add_system(set_peer_info.run_if(resource_exists::())) + .add_system(count_edibles.run_if(resource_exists::())) + .add_system(update_console_text.run_if(resource_exists::())) .add_system(reset_console_ready.run_if(resource_exists::())) .add_system(update_peer_info.run_if(resource_exists::>())); } } +pub fn count_edibles(mut edible_count: ResMut, edible_query: Query<&Edible>) { + edible_count.0 = edible_query.iter().collect::>().len(); +} + pub fn update_peer_info( session: Res>, time: Res