Cargo fmt

This commit is contained in:
Franklin 2023-11-15 08:01:25 -04:00
parent b79bf00227
commit a81b2f340e
18 changed files with 59 additions and 48 deletions

View File

@ -1,12 +1,15 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy_rapier3d::prelude::*; use bevy_rapier3d::prelude::*;
use crate::{logic::core::player::{ use crate::{
logic::core::player::{
player_movement::{ player_movement::{
move_player, PlayerLinearXZState, PlayerLinearYState, PlayerMovementInput, move_player, PlayerLinearXZState, PlayerLinearYState, PlayerMovementInput,
}, },
player_values_state::PlayerValuesState, player_values_state::PlayerValuesState,
}, ui::game::game_ui_state::GameUiState}; },
ui::game::game_ui_state::GameUiState,
};
use super::markers::player::Player; use super::markers::player::Player;

View File

@ -1,6 +1,4 @@
use bevy::ecs::component::Component; use bevy::ecs::component::Component;
#[derive(Component)] #[derive(Component)]
pub struct InventoryScreenUiMarker; pub struct InventoryScreenUiMarker;

View File

@ -3,7 +3,7 @@ pub mod camera;
pub mod firearm; pub mod firearm;
pub mod holdable; pub mod holdable;
pub mod interactable; pub mod interactable;
pub mod inventory_screen;
pub mod muzzle_flash; pub mod muzzle_flash;
pub mod player; pub mod player;
pub mod inventory_screen; pub mod settings_screen;
pub mod settings_screen;

View File

@ -1,4 +1,4 @@
use bevy::ecs::component::Component; use bevy::ecs::component::Component;
#[derive(Component)] #[derive(Component)]
pub struct SettingsScreenMarker; pub struct SettingsScreenMarker;

View File

@ -50,9 +50,7 @@ pub fn player_spawner(
// Spawn hand // Spawn hand
let player_hand = commands let player_hand = commands
.spawn((PlayerHand, Name::new("Player Hand"))) .spawn((PlayerHand, Name::new("Player Hand")))
.insert(TransformBundle::from(Transform::from_xyz( .insert(TransformBundle::from(Transform::from_xyz(0.6, -0.45, 0.0)))
0.6, -0.45, 0.0,
)))
.insert(VisibilityBundle { .insert(VisibilityBundle {
visibility: Visibility::Inherited, visibility: Visibility::Inherited,
..Default::default() ..Default::default()

View File

@ -3,7 +3,8 @@ use bevy::{input::mouse::MouseMotion, prelude::*, window::CursorGrabMode};
use crate::{ use crate::{
comps::core::markers::{camera::MainCamera, player::Player}, 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}; 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.grab_mode = CursorGrabMode::None; // Release cursor
window.cursor.visible = true; // Show 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) { if game_ui_state.is_showing_window(GameUiWindow::InventoryMenu) {
// Hide the inventory screen only // Hide the inventory screen only
game_ui_state.current_ui_window_shown = None; game_ui_state.current_ui_window_shown = None;

View File

@ -19,7 +19,7 @@ use crate::{
equipment::{Equipment, EquipmentChangeEvent}, equipment::{Equipment, EquipmentChangeEvent},
load_state::GameLoadState, 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}, utils::{self, rad_deg::radians_from_degrees},
}; };

View File

@ -35,8 +35,8 @@ pub fn update_player_inventory_system(
+ player_transform.forward() * 2.0, + player_transform.forward() * 2.0,
); );
let drop_impulse = player_transform.translation let drop_impulse = player_transform.translation
+ player_transform.up() * 100.0 + player_transform.up() * 100.0
+ player_transform.forward() * 30.0; + player_transform.forward() * 30.0;
match firearm.firearm_data().firearm_type { match firearm.firearm_data().firearm_type {
FirearmType::Primary => { FirearmType::Primary => {
// Send equipment_changed_event // Send equipment_changed_event

View File

@ -41,10 +41,7 @@ pub fn load_scene(application: &mut App) {
// Startup // Startup
application.add_systems(PreStartup, load_all_assets); application.add_systems(PreStartup, load_all_assets);
application.add_systems(Startup, spawn_ground); application.add_systems(Startup, spawn_ground);
application.add_systems( application.add_systems(Startup, spawn_obstacles);
Startup,
spawn_obstacles,
);
application.add_systems(Startup, setup_lighting); application.add_systems(Startup, setup_lighting);
application.add_systems(Startup, set_spawn_points); application.add_systems(Startup, set_spawn_points);
// Update // Update

View File

@ -16,7 +16,10 @@ pub struct GameUiState {
impl Default for GameUiState { impl Default for GameUiState {
fn default() -> Self { 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 { pub fn any_window(&self) -> bool {
self.current_ui_window_shown.is_some() self.current_ui_window_shown.is_some()
} }
} }

View File

@ -1,4 +1,4 @@
pub mod fps_counter;
pub mod hud; pub mod hud;
pub mod interact_clue; pub mod interact_clue;
pub mod plugin; pub mod plugin;
pub mod fps_counter;

View File

@ -2,7 +2,10 @@ use bevy::prelude::*;
use crate::ui::game::hud::hud::HudState; 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; pub struct HudOverlayPlugin;
@ -13,6 +16,6 @@ impl Plugin for HudOverlayPlugin {
app.add_systems(Startup, setup_interact_clue); app.add_systems(Startup, setup_interact_clue);
app.add_systems(Update, update_interact_clue); app.add_systems(Update, update_interact_clue);
app.add_systems(Startup, fps_counter::setup_fps_counter); 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);
} }
} }

View File

@ -1,7 +1,9 @@
use bevy::{prelude::*, ui::FocusPolicy}; 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 /// # Inventory Screen
/// Should contain player inventory and if player is looting something as well /// 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"), Name::new("Inventory Screen"),
)) ))
.insert(InventoryScreenUiMarker).id(); .insert(InventoryScreenUiMarker)
.id();
// Left panel // Left panel
let left_panel_id = commands.spawn( let left_panel_id = commands
NodeBundle { .spawn(NodeBundle {
style: Style { style: Style {
display: Display::Flex, display: Display::Flex,
width: Val::Percent(50.0), width: Val::Percent(50.0),
@ -42,11 +45,12 @@ pub fn setup_inventory_screen(mut commands: Commands) {
..Default::default() ..Default::default()
}, },
..Default::default() ..Default::default()
} })
).set_parent(background_id).id(); .set_parent(background_id)
.id();
// Right panel // Right panel
let right_panel_id = commands.spawn( let right_panel_id = commands
NodeBundle { .spawn(NodeBundle {
style: Style { style: Style {
display: Display::Flex, display: Display::Flex,
width: Val::Percent(50.0), width: Val::Percent(50.0),
@ -58,9 +62,9 @@ pub fn setup_inventory_screen(mut commands: Commands) {
..Default::default() ..Default::default()
}, },
..Default::default() ..Default::default()
} })
).set_parent(background_id).id(); .set_parent(background_id)
.id();
} }
pub fn update_inventory_screen( pub fn update_inventory_screen(
@ -75,5 +79,4 @@ pub fn update_inventory_screen(
*visibility = Visibility::Hidden; *visibility = Visibility::Hidden;
} }
} }
} }

View File

@ -1,6 +1,6 @@
//! Game UI means all the UI that will be part of the actual game //! Game UI means all the UI that will be part of the actual game
pub mod game_ui_state;
pub mod hud; pub mod hud;
pub mod inventory; pub mod inventory;
pub mod plugin; pub mod plugin;
pub mod game_ui_state;
pub mod settings; pub mod settings;

View File

@ -1,8 +1,6 @@
use bevy::prelude::*; use bevy::prelude::*;
use super::{ use super::{game_ui_state::GameUiState, hud, inventory, settings};
hud, inventory, game_ui_state::GameUiState, settings,
};
pub struct MainGameUIPlugin; pub struct MainGameUIPlugin;

View File

@ -1,6 +1,9 @@
use bevy::{app::AppExit, prelude::*, ui::FocusPolicy}; 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)] #[derive(Component)]
pub enum SettingsScreenActions { pub enum SettingsScreenActions {

View File

@ -1,2 +1,2 @@
pub mod menu;
pub mod plugin; pub mod plugin;
pub mod menu;

View File

@ -2,12 +2,17 @@ use bevy::app::{Plugin, Startup, Update};
use super::menu; use super::menu;
pub struct SettingsMenuPlugin; pub struct SettingsMenuPlugin;
impl Plugin for SettingsMenuPlugin { impl Plugin for SettingsMenuPlugin {
fn build(&self, app: &mut bevy::prelude::App) { fn build(&self, app: &mut bevy::prelude::App) {
app.add_systems(Startup, menu::setup_settings_screen); 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,
),
);
} }
} }