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_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;

View File

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

View File

@ -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;

View File

@ -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()

View File

@ -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;

View File

@ -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},
};

View File

@ -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

View File

@ -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,
}
}
}

View File

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

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

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

View File

@ -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,
),
);
}
}