Skip to content

Commit

Permalink
Refactor some names
Browse files Browse the repository at this point in the history
Former-commit-id: 4ab2b40
  • Loading branch information
janhohenheim committed Feb 20, 2023
1 parent df8c5bd commit a32bf35
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions src/dev.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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,
Expand Down
44 changes: 22 additions & 22 deletions src/dev/scene_editor.rs → src/dev/dev_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<DevEditorState>()
.add_editor_window::<DevEditorWindow>()
.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(
Expand All @@ -30,7 +43,7 @@ impl EditorWindow for FoxtrotDevWindow {
ui: &mut egui::Ui,
) {
let state = cx
.state_mut::<FoxtrotDevWindow>()
.state_mut::<DevEditorWindow>()
.expect("Failed to get dev window state");

state.open = true;
Expand Down Expand Up @@ -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,
Expand All @@ -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(),
Expand All @@ -131,22 +144,9 @@ impl Default for SceneEditorState {
}
}

impl Plugin for SceneEditorPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<SceneEditorState>()
.add_editor_window::<FoxtrotDevWindow>()
.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<Editor>, mut debug_render_context: ResMut<DebugRenderContext>) {
debug_render_context.enabled = state
.window_state::<FoxtrotDevWindow>()
.window_state::<DevEditorWindow>()
.expect("Window State Loaded")
.collider_render_enabled;
}
Expand All @@ -172,7 +172,7 @@ fn handle_navmesh_render(
mut lines: ResMut<DebugLines>,
) {
if !state
.window_state::<FoxtrotDevWindow>()
.window_state::<DevEditorWindow>()
.expect("Window State Loaded")
.navmesh_render_enabled
{
Expand Down
4 changes: 2 additions & 2 deletions src/movement/navigation.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -100,7 +100,7 @@ fn query_mesh(
if let Some(path) = path {
#[cfg(feature = "dev")]
if editor_state
.window_state::<FoxtrotDevWindow>()
.window_state::<DevEditorWindow>()
.context("Failed to get dev window state")?
.navmesh_render_enabled
{
Expand Down

0 comments on commit a32bf35

Please sign in to comment.