From a32bf356a03a8b5031555877fc6ee906badc21f3 Mon Sep 17 00:00:00 2001 From: Jan Nils Ferner Date: Mon, 20 Feb 2023 22:08:15 +0100 Subject: [PATCH] Refactor some names Former-commit-id: 4ab2b40f1fd33fc73903d255e069e914b4c61d43 --- src/dev.rs | 6 +-- src/dev/{scene_editor.rs => dev_editor.rs} | 44 +++++++++++----------- src/movement/navigation.rs | 4 +- 3 files changed, 27 insertions(+), 27 deletions(-) rename src/dev/{scene_editor.rs => dev_editor.rs} (93%) diff --git a/src/dev.rs b/src/dev.rs index 8571b422..83c0d7e1 100644 --- a/src/dev.rs +++ b/src/dev.rs @@ -1,11 +1,11 @@ -use crate::dev::scene_editor::SceneEditorPlugin; +use crate::dev::dev_editor::DevEditorPlugin; use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}; use bevy::prelude::*; use bevy_editor_pls::prelude::*; use bevy_prototype_debug_lines::DebugLinesPlugin; use bevy_rapier3d::prelude::*; -pub mod scene_editor; +pub mod dev_editor; /// Plugin with debugging utility intended for use during development only. /// Don't include this in a release build. @@ -18,7 +18,7 @@ impl Plugin for DevPlugin { .add_plugin(EditorPlugin) .add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(DebugLinesPlugin::default()) - .add_plugin(SceneEditorPlugin) + .add_plugin(DevEditorPlugin) .add_plugin(LogDiagnosticsPlugin::filtered(vec![])) .add_plugin(RapierDebugRenderPlugin { enabled: false, diff --git a/src/dev/scene_editor.rs b/src/dev/dev_editor.rs similarity index 93% rename from src/dev/scene_editor.rs rename to src/dev/dev_editor.rs index 6f38f991..ec47268d 100644 --- a/src/dev/scene_editor.rs +++ b/src/dev/dev_editor.rs @@ -16,12 +16,25 @@ use oxidized_navigation::NavMesh; use serde::{Deserialize, Serialize}; use strum::IntoEnumIterator; -pub struct SceneEditorPlugin; +pub struct DevEditorPlugin; -pub struct FoxtrotDevWindow; +impl Plugin for DevEditorPlugin { + fn build(&self, app: &mut App) { + app.init_resource::() + .add_editor_window::() + .add_system_set( + SystemSet::on_update(GameState::Playing) + .with_system(handle_debug_render) + .with_system(handle_navmesh_render) + .with_system(set_cursor_grab_mode), + ); + } +} + +pub struct DevEditorWindow; -impl EditorWindow for FoxtrotDevWindow { - type State = SceneEditorState; +impl EditorWindow for DevEditorWindow { + type State = DevEditorState; const NAME: &'static str = "Foxtrot Dev"; const DEFAULT_SIZE: (f32, f32) = (200., 150.); fn ui( @@ -30,7 +43,7 @@ impl EditorWindow for FoxtrotDevWindow { ui: &mut egui::Ui, ) { let state = cx - .state_mut::() + .state_mut::() .expect("Failed to get dev window state"); state.open = true; @@ -109,7 +122,7 @@ impl EditorWindow for FoxtrotDevWindow { #[derive(Debug, Clone, Eq, PartialEq, Resource, Reflect, Serialize, Deserialize)] #[reflect(Resource, Serialize, Deserialize)] -pub struct SceneEditorState { +pub struct DevEditorState { pub open: bool, pub level_name: String, pub save_name: String, @@ -118,7 +131,7 @@ pub struct SceneEditorState { pub navmesh_render_enabled: bool, } -impl Default for SceneEditorState { +impl Default for DevEditorState { fn default() -> Self { Self { level_name: "old_town".to_owned(), @@ -131,22 +144,9 @@ impl Default for SceneEditorState { } } -impl Plugin for SceneEditorPlugin { - fn build(&self, app: &mut App) { - app.init_resource::() - .add_editor_window::() - .add_system_set( - SystemSet::on_update(GameState::Playing) - .with_system(handle_debug_render) - .with_system(handle_navmesh_render) - .with_system(set_cursor_grab_mode), - ); - } -} - fn handle_debug_render(state: Res, mut debug_render_context: ResMut) { debug_render_context.enabled = state - .window_state::() + .window_state::() .expect("Window State Loaded") .collider_render_enabled; } @@ -172,7 +172,7 @@ fn handle_navmesh_render( mut lines: ResMut, ) { if !state - .window_state::() + .window_state::() .expect("Window State Loaded") .navmesh_render_enabled { diff --git a/src/movement/navigation.rs b/src/movement/navigation.rs index 3bffea0d..60bc2e46 100644 --- a/src/movement/navigation.rs +++ b/src/movement/navigation.rs @@ -1,5 +1,5 @@ #[cfg(feature = "dev")] -use crate::dev::scene_editor::FoxtrotDevWindow; +use crate::dev::dev_editor::DevEditorWindow; use crate::movement::general_movement::{apply_walking, reset_movement_components, Walking}; use crate::player_control::player_embodiment::Player; use crate::util::log_error::log_errors; @@ -100,7 +100,7 @@ fn query_mesh( if let Some(path) = path { #[cfg(feature = "dev")] if editor_state - .window_state::() + .window_state::() .context("Failed to get dev window state")? .navmesh_render_enabled {