From a81b2f340e3b2311f3231edee548818edee2f03a Mon Sep 17 00:00:00 2001 From: Franklin Date: Wed, 15 Nov 2023 08:01:25 -0400 Subject: [PATCH] Cargo fmt --- src/comps/core/controller.rs | 7 +++-- src/comps/core/markers/inventory_screen.rs | 4 +-- src/comps/core/markers/mod.rs | 4 +-- src/comps/core/markers/settings_screen.rs | 2 +- src/comps/core/spawners/player.rs | 4 +-- src/logic/core/player/camera_player_sync.rs | 6 ++--- src/logic/core/player/hands.rs | 2 +- src/logic/core/player/inventory.rs | 4 +-- src/scenes/scene1/init.rs | 5 +--- src/ui/game/game_ui_state.rs | 7 +++-- src/ui/game/hud/mod.rs | 2 +- src/ui/game/hud/plugin.rs | 7 +++-- src/ui/game/inventory/menu.rs | 29 ++++++++++++--------- src/ui/game/mod.rs | 2 +- src/ui/game/plugin.rs | 4 +-- src/ui/game/settings/menu.rs | 5 +++- src/ui/game/settings/mod.rs | 2 +- src/ui/game/settings/plugin.rs | 11 +++++--- 18 files changed, 59 insertions(+), 48 deletions(-) diff --git a/src/comps/core/controller.rs b/src/comps/core/controller.rs index 456f530..e36e066 100644 --- a/src/comps/core/controller.rs +++ b/src/comps/core/controller.rs @@ -1,12 +1,15 @@ use bevy::prelude::*; use bevy_rapier3d::prelude::*; -use crate::{logic::core::player::{ +use crate::{ + logic::core::player::{ player_movement::{ move_player, PlayerLinearXZState, PlayerLinearYState, PlayerMovementInput, }, player_values_state::PlayerValuesState, - }, ui::game::game_ui_state::GameUiState}; + }, + ui::game::game_ui_state::GameUiState, +}; use super::markers::player::Player; diff --git a/src/comps/core/markers/inventory_screen.rs b/src/comps/core/markers/inventory_screen.rs index 2173373..81aa0a0 100644 --- a/src/comps/core/markers/inventory_screen.rs +++ b/src/comps/core/markers/inventory_screen.rs @@ -1,6 +1,4 @@ use bevy::ecs::component::Component; - - #[derive(Component)] -pub struct InventoryScreenUiMarker; \ No newline at end of file +pub struct InventoryScreenUiMarker; diff --git a/src/comps/core/markers/mod.rs b/src/comps/core/markers/mod.rs index ec5cf9a..36c048c 100644 --- a/src/comps/core/markers/mod.rs +++ b/src/comps/core/markers/mod.rs @@ -3,7 +3,7 @@ pub mod camera; pub mod firearm; pub mod holdable; pub mod interactable; +pub mod inventory_screen; pub mod muzzle_flash; pub mod player; -pub mod inventory_screen; -pub mod settings_screen; \ No newline at end of file +pub mod settings_screen; diff --git a/src/comps/core/markers/settings_screen.rs b/src/comps/core/markers/settings_screen.rs index f4fad43..df544fd 100644 --- a/src/comps/core/markers/settings_screen.rs +++ b/src/comps/core/markers/settings_screen.rs @@ -1,4 +1,4 @@ use bevy::ecs::component::Component; #[derive(Component)] -pub struct SettingsScreenMarker; \ No newline at end of file +pub struct SettingsScreenMarker; diff --git a/src/comps/core/spawners/player.rs b/src/comps/core/spawners/player.rs index 06e7ce3..463b018 100644 --- a/src/comps/core/spawners/player.rs +++ b/src/comps/core/spawners/player.rs @@ -50,9 +50,7 @@ pub fn player_spawner( // Spawn hand let player_hand = commands .spawn((PlayerHand, Name::new("Player Hand"))) - .insert(TransformBundle::from(Transform::from_xyz( - 0.6, -0.45, 0.0, - ))) + .insert(TransformBundle::from(Transform::from_xyz(0.6, -0.45, 0.0))) .insert(VisibilityBundle { visibility: Visibility::Inherited, ..Default::default() diff --git a/src/logic/core/player/camera_player_sync.rs b/src/logic/core/player/camera_player_sync.rs index 06c91de..c1dd934 100644 --- a/src/logic/core/player/camera_player_sync.rs +++ b/src/logic/core/player/camera_player_sync.rs @@ -3,7 +3,8 @@ use bevy::{input::mouse::MouseMotion, prelude::*, window::CursorGrabMode}; use crate::{ comps::core::markers::{camera::MainCamera, player::Player}, - utils::rad_deg::radians_from_degrees, ui::game::game_ui_state::{GameUiState, GameUiWindow}, + ui::game::game_ui_state::{GameUiState, GameUiWindow}, + utils::rad_deg::radians_from_degrees, }; use super::{player_movement::PlayerLinearXZState, player_values_state::PlayerValuesState}; @@ -91,8 +92,7 @@ pub fn follow_cursor_with_camera( window.cursor.grab_mode = CursorGrabMode::None; // Release cursor window.cursor.visible = true; // Show cursor } - } - else if keyboard_input.just_pressed(KeyCode::Tab) { + } else if keyboard_input.just_pressed(KeyCode::Tab) { if game_ui_state.is_showing_window(GameUiWindow::InventoryMenu) { // Hide the inventory screen only game_ui_state.current_ui_window_shown = None; diff --git a/src/logic/core/player/hands.rs b/src/logic/core/player/hands.rs index 4577526..2753235 100644 --- a/src/logic/core/player/hands.rs +++ b/src/logic/core/player/hands.rs @@ -19,7 +19,7 @@ use crate::{ equipment::{Equipment, EquipmentChangeEvent}, load_state::GameLoadState, }, - ui::game::{hud::hud::HudState, game_ui_state::GameUiState}, + ui::game::{game_ui_state::GameUiState, hud::hud::HudState}, utils::{self, rad_deg::radians_from_degrees}, }; diff --git a/src/logic/core/player/inventory.rs b/src/logic/core/player/inventory.rs index 516ee81..d96db80 100644 --- a/src/logic/core/player/inventory.rs +++ b/src/logic/core/player/inventory.rs @@ -35,8 +35,8 @@ pub fn update_player_inventory_system( + player_transform.forward() * 2.0, ); let drop_impulse = player_transform.translation - + player_transform.up() * 100.0 - + player_transform.forward() * 30.0; + + player_transform.up() * 100.0 + + player_transform.forward() * 30.0; match firearm.firearm_data().firearm_type { FirearmType::Primary => { // Send equipment_changed_event diff --git a/src/scenes/scene1/init.rs b/src/scenes/scene1/init.rs index e4d2035..c50c45d 100644 --- a/src/scenes/scene1/init.rs +++ b/src/scenes/scene1/init.rs @@ -41,10 +41,7 @@ pub fn load_scene(application: &mut App) { // Startup application.add_systems(PreStartup, load_all_assets); application.add_systems(Startup, spawn_ground); - application.add_systems( - Startup, - spawn_obstacles, - ); + application.add_systems(Startup, spawn_obstacles); application.add_systems(Startup, setup_lighting); application.add_systems(Startup, set_spawn_points); // Update diff --git a/src/ui/game/game_ui_state.rs b/src/ui/game/game_ui_state.rs index f3a1052..3b912ab 100644 --- a/src/ui/game/game_ui_state.rs +++ b/src/ui/game/game_ui_state.rs @@ -16,7 +16,10 @@ pub struct GameUiState { impl Default for GameUiState { fn default() -> Self { - Self { current_ui_window_shown: None, fps_counter_enabled: true } + Self { + current_ui_window_shown: None, + fps_counter_enabled: true, + } } } @@ -30,4 +33,4 @@ impl GameUiState { pub fn any_window(&self) -> bool { self.current_ui_window_shown.is_some() } -} \ No newline at end of file +} diff --git a/src/ui/game/hud/mod.rs b/src/ui/game/hud/mod.rs index 20f56d4..171a2f8 100644 --- a/src/ui/game/hud/mod.rs +++ b/src/ui/game/hud/mod.rs @@ -1,4 +1,4 @@ +pub mod fps_counter; pub mod hud; pub mod interact_clue; pub mod plugin; -pub mod fps_counter; diff --git a/src/ui/game/hud/plugin.rs b/src/ui/game/hud/plugin.rs index e45a8c8..4810d6e 100644 --- a/src/ui/game/hud/plugin.rs +++ b/src/ui/game/hud/plugin.rs @@ -2,7 +2,10 @@ use bevy::prelude::*; use crate::ui::game::hud::hud::HudState; -use super::{interact_clue::{setup_interact_clue, update_interact_clue}, fps_counter}; +use super::{ + fps_counter, + interact_clue::{setup_interact_clue, update_interact_clue}, +}; pub struct HudOverlayPlugin; @@ -13,6 +16,6 @@ impl Plugin for HudOverlayPlugin { app.add_systems(Startup, setup_interact_clue); app.add_systems(Update, update_interact_clue); app.add_systems(Startup, fps_counter::setup_fps_counter); - app.add_systems(Update,fps_counter::tick_fps_counter); + app.add_systems(Update, fps_counter::tick_fps_counter); } } diff --git a/src/ui/game/inventory/menu.rs b/src/ui/game/inventory/menu.rs index 3fd2a25..019f3fe 100644 --- a/src/ui/game/inventory/menu.rs +++ b/src/ui/game/inventory/menu.rs @@ -1,7 +1,9 @@ use bevy::{prelude::*, ui::FocusPolicy}; -use crate::{comps::core::markers::inventory_screen::InventoryScreenUiMarker, ui::game::game_ui_state::{GameUiState, GameUiWindow}}; - +use crate::{ + comps::core::markers::inventory_screen::InventoryScreenUiMarker, + ui::game::game_ui_state::{GameUiState, GameUiWindow}, +}; /// # Inventory Screen /// Should contain player inventory and if player is looting something as well @@ -27,10 +29,11 @@ pub fn setup_inventory_screen(mut commands: Commands) { }, Name::new("Inventory Screen"), )) - .insert(InventoryScreenUiMarker).id(); + .insert(InventoryScreenUiMarker) + .id(); // Left panel - let left_panel_id = commands.spawn( - NodeBundle { + let left_panel_id = commands + .spawn(NodeBundle { style: Style { display: Display::Flex, width: Val::Percent(50.0), @@ -42,11 +45,12 @@ pub fn setup_inventory_screen(mut commands: Commands) { ..Default::default() }, ..Default::default() - } - ).set_parent(background_id).id(); + }) + .set_parent(background_id) + .id(); // Right panel - let right_panel_id = commands.spawn( - NodeBundle { + let right_panel_id = commands + .spawn(NodeBundle { style: Style { display: Display::Flex, width: Val::Percent(50.0), @@ -58,9 +62,9 @@ pub fn setup_inventory_screen(mut commands: Commands) { ..Default::default() }, ..Default::default() - } - ).set_parent(background_id).id(); - + }) + .set_parent(background_id) + .id(); } pub fn update_inventory_screen( @@ -75,5 +79,4 @@ pub fn update_inventory_screen( *visibility = Visibility::Hidden; } } - } diff --git a/src/ui/game/mod.rs b/src/ui/game/mod.rs index 0707117..3d4d014 100644 --- a/src/ui/game/mod.rs +++ b/src/ui/game/mod.rs @@ -1,6 +1,6 @@ //! Game UI means all the UI that will be part of the actual game +pub mod game_ui_state; pub mod hud; pub mod inventory; pub mod plugin; -pub mod game_ui_state; pub mod settings; diff --git a/src/ui/game/plugin.rs b/src/ui/game/plugin.rs index bbb2434..4e2b882 100644 --- a/src/ui/game/plugin.rs +++ b/src/ui/game/plugin.rs @@ -1,8 +1,6 @@ use bevy::prelude::*; -use super::{ - hud, inventory, game_ui_state::GameUiState, settings, -}; +use super::{game_ui_state::GameUiState, hud, inventory, settings}; pub struct MainGameUIPlugin; diff --git a/src/ui/game/settings/menu.rs b/src/ui/game/settings/menu.rs index 28d9e40..d3ab493 100644 --- a/src/ui/game/settings/menu.rs +++ b/src/ui/game/settings/menu.rs @@ -1,6 +1,9 @@ use bevy::{app::AppExit, prelude::*, ui::FocusPolicy}; -use crate::{comps::core::markers::settings_screen::SettingsScreenMarker, ui::game::game_ui_state::{GameUiState, GameUiWindow}}; +use crate::{ + comps::core::markers::settings_screen::SettingsScreenMarker, + ui::game::game_ui_state::{GameUiState, GameUiWindow}, +}; #[derive(Component)] pub enum SettingsScreenActions { diff --git a/src/ui/game/settings/mod.rs b/src/ui/game/settings/mod.rs index 8875e5f..738357c 100644 --- a/src/ui/game/settings/mod.rs +++ b/src/ui/game/settings/mod.rs @@ -1,2 +1,2 @@ +pub mod menu; pub mod plugin; -pub mod menu; \ No newline at end of file diff --git a/src/ui/game/settings/plugin.rs b/src/ui/game/settings/plugin.rs index 54edfca..5175c05 100644 --- a/src/ui/game/settings/plugin.rs +++ b/src/ui/game/settings/plugin.rs @@ -2,12 +2,17 @@ use bevy::app::{Plugin, Startup, Update}; use super::menu; - pub struct SettingsMenuPlugin; impl Plugin for SettingsMenuPlugin { fn build(&self, app: &mut bevy::prelude::App) { app.add_systems(Startup, menu::setup_settings_screen); - app.add_systems(Update, (menu::toggle_settings_screen, menu::handle_settings_button_click)); + app.add_systems( + Update, + ( + menu::toggle_settings_screen, + menu::handle_settings_button_click, + ), + ); } -} \ No newline at end of file +}