Added resources to reflect derive macro

This commit is contained in:
Franklin Blanco 2023-11-08 12:29:07 -08:00
parent b5a2d76b58
commit ab230a95f1
9 changed files with 40 additions and 14 deletions

View File

@ -3,7 +3,6 @@ use bevy::prelude::*;
use super::{caliber::Caliber, spray_pattern::FirearmSprayPattern};
#[allow(unused)]
#[derive(Component, PartialEq, Eq, PartialOrd, Ord, Clone, Reflect)]
pub enum Firearm {
M4A1,

View File

@ -10,16 +10,17 @@ use super::{player_movement::PlayerLinearXZState, player_values_state::PlayerVal
/// Mouse sensitivity and movement speed
#[derive(Resource, Reflect)]
#[reflect(Resource)]
pub struct MouseMovementSettings {
pub sensitivity: f32,
pub speed: f32,
pub aimed_sensitivity: f32,
pub sensitivity: f64,
pub speed: f64,
pub aimed_sensitivity: f64,
}
impl Default for MouseMovementSettings {
fn default() -> Self {
Self {
sensitivity: 0.0003,
sensitivity: 0.0001,
speed: 3.0,
aimed_sensitivity: 0.00005,
}
@ -111,14 +112,14 @@ pub fn follow_cursor_with_camera(
for motion in motions.iter() {
let window_scale = window.height().min(window.width());
if btn.pressed(MouseButton::Right) {
pitch -= (settings.aimed_sensitivity * motion.delta.y * window_scale)
pitch -= ((settings.aimed_sensitivity * motion.delta.y as f64 * window_scale as f64) as f32)
.to_radians();
yaw -= (settings.aimed_sensitivity * motion.delta.x * window_scale)
yaw -= ((settings.aimed_sensitivity * motion.delta.x as f64 * window_scale as f64) as f32)
.to_radians();
} else {
pitch -=
(settings.sensitivity * motion.delta.y * window_scale).to_radians();
yaw -= (settings.sensitivity * motion.delta.x * window_scale).to_radians();
((settings.sensitivity * motion.delta.y as f64 * window_scale as f64) as f32).to_radians();
yaw -= ((settings.sensitivity * motion.delta.x as f64 * window_scale as f64) as f32).to_radians();
}
}
pitch = pitch.clamp(-1.54, 1.54);

View File

@ -13,7 +13,8 @@ use crate::comps::core::markers::camera::MainCamera;
pub const CUBEMAPS: &[(&str, CompressedImageFormats)] =
&[("skybox/skybox.png", CompressedImageFormats::NONE)];
#[derive(Resource, Reflect)]
#[derive(Resource, Reflect, Default)]
#[reflect(Resource)]
pub struct Cubemap {
pub is_loaded: bool,
pub image_handle: Handle<Image>,

View File

@ -5,6 +5,7 @@ use crate::logic::core::guns::firearm::Firearm;
use super::{assets::GltfAssets, load_state::GameLoadState};
#[derive(Resource, Default, Reflect)]
#[reflect(Resource)]
pub struct AllFirearmAnimations {
pub animations: Vec<FirearmAnimations>,
}

View File

@ -10,7 +10,8 @@ pub enum GltfAssetType {
#[allow(unused)]
Enemy,
}
#[derive(Resource, Reflect)]
#[derive(Resource, Reflect, Default)]
#[reflect(Resource)]
pub struct GltfAssets {
pub assets: Vec<GltfAsset>
}

View File

@ -1,6 +1,7 @@
use bevy::prelude::*;
#[derive(Resource, Default, Reflect)]
#[reflect(Resource)]
pub struct GameLoadState {
pub assets_loaded: bool,
pub animations_loaded: bool,

View File

@ -1,4 +1,5 @@
use bevy::{prelude::*, window::PrimaryWindow};
use bevy_editor_pls::controls::{self, EditorControls};
use bevy_inspector_egui::{egui, bevy_egui::EguiContext, bevy_inspector};
#[allow(unused)]
@ -16,3 +17,18 @@ pub fn inspector_ui(world: &mut World) {
});
});
}
pub fn editor_controls() -> EditorControls {
let mut editor_controls = EditorControls::default_bindings();
editor_controls.unbind(controls::Action::PlayPauseEditor);
editor_controls.insert(
controls::Action::PlayPauseEditor,
controls::Binding {
input: controls::UserInput::Single(controls::Button::Keyboard(KeyCode::Back)),
conditions: vec![controls::BindingCondition::ListeningForText(false)],
},
);
editor_controls
}

View File

@ -4,6 +4,8 @@ use bevy_inspector_egui::bevy_egui::EguiPlugin;
use crate::{logic::core::{guns::{player_firing::PlayerFiringInfo, caliber::Caliber, firearm::Firearm, spray_pattern::FirearmSprayPattern}, player::{player_values_state::PlayerValuesState, camera_player_sync::MouseMovementSettings, player_movement::{PlayerLinearYState, PlayerLinearXZState, PlayerMovementInput}}}, comps::core::markers::{firearm::{FirearmData, MagazineData}, holdable::{HoldableObjectData, InPlayerHands}, player::{PlayerData, Player, PlayerHand}}, scenes::scene1::skybox::Cubemap, setup::{animations::{AllFirearmAnimations, FirearmAnimations}, assets::{GltfAssetType, GltfAssets}, equipment::Equipment, load_state::GameLoadState}};
use super::inspector::editor_controls;
//use super::inspector::inspector_ui;
//use super::{panels::editor_ui, state::EditorUiState, camera::set_camera_viewport};
@ -37,7 +39,9 @@ impl Plugin for MainEditorUiPlugin {
.register_type::<Equipment>()
.register_type::<GameLoadState>()
.add_plugins(EguiPlugin)
.add_plugins(EditorPlugin::default());
.add_plugins(EditorPlugin::default())
.insert_resource(editor_controls());
//.add_plugins(ResourceInspectorPlugin::<MouseMovementSettings>::default());
//.add_plugins(bevy_inspector_egui::DefaultInspectorConfigPlugin) // adds default options and `InspectorEguiImpl`s
//.add_systems(Update, inspector_ui);
//app.insert_resource(EditorUiState::new());

View File

@ -1,6 +1,7 @@
use bevy::prelude::*;
#[derive(Resource)]
#[derive(Resource, Reflect)]
#[reflect(Resource)]
pub struct SettingsScreenUIConfiguration {
pub settings_menu_shown: bool,
}
@ -11,7 +12,8 @@ impl Default for SettingsScreenUIConfiguration {
}
}
#[derive(Resource)]
#[derive(Resource, Reflect)]
#[reflect(Resource)]
pub struct GameConfiguration {
pub fps_counter_enabled: bool,