From aa7eb521b848cee497099f646f30ab95f7e4dc16 Mon Sep 17 00:00:00 2001 From: Franklin Date: Sun, 12 Nov 2023 17:24:28 -0400 Subject: [PATCH] Cargo fmt --- Design.md | 1 + Readme.md | 23 +++- src/comps/core/items/guns/glock17.rs | 20 +++- src/comps/core/items/guns/mod.rs | 2 +- src/comps/core/items/item.rs | 6 +- src/comps/core/markers/firearm.rs | 8 ++ src/comps/core/mod.rs | 2 +- .../core/spawners/guns/glock17_spawner.rs | 7 +- src/comps/core/spawners/guns/m4a1_spawner.rs | 7 +- src/comps/core/spawners/guns/mod.rs | 2 +- src/comps/core/spawners/item.rs | 22 +++- src/comps/core/spawners/mod.rs | 4 +- src/comps/core/spawners/player.rs | 2 +- src/comps/core/spawners/spawn.rs | 14 +-- src/comps/core/spawners/spawn_point.rs | 6 +- src/logic/core/guns/firearm.rs | 10 +- src/logic/core/player/hands.rs | 113 ++++++++++-------- src/logic/core/player/player_values_state.rs | 2 +- src/scenes/scene1/init.rs | 9 +- src/scenes/scene1/spawn_points.rs | 11 +- src/ui/game/inventory/menu.rs | 1 - src/utils/hierarchy.rs | 20 +++- src/utils/mod.rs | 2 +- 23 files changed, 194 insertions(+), 100 deletions(-) diff --git a/Design.md b/Design.md index 622fb16..1c17f9b 100644 --- a/Design.md +++ b/Design.md @@ -1,5 +1,6 @@ ## Game design +### OUTDADED: 4-6 guns, with 1 magazine per gun. Optics can be left out Can only be found in the world diff --git a/Readme.md b/Readme.md index 7726650..eb57f81 100644 --- a/Readme.md +++ b/Readme.md @@ -1,17 +1,28 @@ # Experimental game + +## Things to finish: +- [ ] Perfect movement +- [ ] Equipping items (Guns and armor) +- [ ] Gun aiming and noscope is not the same position +- [ ] Controls being bindable +- [ ] Gun moving out of the way on a collision +- [ ] Gun moving when walking, when running, aimed in. +- [ ] Visual effects for camera + + - [ ] Fix: Make gun have more priority in rendering. So it doesn't clip through walls - [ ] Feature: Give a collider to the gun and when it collides with something make it move out of the way. - [ ] Feature: Add bullet holes - [ ] Fix: No Sprinting while aiming - [ ] Fix: Movement is clunky and very linear. Add some sort of Lerping for acceleration vectors. -- [ ] Feature: Muzzle flashes for shots -- [ ] Feature: Bullets (raycast or projectile?) +- [x] Feature: Muzzle flashes for shots +- [x] Feature: Bullets (projectile) - [x] Feature: Add smooth camera movement to camera on crouch. Right now it's too fast and looks arcade af. ~~- [ ] Feature: Add jump effect to camera~~ - [ ] Feature: Add Stamina (with bar?) - [ ] Feature: Subtle Headbob, FOV change on movement (Distinguish between sprinting and walking). -- [ ] Feature: Basic ESC UI, FPS counter, stamina bar +- [x] Feature: Basic ESC UI, FPS counter - [ ] Feature: Gun sprinting animations, high ready, low ready, etc... - [x] Discussion: PvP vs PvE @@ -32,15 +43,15 @@ Build a realistic fps sandbox with arcadey mechanics, and start to document it, ## MVP to start documenting progress: -- [ ] Shooting bullets. +- [x] Shooting bullets. - [ ] A manequinn that registers hits in every hitbox. - [ ] A shooting range/place to be in and show process -- [ ] Some resemblance of UI (Escape menu, stamina bar, etc...) +- [x] Some resemblance of UI (Escape menu, stamina bar, etc...) - [ ] Stamina system ## End goal landmarks - [ ] Dynamic hitboxes (heart, brain, lungs) - [ ] Health system with blodloss instead of a health number -- [ ] Dynamic lighting (Gunshots causing light to be spawned for a duration) +- [x] Dynamic lighting (Gunshots causing light to be spawned for a duration) - [ ] Sound system - [ ] Adrenaline system \ No newline at end of file diff --git a/src/comps/core/items/guns/glock17.rs b/src/comps/core/items/guns/glock17.rs index b0e34a4..bffb555 100644 --- a/src/comps/core/items/guns/glock17.rs +++ b/src/comps/core/items/guns/glock17.rs @@ -1,6 +1,13 @@ use bevy::prelude::*; -use crate::{comps::core::{items::item::{Item, ItemType}, grid::UGrid, markers::holdable::HoldableObjectType}, logic::core::guns::firearm::Firearm}; +use crate::{ + comps::core::{ + grid::UGrid, + items::item::{Item, ItemType}, + markers::holdable::HoldableObjectType, + }, + logic::core::guns::firearm::Firearm, +}; #[derive(Component)] pub struct Glock17GunItem; @@ -10,17 +17,20 @@ impl Item for Glock17GunItem { ItemType::Holdable(HoldableObjectType::Firearm(Firearm::Glock17)) } - fn asset_path(&self) -> &str { + fn asset_path(&self) -> &str { "weapons/glock_17_pistol.glb" } #[doc = " Optional Stackable. If value is Some(x) x is the max quantity per stack"] - fn stackable(&self) -> Option { + fn stackable(&self) -> Option { None } fn inventory_size(&self) -> UGrid { - UGrid { width: 2, height: 1 } + UGrid { + width: 2, + height: 1, + } } fn inventory_rotatable(&self) -> bool { @@ -34,4 +44,4 @@ impl Item for Glock17GunItem { fn inventory_description(&self) -> String { String::from("Glock17 Firearm chambered in 9x19mm.") } -} \ No newline at end of file +} diff --git a/src/comps/core/items/guns/mod.rs b/src/comps/core/items/guns/mod.rs index c743ae6..d204833 100644 --- a/src/comps/core/items/guns/mod.rs +++ b/src/comps/core/items/guns/mod.rs @@ -1,2 +1,2 @@ +pub mod glock17; pub mod m4a1; -pub mod glock17; \ No newline at end of file diff --git a/src/comps/core/items/item.rs b/src/comps/core/items/item.rs index 5f4d4e1..f75597d 100644 --- a/src/comps/core/items/item.rs +++ b/src/comps/core/items/item.rs @@ -81,7 +81,11 @@ pub trait Item { ..Default::default() }, RigidBody::Dynamic, - Collider::cuboid(firearm_size.x, firearm_size.y, firearm_size.z), + Collider::cuboid( + firearm_size.x, + firearm_size.y, + firearm_size.z, + ), Interactable::Item, )) .push_children(&[firearm_asset_entity]); diff --git a/src/comps/core/markers/firearm.rs b/src/comps/core/markers/firearm.rs index 2039bba..922b47e 100644 --- a/src/comps/core/markers/firearm.rs +++ b/src/comps/core/markers/firearm.rs @@ -12,6 +12,12 @@ pub struct FiringPoint { pub right: f32, } +#[derive(Reflect, Clone)] +pub enum FirearmType { + Primary, + Secondary, +} + #[derive(Component, Clone, Reflect)] pub struct FirearmData { /// Where the bullets will come out of, and muzzle flash will be spawned out of. @@ -43,6 +49,8 @@ pub struct FirearmData { pub final_position: Vec3, pub scale_factor: f32, + + pub firearm_type: FirearmType, } #[derive(Component, Reflect)] diff --git a/src/comps/core/mod.rs b/src/comps/core/mod.rs index 53963b0..1005fae 100644 --- a/src/comps/core/mod.rs +++ b/src/comps/core/mod.rs @@ -4,4 +4,4 @@ pub mod grid; pub mod inventory; pub mod items; pub mod markers; -pub mod spawners; \ No newline at end of file +pub mod spawners; diff --git a/src/comps/core/spawners/guns/glock17_spawner.rs b/src/comps/core/spawners/guns/glock17_spawner.rs index 28fe788..d9271ff 100644 --- a/src/comps/core/spawners/guns/glock17_spawner.rs +++ b/src/comps/core/spawners/guns/glock17_spawner.rs @@ -1,6 +1,9 @@ use bevy::prelude::*; -use crate::comps::core::{items::{guns::glock17::Glock17GunItem, item::Item}, spawners::item::ItemSpawnPoint}; +use crate::comps::core::{ + items::{guns::glock17::Glock17GunItem, item::Item}, + spawners::item::ItemSpawnPoint, +}; #[derive(Component)] pub struct Glock17SpawnPoint { @@ -15,4 +18,4 @@ impl ItemSpawnPoint for Glock17SpawnPoint { fn get_item(&self) -> Box { Box::new(Glock17GunItem) } -} \ No newline at end of file +} diff --git a/src/comps/core/spawners/guns/m4a1_spawner.rs b/src/comps/core/spawners/guns/m4a1_spawner.rs index 152522b..b567f90 100644 --- a/src/comps/core/spawners/guns/m4a1_spawner.rs +++ b/src/comps/core/spawners/guns/m4a1_spawner.rs @@ -1,6 +1,9 @@ use bevy::prelude::*; -use crate::comps::core::{items::{guns::m4a1::M4a1GunItem, item::Item}, spawners::item::ItemSpawnPoint}; +use crate::comps::core::{ + items::{guns::m4a1::M4a1GunItem, item::Item}, + spawners::item::ItemSpawnPoint, +}; #[derive(Component)] pub struct M4a1SpawnPoint { @@ -15,4 +18,4 @@ impl ItemSpawnPoint for M4a1SpawnPoint { fn get_item(&self) -> Box { Box::new(M4a1GunItem) } -} \ No newline at end of file +} diff --git a/src/comps/core/spawners/guns/mod.rs b/src/comps/core/spawners/guns/mod.rs index 32ee70e..37289a5 100644 --- a/src/comps/core/spawners/guns/mod.rs +++ b/src/comps/core/spawners/guns/mod.rs @@ -1,2 +1,2 @@ +pub mod glock17_spawner; pub mod m4a1_spawner; -pub mod glock17_spawner; \ No newline at end of file diff --git a/src/comps/core/spawners/item.rs b/src/comps/core/spawners/item.rs index 3e0219a..56b5dae 100644 --- a/src/comps/core/spawners/item.rs +++ b/src/comps/core/spawners/item.rs @@ -1,6 +1,12 @@ -use bevy::{prelude::*, gltf::Gltf}; +use bevy::{gltf::Gltf, prelude::*}; -use crate::{setup::{load_state::GameLoadState, assets::GltfAssets}, comps::core::{items::item::Item, spawners::guns::{m4a1_spawner::M4a1SpawnPoint, glock17_spawner::Glock17SpawnPoint}}}; +use crate::{ + comps::core::{ + items::item::Item, + spawners::guns::{glock17_spawner::Glock17SpawnPoint, m4a1_spawner::M4a1SpawnPoint}, + }, + setup::{assets::GltfAssets, load_state::GameLoadState}, +}; #[bevy_trait_query::queryable] pub trait ItemSpawnPoint { @@ -19,7 +25,12 @@ pub fn item_spawner( for (entity, item_sp_entity) in item_sp_query.iter() { for component_sp in item_sp_entity { println!("Spawning item"); - component_sp.get_item().spawn(&mut commands, component_sp.get_transform(), &assets_gltf, &loaded_gltf_assets) + component_sp.get_item().spawn( + &mut commands, + component_sp.get_transform(), + &assets_gltf, + &loaded_gltf_assets, + ) } //m4.spawn(&mut commands, item_sp.at, &assets_gltf, &loaded_gltf_assets); commands.entity(entity).despawn(); @@ -31,8 +42,7 @@ pub struct ItemSpawnPointPlugin; impl Plugin for ItemSpawnPointPlugin { fn build(&self, app: &mut App) { use bevy_trait_query::RegisterExt; - app - .register_component_as::() + app.register_component_as::() .register_component_as::(); } -} \ No newline at end of file +} diff --git a/src/comps/core/spawners/mod.rs b/src/comps/core/spawners/mod.rs index 03190df..a4ff6eb 100644 --- a/src/comps/core/spawners/mod.rs +++ b/src/comps/core/spawners/mod.rs @@ -1,5 +1,5 @@ +pub mod guns; pub mod item; pub mod player; +pub mod spawn; pub mod spawn_point; -pub mod guns; -pub mod spawn; \ No newline at end of file diff --git a/src/comps/core/spawners/player.rs b/src/comps/core/spawners/player.rs index 2b8155f..11877bb 100644 --- a/src/comps/core/spawners/player.rs +++ b/src/comps/core/spawners/player.rs @@ -118,7 +118,7 @@ pub fn player_spawner( game_load_state.player_loaded = true; equipment_change_event_writer.send(EquipmentChangeEvent( - player_spawn_point.player.0.equipment.clone() + player_spawn_point.player.0.equipment.clone(), )); commands.entity(player_spawn_point_entity).despawn(); } diff --git a/src/comps/core/spawners/spawn.rs b/src/comps/core/spawners/spawn.rs index e945ad1..dcc009b 100644 --- a/src/comps/core/spawners/spawn.rs +++ b/src/comps/core/spawners/spawn.rs @@ -1,15 +1,15 @@ use bevy::prelude::*; -use super::{player::player_spawner, item::{item_spawner, ItemSpawnPointPlugin}, spawn_point::SpawnPointPlugin}; - +use super::{ + item::{item_spawner, ItemSpawnPointPlugin}, + player::player_spawner, + spawn_point::SpawnPointPlugin, +}; pub struct SpawnerPlugin; impl Plugin for SpawnerPlugin { fn build(&self, app: &mut App) { app.add_plugins((SpawnPointPlugin, ItemSpawnPointPlugin)); - app.add_systems( - Update, - (player_spawner, item_spawner), - ); + app.add_systems(Update, (player_spawner, item_spawner)); } -} \ No newline at end of file +} diff --git a/src/comps/core/spawners/spawn_point.rs b/src/comps/core/spawners/spawn_point.rs index 9519105..e765c93 100644 --- a/src/comps/core/spawners/spawn_point.rs +++ b/src/comps/core/spawners/spawn_point.rs @@ -2,7 +2,6 @@ use bevy::prelude::*; use crate::comps::core::spawners::player::PlayerSpawnPoint; - #[bevy_trait_query::queryable] pub trait SpawnPoint { fn get_transform(&self) -> Transform; @@ -12,7 +11,6 @@ pub struct SpawnPointPlugin; impl Plugin for SpawnPointPlugin { fn build(&self, app: &mut App) { use bevy_trait_query::RegisterExt; - app. - register_component_as::(); + app.register_component_as::(); } -} \ No newline at end of file +} diff --git a/src/logic/core/guns/firearm.rs b/src/logic/core/guns/firearm.rs index a57182c..2c7f051 100644 --- a/src/logic/core/guns/firearm.rs +++ b/src/logic/core/guns/firearm.rs @@ -1,5 +1,5 @@ use crate::comps::core::markers::{ - firearm::{FirearmData, FiringPoint}, + firearm::{FirearmData, FirearmType, FiringPoint}, holdable::HoldableObjectData, }; use bevy::prelude::*; @@ -54,6 +54,7 @@ impl Firearm { }, scale_factor: 1.0, asset_path: String::from("weapons/m4a1_rifle.glb"), + firearm_type: FirearmType::Primary, } } Firearm::Glock17 => { @@ -95,6 +96,7 @@ impl Firearm { }, scale_factor: 0.25, asset_path: String::from("weapons/glock_17_pistol.glb"), + firearm_type: FirearmType::Secondary, } } } @@ -113,7 +115,11 @@ impl Firearm { } pub fn get_size(&self) -> Vec3 { match self { - Firearm::M4A1 => Vec3 { x: 0.3, y: 0.7, z: 2.5 }, + Firearm::M4A1 => Vec3 { + x: 0.3, + y: 0.7, + z: 2.5, + }, Firearm::Glock17 => Vec3::ZERO, } } diff --git a/src/logic/core/player/hands.rs b/src/logic/core/player/hands.rs index 4933f8a..4b9ecb0 100644 --- a/src/logic/core/player/hands.rs +++ b/src/logic/core/player/hands.rs @@ -1,16 +1,13 @@ -use bevy::{prelude::*, ecs::system::SystemParam}; +use bevy::{ecs::system::SystemParam, prelude::*}; use bevy_rapier3d::prelude::*; use crate::{ - comps::core::{ - //events::loot_container::LootContainerEvent, - markers::{ - camera::MainCamera, - firearm::{FirearmData, MagazineData}, - holdable::InPlayerHands, - interactable::Interactable, - player::{Player, PlayerHand}, - }, + comps::core::markers::{ + camera::MainCamera, + firearm::{FirearmData, MagazineData}, + holdable::InPlayerHands, + interactable::Interactable, + player::{Player, PlayerHand}, }, logic::core::guns::{firearm::Firearm, player_firing::PlayerFiringInfo, shoot::shoot_bullet}, setup::{ @@ -19,7 +16,7 @@ use crate::{ load_state::GameLoadState, }, ui::game::{hud::hud::HudState, settings::SettingsScreenUIConfiguration}, - utils::{rad_deg::radians_from_degrees, self}, + utils::{self, rad_deg::radians_from_degrees}, }; #[derive(SystemParam)] @@ -41,7 +38,12 @@ pub fn capture_hand_usage( mut hand_query: Query<&mut Transform, With>, mut firearm_query: Query< - (Entity, &GlobalTransform, &'static FirearmData, &mut MagazineData), + ( + Entity, + &GlobalTransform, + &'static FirearmData, + &mut MagazineData, + ), (With, Without), >, player_query: Query<&Player>, @@ -49,7 +51,7 @@ pub fn capture_hand_usage( mut animation_players: Query<(Entity, &mut AnimationPlayer)>, children: Query<&Children>, - + mut equipment_change_event_writer: EventWriter, ) { if !resources.game_load_state.player_loaded { @@ -77,32 +79,41 @@ pub fn capture_hand_usage( // Firearm stuff if let Equipment::Firearm(player_firearm) = player_query.single().0.equipment.clone() { for mut player_firing_info in player_firing_info_query.iter_mut() { - player_firing_info.full_auto_timer.tick(resources.time.delta()); + player_firing_info + .full_auto_timer + .tick(resources.time.delta()); - for (firearm_entity, firearm_transform, firearm_data, mut magazine_data) in firearm_query.iter_mut() { + for (firearm_entity, firearm_transform, firearm_data, mut magazine_data) in + firearm_query.iter_mut() + { for mut hand_transform in hand_query.iter_mut() { if player_firing_info.is_reloading { for (animation_player_entity, animation_player) in &mut animation_players { //children.get_component(entity) // Only reload if this animation_player_entity is a child of the firearm_entity - if utils::hierarchy::find_child_in_parent_children(&mut commands, firearm_entity, animation_player_entity, &children) { - if let Some(firearm_animations) = resources.all_firearm_animations - .animations - .iter() - .find(|animation| &animation.firearm == &player_firearm) - { - if let Some(animation_clip) = - resources.animation_clips.get(&firearm_animations.reload_magazine) + if utils::hierarchy::find_child_in_parent_children( + &mut commands, + firearm_entity, + animation_player_entity, + &children, + ) { + if let Some(firearm_animations) = resources + .all_firearm_animations + .animations + .iter() + .find(|animation| &animation.firearm == &player_firearm) { - if animation_player.elapsed() >= animation_clip.duration() { - magazine_data.rounds_shot = 0; - player_firing_info.is_reloading = false; + if let Some(animation_clip) = resources + .animation_clips + .get(&firearm_animations.reload_magazine) + { + if animation_player.elapsed() >= animation_clip.duration() { + magazine_data.rounds_shot = 0; + player_firing_info.is_reloading = false; + } } } } - } - - } } else { // Player is not in a reload animation @@ -110,13 +121,21 @@ pub fn capture_hand_usage( && !resources.settings_screen_config.settings_menu_shown { // Start reload animation - for (animation_player_entity, mut animation_player) in &mut animation_players { + for (animation_player_entity, mut animation_player) in + &mut animation_players + { // Only reload if this animation_player_entity is a child of the firearm_entity - if utils::hierarchy::find_child_in_parent_children(&mut commands, firearm_entity, animation_player_entity, &children) { - if let Some(firearm_animations) = resources.all_firearm_animations - .animations - .iter() - .find(|animation| &animation.firearm == &player_firearm) + if utils::hierarchy::find_child_in_parent_children( + &mut commands, + firearm_entity, + animation_player_entity, + &children, + ) { + if let Some(firearm_animations) = resources + .all_firearm_animations + .animations + .iter() + .find(|animation| &animation.firearm == &player_firearm) { animation_player .start(firearm_animations.reload_magazine.clone_weak()); @@ -133,12 +152,14 @@ pub fn capture_hand_usage( { let rotation_lerp_quat = hand_transform.rotation.lerp( firearm_data.final_aimed_rotation, - (resources.time.delta_seconds() / firearm_data.rebound_time_seconds) + (resources.time.delta_seconds() + / firearm_data.rebound_time_seconds) .clamp(0.0, 1.0), ); let position_lerp_vec3 = hand_transform.translation.lerp( firearm_data.final_aimed_position, - (resources.time.delta_seconds() / firearm_data.rebound_time_seconds) + (resources.time.delta_seconds() + / firearm_data.rebound_time_seconds) .clamp(0.0, 1.0), ); hand_transform.rotation = rotation_lerp_quat; @@ -146,12 +167,14 @@ pub fn capture_hand_usage( } else { hand_transform.rotation = hand_transform.rotation.lerp( firearm_data.final_rotation, - (resources.time.delta_seconds() / firearm_data.rebound_time_seconds) + (resources.time.delta_seconds() + / firearm_data.rebound_time_seconds) .clamp(0.0, 1.0), ); hand_transform.translation = hand_transform.translation.lerp( firearm_data.final_position, - (resources.time.delta_seconds() / firearm_data.rebound_time_seconds) + (resources.time.delta_seconds() + / firearm_data.rebound_time_seconds) .clamp(0.0, 1.0), ); } @@ -175,13 +198,8 @@ pub fn capture_hand_usage( *firearm_data.recoil_pattern.horizontal.last().expect("FOUND A FIREARM_DATA WITHOUT ANY FIREARM_RECOIL_PATTERN.") }, }; - // TODO: Spawn Bullet & Muzzle flash - /*let firing_point_global = firearm_transform.translation().clone(); - let firint_point_final = firing_point_global + (firearm_transform.forward() * 1.5) + (firearm_transform.up() / 2.5); - shoot_bullet(&mut commands, &mut meshes, &mut materials, Transform::from_translation(firint_point_final), firearm_transform.forward() * 10.0, firearm_data.caliber.clone());*/ let firearm_transform = firearm_transform.clone(); - // TODO: M4 holdableobject data has a Y ROT of -90. Apply that rotation here if it exists. let firing_point = firearm_transform.translation() + (firearm_transform.forward() * firearm_data.firing_point.forward) @@ -201,7 +219,8 @@ pub fn capture_hand_usage( ); // Increment indexes and timers player_firing_info.current_round_index += 1; - player_firing_info.last_shot_timestamp = resources.time.elapsed_seconds(); + player_firing_info.last_shot_timestamp = + resources.time.elapsed_seconds(); player_firing_info.full_auto_timer.reset(); magazine_data.rounds_shot += 1; @@ -275,8 +294,8 @@ pub fn interact_action( }*/ Interactable::Item => { //loot_container_event_writer - // .send() - }, + // .send() + } } } return; diff --git a/src/logic/core/player/player_values_state.rs b/src/logic/core/player/player_values_state.rs index 3f8f43c..9ec7605 100644 --- a/src/logic/core/player/player_values_state.rs +++ b/src/logic/core/player/player_values_state.rs @@ -39,7 +39,7 @@ impl Default for PlayerValuesState { max_linear_player_velocity: 20.0, player_acceleration: 20.0, player_jump_force: 1000.0, - player_jump_cooldown_s: 0.075, + player_jump_cooldown_s: 0.045, player_sprint_speed_multiplier: 3.5, player_crouch_speed_multiplier: 0.25, player_initial_weight: 75.0, diff --git a/src/scenes/scene1/init.rs b/src/scenes/scene1/init.rs index 6c69b00..c10827b 100644 --- a/src/scenes/scene1/init.rs +++ b/src/scenes/scene1/init.rs @@ -1,7 +1,10 @@ use bevy::prelude::*; use crate::{ - comps::core::{controller::capture_input, spawners::{player::player_spawner, spawn::SpawnerPlugin}}, + comps::core::{ + controller::capture_input, + spawners::{player::player_spawner, spawn::SpawnerPlugin}, + }, logic::core::{ guns::despawn_shots::{despawn_muzzle_flashes, despawn_stray_bullets}, player::{ @@ -43,7 +46,7 @@ pub fn load_scene(application: &mut App) { application.add_systems(Startup, setup_lighting); application.add_systems(Startup, set_spawn_points); // Update - + application.add_systems(Update, capture_input); application.add_systems(Update, sync_player_y_state); application.add_systems(Update, follow_cursor_with_camera); @@ -59,4 +62,4 @@ pub fn load_scene(application: &mut App) { //application.add_systems(Update, register_bullet_hits); application.add_event::(); -} \ No newline at end of file +} diff --git a/src/scenes/scene1/spawn_points.rs b/src/scenes/scene1/spawn_points.rs index 6ed4350..0efd782 100644 --- a/src/scenes/scene1/spawn_points.rs +++ b/src/scenes/scene1/spawn_points.rs @@ -1,6 +1,15 @@ use bevy::prelude::*; -use crate::{comps::core::{markers::player::{Player, PlayerData}, spawners::{player::PlayerSpawnPoint, guns::{m4a1_spawner::M4a1SpawnPoint, glock17_spawner::Glock17SpawnPoint}}}, utils}; +use crate::{ + comps::core::{ + markers::player::{Player, PlayerData}, + spawners::{ + guns::{glock17_spawner::Glock17SpawnPoint, m4a1_spawner::M4a1SpawnPoint}, + player::PlayerSpawnPoint, + }, + }, + utils, +}; pub fn set_spawn_points(mut commands: Commands) { commands.spawn(PlayerSpawnPoint { diff --git a/src/ui/game/inventory/menu.rs b/src/ui/game/inventory/menu.rs index a878360..3214603 100644 --- a/src/ui/game/inventory/menu.rs +++ b/src/ui/game/inventory/menu.rs @@ -10,5 +10,4 @@ pub fn update_inventory_screen( mut _commands: Commands, //mut event_reader: EventReader, ) { - } diff --git a/src/utils/hierarchy.rs b/src/utils/hierarchy.rs index e92c1bb..3ce4b76 100644 --- a/src/utils/hierarchy.rs +++ b/src/utils/hierarchy.rs @@ -1,17 +1,27 @@ use bevy::prelude::*; - -pub fn find_child_in_parent_children(commands: &mut Commands, parent_entity: Entity, descendant_entity: Entity, children: &Query<&Children>) -> bool { +pub fn find_child_in_parent_children( + commands: &mut Commands, + parent_entity: Entity, + descendant_entity: Entity, + children: &Query<&Children>, +) -> bool { let all_children = flatten_if_possible_inf_levels(commands, parent_entity, children); all_children.contains(&descendant_entity) } -fn flatten_if_possible_inf_levels(commands: &mut Commands, parent_entity: Entity, children: &Query<&Children>) -> Vec { +fn flatten_if_possible_inf_levels( + commands: &mut Commands, + parent_entity: Entity, + children: &Query<&Children>, +) -> Vec { let mut all_descendant_entities: Vec = Vec::new(); let descendants = children.iter_descendants(parent_entity); for descendant in descendants { all_descendant_entities.push(descendant); - all_descendant_entities.append(&mut flatten_if_possible_inf_levels(commands, descendant, children)); + all_descendant_entities.append(&mut flatten_if_possible_inf_levels( + commands, descendant, children, + )); } all_descendant_entities -} \ No newline at end of file +} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 7998ca7..6886906 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,2 +1,2 @@ +pub mod hierarchy; pub mod rad_deg; -pub mod hierarchy; \ No newline at end of file