From 463da65e4b9608998a86bf2b9b9dc7a02ad6bcc8 Mon Sep 17 00:00:00 2001 From: kEpEx Date: Sat, 7 Sep 2024 08:16:01 -0700 Subject: [PATCH 1/2] at least It compiles --- Cargo.lock | 292 ++++++++++++++++++ Cargo.toml | 6 +- src/dev.rs | 25 +- src/dev/dev_editor.rs | 85 +++++ src/ingame_menu.rs | 2 +- src/level_instantiation/on_spawn/util.rs | 2 +- src/menu.rs | 10 +- .../character_controller/animation.rs | 62 ++-- src/movement/navigation.rs | 80 +++-- src/player_control/camera/rig/arm.rs | 2 +- 10 files changed, 496 insertions(+), 70 deletions(-) create mode 100644 src/dev/dev_editor.rs diff --git a/Cargo.lock b/Cargo.lock index 2483302e..72ad838c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -802,6 +802,47 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "bevy_editor_pls" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02242646d9efb114c156b11ade613bc47339133422c261435eca8c07c36f6dd7" +dependencies = [ + "bevy", + "bevy_editor_pls_core", + "bevy_editor_pls_default_windows", + "egui", + "transform-gizmo-bevy", +] + +[[package]] +name = "bevy_editor_pls_core" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c405936c0efb9279ce9a0689cd40df87fd94b85d9723530a8f88d2f98627eb9" +dependencies = [ + "bevy", + "bevy-inspector-egui", + "egui_dock", + "indexmap", +] + +[[package]] +name = "bevy_editor_pls_default_windows" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c81d69f24cc6b61f0f62f997c491365a1c0956b6276530e4fec12c5839c8fff4" +dependencies = [ + "bevy", + "bevy-inspector-egui", + "bevy_editor_pls_core", + "bevy_mod_debugdump", + "indexmap", + "opener", + "pretty-type-name", + "transform-gizmo-bevy", +] + [[package]] name = "bevy_egui" version = "0.28.0" @@ -915,6 +956,25 @@ dependencies = [ "thiserror", ] +[[package]] +name = "bevy_gltf_blueprints" +version = "0.11.0" +source = "git+https://github.com/kaosat-dev/Blenvy?branch=bevy-0.14#93ef2a7808b66ba1e67df1cb7b99888676fdc51c" +dependencies = [ + "bevy", + "bevy_gltf_components", +] + +[[package]] +name = "bevy_gltf_components" +version = "0.6.0" +source = "git+https://github.com/kaosat-dev/Blenvy?branch=bevy-0.14#93ef2a7808b66ba1e67df1cb7b99888676fdc51c" +dependencies = [ + "bevy", + "ron", + "serde", +] + [[package]] name = "bevy_hanabi" version = "0.12.1" @@ -1074,6 +1134,23 @@ dependencies = [ "glam 0.27.0", ] +[[package]] +name = "bevy_mod_debugdump" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30f0eab3099d7d474b25a95a6a2a945e6089d75e099af5a571fe896f7c1a455b" +dependencies = [ + "bevy_app", + "bevy_color", + "bevy_ecs", + "bevy_render", + "bevy_utils", + "lexopt", + "once_cell", + "petgraph", + "pretty-type-name", +] + [[package]] name = "bevy_pbr" version = "0.14.1" @@ -1581,6 +1658,17 @@ dependencies = [ "piper", ] +[[package]] +name = "bstr" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +dependencies = [ + "memchr", + "regex-automata 0.4.7", + "serde", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -2029,6 +2117,40 @@ dependencies = [ "winapi", ] +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.66", +] + [[package]] name = "dasp_sample" version = "0.11.0" @@ -2111,6 +2233,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53" +[[package]] +name = "duplicate" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de78e66ac9061e030587b2a2e75cc88f22304913c907b11307bca737141230cb" +dependencies = [ + "heck", + "proc-macro-error", +] + [[package]] name = "ecolor" version = "0.28.1" @@ -2133,6 +2265,17 @@ dependencies = [ "nohash-hasher", ] +[[package]] +name = "egui_dock" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "629a8b0e440d69996795669ceacc0dd839a997843489273600d31d16c9cb3500" +dependencies = [ + "duplicate", + "egui", + "paste", +] + [[package]] name = "either" version = "1.12.0" @@ -2203,6 +2346,39 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enum_dispatch" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd" +dependencies = [ + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "enumset" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a4b049558765cef5f0c1a273c3fc57084d768b44d2f98127aef4cceb17293" +dependencies = [ + "enumset_derive", +] + +[[package]] +name = "enumset_derive" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59c3b24c345d8c314966bdc1832f6c2635bfcce8e7cf363bd115987bba2ee242" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "epaint" version = "0.28.1" @@ -2412,7 +2588,9 @@ dependencies = [ "bevy_atmosphere", "bevy_common_assets", "bevy_dolly", + "bevy_editor_pls", "bevy_egui", + "bevy_gltf_blueprints", "bevy_hanabi", "bevy_kira_audio", "bevy_yarnspinner", @@ -2424,6 +2602,7 @@ dependencies = [ "leafwing-input-manager", "log", "oxidized_navigation", + "parry3d", "serde", "winit", ] @@ -2574,10 +2753,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e05e7e6723e3455f4818c7b26e855439f7546cf617ef669d1adedb8669e5cb9" dependencies = [ "bytemuck", + "mint", "rand", "serde", ] +[[package]] +name = "glam" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "779ae4bf7e8421cf91c0b3b64e7e8b40b862fba4d393f59150042de7c4965a94" +dependencies = [ + "mint", +] + [[package]] name = "glob" version = "0.3.1" @@ -2746,6 +2935,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -2916,6 +3111,12 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "1.0.0" @@ -3230,6 +3431,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "lexopt" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baff4b617f7df3d896f97fe922b64817f6cd9a756bb81d40f8883f2f66dcb401" + [[package]] name = "libc" version = "0.2.155" @@ -3601,6 +3808,15 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" +[[package]] +name = "normpath" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5831952a9476f2fed74b77d74182fa5ddc4d21c72ec45a333b250e3ed0272804" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "notify" version = "6.1.1" @@ -3984,6 +4200,17 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "opener" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c62dcb6174f9cb326eac248f07e955d5d559c272730b6c03e396b443b562788" +dependencies = [ + "bstr", + "normpath", + "winapi", +] + [[package]] name = "orbclient" version = "0.3.47" @@ -4258,6 +4485,30 @@ dependencies = [ "toml_edit 0.21.1", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.85" @@ -5205,6 +5456,47 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "transform-gizmo" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b43a029251c55e00d44930e24b78f5b471b3e75fa9c88c30ecb816db08646b93" +dependencies = [ + "ahash", + "ecolor", + "emath", + "enum_dispatch", + "enumset", + "epaint", + "glam 0.28.0", + "mint", +] + +[[package]] +name = "transform-gizmo-bevy" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e8240adbd84abd8b020fe5a5c8eb4f11771495f189cb080eb0344947ac18449" +dependencies = [ + "bevy_app", + "bevy_asset", + "bevy_core", + "bevy_core_pipeline", + "bevy_ecs", + "bevy_input", + "bevy_log", + "bevy_math", + "bevy_pbr", + "bevy_reflect", + "bevy_render", + "bevy_transform", + "bevy_utils", + "bevy_window", + "bytemuck", + "transform-gizmo", + "uuid 1.8.0", +] + [[package]] name = "ttf-parser" version = "0.21.1" diff --git a/Cargo.toml b/Cargo.toml index ba52baab..bb3d4a76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ homepage = "https://janhohenheim.github.io/foxtrot/" [features] default = ["dev"] dev = [ + "dep:bevy_editor_pls", "dep:bevy-inspector-egui", "bevy/file_watcher", "bevy/dynamic_linking", @@ -54,10 +55,13 @@ bevy_hanabi = { version = "0.12", default-features = false, features = ["3d"] } bevy_yarnspinner = "0.3" bevy_yarnspinner_example_dialogue_view = "0.3" bevy-tnua-avian3d = "0.1" -avian3d = { version = "0.1", features = ["simd"] } +avian3d = { version = "0.1", features = ["simd", "default-collider"] } bevy-tnua = "0.19" bevy_atmosphere = "0.10" blenvy = { git = "https://github.com/kaosat-dev/blenvy", branch = "blenvy" } +bevy_gltf_blueprints = { git = "https://github.com/kaosat-dev/Blenvy", branch = "bevy-0.14" } +bevy_editor_pls = { version = "0.9", optional = true } +parry3d = { version = "0.15" } [build-dependencies] embed-resource = "2" diff --git a/src/dev.rs b/src/dev.rs index ead25c46..71e4f3c8 100644 --- a/src/dev.rs +++ b/src/dev.rs @@ -4,6 +4,9 @@ use bevy::{ prelude::*, }; use bevy_inspector_egui::quick::WorldInspectorPlugin; +use bevy_editor_pls::prelude::*; + +pub(crate) mod dev_editor; /// Plugin with debugging utility intended for use during development only. /// Don't include this in a release build. @@ -15,15 +18,17 @@ pub(super) fn plugin(app: &mut App) { LogDiagnosticsPlugin::filtered(vec![]), PhysicsDebugPlugin::default(), )) - .insert_gizmo_group( - PhysicsGizmos { - aabb_color: Some(Color::WHITE), - ..default() - }, - GizmoConfig { - enabled: false, - ..default() - }, - ); + + // .insert_gizmo_group( + // PhysicsGizmos { + // aabb_color: Some(Color::WHITE), + // ..default() + // }, + // GizmoConfig { + // enabled: false, + // ..default() + // }, + // ) + ; } } diff --git a/src/dev/dev_editor.rs b/src/dev/dev_editor.rs new file mode 100644 index 00000000..76b3d86c --- /dev/null +++ b/src/dev/dev_editor.rs @@ -0,0 +1,85 @@ +use crate::player_control::camera::ForceCursorGrabMode; +use crate::util::error; +use anyhow::Context; +use bevy::{prelude::*, window::CursorGrabMode}; +use bevy_editor_pls::{ + editor::{Editor, EditorEvent}, + editor_window::EditorWindow, + AddEditorWindow, +}; +use bevy_egui::egui; +use avian3d::prelude::PhysicsGizmos; +use serde::{Deserialize, Serialize}; + +pub(super) fn plugin(app: &mut App) { + app.init_resource::() + .add_editor_window::() + .add_systems( + Update, + (handle_debug_render.pipe(error), set_cursor_grab_mode), + ); +} + +pub(crate) struct DevEditorWindow; + +impl EditorWindow for DevEditorWindow { + type State = DevEditorState; + const NAME: &'static str = "Foxtrot Dev"; + const DEFAULT_SIZE: (f32, f32) = (200., 150.); + fn ui( + _world: &mut World, + mut cx: bevy_editor_pls::editor_window::EditorWindowContext, + ui: &mut egui::Ui, + ) { + let state = cx + .state_mut::() + .expect("Failed to get dev window state"); + + state.open = true; + ui.heading("Debug Rendering"); + ui.checkbox(&mut state.collider_render_enabled, "Colliders"); + ui.checkbox(&mut state.navmesh_render_enabled, "Navmeshes"); + } +} + +#[derive(Debug, Clone, Eq, PartialEq, Resource, Reflect, Serialize, Deserialize)] +#[reflect(Resource, Serialize, Deserialize)] +#[derive(Default)] +pub(crate) struct DevEditorState { + pub(crate) open: bool, + pub(crate) collider_render_enabled: bool, + pub(crate) navmesh_render_enabled: bool, +} + +fn handle_debug_render( + state: Res, + mut last_enabled: Local, + mut config_store: ResMut, +) -> anyhow::Result<()> { + let current_enabled = state + .window_state::() + .context("Failed to read dev window state")? + .collider_render_enabled; + if current_enabled == *last_enabled { + return Ok(()); + } + *last_enabled = current_enabled; + let config = config_store.config_mut::().0; + config.enabled = current_enabled; + Ok(()) +} + +fn set_cursor_grab_mode( + mut events: EventReader, + mut force_cursor_grab: ResMut, +) { + for event in events.read() { + if let EditorEvent::Toggle { now_active } = event { + if *now_active { + force_cursor_grab.0 = Some(CursorGrabMode::None); + } else { + force_cursor_grab.0 = None; + } + } + } +} \ No newline at end of file diff --git a/src/ingame_menu.rs b/src/ingame_menu.rs index 18228ae1..e9133451 100644 --- a/src/ingame_menu.rs +++ b/src/ingame_menu.rs @@ -57,7 +57,7 @@ fn handle_pause( ui.add_space(100.0); if ui.button("Quit Game").clicked() { - app_exit_events.send(AppExit); + app_exit_events.send(AppExit::Success); } }); }); diff --git a/src/level_instantiation/on_spawn/util.rs b/src/level_instantiation/on_spawn/util.rs index 91d02e1e..7381943d 100644 --- a/src/level_instantiation/on_spawn/util.rs +++ b/src/level_instantiation/on_spawn/util.rs @@ -6,7 +6,7 @@ pub(crate) trait MeshAssetsExt { impl MeshAssetsExt for Assets { fn get_or_add(&mut self, handle: Handle, create_mesh: impl Fn() -> Mesh) -> Handle { - self.get_or_insert_with(handle.clone_weak(), create_mesh); + self.get_or_insert_with(&handle.clone_weak(), create_mesh); handle } } diff --git a/src/menu.rs b/src/menu.rs index c3adba42..0f216c5d 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -1,12 +1,7 @@ use crate::GameState; use bevy::prelude::*; use bevy_egui::{ - egui, - egui::{ - FontFamily::Proportional, - FontId, - TextStyle::{Body, Button, Heading}, - }, + egui::{self, FontFamily::Proportional, FontId, Margin, TextStyle::{Body, Button, Heading}}, EguiContexts, }; @@ -33,7 +28,8 @@ fn setup_menu(mut egui_contexts: EguiContexts, mut next_state: ResMut egui::CentralPanel { egui::CentralPanel::default().frame(egui::Frame { - inner_margin: egui::style::Margin::same(60.), + // inner_margin: egui::style::Margin::same(60.), + inner_margin: Margin::same(60.), ..default() }) } diff --git a/src/movement/character_controller/animation.rs b/src/movement/character_controller/animation.rs index 5e32af59..21b4ae1e 100644 --- a/src/movement/character_controller/animation.rs +++ b/src/movement/character_controller/animation.rs @@ -75,7 +75,7 @@ fn play_animations( TnuaAnimatingStateDirective::Maintain { state } => { if let AnimationState::Running(speed) = state { let anim_speed = (speed / 7.0).max(1.0); - animation_player.set_speed(anim_speed); + animation_player.adjust_speeds(anim_speed); } } TnuaAnimatingStateDirective::Alter { @@ -85,40 +85,40 @@ fn play_animations( state, } => match state { AnimationState::Airborne | AnimationState::Running(..) => { - animation_player - .play_with_transition( - animations - .named_animations - .get(&animation_names.aerial) - .unwrap() - .clone_weak(), - Duration::from_secs_f32(0.2), - ) - .repeat(); + // animation_player + // .play_with_transition( + // animations + // .named_animations + // .get(&animation_names.aerial) + // .unwrap() + // .clone_weak(), + // Duration::from_secs_f32(0.2), + // ) + // .repeat(); } AnimationState::Standing => { - animation_player - .play_with_transition( - animations - .named_animations - .get(&animation_names.idle) - .unwrap() - .clone_weak(), - Duration::from_secs_f32(0.2), - ) - .repeat(); + // animation_player + // .play_with_transition( + // animations + // .named_animations + // .get(&animation_names.idle) + // .unwrap() + // .clone_weak(), + // Duration::from_secs_f32(0.2), + // ) + // .repeat(); } AnimationState::Walking(_speed) => { - animation_player - .play_with_transition( - animations - .named_animations - .get(&animation_names.walk) - .unwrap() - .clone_weak(), - Duration::from_secs_f32(0.1), - ) - .repeat(); + // animation_player + // .play_with_transition( + // animations + // .named_animations + // .get(&animation_names.walk) + // .unwrap() + // .clone_weak(), + // Duration::from_secs_f32(0.1), + // ) + // .repeat(); } }, } diff --git a/src/movement/navigation.rs b/src/movement/navigation.rs index f2b2e56b..650cad3a 100644 --- a/src/movement/navigation.rs +++ b/src/movement/navigation.rs @@ -1,3 +1,5 @@ +#[cfg(feature = "dev")] +use crate::dev::dev_editor::DevEditorWindow; use crate::util::error; use crate::{ level_instantiation::on_spawn::{player, Npc, Player}, @@ -7,37 +9,79 @@ use crate::{ }; #[cfg(feature = "dev")] use anyhow::Context; +use avian3d::parry::shape::{SharedShape}; use bevy::prelude::*; -use avian3d::prelude::Collider; +use oxidized_navigation::colliders::OxidizedCollider; #[cfg(feature = "dev")] use oxidized_navigation::debug_draw::{DrawNavMesh, DrawPath, OxidizedNavigationDebugDrawPlugin}; use oxidized_navigation::{ query::{find_polygon_path, perform_string_pulling_on_path}, NavMesh, NavMeshSettings, OxidizedNavigationPlugin, }; +use parry3d::bounding_volume::Aabb; +use parry3d::shape::TypedShape; /// Manually tweaked const CELL_WIDTH: f32 = 0.4 * player::RADIUS; +#[derive(Component)] +struct MyColliderWrapper { + collider: SharedShape, +} + +impl OxidizedCollider for MyColliderWrapper { + fn oxidized_into_typed_shape(&self) -> TypedShape { + self.collider.as_typed_shape() + } + + fn oxidized_compute_local_aabb(&self) -> Aabb { + self.collider.compute_local_aabb() + } +} + /// Handles NPC pathfinding. Currently, all entities with the [`Npc`] component will follow the [`Player`]. pub(super) fn plugin(app: &mut App) { // consts manually tweaked - app.add_plugins(OxidizedNavigationPlugin::::new(NavMeshSettings { - cell_width: CELL_WIDTH, - cell_height: 0.5 * CELL_WIDTH, - tile_width: 170, - world_half_extents: 250.0, - world_bottom_bound: -20.0, - max_traversable_slope_radians: (40.0_f32 - 0.1).to_radians(), - walkable_height: 25, - walkable_radius: 4, - step_height: 3, - min_region_area: 30, - merge_region_area: 500, - max_contour_simplification_error: 1.3, - max_edge_length: 100, - max_tile_generation_tasks: None, - })) + app.add_plugins( + + OxidizedNavigationPlugin::::new(NavMeshSettings { + cell_width: CELL_WIDTH, + cell_height: 0.5 * CELL_WIDTH, + tile_width: 170, + world_half_extents: 250.0, + world_bottom_bound: -20.0, + max_traversable_slope_radians: (40.0_f32 - 0.1).to_radians(), + walkable_height: 25, + walkable_radius: 4, + step_height: 3, + min_region_area: 30, + max_region_area_to_merge_into: 500, + // merge_region_area: 500, + max_contour_simplification_error: 1.3, + max_edge_length: 100, + max_tile_generation_tasks: None, + }) + + // OxidizedNavigationPlugin::::new(NavMeshSettings { + // cell_width: CELL_WIDTH, + // cell_height: 0.5 * CELL_WIDTH, + // tile_width: 170, + // world_half_extents: 250.0, + // world_bottom_bound: -20.0, + // max_traversable_slope_radians: (40.0_f32 - 0.1).to_radians(), + // walkable_height: 25, + // walkable_radius: 4, + // step_height: 3, + // min_region_area: 30, + // max_region_area_to_merge_into: 500, + // // merge_region_area: 500, + // max_contour_simplification_error: 1.3, + // max_edge_length: 100, + // max_tile_generation_tasks: None, + // }) + + + ) .add_systems( Update, query_mesh.pipe(error).in_set(GameSystemSet::Navigation), @@ -85,7 +129,7 @@ fn query_mesh( commands.spawn(DrawPath { timer: Some(Timer::from_seconds(4.0, TimerMode::Once)), pulled_path: shifted_path, - color: Color::BLUE, + color: Color::WHITE, }); } } diff --git a/src/player_control/camera/rig/arm.rs b/src/player_control/camera/rig/arm.rs index 07c05bd4..f4f9ae89 100644 --- a/src/player_control/camera/rig/arm.rs +++ b/src/player_control/camera/rig/arm.rs @@ -85,7 +85,7 @@ fn get_distance_to_collision( fn get_distance_such_that_min_distance_from_collision_is_ensured( hit: RayHitData, - direction: Direction3d, + direction: Dir3, min_distance: f32, ) -> f32 { // Wall From 5c10315ff41a3a021d9f01abf8f8f9edce1212f1 Mon Sep 17 00:00:00 2001 From: kEpEx Date: Sat, 7 Sep 2024 23:01:32 -0700 Subject: [PATCH 2/2] Kind of works, no fox visible --- src/dev.rs | 44 +++++++++++-------- src/lib.rs | 7 ++- .../character_controller/animation.rs | 21 +++++++++ 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/src/dev.rs b/src/dev.rs index 71e4f3c8..48936010 100644 --- a/src/dev.rs +++ b/src/dev.rs @@ -11,24 +11,30 @@ pub(crate) mod dev_editor; /// Plugin with debugging utility intended for use during development only. /// Don't include this in a release build. pub(super) fn plugin(app: &mut App) { - { - app.add_plugins(( - WorldInspectorPlugin::new(), - FrameTimeDiagnosticsPlugin, - LogDiagnosticsPlugin::filtered(vec![]), - PhysicsDebugPlugin::default(), - )) + + app.add_plugins(EditorPlugin::new()) + .insert_resource(default_editor_controls()) + .add_plugins(( + FrameTimeDiagnosticsPlugin, + dev_editor::plugin, + LogDiagnosticsPlugin::filtered(vec![]), + PhysicsDebugPlugin::default(), + )) + .init_gizmo_group::(); - // .insert_gizmo_group( - // PhysicsGizmos { - // aabb_color: Some(Color::WHITE), - // ..default() - // }, - // GizmoConfig { - // enabled: false, - // ..default() - // }, - // ) - ; - } } + + +fn default_editor_controls() -> bevy_editor_pls::controls::EditorControls { + use bevy_editor_pls::controls::*; + let mut editor_controls = EditorControls::default_bindings(); + editor_controls.unbind(Action::PlayPauseEditor); + editor_controls.insert( + Action::PlayPauseEditor, + Binding { + input: UserInput::Single(Button::Keyboard(KeyCode::KeyQ)), + conditions: vec![BindingCondition::ListeningForText(false)], + }, + ); + editor_controls +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 9f899645..7699dffb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,7 +58,8 @@ pub struct GamePlugin; impl Plugin for GamePlugin { fn build(&self, app: &mut App) { - app.init_state::().add_plugins(( + app + .add_plugins(( system_set::plugin, bevy_config::plugin, menu::plugin, @@ -72,6 +73,8 @@ impl Plugin for GamePlugin { particles::plugin, #[cfg(feature = "dev")] dev::plugin, - )); + )) + .init_state::() + ; } } diff --git a/src/movement/character_controller/animation.rs b/src/movement/character_controller/animation.rs index 21b4ae1e..3eb88ca0 100644 --- a/src/movement/character_controller/animation.rs +++ b/src/movement/character_controller/animation.rs @@ -85,6 +85,12 @@ fn play_animations( state, } => match state { AnimationState::Airborne | AnimationState::Running(..) => { + animation_player + .play( + *animations.named_indices + .get(&animation_names.aerial) + .unwrap() + ).repeat().set_speed(0.2); // animation_player // .play_with_transition( // animations @@ -97,6 +103,13 @@ fn play_animations( // .repeat(); } AnimationState::Standing => { + animation_player + .play( + *animations.named_indices + .get(&animation_names.idle) + .unwrap() + ).repeat().set_speed(0.2); + // animation_player // .play_with_transition( // animations @@ -109,6 +122,14 @@ fn play_animations( // .repeat(); } AnimationState::Walking(_speed) => { + + animation_player + .play( + *animations.named_indices + .get(&animation_names.walk) + .unwrap() + ).repeat().set_speed(0.1); + // animation_player // .play_with_transition( // animations