Skip to content

Commit

Permalink
set-bevy-inspector-as-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
naomijub committed Dec 6, 2023
1 parent 9b0d635 commit 8965463
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ lto = "thin"
[features]
dev = [
"bevy/dynamic_linking",
"dep:bevy-inspector-egui"
]
default = ["dev"]

# All of Bevy's default features exept for the audio related ones (bevy_audio, vorbis), since they clash with bevy_kira_audio
# and android_shared_stdcxx, since that is covered in `mobile`
Expand Down Expand Up @@ -63,7 +65,7 @@ webbrowser = { version = "0.8", features = ["hardened"] }
winit = { version = "0.28.7", default-features = false }
image = { version = "0.24", default-features = false }
bevy_egui = "0.23.0"
bevy-inspector-egui = "0.21.0"
bevy-inspector-egui = {version = "0.21.0", optional = true }

[build-dependencies]
embed-resource = "1.4"
5 changes: 3 additions & 2 deletions src/debug_diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ impl Plugin for DiagnosticPlugin {
)
.chain(),
)
.add_systems(Update, (fps_counting, sheep_counter_text))
.add_plugins(bevy_inspector_egui::quick::WorldInspectorPlugin::default());
.add_systems(Update, (fps_counting, sheep_counter_text));
# [cfg(feature = "dev")]
app.add_plugins(bevy_inspector_egui::quick::WorldInspectorPlugin::default());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/player.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::{input::mouse::MouseWheel, pbr::ExtendedMaterial, prelude::*, window::PrimaryWindow};
use bevy::{input::mouse::MouseWheel, prelude::*, window::PrimaryWindow};

use crate::{
get_sprite_rotation,
Expand Down Expand Up @@ -75,7 +75,7 @@ fn spawn_player_by_event(
mut event_reader: EventReader<SpawnPlayer>,
asset_server: Res<AssetServer>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
_materials: ResMut<Assets<StandardMaterial>>,
mut sprite_material: ResMut<Assets<SpriteMaterial>>,
) {
for event in event_reader.read() {
Expand Down
12 changes: 6 additions & 6 deletions src/safe_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl SafeArea {

dx.abs() < size.x / 2.0 && dy.abs() < size.y / 2.0
}
SafeArea::Ellipse { pos1, pos2, radius } => {
SafeArea::Ellipse { pos1, pos2, radius: _ } => {
let d = (*pos1 - *pos2).length();
let r = (*pos1 - sheep_pos).length();
r * r <= d * d
Expand All @@ -43,8 +43,8 @@ impl SafeArea {

pub fn get_center(&self) -> Vec3 {
match self {
SafeArea::Rect { pos, size } => Vec3::new(pos.x, 0.0, pos.y),
SafeArea::Ellipse { pos1, pos2, radius } => {
SafeArea::Rect { pos, size: _ } => Vec3::new(pos.x, 0.0, pos.y),
SafeArea::Ellipse { pos1, pos2, radius: _ } => {
Vec3::new((pos1.x + pos2.x) / 2.0, 0.0, (pos1.y + pos2.y) / 2.0)
}
}
Expand All @@ -62,7 +62,7 @@ fn draw_safe_area(mut gizmos: Gizmos, query: Query<&SafeArea>) {
Color::GREEN,
);
}
SafeArea::Ellipse { pos1, pos2, radius } => {}
SafeArea::Ellipse { pos1: _, pos2: _, radius: _ } => {}
}
}
}
Expand All @@ -73,8 +73,8 @@ pub struct SheepCounter {
}

fn count_sheeps(
mut safe_areas: Query<&SafeArea>,
mut sheep: Query<&Transform, With<Sheep>>,
safe_areas: Query<&SafeArea>,
sheep: Query<&Transform, With<Sheep>>,
mut counter: ResMut<SheepCounter>,
) {
let mut count = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/sheep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn update_scared_sheeps(
time: Res<Time>,
mut sheeps: Query<(&Sheep, &mut Velocity, &mut Decision, &mut IsScared)>,
) {
for mut sheep in sheeps.iter_mut().filter(|q| q.3 .0) {
for mut sheep in sheeps.iter_mut().filter(|q| q.3.0) {
if sheep.3 .1 > 2. {
*sheep.2 = Decision::Idle;
*sheep.1 = Velocity::default();
Expand All @@ -104,7 +104,7 @@ pub fn setup(
);
let sheep_texture: Handle<Image> = asset_server.load(SHEEP_PATH);

let sheep_material = materials.add(StandardMaterial {
let _sheep_material = materials.add(StandardMaterial {
base_color_texture: Some(sheep_texture.clone()),
alpha_mode: AlphaMode::Blend,
..default()
Expand Down

0 comments on commit 8965463

Please sign in to comment.