Fixed player spawning without firearm bug
This commit is contained in:
parent
ab230a95f1
commit
65c555aa03
|
@ -18,7 +18,7 @@ pub fn shoot_bullet(
|
||||||
//252, 238, 128
|
//252, 238, 128
|
||||||
color: Color::Rgba { red: 252., green: 238., blue: 128., alpha: 0.5 },
|
color: Color::Rgba { red: 252., green: 238., blue: 128., alpha: 0.5 },
|
||||||
intensity: 0.005,
|
intensity: 0.005,
|
||||||
range: 30.0,
|
range: 50.0,
|
||||||
shadows_enabled: true,
|
shadows_enabled: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl Default for PlayerValuesState {
|
||||||
Self {
|
Self {
|
||||||
max_linear_player_velocity: 20.0,
|
max_linear_player_velocity: 20.0,
|
||||||
player_acceleration: 20.0,
|
player_acceleration: 20.0,
|
||||||
player_jump_force: 900.0,
|
player_jump_force: 1000.0,
|
||||||
player_jump_cooldown_s: 0.075,
|
player_jump_cooldown_s: 0.075,
|
||||||
player_sprint_speed_multiplier: 3.5,
|
player_sprint_speed_multiplier: 3.5,
|
||||||
player_crouch_speed_multiplier: 0.25,
|
player_crouch_speed_multiplier: 0.25,
|
||||||
|
@ -47,7 +47,7 @@ impl Default for PlayerValuesState {
|
||||||
player_crouch_height: 0.0,
|
player_crouch_height: 0.0,
|
||||||
player_crouch_time_s: 1.25,
|
player_crouch_time_s: 1.25,
|
||||||
player_linear_damping: 3.5,
|
player_linear_damping: 3.5,
|
||||||
player_linear_damping_while_jumping: 0.25,
|
player_linear_damping_while_jumping: 0.8,
|
||||||
player_lean_time: 0.3,
|
player_lean_time: 0.3,
|
||||||
player_lean_angle: 30.0,
|
player_lean_angle: 30.0,
|
||||||
player_lateral_acceleration_while_sprinting_multiplier: 0.2,
|
player_lateral_acceleration_while_sprinting_multiplier: 0.2,
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
hands::capture_hand_usage,
|
hands::capture_hand_usage,
|
||||||
player_vertical_sync::sync_player_y_state, player_values_state::PlayerValuesState,
|
player_vertical_sync::sync_player_y_state, player_values_state::PlayerValuesState,
|
||||||
}, guns::despawn_shots::despawn_muzzle_flashes}, setup::{assets::load_all_assets, load_state::GameLoadState, spawn::add_all_spawners, animations::{load_animations, AllFirearmAnimations}, equipment::{EquipmentChangeEvent, change_equipment}},
|
}, guns::despawn_shots::despawn_muzzle_flashes}, setup::{assets::load_all_assets, load_state::GameLoadState, spawn::add_all_spawners, animations::{load_animations, AllFirearmAnimations}, equipment::{EquipmentChangeEvent, change_equipment}, spawners::player::player_spawner},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -38,7 +38,7 @@ pub fn load_scene(application: &mut App) {
|
||||||
application.add_systems(Update, update_camera_vertical_position);
|
application.add_systems(Update, update_camera_vertical_position);
|
||||||
application.add_systems(Update, capture_hand_usage);
|
application.add_systems(Update, capture_hand_usage);
|
||||||
|
|
||||||
application.add_systems(Update, change_equipment);
|
application.add_systems(Update, change_equipment.before(player_spawner));
|
||||||
application.add_systems(Update, despawn_muzzle_flashes);
|
application.add_systems(Update, despawn_muzzle_flashes);
|
||||||
|
|
||||||
application.add_event::<EquipmentChangeEvent>();
|
application.add_event::<EquipmentChangeEvent>();
|
||||||
|
|
|
@ -41,6 +41,7 @@ pub fn change_equipment(
|
||||||
|
|
||||||
// Set the player's equipment to the newly spawned equipment
|
// Set the player's equipment to the newly spawned equipment
|
||||||
player.0.equipment.primary_firearm = equipment_change_event.0.primary_firearm.clone();
|
player.0.equipment.primary_firearm = equipment_change_event.0.primary_firearm.clone();
|
||||||
|
println!("Equipment change done");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use super::spawners::{player::player_spawner, firearm::firearm_spawner};
|
use super::{spawners::{player::player_spawner, firearm::firearm_spawner}, equipment::change_equipment};
|
||||||
|
|
||||||
/// Where some Bundle T will replace this.
|
/// Where some Bundle T will replace this.
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Reflect)]
|
||||||
|
@ -10,5 +10,5 @@ pub struct SpawnPoint<T: Bundle> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_all_spawners(application: &mut App) {
|
pub fn add_all_spawners(application: &mut App) {
|
||||||
application.add_systems(Update, (player_spawner, firearm_spawner));
|
application.add_systems(Update, (player_spawner, firearm_spawner).after(change_equipment));
|
||||||
}
|
}
|
|
@ -22,6 +22,7 @@ pub fn editor_controls() -> EditorControls {
|
||||||
let mut editor_controls = EditorControls::default_bindings();
|
let mut editor_controls = EditorControls::default_bindings();
|
||||||
editor_controls.unbind(controls::Action::PlayPauseEditor);
|
editor_controls.unbind(controls::Action::PlayPauseEditor);
|
||||||
|
|
||||||
|
|
||||||
editor_controls.insert(
|
editor_controls.insert(
|
||||||
controls::Action::PlayPauseEditor,
|
controls::Action::PlayPauseEditor,
|
||||||
controls::Binding {
|
controls::Binding {
|
||||||
|
@ -32,3 +33,14 @@ pub fn editor_controls() -> EditorControls {
|
||||||
|
|
||||||
editor_controls
|
editor_controls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_cam3d_controls(
|
||||||
|
mut query: Query<&mut bevy_editor_pls::default_windows::cameras::camera_3d_free::FlycamControls>,
|
||||||
|
) {
|
||||||
|
let mut controls = query.single_mut();
|
||||||
|
controls.key_forward = KeyCode::Up;
|
||||||
|
controls.key_back = KeyCode::Down;
|
||||||
|
controls.key_left = KeyCode::Left;
|
||||||
|
controls.key_right = KeyCode::Right;
|
||||||
|
controls.key_up = KeyCode::U;
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ 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 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::{editor_controls, set_cam3d_controls};
|
||||||
|
|
||||||
//use super::inspector::inspector_ui;
|
//use super::inspector::inspector_ui;
|
||||||
|
|
||||||
|
@ -40,7 +40,8 @@ impl Plugin for MainEditorUiPlugin {
|
||||||
.register_type::<GameLoadState>()
|
.register_type::<GameLoadState>()
|
||||||
.add_plugins(EguiPlugin)
|
.add_plugins(EguiPlugin)
|
||||||
.add_plugins(EditorPlugin::default())
|
.add_plugins(EditorPlugin::default())
|
||||||
.insert_resource(editor_controls());
|
.insert_resource(editor_controls())
|
||||||
|
.add_systems(Startup, set_cam3d_controls);
|
||||||
//.add_plugins(ResourceInspectorPlugin::<MouseMovementSettings>::default());
|
//.add_plugins(ResourceInspectorPlugin::<MouseMovementSettings>::default());
|
||||||
//.add_plugins(bevy_inspector_egui::DefaultInspectorConfigPlugin) // adds default options and `InspectorEguiImpl`s
|
//.add_plugins(bevy_inspector_egui::DefaultInspectorConfigPlugin) // adds default options and `InspectorEguiImpl`s
|
||||||
//.add_systems(Update, inspector_ui);
|
//.add_systems(Update, inspector_ui);
|
||||||
|
|
Loading…
Reference in New Issue