Work on the inspect screen and other details

This commit is contained in:
Franklin 2023-11-23 19:24:58 -04:00
parent 24df81424b
commit 66c651cb93
10 changed files with 107 additions and 6 deletions

View File

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

View File

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

View File

@ -6,4 +6,5 @@ pub mod inventory_screen;
pub mod muzzle_flash;
pub mod player;
pub mod settings_screen;
pub mod proxy;
pub mod proxy;
pub mod inspect_screen;

View File

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

View File

@ -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<Player>>,
mut firearm_query: Query<(Entity, &mut FirearmState), Without<InPlayerHands>>,
slots_query: Query<(Entity, &WeaponSlot, &GlobalTransform)>,
mut inspect_screen_query: Query<(Entity, &mut Visibility), With<InspectScreenUiMarker>>,
mut inspect_slots_query: Query<(Entity, &mut Visibility, &mut InspectScreenSlotUiMarker)>,
camera_query: Query<(&Camera, &GlobalTransform), With<MainCamera>>,
) {
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;
}
}
}
}

View File

@ -0,0 +1,3 @@
pub mod plugin;
pub mod mapper;
pub mod menu;

View File

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

View File

@ -4,3 +4,4 @@ pub mod hud;
pub mod inventory;
pub mod plugin;
pub mod settings;
pub mod inspect;

View File

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

View File

@ -1,2 +1,2 @@
pub mod editor;
pub mod game;
pub mod game;