Add dev tools
This commit is contained in:
parent
8fc7817154
commit
4dac7c5366
5 changed files with 74 additions and 10 deletions
25
Cargo.lock
generated
25
Cargo.lock
generated
|
@ -590,6 +590,30 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bevy_dev_tools"
|
||||||
|
version = "0.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3e1ae2246832d0fce2f6eb3b7f3d05084a06e36b24bb72cb8b9a171de7e4a341"
|
||||||
|
dependencies = [
|
||||||
|
"bevy_app",
|
||||||
|
"bevy_asset",
|
||||||
|
"bevy_color",
|
||||||
|
"bevy_diagnostic",
|
||||||
|
"bevy_ecs",
|
||||||
|
"bevy_input",
|
||||||
|
"bevy_picking",
|
||||||
|
"bevy_reflect",
|
||||||
|
"bevy_render",
|
||||||
|
"bevy_state",
|
||||||
|
"bevy_text",
|
||||||
|
"bevy_time",
|
||||||
|
"bevy_ui",
|
||||||
|
"bevy_utils",
|
||||||
|
"bevy_window",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_diagnostic"
|
name = "bevy_diagnostic"
|
||||||
version = "0.16.0"
|
version = "0.16.0"
|
||||||
|
@ -786,6 +810,7 @@ dependencies = [
|
||||||
"bevy_color",
|
"bevy_color",
|
||||||
"bevy_core_pipeline",
|
"bevy_core_pipeline",
|
||||||
"bevy_derive",
|
"bevy_derive",
|
||||||
|
"bevy_dev_tools",
|
||||||
"bevy_diagnostic",
|
"bevy_diagnostic",
|
||||||
"bevy_ecs",
|
"bevy_ecs",
|
||||||
"bevy_gizmos",
|
"bevy_gizmos",
|
||||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -25,10 +25,11 @@ bevy = { version = "0.16.0", default-features = false, features = [
|
||||||
"bevy_core_pipeline",
|
"bevy_core_pipeline",
|
||||||
"bevy_remote",
|
"bevy_remote",
|
||||||
"bevy_render",
|
"bevy_render",
|
||||||
|
"bevy_state",
|
||||||
"bevy_ui",
|
"bevy_ui",
|
||||||
"bevy_window",
|
"bevy_window",
|
||||||
"bevy_winit",
|
"bevy_winit",
|
||||||
"dynamic_linking",
|
"default_font",
|
||||||
"multi_threaded",
|
"multi_threaded",
|
||||||
"std",
|
"std",
|
||||||
"wayland",
|
"wayland",
|
||||||
|
@ -44,3 +45,12 @@ rand = { version = "0.9.1", default-features = false, features = [
|
||||||
"thread_rng",
|
"thread_rng",
|
||||||
] }
|
] }
|
||||||
wyrand = "0.3.2"
|
wyrand = "0.3.2"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["dev"]
|
||||||
|
dev = [
|
||||||
|
"bevy/bevy_dev_tools",
|
||||||
|
"bevy/bevy_remote",
|
||||||
|
"bevy/bevy_ui_debug",
|
||||||
|
"bevy/dynamic_linking",
|
||||||
|
]
|
||||||
|
|
30
src/dev.rs
Normal file
30
src/dev.rs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
use bevy::{
|
||||||
|
dev_tools::{
|
||||||
|
fps_overlay::{FpsOverlayConfig, FpsOverlayPlugin},
|
||||||
|
states::log_transitions,
|
||||||
|
},
|
||||||
|
input::common_conditions::input_just_pressed,
|
||||||
|
prelude::*,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::AppState;
|
||||||
|
|
||||||
|
pub(super) fn dev_tools(app: &mut App) {
|
||||||
|
app.add_plugins(FpsOverlayPlugin::default());
|
||||||
|
app.add_systems(
|
||||||
|
Update,
|
||||||
|
(
|
||||||
|
log_transitions::<AppState>,
|
||||||
|
toggle_debug_ui.run_if(input_just_pressed(KeyCode::Digit1)),
|
||||||
|
toggle_fps.run_if(input_just_pressed(KeyCode::Digit2)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn toggle_debug_ui(mut ui: ResMut<UiDebugOptions>) {
|
||||||
|
ui.toggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn toggle_fps(mut fps: ResMut<FpsOverlayConfig>) {
|
||||||
|
fps.enabled = !fps.enabled;
|
||||||
|
}
|
|
@ -4,6 +4,9 @@ use avian2d::{math::Vector, prelude::*};
|
||||||
use bevy::{input::common_conditions::input_pressed, prelude::*};
|
use bevy::{input::common_conditions::input_pressed, prelude::*};
|
||||||
use clap::{Args, Parser};
|
use clap::{Args, Parser};
|
||||||
|
|
||||||
|
#[cfg(feature = "dev")]
|
||||||
|
mod dev;
|
||||||
|
|
||||||
mod game;
|
mod game;
|
||||||
use game::{
|
use game::{
|
||||||
runtime::{move_camera, move_player, quit, zoom_camera},
|
runtime::{move_camera, move_player, quit, zoom_camera},
|
||||||
|
@ -50,6 +53,8 @@ impl Plugin for AppSettings {
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
PhysicsPlugins::default().with_length_unit(50.0),
|
PhysicsPlugins::default().with_length_unit(50.0),
|
||||||
|
#[cfg(feature = "dev")]
|
||||||
|
dev::dev_tools,
|
||||||
))
|
))
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Startup,
|
Startup,
|
||||||
|
@ -71,7 +76,7 @@ impl Plugin for AppSettings {
|
||||||
if let Some(ref seed) = self.source.seed {
|
if let Some(ref seed) = self.source.seed {
|
||||||
app.insert_resource(seed.clone());
|
app.insert_resource(seed.clone());
|
||||||
} else if let Some(ref peer) = self.source.connect {
|
} else if let Some(ref peer) = self.source.connect {
|
||||||
println!("{peer}");
|
info!("Got peer: {peer}");
|
||||||
todo!("Handle connecting to peer and retrieving seed");
|
todo!("Handle connecting to peer and retrieving seed");
|
||||||
} else {
|
} else {
|
||||||
app.insert_resource(Seed::random());
|
app.insert_resource(Seed::random());
|
||||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -1,14 +1,8 @@
|
||||||
use bevy::{
|
use bevy::prelude::{App, AppExit};
|
||||||
prelude::{App, AppExit},
|
|
||||||
remote::{RemotePlugin, http::RemoteHttpPlugin},
|
|
||||||
};
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
use distributed_physics_test::AppSettings;
|
use distributed_physics_test::AppSettings;
|
||||||
|
|
||||||
fn main() -> AppExit {
|
fn main() -> AppExit {
|
||||||
App::new()
|
App::new().add_plugins(AppSettings::parse()).run()
|
||||||
.add_plugins(AppSettings::parse())
|
|
||||||
.add_plugins((RemotePlugin::default(), RemoteHttpPlugin::default()))
|
|
||||||
.run()
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue