diff --git a/Cargo.toml b/Cargo.toml index d324026d..026867c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ opt-level = 3 [features] godmode = ["de_spawner/godmode"] +graph_debug_lines = ["de_energy/graph_debug_lines"] [dependencies] # DE @@ -112,7 +113,6 @@ async-compat = "0.2.1" async-std = "1.11" async-tar = "0.4.2" bevy = { version = "0.11", features = ["mp3"] } -bevy_prototype_debug_lines = { version="0.11", features = ["3d"] } bincode = "2.0.0-rc.3" chrono = "0.4.24" clap = { version = "4.0", features = ["derive"] } diff --git a/crates/energy/Cargo.toml b/crates/energy/Cargo.toml index 84d80d96..2964ccd6 100644 --- a/crates/energy/Cargo.toml +++ b/crates/energy/Cargo.toml @@ -13,6 +13,9 @@ categories.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +graph_debug_lines = ["dep:bevy_prototype_debug_lines"] + [dependencies] # DE de_core.workspace = true @@ -21,6 +24,8 @@ de_spawner.workspace = true # Other bevy.workspace = true -bevy_prototype_debug_lines.workspace = true parry3d.workspace = true tinyvec.workspace = true + +# This cannot be a workspace dependency because it is optional +bevy_prototype_debug_lines = { version="0.11", features = ["3d"], optional = true } diff --git a/crates/energy/src/graph.rs b/crates/energy/src/graph.rs index 96e686e2..4c1855a9 100644 --- a/crates/energy/src/graph.rs +++ b/crates/energy/src/graph.rs @@ -2,8 +2,8 @@ use std::collections::HashSet; use bevy::prelude::*; use bevy::utils::petgraph::prelude::*; -use bevy::utils::petgraph::visit::IntoNodeReferences; use bevy::utils::Instant; +#[cfg(feature = "graph_debug_lines")] use bevy_prototype_debug_lines::{DebugLines, DebugLinesPlugin}; use de_core::gamestate::GameState; use de_core::objects::Active; @@ -22,7 +22,6 @@ pub(crate) struct GraphPlugin; impl Plugin for GraphPlugin { fn build(&self, app: &mut App) { app.add_plugins(( - DebugLinesPlugin::default(), DespawnEventsPlugin::<&NearbyUnits, NearbyUnits>::default(), )) .add_systems(OnEnter(GameState::Playing), setup) @@ -36,10 +35,18 @@ impl Plugin for GraphPlugin { update_graph .in_set(GraphSystemSet::UpdateGraph) .after(GraphSystemSet::UpdateNearby), - debug_lines.after(GraphSystemSet::UpdateGraph), + ) .run_if(in_state(GameState::Playing)), ); + + #[cfg(feature = "graph_debug_lines")] + app.add_plugins(DebugLinesPlugin::default()) + .add_systems( + PostUpdate, + (debug_lines) + .run_if(in_state(GameState::Playing)), + ); } } @@ -235,6 +242,7 @@ fn remove_old_nodes( } } +#[cfg(feature = "graph_debug_lines")] fn debug_lines( power_grid: Res, query: Query<&Transform>,