From c685177a86e18a477131610fd4667aa5627c7e4e Mon Sep 17 00:00:00 2001 From: "a.yamaev" Date: Wed, 6 Dec 2023 15:13:09 +0300 Subject: [PATCH] Sheep counter --- src/debug_diagnostic.rs | 45 +++++++++++++++++++++++++++++++++++------ src/lib.rs | 3 +++ src/safe_area.rs | 45 +++++++++++++++++++++++++++++++++++++++++ src/sheep.rs | 1 + 4 files changed, 88 insertions(+), 6 deletions(-) diff --git a/src/debug_diagnostic.rs b/src/debug_diagnostic.rs index b9bfdf0..a627a91 100644 --- a/src/debug_diagnostic.rs +++ b/src/debug_diagnostic.rs @@ -1,14 +1,19 @@ use bevy::prelude::*; +use crate::safe_area::SheepCounter; + pub struct DiagnosticPlugin; impl Plugin for DiagnosticPlugin { fn build(&self, app: &mut App) { app.add_systems( Startup, - (setup_diagnostic_panel, apply_deferred, setup_counter), + (setup_diagnostic_panel, apply_deferred, setup_counter, setup_sheep_counter).chain(), ) - .add_systems(Update, (fps_counting,)) + .add_systems(Update, ( + fps_counting, + sheep_counter_text, + )) .add_plugins(bevy_inspector_egui::quick::WorldInspectorPlugin::default()); } } @@ -22,16 +27,18 @@ pub fn setup_diagnostic_panel(mut commands: Commands) { top: Val::Px(0.0), left: Val::Px(0.0), width: Val::Px(100.0), - height: Val::Percent(100.0), position_type: PositionType::Absolute, - flex_direction: FlexDirection::Row, - align_items: AlignItems::Center, + flex_direction: FlexDirection::Column, justify_content: JustifyContent::Center, + align_items: AlignItems::Center, + + align_self: AlignSelf::Stretch, + ..default() }, background_color: BackgroundColor(Color::rgba(0.0, 0.0, 0.0, 0.5)), ..default() - }); + }).insert(DiagnosticPanel); } #[derive(Component)] @@ -53,3 +60,29 @@ fn fps_counting(mut query: Query<&mut Text, With>, time: Res