diff --git a/Design.md b/Design.md index b33e27f..76be8b9 100644 --- a/Design.md +++ b/Design.md @@ -24,15 +24,16 @@ Multiplayer - [x] Issue with moving around quickly - [x] Bring Crouching back - [x] Inspect animation & state (procedural) - - [ ] Attachment editor system when in inspect mode + - [ ] TODO: Attachment editor system when in inspect mode + - [ ] TODO: remove Start and End optic from Slots, instead make one slot, and have code that checks for the starter slot and the end slot - [x] High Ready & Low Ready system with state - [x] High ready animation (procedural) - [x] Low ready animation (procedural) + - [ ] TODO: Auto Low ready when gun collider hits object OR when player starts sprinting - [ ] Reload animation (procedural) - [ ] Real world magazines - [ ] Rewriting bullet physics to use raycasts & kinematic rigidbodies (logic controlled) -- [ ] Low Ready & High ready (low ready == more speed | high ready == more accuracy) - - [ ] Auto Low ready when gun collider hits object OR when player starts sprinting + - [ ] Create a Controls struct that holds mappings to all the game keys and replace them in all the game's code diff --git a/src/comps/core/markers/inspect_screen.rs b/src/comps/core/markers/inspect_screen.rs new file mode 100644 index 0000000..05cb0b2 --- /dev/null +++ b/src/comps/core/markers/inspect_screen.rs @@ -0,0 +1,9 @@ +use bevy::ecs::component::Component; + +use crate::comps::core::weapons::slot::slot::WeaponSlot; + +#[derive(Component, PartialEq, Eq, PartialOrd, Ord)] +pub struct InspectScreenUiMarker; + +#[derive(Component, PartialEq, Eq, PartialOrd, Ord)] +pub struct InspectScreenSlotUiMarker(pub WeaponSlot); \ No newline at end of file diff --git a/src/comps/core/markers/mod.rs b/src/comps/core/markers/mod.rs index 3ea8700..827459c 100644 --- a/src/comps/core/markers/mod.rs +++ b/src/comps/core/markers/mod.rs @@ -6,4 +6,5 @@ pub mod inventory_screen; pub mod muzzle_flash; pub mod player; pub mod settings_screen; -pub mod proxy; \ No newline at end of file +pub mod proxy; +pub mod inspect_screen; \ No newline at end of file diff --git a/src/ui/game/inspect/mapper.rs b/src/ui/game/inspect/mapper.rs new file mode 100644 index 0000000..1d74c9e --- /dev/null +++ b/src/ui/game/inspect/mapper.rs @@ -0,0 +1,6 @@ +use bevy::prelude::*; + +/// This function takes currently equipped gun real world coordinates and converts them to UI coordinates that match the real world position in the screen. +pub fn map_gun_slots_to_ui_slots() { + +} \ No newline at end of file diff --git a/src/ui/game/inspect/menu.rs b/src/ui/game/inspect/menu.rs new file mode 100644 index 0000000..439f68f --- /dev/null +++ b/src/ui/game/inspect/menu.rs @@ -0,0 +1,65 @@ +use bevy::{prelude::*, ui::FocusPolicy}; + +use crate::{comps::core::{markers::{inspect_screen::{InspectScreenUiMarker, InspectScreenSlotUiMarker}, player::Player, holdable::InPlayerHands, camera::MainCamera}, weapons::{firearm_state::FirearmState, slot::slot::WeaponSlot}}, logic::core::guns::player_firing::PlayerFiringInfo}; + +pub fn setup_inspect_screen(mut commands: Commands) { + // Background + commands + .spawn(( + NodeBundle { + style: Style { + display: Display::Flex, + width: Val::Percent(100.0), + height: Val::Percent(100.0), + justify_content: JustifyContent::Center, + padding: UiRect::percent(3.0, 3.0, 3.0, 3.0), + align_items: AlignItems::Center, + flex_direction: FlexDirection::Row, + ..Default::default() + }, + visibility: Visibility::Visible, //TODO: switch off + background_color: BackgroundColor(Color::NONE), + focus_policy: FocusPolicy::Block, + ..Default::default() + }, + Name::new("Inspect Screen"), + )) + .insert(InspectScreenUiMarker); +// TODO: Create every single slot to be used here (1 per weapon slot) +} + +// TODO: put all queries in one params +// TODO: Add state of this screen to GameUiState +// TODO: Create slots if they aren't there for a specific weapon slot +// TODO: Hide and show slots depending on the weapon. +// TODO: Modify their contents to show what they have +pub fn update_inspect_screen( + mut commands: Commands, + player_firing_info_query: Query<(&Player, &PlayerFiringInfo)>, + in_player_hands_query: Query<(Entity, &InPlayerHands, &Children), Without>, + mut firearm_query: Query<(Entity, &mut FirearmState), Without>, + slots_query: Query<(Entity, &WeaponSlot, &GlobalTransform)>, + mut inspect_screen_query: Query<(Entity, &mut Visibility), With>, + mut inspect_slots_query: Query<(Entity, &mut Visibility, &mut InspectScreenSlotUiMarker)>, + camera_query: Query<(&Camera, &GlobalTransform), With>, +) { + for (inspect_screen_entity, mut inspect_screen_visibility) in inspect_screen_query.iter_mut() { + for (player, player_firing_info) in player_firing_info_query.iter() { + if player_firing_info.is_inspecting { + *inspect_screen_visibility = Visibility::Visible; + // TODO: Build + for (camera, camera_transform) in camera_query.iter() { + for (slot_entity, slot, slot_transform) in slots_query.iter() { + for (inspect_slot_entity, mut inspect_slot_visibility, mut inspect_slot) in inspect_slots_query.iter_mut() { + // Create slot if not there, number them, etc... + } + camera.world_to_viewport(camera_transform, slot_transform.translation()); + + } + } + } else { + *inspect_screen_visibility = Visibility::Hidden; + } + } + } +} \ No newline at end of file diff --git a/src/ui/game/inspect/mod.rs b/src/ui/game/inspect/mod.rs new file mode 100644 index 0000000..838d162 --- /dev/null +++ b/src/ui/game/inspect/mod.rs @@ -0,0 +1,3 @@ +pub mod plugin; +pub mod mapper; +pub mod menu; \ No newline at end of file diff --git a/src/ui/game/inspect/plugin.rs b/src/ui/game/inspect/plugin.rs new file mode 100644 index 0000000..054ac96 --- /dev/null +++ b/src/ui/game/inspect/plugin.rs @@ -0,0 +1,14 @@ +use bevy::prelude::*; + +use super::menu::{setup_inspect_screen, update_inspect_screen}; + +pub struct InspectMenuPlugin; + +impl Plugin for InspectMenuPlugin { + fn build(&self, app: &mut App) { + app + .add_systems(Startup, setup_inspect_screen) + .add_systems(Update, update_inspect_screen) + ; + } +} diff --git a/src/ui/game/mod.rs b/src/ui/game/mod.rs index 3d4d014..0f894b6 100644 --- a/src/ui/game/mod.rs +++ b/src/ui/game/mod.rs @@ -4,3 +4,4 @@ pub mod hud; pub mod inventory; pub mod plugin; pub mod settings; +pub mod inspect; \ No newline at end of file diff --git a/src/ui/game/plugin.rs b/src/ui/game/plugin.rs index 4e2b882..e267098 100644 --- a/src/ui/game/plugin.rs +++ b/src/ui/game/plugin.rs @@ -1,6 +1,6 @@ use bevy::prelude::*; -use super::{game_ui_state::GameUiState, hud, inventory, settings}; +use super::{game_ui_state::GameUiState, hud, inventory, settings, inspect}; pub struct MainGameUIPlugin; @@ -9,6 +9,7 @@ impl Plugin for MainGameUIPlugin { app.add_plugins(hud::plugin::HudOverlayPlugin); app.add_plugins(inventory::plugin::InventoryMenuPlugin); app.add_plugins(settings::plugin::SettingsMenuPlugin); + app.add_plugins(inspect::plugin::InspectMenuPlugin); app.insert_resource(GameUiState::default()); } } diff --git a/src/ui/mod.rs b/src/ui/mod.rs index ba5faa2..35f6abc 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,2 +1,2 @@ pub mod editor; -pub mod game; +pub mod game; \ No newline at end of file