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:
|
## Things to finish:
|
||||||
- [ ] Perfect movement
|
- [ ] 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
|
- [ ] Gun aiming and noscope is not the same position
|
||||||
- [ ] Controls being bindable
|
- [ ] Controls being bindable
|
||||||
- [ ] Gun moving out of the way on a collision
|
- [ ] Gun moving out of the way on a collision
|
||||||
- [ ] Gun moving when walking, when running, aimed in.
|
- [ ] Gun moving when walking, when running, aimed in.
|
||||||
- [ ] Visual effects for camera
|
- [ ] 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
|
- [ ] 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
|
- [ ] Feature: Add bullet holes
|
||||||
- [ ] Fix: No Sprinting while aiming
|
|
||||||
- [ ] Fix: Movement is clunky and very linear. Add some sort of Lerping for acceleration vectors.
|
- [ ] Fix: Movement is clunky and very linear. Add some sort of Lerping for acceleration vectors.
|
||||||
- [x] Feature: Muzzle flashes for shots
|
- [x] Feature: Muzzle flashes for shots
|
||||||
- [x] Feature: Bullets (projectile)
|
- [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.
|
/// This will be what is triggered after picking up an item or dropping an item.
|
||||||
#[derive(Event)]
|
#[derive(Event)]
|
||||||
pub struct InventoryChangedEvent {
|
pub struct InventoryChangedEvent {}
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
//pub mod loot_container;
|
//pub mod loot_container;
|
||||||
pub mod pickup_item;
|
|
||||||
pub mod inventory_changed;
|
pub mod inventory_changed;
|
||||||
|
pub mod pickup_item;
|
||||||
|
@ -10,6 +10,6 @@ use crate::comps::core::items::item::Item;
|
|||||||
pub struct PickupItemEvent {
|
pub struct PickupItemEvent {
|
||||||
/// Item entity
|
/// Item entity
|
||||||
pub entity: Entity,
|
pub entity: Entity,
|
||||||
pub item: Arc<dyn Item>,
|
pub item: Arc<dyn Item>,
|
||||||
pub player: Entity,
|
pub player: Entity,
|
||||||
}
|
}
|
||||||
|
@ -35,5 +35,4 @@ impl PlayerInventory {
|
|||||||
pub fn get_secondary(&self) -> &Option<Box<dyn Item>> {
|
pub fn get_secondary(&self) -> &Option<Box<dyn Item>> {
|
||||||
&self.secondary.item
|
&self.secondary.item
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,9 @@
|
|||||||
use bevy::prelude::*;
|
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;
|
pub struct InventoryPlugin;
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@ use crate::{
|
|||||||
grid::UGrid,
|
grid::UGrid,
|
||||||
markers::{firearm::FirearmData, holdable::HoldableObjectType, interactable::Interactable},
|
markers::{firearm::FirearmData, holdable::HoldableObjectType, interactable::Interactable},
|
||||||
},
|
},
|
||||||
|
logic::core::guns::firearm::Firearm,
|
||||||
setup::assets::{GltfAssetType, GltfAssets},
|
setup::assets::{GltfAssetType, GltfAssets},
|
||||||
utils, logic::core::guns::firearm::Firearm,
|
utils,
|
||||||
};
|
};
|
||||||
use bevy::{gltf::Gltf, prelude::*};
|
use bevy::{gltf::Gltf, prelude::*};
|
||||||
use bevy_rapier3d::prelude::*;
|
use bevy_rapier3d::prelude::*;
|
||||||
@ -105,7 +106,7 @@ pub trait Item: Sync + Send {
|
|||||||
ItemType::Holdable(holdable) => match holdable {
|
ItemType::Holdable(holdable) => match holdable {
|
||||||
HoldableObjectType::Firearm(firearm) => Some(firearm),
|
HoldableObjectType::Firearm(firearm) => Some(firearm),
|
||||||
},
|
},
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,13 @@ use bevy::prelude::*;
|
|||||||
use bevy_rapier3d::prelude::*;
|
use bevy_rapier3d::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
comps::core::{markers::{
|
comps::core::{
|
||||||
camera::MainCamera,
|
inventory::player_inventory::PlayerInventory,
|
||||||
player::{Player, PlayerData, PlayerHand},
|
markers::{
|
||||||
}, inventory::player_inventory::PlayerInventory},
|
camera::MainCamera,
|
||||||
|
player::{Player, PlayerData, PlayerHand},
|
||||||
|
},
|
||||||
|
},
|
||||||
logic::core::{
|
logic::core::{
|
||||||
guns::player_firing::PlayerFiringInfo,
|
guns::player_firing::PlayerFiringInfo,
|
||||||
player::{
|
player::{
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::comps::core::{markers::{
|
use crate::comps::core::{
|
||||||
firearm::{FirearmData, FirearmType, FiringPoint},
|
items::{
|
||||||
holdable::HoldableObjectData,
|
guns::{glock17::Glock17GunItem, m4a1::M4a1GunItem},
|
||||||
}, items::{item::Item, guns::{m4a1::M4a1GunItem, glock17::Glock17GunItem}}};
|
item::Item,
|
||||||
|
},
|
||||||
|
markers::{
|
||||||
|
firearm::{FirearmData, FirearmType, FiringPoint},
|
||||||
|
holdable::HoldableObjectData,
|
||||||
|
},
|
||||||
|
};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use super::{caliber::Caliber, spray_pattern::FirearmSprayPattern};
|
use super::{caliber::Caliber, spray_pattern::FirearmSprayPattern};
|
||||||
|
@ -2,13 +2,18 @@ use bevy::{ecs::system::SystemParam, prelude::*};
|
|||||||
use bevy_rapier3d::prelude::*;
|
use bevy_rapier3d::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
comps::core::{markers::{
|
comps::core::{
|
||||||
camera::MainCamera,
|
events::pickup_item::PickupItemEvent,
|
||||||
firearm::{FirearmData, MagazineData},
|
inventory::player_inventory::PlayerInventory,
|
||||||
holdable::{InPlayerHands, HoldableObjectType},
|
items::item::ItemType,
|
||||||
interactable::Interactable,
|
markers::{
|
||||||
player::{Player, PlayerHand},
|
camera::MainCamera,
|
||||||
}, events::pickup_item::PickupItemEvent, inventory::player_inventory::PlayerInventory, items::item::ItemType},
|
firearm::{FirearmData, MagazineData},
|
||||||
|
holdable::{HoldableObjectType, InPlayerHands},
|
||||||
|
interactable::Interactable,
|
||||||
|
player::{Player, PlayerHand},
|
||||||
|
},
|
||||||
|
},
|
||||||
logic::core::guns::{firearm::Firearm, player_firing::PlayerFiringInfo, shoot::shoot_bullet},
|
logic::core::guns::{firearm::Firearm, player_firing::PlayerFiringInfo, shoot::shoot_bullet},
|
||||||
setup::{
|
setup::{
|
||||||
animations::AllFirearmAnimations,
|
animations::AllFirearmAnimations,
|
||||||
@ -70,32 +75,34 @@ pub fn capture_hand_usage(
|
|||||||
if resources.keyboard_input.just_pressed(KeyCode::Key1) {
|
if resources.keyboard_input.just_pressed(KeyCode::Key1) {
|
||||||
if let Some(primary_item) = player_query.single().1.get_primary() {
|
if let Some(primary_item) = player_query.single().1.get_primary() {
|
||||||
if let Some(primary_firearm) = primary_item.get_firearm() {
|
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
|
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) {
|
} else if resources.keyboard_input.just_pressed(KeyCode::Key2) {
|
||||||
if let Some(secondary_item) = player_query.single().1.get_secondary() {
|
if let Some(secondary_item) = player_query.single().1.get_secondary() {
|
||||||
if let Some(secondary_firearm) = secondary_item.get_firearm() {
|
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
|
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) {
|
} 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));
|
equipment_change_event_writer.send(EquipmentChangeEvent(Equipment::Nothing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Firearm stuff
|
// 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() {
|
for mut player_firing_info in player_firing_info_query.iter_mut() {
|
||||||
player_firing_info
|
player_firing_info
|
||||||
.full_auto_timer
|
.full_auto_timer
|
||||||
@ -306,7 +313,11 @@ pub fn interact_action(
|
|||||||
.send(LootContainerEvent(any_inventory.clone()))
|
.send(LootContainerEvent(any_inventory.clone()))
|
||||||
}*/
|
}*/
|
||||||
Interactable::Item(item) => {
|
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(
|
pub fn update_player_inventory_system(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
@ -17,30 +25,55 @@ pub fn update_player_inventory_system(
|
|||||||
ItemType::Holdable(holdable_object) => {
|
ItemType::Holdable(holdable_object) => {
|
||||||
match holdable_object {
|
match holdable_object {
|
||||||
HoldableObjectType::Firearm(firearm) => {
|
HoldableObjectType::Firearm(firearm) => {
|
||||||
commands.entity(event.entity).despawn_descendants().despawn();
|
commands
|
||||||
|
.entity(event.entity)
|
||||||
|
.despawn_descendants()
|
||||||
|
.despawn();
|
||||||
match firearm.firearm_data().firearm_type {
|
match firearm.firearm_data().firearm_type {
|
||||||
FirearmType::Primary => {
|
FirearmType::Primary => {
|
||||||
// Send equipment_changed_event
|
// Send equipment_changed_event
|
||||||
if let Some(primary_item) = player_inventory.get_primary() {
|
if let Some(primary_item) = player_inventory.get_primary() {
|
||||||
// Drop this one
|
// 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);
|
primary_item.spawn(
|
||||||
player_inventory.primary.item = Some(firearm.get_item_box())
|
&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 {
|
} else {
|
||||||
player_inventory.primary.item = Some(firearm.get_item_box())
|
player_inventory.primary.item =
|
||||||
|
Some(firearm.get_item_box())
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
FirearmType::Secondary => {
|
FirearmType::Secondary => {
|
||||||
if let Some(secondary) = player_inventory.get_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);
|
secondary.spawn(
|
||||||
player_inventory.secondary.item = Some(firearm.get_item_box())
|
&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 {
|
} else {
|
||||||
player_inventory.secondary.item = Some(firearm.get_item_box())
|
player_inventory.secondary.item =
|
||||||
|
Some(firearm.get_item_box())
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
ItemType::Equippable => todo!(),
|
ItemType::Equippable => todo!(),
|
||||||
ItemType::Consumable => todo!(),
|
ItemType::Consumable => todo!(),
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
pub mod camera_effects;
|
pub mod camera_effects;
|
||||||
pub mod camera_player_sync;
|
pub mod camera_player_sync;
|
||||||
pub mod hands;
|
pub mod hands;
|
||||||
|
pub mod inventory;
|
||||||
pub mod player_movement;
|
pub mod player_movement;
|
||||||
pub mod player_values_state;
|
pub mod player_values_state;
|
||||||
pub mod player_vertical_sync;
|
pub mod player_vertical_sync;
|
||||||
pub mod inventory;
|
|
@ -3,7 +3,8 @@ use bevy::prelude::*;
|
|||||||
use crate::{
|
use crate::{
|
||||||
comps::core::{
|
comps::core::{
|
||||||
controller::capture_input,
|
controller::capture_input,
|
||||||
spawners::{player::player_spawner, spawn::SpawnerPlugin}, inventory::plugin::InventoryPlugin,
|
inventory::plugin::InventoryPlugin,
|
||||||
|
spawners::{player::player_spawner, spawn::SpawnerPlugin},
|
||||||
},
|
},
|
||||||
logic::core::{
|
logic::core::{
|
||||||
guns::despawn_shots::{despawn_muzzle_flashes, despawn_stray_bullets},
|
guns::despawn_shots::{despawn_muzzle_flashes, despawn_stray_bullets},
|
||||||
|
@ -82,22 +82,22 @@ pub fn spawn_obstacles(
|
|||||||
|
|
||||||
// CRATE
|
// CRATE
|
||||||
/*commands
|
/*commands
|
||||||
.spawn((
|
.spawn((
|
||||||
Collider::from_bevy_mesh(&box_5_mesh, &Default::default()).unwrap(),
|
Collider::from_bevy_mesh(&box_5_mesh, &Default::default()).unwrap(),
|
||||||
Name::new("Crate"),
|
Name::new("Crate"),
|
||||||
))
|
))
|
||||||
.insert(RigidBody::Fixed)
|
.insert(RigidBody::Fixed)
|
||||||
.insert(PbrBundle {
|
.insert(PbrBundle {
|
||||||
mesh: meshes.add(box_5_mesh.into()),
|
mesh: meshes.add(box_5_mesh.into()),
|
||||||
material: materials.add(StandardMaterial {
|
material: materials.add(StandardMaterial {
|
||||||
base_color: Color::BLUE,
|
base_color: Color::BLUE,
|
||||||
perceptual_roughness: 0.1,
|
perceptual_roughness: 0.1,
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
transform: Transform::from_xyz(20.0, 2.0, 20.0),
|
|
||||||
..default()
|
..default()
|
||||||
})
|
}),
|
||||||
/*.insert(Interactable::Lootable(AnyInventory::new(
|
transform: Transform::from_xyz(20.0, 2.0, 20.0),
|
||||||
UGrid::new_square(10),
|
..default()
|
||||||
)))*/;*/
|
})
|
||||||
|
/*.insert(Interactable::Lootable(AnyInventory::new(
|
||||||
|
UGrid::new_square(10),
|
||||||
|
)))*/;*/
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ use crate::{
|
|||||||
comps::core::markers::{
|
comps::core::markers::{
|
||||||
firearm::{FirearmData, MagazineData},
|
firearm::{FirearmData, MagazineData},
|
||||||
holdable::InPlayerHands,
|
holdable::InPlayerHands,
|
||||||
player::{Player, PlayerHand, PlayerData},
|
player::{Player, PlayerHand},
|
||||||
},
|
},
|
||||||
logic::core::guns::{firearm::Firearm, player_firing::PlayerFiringInfo},
|
logic::core::guns::{firearm::Firearm, player_firing::PlayerFiringInfo},
|
||||||
utils,
|
utils,
|
||||||
|
@ -6,8 +6,4 @@ use bevy::prelude::*;
|
|||||||
/// Should contain player inventory and if player is looting something as well
|
/// Should contain player inventory and if player is looting something as well
|
||||||
pub fn setup_inventory_screen(mut _commands: Commands) {}
|
pub fn setup_inventory_screen(mut _commands: Commands) {}
|
||||||
|
|
||||||
pub fn update_inventory_screen(
|
pub fn update_inventory_screen(mut _commands: Commands) {}
|
||||||
mut _commands: Commands,
|
|
||||||
) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user