diff --git a/assets/attachments/aimpoint_t1.glb b/assets/attachments/aimpoint_t1.glb index 4e8d0b4..d03deff 100644 Binary files a/assets/attachments/aimpoint_t1.glb and b/assets/attachments/aimpoint_t1.glb differ diff --git a/src/comps/core/markers/proxy/character/player_eye.rs b/src/comps/core/markers/proxy/character/player_eye.rs index 83f8cb3..a707869 100644 --- a/src/comps/core/markers/proxy/character/player_eye.rs +++ b/src/comps/core/markers/proxy/character/player_eye.rs @@ -1,4 +1,4 @@ -use bevy::prelude::*; +use bevy::{prelude::*, core_pipeline::{tonemapping::Tonemapping, bloom::{BloomSettings, BloomCompositeMode}}}; use bevy_rapier3d::prelude::*; use crate::{comps::core::markers::{proxy::physics::rapier::LinkToPlayer, camera::MainCamera}, logic::core::player::player_values_state::PlayerValuesState}; @@ -24,6 +24,14 @@ pub fn insert_components_into_spawned_player( .spawn(MainCamera) .insert(Camera3dBundle { transform: Transform::from_xyz(0.0, 0.0, 0.0), + camera: Camera { + hdr: true, + ..Default::default() + }, + tonemapping: Tonemapping::TonyMcMapface, + ..Default::default() + }) + .insert(BloomSettings { ..Default::default() }) //s.insert(Skybox(skybox_handle.clone())) diff --git a/src/comps/core/weapons/attachments/optic.rs b/src/comps/core/weapons/attachments/optic.rs index e652c88..201c738 100644 --- a/src/comps/core/weapons/attachments/optic.rs +++ b/src/comps/core/weapons/attachments/optic.rs @@ -1,7 +1,7 @@ use bevy::{reflect::{Reflect, std_traits::ReflectDefault}, ecs::{component::Component, reflect::ReflectComponent}, math::Vec3, pbr::StandardMaterial, render::color::Color}; use bevy_inspector_egui::egui::Rgba; -use crate::comps::core::weapons::optic_data::OpticData; +use crate::comps::core::weapons::{optic_data::OpticData, reticle::SightReticle}; use super::attachment::Attachment; @@ -24,6 +24,12 @@ impl Optic { 1.0 } + pub fn reticle(&self) -> SightReticle { + match self { + Optic::AimpointT1 => SightReticle::Dot(0.1, Color::rgb_linear(100.0, 0.0, 0.0)), + } + } + pub fn optic_data(&self) -> OpticData { OpticData { optic_pos_y: None, reticle_brightness: self.default_reticle_brightness() } } diff --git a/src/comps/core/weapons/mod.rs b/src/comps/core/weapons/mod.rs index c8e76f3..4b59522 100644 --- a/src/comps/core/weapons/mod.rs +++ b/src/comps/core/weapons/mod.rs @@ -8,4 +8,5 @@ pub mod slot; pub mod parts; pub mod firearm_state; pub mod attachment_slot; -pub mod optic_data; \ No newline at end of file +pub mod optic_data; +pub mod reticle; \ No newline at end of file diff --git a/src/comps/core/weapons/reticle.rs b/src/comps/core/weapons/reticle.rs new file mode 100644 index 0000000..751eba1 --- /dev/null +++ b/src/comps/core/weapons/reticle.rs @@ -0,0 +1,37 @@ +use bevy::{prelude::*, sprite::MaterialMesh2dBundle}; + +#[derive(Reflect, PartialEq, Clone, Debug)] +pub enum SightReticle { + /// Reticle Radius & Reticle Color + Dot(f32, Color), +} + +impl Default for SightReticle { + fn default() -> Self { + Self::Dot(0.05, Color::rgb_linear(100.0, 0.0, 0.0)) + } +} + +impl SightReticle { + pub fn spawn(self, commands: &mut Commands, parent: Entity, meshes: &mut ResMut>, materials: &mut ResMut>) { + match self { + SightReticle::Dot(radius, color) => { + commands.spawn( + MaterialMeshBundle { + mesh: meshes.add(shape::Circle::new(radius).into()).into(), + material: materials.add(StandardMaterial { + emissive: color, + ..Default::default() + }), + transform: { + let mut t = Transform::from_translation(Vec3::ZERO); + t.rotate_x(90.0f32.to_radians()); + t + }, + ..default() + } + ).set_parent(parent); + }, + } + } +} \ No newline at end of file diff --git a/src/logic/core/guns/mod.rs b/src/logic/core/guns/mod.rs index 40b27fb..9eeb298 100644 --- a/src/logic/core/guns/mod.rs +++ b/src/logic/core/guns/mod.rs @@ -3,4 +3,5 @@ pub mod player_firing; pub mod shoot; pub mod inspect; pub mod equipped_gun_collisions; -pub mod update_bullet; \ No newline at end of file +pub mod update_bullet; +pub mod reticle; \ No newline at end of file diff --git a/src/logic/core/guns/reticle.rs b/src/logic/core/guns/reticle.rs new file mode 100644 index 0000000..d37c0c4 --- /dev/null +++ b/src/logic/core/guns/reticle.rs @@ -0,0 +1,20 @@ +use bevy::prelude::*; + +use crate::comps::core::markers::proxy::weapons::optic_sight_glass::OpticSightGlass; + +/// How? +/// Achieve parallax on all reticles by drawing a line straight out of the barrel and a straight line from the sight that intersected at the specified zeroed range for the optic. +/// Make sure that the reticle is where the bullets will land at the specified zeroed range. +pub fn update_reticle( + mut commands: Commands, + // TODO: make this identify which optic is on the gun, but meanwhile just start doing it to all the optics in + sight_query: Query<(Entity, &OpticSightGlass), Added>, + mut meshes: ResMut>, + mut materials: ResMut>, +) { + for (entity, sight) in sight_query.iter() { + let reticle = sight.0.reticle(); + reticle.spawn(&mut commands, entity, &mut meshes, &mut materials); + println!("Added reticle"); + } +} \ No newline at end of file diff --git a/src/scenes/scene1/init.rs b/src/scenes/scene1/init.rs index 6617de8..b167898 100644 --- a/src/scenes/scene1/init.rs +++ b/src/scenes/scene1/init.rs @@ -7,7 +7,7 @@ use crate::{ spawners::{player::player_spawner, spawn::SpawnerPlugin}, events::{bullet_collision::BulletCollisionEvent, equipped_gun_collision::EquippedGunCollisionEvent}, }, logic::core::{ - guns::{despawn_shots::{despawn_muzzle_flashes, despawn_stray_bullets}, inspect::inspect_firearm, equipped_gun_collisions::update_gun_position_on_collision, update_bullet::update_bullet}, + guns::{despawn_shots::{despawn_muzzle_flashes, despawn_stray_bullets}, inspect::inspect_firearm, equipped_gun_collisions::update_gun_position_on_collision, update_bullet::update_bullet, reticle::update_reticle}, player::{ camera_player_sync::{ follow_cursor_with_camera, update_camera_vertical_position, MouseMovementSettings, @@ -63,6 +63,7 @@ pub fn load_scene(application: &mut App) { application.add_systems(Update, collision_handler); application.add_systems(Update, update_gun_position_on_collision); application.add_systems(Update, update_bullet); + application.add_systems(Update, update_reticle); //application.add_systems(Update, animate_player); //application.add_systems(Update, register_bullet_hits); diff --git a/src/ui/editor/plugin.rs b/src/ui/editor/plugin.rs index a754ed4..82826ee 100644 --- a/src/ui/editor/plugin.rs +++ b/src/ui/editor/plugin.rs @@ -6,7 +6,7 @@ use crate::{ comps::core::{markers::{ holdable::{HoldableObjectData, InPlayerHands}, player::{Player, PlayerData, PlayerHand}, inspect_screen::InspectScreenSlotUiMarker, bullet::BulletMarker, - }, weapons::{firearm_data::FirearmData, magazine_data::MagazineData, caliber::Caliber, firearm::Firearm, spray_pattern::FirearmSprayPattern, firearm_state::FirearmState}}, + }, weapons::{firearm_data::FirearmData, magazine_data::MagazineData, caliber::Caliber, firearm::Firearm, spray_pattern::FirearmSprayPattern, firearm_state::FirearmState, reticle::SightReticle}}, logic::core::{ guns::player_firing::PlayerFiringInfo, player::{ @@ -57,6 +57,7 @@ impl Plugin for MainEditorUiPlugin { .register_type::() .register_type::() .register_type::() + .register_type::() //.register_type::() //.register_type::() .register_type::()