diff --git a/src/comps/core/markers/bullet.rs b/src/comps/core/markers/bullet.rs index 0c27da8..848e86a 100644 --- a/src/comps/core/markers/bullet.rs +++ b/src/comps/core/markers/bullet.rs @@ -1,7 +1,6 @@ use bevy::{ prelude::{Component, Vec3}, - reflect::Reflect, - time::Timer, ecs::{reflect::ReflectComponent, entity::Entity}, + reflect::Reflect, ecs::{reflect::ReflectComponent, entity::Entity}, }; use crate::comps::core::weapons::caliber::Caliber; @@ -17,7 +16,6 @@ pub struct BulletHit { pub struct BulletMarker { pub caliber: Caliber, pub starting_point: Vec3, - pub timer: Timer, pub current_velocity: Vec3, pub hits: Vec, } diff --git a/src/comps/core/weapons/caliber.rs b/src/comps/core/weapons/caliber.rs index f1fa7b2..734e506 100644 --- a/src/comps/core/weapons/caliber.rs +++ b/src/comps/core/weapons/caliber.rs @@ -1,82 +1,80 @@ use bevy::reflect::Reflect; +/// Unit = m/s +pub const MIN_LETHAL_BULLET_VELOCITY: f32 = 60.0; + #[allow(unused)] #[derive(Clone, Reflect, Default)] pub enum Caliber { /// 5.56x45mm NATO556, - /// 9x19mm + /// 9x19mm Parabellum (NATO) + /// Reference: [Wikipedia](https://en.wikipedia.org/wiki/9%C3%9719mm_Parabellum) #[default] - Parabellum9mm, + NATOParabellum9mm, /// 5.45x39mm (7N6M) /// Reference: [Wikipedia](https://en.wikipedia.org/wiki/5.45%C3%9739mm) RU545 } impl Caliber { + /// Unit = Meters + /// Not real for the moment as this is just to make sure the bullet despawns if it goes too far pub fn range(&self) -> f32 { match self { Caliber::NATO556 => 7500.0, - Caliber::Parabellum9mm => 2500.0, + Caliber::NATOParabellum9mm => 2500.0, Caliber::RU545 => 4500.0, } } - pub fn max_airtime_secs(&self) -> f32 { - match self { - Caliber::NATO556 => 3.0, - Caliber::Parabellum9mm => 3.0, - Caliber::RU545 => 3.0, - } - } - pub fn impulse(&self) -> f32 { - match self { - Caliber::NATO556 => 100.0, - Caliber::Parabellum9mm => 50.0, - Caliber::RU545 => 75.0, - } - } + /// Unit = kg + /// Real life value (BULLET WEIGHT) pub fn mass(&self) -> f32 { match self { Caliber::NATO556 => 0.00402, - Caliber::Parabellum9mm => 0.05, + Caliber::NATOParabellum9mm => 0.0052, Caliber::RU545 => 0.00343, } } pub fn linear_damping(&self) -> f32 { match self { Caliber::NATO556 => 1.0, - Caliber::Parabellum9mm => 2.0, + Caliber::NATOParabellum9mm => 2.0, Caliber::RU545 => 1.5, } } pub fn angular_damping(&self) -> f32 { match self { Caliber::NATO556 => 1.0, - Caliber::Parabellum9mm => 1.0, + Caliber::NATOParabellum9mm => 1.0, Caliber::RU545 => 1.0, } } pub fn size(&self) -> f32 { match self { Caliber::NATO556 => 0.07, - Caliber::Parabellum9mm => 0.05, + Caliber::NATOParabellum9mm => 0.05, Caliber::RU545 => 0.06 } } + /// Unit = m/s + /// Real life value pub fn muzzle_velocity(&self) -> f32 { match self { Caliber::NATO556 => 991.0, - Caliber::Parabellum9mm => todo!(), + Caliber::NATOParabellum9mm => 460.0, Caliber::RU545 => 880.0, } } + /// Unit = m/s + /// Can't find accurate information for real bullets, so invented these values based on how good the wiki says they are long range. pub fn velocity_shed(&self) -> f32 { match self { - Caliber::NATO556 => todo!(), - Caliber::Parabellum9mm => todo!(), - Caliber::RU545 => 120.0, + Caliber::NATO556 => 150.0, + Caliber::NATOParabellum9mm => 450.0, + Caliber::RU545 => 300.0, } } } diff --git a/src/comps/core/weapons/firearm.rs b/src/comps/core/weapons/firearm.rs index c446137..a7231bf 100644 --- a/src/comps/core/weapons/firearm.rs +++ b/src/comps/core/weapons/firearm.rs @@ -62,7 +62,7 @@ impl Firearm { }*/ Firearm::Glock17 => { FirearmData { - caliber: Caliber::Parabellum9mm, + caliber: Caliber::NATOParabellum9mm, fire_rate: 600.0, aim_time_seconds: 0.1, rebound_time_seconds: 0.5, diff --git a/src/logic/core/guns/despawn_shots.rs b/src/logic/core/guns/despawn_shots.rs index c28474a..384128a 100644 --- a/src/logic/core/guns/despawn_shots.rs +++ b/src/logic/core/guns/despawn_shots.rs @@ -1,4 +1,4 @@ -use crate::comps::core::{markers::{bullet::BulletMarker, muzzle_flash::MuzzleFlashMarker}, events::{bullet_collision::BulletCollisionEvent, collision_event_type::CollisionEventType}}; +use crate::comps::core::{markers::muzzle_flash::MuzzleFlashMarker, events::{bullet_collision::BulletCollisionEvent, collision_event_type::CollisionEventType}}; use bevy::prelude::*; pub fn despawn_muzzle_flashes( @@ -18,18 +18,13 @@ pub fn despawn_stray_bullets( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, - mut query: Query<(&mut BulletMarker, Entity, &Transform)>, mut bullet_collisions: EventReader, - time: Res