Cargo fmt, readme update and removed warnings
This commit is contained in:
parent
affacae0a0
commit
c55bb81fd7
10
Readme.md
10
Readme.md
@ -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)
|
||||
|
@ -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 {}
|
||||
|
@ -1,3 +1,3 @@
|
||||
//pub mod loot_container;
|
||||
pub mod inventory_changed;
|
||||
pub mod pickup_item;
|
||||
pub mod inventory_changed;
|
@ -7,9 +7,9 @@ use crate::comps::core::items::item::Item;
|
||||
/// When an item gets picked up in the game world, this event should handle all the physical properties on the game world.
|
||||
/// Mainly, removing the item from the game world, triggering inventory events, changing the player's equipment, etc...
|
||||
#[derive(Event)]
|
||||
pub struct PickupItemEvent {
|
||||
pub struct PickupItemEvent {
|
||||
/// Item entity
|
||||
pub entity: Entity,
|
||||
pub item: Arc<dyn Item>,
|
||||
pub item: Arc<dyn Item>,
|
||||
pub player: Entity,
|
||||
}
|
||||
|
@ -2,4 +2,4 @@
|
||||
//pub mod inventory_item;
|
||||
pub mod item_inventory;
|
||||
pub mod player_inventory;
|
||||
pub mod plugin;
|
||||
pub mod plugin;
|
||||
|
@ -35,5 +35,4 @@ impl PlayerInventory {
|
||||
pub fn get_secondary(&self) -> &Option<Box<dyn Item>> {
|
||||
&self.secondary.item
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
@ -9,4 +12,4 @@ impl Plugin for InventoryPlugin {
|
||||
app.add_event::<PickupItemEvent>();
|
||||
app.add_systems(Update, update_player_inventory_system);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,13 @@ use bevy::prelude::*;
|
||||
use bevy_rapier3d::prelude::*;
|
||||
|
||||
use crate::{
|
||||
comps::core::{markers::{
|
||||
camera::MainCamera,
|
||||
player::{Player, PlayerData, PlayerHand},
|
||||
}, inventory::player_inventory::PlayerInventory},
|
||||
comps::core::{
|
||||
inventory::player_inventory::PlayerInventory,
|
||||
markers::{
|
||||
camera::MainCamera,
|
||||
player::{Player, PlayerData, PlayerHand},
|
||||
},
|
||||
},
|
||||
logic::core::{
|
||||
guns::player_firing::PlayerFiringInfo,
|
||||
player::{
|
||||
|
@ -1,9 +1,15 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::comps::core::{markers::{
|
||||
firearm::{FirearmData, FirearmType, FiringPoint},
|
||||
holdable::HoldableObjectData,
|
||||
}, items::{item::Item, guns::{m4a1::M4a1GunItem, glock17::Glock17GunItem}}};
|
||||
use crate::comps::core::{
|
||||
items::{
|
||||
guns::{glock17::Glock17GunItem, m4a1::M4a1GunItem},
|
||||
item::Item,
|
||||
},
|
||||
markers::{
|
||||
firearm::{FirearmData, FirearmType, FiringPoint},
|
||||
holdable::HoldableObjectData,
|
||||
},
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
|
||||
use super::{caliber::Caliber, spray_pattern::FirearmSprayPattern};
|
||||
|
@ -2,13 +2,18 @@ use bevy::{ecs::system::SystemParam, prelude::*};
|
||||
use bevy_rapier3d::prelude::*;
|
||||
|
||||
use crate::{
|
||||
comps::core::{markers::{
|
||||
camera::MainCamera,
|
||||
firearm::{FirearmData, MagazineData},
|
||||
holdable::{InPlayerHands, HoldableObjectType},
|
||||
interactable::Interactable,
|
||||
player::{Player, PlayerHand},
|
||||
}, events::pickup_item::PickupItemEvent, inventory::player_inventory::PlayerInventory, items::item::ItemType},
|
||||
comps::core::{
|
||||
events::pickup_item::PickupItemEvent,
|
||||
inventory::player_inventory::PlayerInventory,
|
||||
items::item::ItemType,
|
||||
markers::{
|
||||
camera::MainCamera,
|
||||
firearm::{FirearmData, MagazineData},
|
||||
holdable::{HoldableObjectType, InPlayerHands},
|
||||
interactable::Interactable,
|
||||
player::{Player, PlayerHand},
|
||||
},
|
||||
},
|
||||
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)));
|
||||
.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)));
|
||||
.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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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!(),
|
||||
}
|
||||
|
@ -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;
|
@ -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},
|
||||
|
@ -82,22 +82,22 @@ pub fn spawn_obstacles(
|
||||
|
||||
// CRATE
|
||||
/*commands
|
||||
.spawn((
|
||||
Collider::from_bevy_mesh(&box_5_mesh, &Default::default()).unwrap(),
|
||||
Name::new("Crate"),
|
||||
))
|
||||
.insert(RigidBody::Fixed)
|
||||
.insert(PbrBundle {
|
||||
mesh: meshes.add(box_5_mesh.into()),
|
||||
material: materials.add(StandardMaterial {
|
||||
base_color: Color::BLUE,
|
||||
perceptual_roughness: 0.1,
|
||||
..default()
|
||||
}),
|
||||
transform: Transform::from_xyz(20.0, 2.0, 20.0),
|
||||
.spawn((
|
||||
Collider::from_bevy_mesh(&box_5_mesh, &Default::default()).unwrap(),
|
||||
Name::new("Crate"),
|
||||
))
|
||||
.insert(RigidBody::Fixed)
|
||||
.insert(PbrBundle {
|
||||
mesh: meshes.add(box_5_mesh.into()),
|
||||
material: materials.add(StandardMaterial {
|
||||
base_color: Color::BLUE,
|
||||
perceptual_roughness: 0.1,
|
||||
..default()
|
||||
})
|
||||
/*.insert(Interactable::Lootable(AnyInventory::new(
|
||||
UGrid::new_square(10),
|
||||
)))*/;*/
|
||||
}),
|
||||
transform: Transform::from_xyz(20.0, 2.0, 20.0),
|
||||
..default()
|
||||
})
|
||||
/*.insert(Interactable::Lootable(AnyInventory::new(
|
||||
UGrid::new_square(10),
|
||||
)))*/;*/
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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) {}
|
||||
|
Loading…
Reference in New Issue
Block a user