Cargo fmt, readme update and removed warnings

This commit is contained in:
Franklin 2023-11-13 13:57:24 -04:00
parent affacae0a0
commit c55bb81fd7
17 changed files with 133 additions and 78 deletions

View File

@ -3,18 +3,22 @@
## Things to finish:
- [ ] Perfect movement
- [ ] Equipping items (Guns and armor)
- [x] Equipping items
- [x] Replace items in the same slot, drop them
- [ ] When equipping an item that replaces another item because of the slot, throw item towards front of player
- [ ] 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
- [ ] Persistent magazine data
- [ ] Perfectly center interact clue text on screen
- [ ] Fix: No Sprinting while aiming
- [ ] 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: Give a (sensor) 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.
- [x] Feature: Muzzle flashes for shots
- [x] Feature: Bullets (projectile)

View File

@ -2,6 +2,4 @@ use bevy::prelude::*;
/// This will be what is triggered after picking up an item or dropping an item.
#[derive(Event)]
pub struct InventoryChangedEvent {
}
pub struct InventoryChangedEvent {}

View File

@ -1,3 +1,3 @@
//pub mod loot_container;
pub mod pickup_item;
pub mod inventory_changed;
pub mod pickup_item;

View File

@ -35,5 +35,4 @@ impl PlayerInventory {
pub fn get_secondary(&self) -> &Option<Box<dyn Item>> {
&self.secondary.item
}
}

View File

@ -1,6 +1,9 @@
use bevy::prelude::*;
use crate::{comps::core::events::pickup_item::PickupItemEvent, logic::core::player::inventory::update_player_inventory_system};
use crate::{
comps::core::events::pickup_item::PickupItemEvent,
logic::core::player::inventory::update_player_inventory_system,
};
pub struct InventoryPlugin;

View File

@ -3,8 +3,9 @@ use crate::{
grid::UGrid,
markers::{firearm::FirearmData, holdable::HoldableObjectType, interactable::Interactable},
},
logic::core::guns::firearm::Firearm,
setup::assets::{GltfAssetType, GltfAssets},
utils, logic::core::guns::firearm::Firearm,
utils,
};
use bevy::{gltf::Gltf, prelude::*};
use bevy_rapier3d::prelude::*;
@ -105,7 +106,7 @@ pub trait Item: Sync + Send {
ItemType::Holdable(holdable) => match holdable {
HoldableObjectType::Firearm(firearm) => Some(firearm),
},
_ => None
_ => None,
}
}
}

View File

@ -2,10 +2,13 @@ use bevy::prelude::*;
use bevy_rapier3d::prelude::*;
use crate::{
comps::core::{markers::{
comps::core::{
inventory::player_inventory::PlayerInventory,
markers::{
camera::MainCamera,
player::{Player, PlayerData, PlayerHand},
}, inventory::player_inventory::PlayerInventory},
},
},
logic::core::{
guns::player_firing::PlayerFiringInfo,
player::{

View File

@ -1,9 +1,15 @@
use std::sync::Arc;
use crate::comps::core::{markers::{
use crate::comps::core::{
items::{
guns::{glock17::Glock17GunItem, m4a1::M4a1GunItem},
item::Item,
},
markers::{
firearm::{FirearmData, FirearmType, FiringPoint},
holdable::HoldableObjectData,
}, items::{item::Item, guns::{m4a1::M4a1GunItem, glock17::Glock17GunItem}}};
},
};
use bevy::prelude::*;
use super::{caliber::Caliber, spray_pattern::FirearmSprayPattern};

View File

@ -2,13 +2,18 @@ use bevy::{ecs::system::SystemParam, prelude::*};
use bevy_rapier3d::prelude::*;
use crate::{
comps::core::{markers::{
comps::core::{
events::pickup_item::PickupItemEvent,
inventory::player_inventory::PlayerInventory,
items::item::ItemType,
markers::{
camera::MainCamera,
firearm::{FirearmData, MagazineData},
holdable::{InPlayerHands, HoldableObjectType},
holdable::{HoldableObjectType, InPlayerHands},
interactable::Interactable,
player::{Player, PlayerHand},
}, events::pickup_item::PickupItemEvent, inventory::player_inventory::PlayerInventory, items::item::ItemType},
},
},
logic::core::guns::{firearm::Firearm, player_firing::PlayerFiringInfo, shoot::shoot_bullet},
setup::{
animations::AllFirearmAnimations,
@ -70,32 +75,34 @@ pub fn capture_hand_usage(
if resources.keyboard_input.just_pressed(KeyCode::Key1) {
if let Some(primary_item) = player_query.single().1.get_primary() {
if let Some(primary_firearm) = primary_item.get_firearm() {
if Equipment::Firearm(primary_firearm.clone()) != player_query.single().0.0.equipment {
if Equipment::Firearm(primary_firearm.clone())
!= player_query.single().0 .0.equipment
{
equipment_change_event_writer
.send(EquipmentChangeEvent(Equipment::Firearm(primary_firearm)));
}
}
}
} else if resources.keyboard_input.just_pressed(KeyCode::Key2) {
if let Some(secondary_item) = player_query.single().1.get_secondary() {
if let Some(secondary_firearm) = secondary_item.get_firearm() {
if Equipment::Firearm(secondary_firearm.clone()) != player_query.single().0.0.equipment {
if Equipment::Firearm(secondary_firearm.clone())
!= player_query.single().0 .0.equipment
{
equipment_change_event_writer
.send(EquipmentChangeEvent(Equipment::Firearm(secondary_firearm)));
}
}
}
} else if resources.keyboard_input.just_pressed(KeyCode::Key3) {
if Equipment::Nothing != player_query.single().0.0.equipment {
if Equipment::Nothing != player_query.single().0 .0.equipment {
equipment_change_event_writer.send(EquipmentChangeEvent(Equipment::Nothing));
}
}
}
// Firearm stuff
if let Equipment::Firearm(player_firearm) = player_query.single().0.0.equipment.clone() {
if let Equipment::Firearm(player_firearm) = player_query.single().0 .0.equipment.clone() {
for mut player_firing_info in player_firing_info_query.iter_mut() {
player_firing_info
.full_auto_timer
@ -306,7 +313,11 @@ pub fn interact_action(
.send(LootContainerEvent(any_inventory.clone()))
}*/
Interactable::Item(item) => {
pickup_item_event_writer.send(PickupItemEvent { entity: interactable_entity, item: item.clone(), player: player_entity });
pickup_item_event_writer.send(PickupItemEvent {
entity: interactable_entity,
item: item.clone(),
player: player_entity,
});
}
}
}

View File

@ -1,6 +1,14 @@
use bevy::{prelude::*, gltf::Gltf};
use bevy::{gltf::Gltf, prelude::*};
use crate::{comps::core::{events::pickup_item::PickupItemEvent, markers::{player::Player, holdable::HoldableObjectType, firearm::FirearmType}, inventory::player_inventory::PlayerInventory, items::item::ItemType}, setup::assets::GltfAssets};
use crate::{
comps::core::{
events::pickup_item::PickupItemEvent,
inventory::player_inventory::PlayerInventory,
items::item::ItemType,
markers::{firearm::FirearmType, holdable::HoldableObjectType, player::Player},
},
setup::assets::GltfAssets,
};
pub fn update_player_inventory_system(
mut commands: Commands,
@ -17,30 +25,55 @@ pub fn update_player_inventory_system(
ItemType::Holdable(holdable_object) => {
match holdable_object {
HoldableObjectType::Firearm(firearm) => {
commands.entity(event.entity).despawn_descendants().despawn();
commands
.entity(event.entity)
.despawn_descendants()
.despawn();
match firearm.firearm_data().firearm_type {
FirearmType::Primary => {
// Send equipment_changed_event
if let Some(primary_item) = player_inventory.get_primary() {
// Drop this one
primary_item.spawn(&mut commands, Transform::from_translation(player_transform.translation + player_transform.up() * 5.0 + player_transform.forward()), &assets_gltf, &loaded_gltf_assets);
player_inventory.primary.item = Some(firearm.get_item_box())
primary_item.spawn(
&mut commands,
Transform::from_translation(
player_transform.translation
+ player_transform.up() * 5.0
+ player_transform.forward(),
),
&assets_gltf,
&loaded_gltf_assets,
);
player_inventory.primary.item =
Some(firearm.get_item_box())
} else {
player_inventory.primary.item = Some(firearm.get_item_box())
player_inventory.primary.item =
Some(firearm.get_item_box())
}
}
},
FirearmType::Secondary => {
if let Some(secondary) = player_inventory.get_secondary() {
secondary.spawn(&mut commands, Transform::from_translation(player_transform.translation + player_transform.up() * 5.0 + player_transform.forward()), &assets_gltf, &loaded_gltf_assets);
player_inventory.secondary.item = Some(firearm.get_item_box())
secondary.spawn(
&mut commands,
Transform::from_translation(
player_transform.translation
+ player_transform.up() * 5.0
+ player_transform.forward(),
),
&assets_gltf,
&loaded_gltf_assets,
);
player_inventory.secondary.item =
Some(firearm.get_item_box())
} else {
player_inventory.secondary.item = Some(firearm.get_item_box())
player_inventory.secondary.item =
Some(firearm.get_item_box())
}
}
}
}
},
}
},
}
},
ItemType::Equippable => todo!(),
ItemType::Consumable => todo!(),
}

View File

@ -1,7 +1,7 @@
pub mod camera_effects;
pub mod camera_player_sync;
pub mod hands;
pub mod inventory;
pub mod player_movement;
pub mod player_values_state;
pub mod player_vertical_sync;
pub mod inventory;

View File

@ -3,7 +3,8 @@ use bevy::prelude::*;
use crate::{
comps::core::{
controller::capture_input,
spawners::{player::player_spawner, spawn::SpawnerPlugin}, inventory::plugin::InventoryPlugin,
inventory::plugin::InventoryPlugin,
spawners::{player::player_spawner, spawn::SpawnerPlugin},
},
logic::core::{
guns::despawn_shots::{despawn_muzzle_flashes, despawn_stray_bullets},

View File

@ -6,7 +6,7 @@ use crate::{
comps::core::markers::{
firearm::{FirearmData, MagazineData},
holdable::InPlayerHands,
player::{Player, PlayerHand, PlayerData},
player::{Player, PlayerHand},
},
logic::core::guns::{firearm::Firearm, player_firing::PlayerFiringInfo},
utils,

View File

@ -6,8 +6,4 @@ use bevy::prelude::*;
/// Should contain player inventory and if player is looting something as well
pub fn setup_inventory_screen(mut _commands: Commands) {}
pub fn update_inventory_screen(
mut _commands: Commands,
) {
}
pub fn update_inventory_screen(mut _commands: Commands) {}