Moving pcs
This commit is contained in:
parent
d1a1589bf6
commit
785bd89b6b
|
@ -0,0 +1,16 @@
|
||||||
|
## Game design
|
||||||
|
|
||||||
|
4-6 guns, with 1 magazine per gun.
|
||||||
|
Optics can be left out
|
||||||
|
Can only be found in the world
|
||||||
|
Always have a starting pistol available
|
||||||
|
Inventory system + Looting system
|
||||||
|
Boxes all around the map with guns, equipment, ammo.
|
||||||
|
|
||||||
|
A mix between a battle royale and an extraction looter shooter:
|
||||||
|
All players spawn like an extraction looter shooter, to get out they have to extract,
|
||||||
|
but the map contains loot like a battle royale.
|
||||||
|
|
||||||
|
Make sure guns are usable with iron sights.
|
||||||
|
|
||||||
|
Multiplayer
|
Binary file not shown.
|
@ -16,6 +16,8 @@ pub struct FirearmData<'a> {
|
||||||
pub rebound_time_seconds: f32,
|
pub rebound_time_seconds: f32,
|
||||||
pub asset_path: &'a str,
|
pub asset_path: &'a str,
|
||||||
|
|
||||||
|
pub identifier: String,
|
||||||
|
|
||||||
pub vertical_recoil_modifier: f32,
|
pub vertical_recoil_modifier: f32,
|
||||||
pub horizontal_recoil_modifier: f32,
|
pub horizontal_recoil_modifier: f32,
|
||||||
pub recoil_pattern: FirearmSprayPattern,
|
pub recoil_pattern: FirearmSprayPattern,
|
||||||
|
|
|
@ -27,10 +27,3 @@ pub const PLAYER_LATERAL_ACCELERATION_MULTIPLIER: f32 = 1.0;
|
||||||
pub const PLAYER_LINEAR_DAMPING_TIME_OFFSET_AFTER_JUMP_IN_MS: u128 = 20;
|
pub const PLAYER_LINEAR_DAMPING_TIME_OFFSET_AFTER_JUMP_IN_MS: u128 = 20;
|
||||||
|
|
||||||
pub const DEFAULT_PLAYER_FIREARM: Firearm = Firearm::M4A1;
|
pub const DEFAULT_PLAYER_FIREARM: Firearm = Firearm::M4A1;
|
||||||
|
|
||||||
/*
|
|
||||||
pub const PLAYER_CAMERA_HEADBOB_Y_POS: f32 = 0.2;
|
|
||||||
pub const PLAYER_CAMERA_HEADBOB_Y_NEG: f32 = -0.2;
|
|
||||||
pub const PLAYER_CAMERA_HEADBOB_X_POS: f32 = 0.2;
|
|
||||||
pub const PLAYER_CAMERA_HEADBOB_X_NEG: f32 = -0.2;
|
|
||||||
*/
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ impl Firearm {
|
||||||
y: -0.45,
|
y: -0.45,
|
||||||
z: -2.7,
|
z: -2.7,
|
||||||
},
|
},
|
||||||
|
identifier: String::from("m4a1_rifle"),
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,3 +3,4 @@ pub mod firearm;
|
||||||
pub mod player_firing;
|
pub mod player_firing;
|
||||||
pub mod spawn_firearm;
|
pub mod spawn_firearm;
|
||||||
pub mod spray_pattern;
|
pub mod spray_pattern;
|
||||||
|
pub mod equip_firearm;
|
|
@ -1,50 +1,61 @@
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::{prelude::*, gltf::Gltf};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
comps::core::markers::{holdable::InPlayerHands, player::PlayerHand, firearm::MagazineData},
|
comps::core::markers::{holdable::InPlayerHands, player::PlayerHand, firearm::{MagazineData, FirearmData}},
|
||||||
constants::player_values::DEFAULT_PLAYER_FIREARM,
|
constants::player_values::DEFAULT_PLAYER_FIREARM,
|
||||||
utils, setup::animations::FirearmAnimations,
|
utils, setup::{animations::FirearmAnimations, gltf_assets::GltfAssets},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::player_firing::PlayerFiringInfo;
|
use super::{player_firing::PlayerFiringInfo, firearm::Firearm};
|
||||||
|
|
||||||
pub fn spawn_firearm_on_player_hands(
|
pub fn spawn_firearm_on_player_hands(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
query: Query<Entity, With<PlayerHand>>,
|
query: Query<Entity, With<PlayerHand>>,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
mut player_firing_info: ResMut<PlayerFiringInfo>,
|
mut player_firing_info: ResMut<PlayerFiringInfo>,
|
||||||
|
assets_gltf: Res<GltfAssets>,
|
||||||
|
loaded_gltf_assets: Res<Assets<Gltf>>,
|
||||||
) {
|
) {
|
||||||
for entity in query.iter() {
|
if let Some(asset_handle) = assets_gltf.assets.iter().find(|asset| asset.id == Firearm::M4A1.firearm_data().identifier) {
|
||||||
let mut firearm_transform = Transform::from_xyz(0.0, 0.0, 0.0);
|
if let Some(gltf) = loaded_gltf_assets.get(&asset_handle.asset) {
|
||||||
firearm_transform.rotate_y(utils::rad_deg::radians_from_degrees(
|
println!("C");
|
||||||
DEFAULT_PLAYER_FIREARM.holdable_object_data().y_rot,
|
for entity in query.iter() {
|
||||||
));
|
let mut firearm_transform = Transform::from_xyz(0.0, 0.0, 0.0);
|
||||||
|
firearm_transform.rotate_y(utils::rad_deg::radians_from_degrees(
|
||||||
|
DEFAULT_PLAYER_FIREARM.holdable_object_data().y_rot,
|
||||||
|
));
|
||||||
|
|
||||||
let firearm = commands
|
let scene = gltf.scenes[0].clone();
|
||||||
.spawn((
|
|
||||||
SceneBundle {
|
|
||||||
scene: asset_server.load(format!("{}#Scene0", DEFAULT_PLAYER_FIREARM.firearm_data().asset_path)),
|
|
||||||
visibility: Visibility::Inherited,
|
|
||||||
transform: firearm_transform,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
DEFAULT_PLAYER_FIREARM.firearm_data(),
|
|
||||||
DEFAULT_PLAYER_FIREARM.holdable_object_data(),
|
|
||||||
MagazineData { rounds_shot: 0, max_capacity: DEFAULT_PLAYER_FIREARM.firearm_data().max_capacity },
|
|
||||||
InPlayerHands,
|
|
||||||
))
|
|
||||||
.id();
|
|
||||||
|
|
||||||
commands.entity(entity).push_children(&[firearm]);
|
let firearm = commands
|
||||||
let time_in_secs_between_each_round =
|
.spawn((
|
||||||
1.0 / DEFAULT_PLAYER_FIREARM.firearm_data().fire_rate * 60.0;
|
SceneBundle {
|
||||||
player_firing_info.full_auto_timer = Timer::new(
|
scene,
|
||||||
Duration::from_secs_f32(time_in_secs_between_each_round),
|
visibility: Visibility::Inherited,
|
||||||
TimerMode::Once,
|
transform: firearm_transform,
|
||||||
);
|
..default()
|
||||||
// Load animations
|
},
|
||||||
commands.insert_resource(FirearmAnimations { reload_magazine: asset_server.load(format!("{}#Animation0", DEFAULT_PLAYER_FIREARM.firearm_data().asset_path))})
|
DEFAULT_PLAYER_FIREARM.firearm_data(),
|
||||||
|
FirearmAnimations { reload_magazine: todo!() },
|
||||||
|
DEFAULT_PLAYER_FIREARM.holdable_object_data(),
|
||||||
|
MagazineData { rounds_shot: 0, max_capacity: DEFAULT_PLAYER_FIREARM.firearm_data().max_capacity },
|
||||||
|
InPlayerHands,
|
||||||
|
|
||||||
|
))
|
||||||
|
.id();
|
||||||
|
|
||||||
|
commands.entity(entity).push_children(&[firearm]);
|
||||||
|
let time_in_secs_between_each_round =
|
||||||
|
1.0 / DEFAULT_PLAYER_FIREARM.firearm_data().fire_rate * 60.0;
|
||||||
|
player_firing_info.full_auto_timer = Timer::new(
|
||||||
|
Duration::from_secs_f32(time_in_secs_between_each_round),
|
||||||
|
TimerMode::Once,
|
||||||
|
);
|
||||||
|
// Load animations
|
||||||
|
commands.insert_resource(FirearmAnimations { reload_magazine: asset_server.load(format!("{}#Animation0", DEFAULT_PLAYER_FIREARM.firearm_data().asset_path))})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
use bevy::{prelude::*, gltf::Gltf};
|
||||||
|
|
||||||
|
// Once the scene is loaded, start the animation
|
||||||
|
pub fn setup_scene_once_loaded(
|
||||||
|
gltf_assets: Res<Assets<Gltf>>,
|
||||||
|
asset_server: Res<AssetServer>,
|
||||||
|
) {
|
||||||
|
for asset in gltf_assets.iter() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ use crate::{
|
||||||
player_vertical_sync::sync_player_y_state,
|
player_vertical_sync::sync_player_y_state,
|
||||||
spawn_player::spawn_player,
|
spawn_player::spawn_player,
|
||||||
},
|
},
|
||||||
},
|
}, setup::{gltf_assets::load_all_assets, load_state::GameLoadState},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -21,17 +21,20 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn load_scene(application: &mut App) {
|
pub fn load_scene(application: &mut App) {
|
||||||
|
application.insert_resource(GameLoadState::default());
|
||||||
application.insert_resource(MouseMovementSettings::default());
|
application.insert_resource(MouseMovementSettings::default());
|
||||||
application.insert_resource(PlayerFiringInfo::default());
|
application.insert_resource(PlayerFiringInfo::default());
|
||||||
// Startup
|
// Startup
|
||||||
|
application.add_systems(PreStartup, load_all_assets);
|
||||||
application.add_systems(Startup, spawn_ground);
|
application.add_systems(Startup, spawn_ground);
|
||||||
application.add_systems(Startup, spawn_obstacles);
|
application.add_systems(Startup, spawn_obstacles);
|
||||||
application.add_systems(Startup, spawn_player);
|
application.add_systems(Startup, spawn_player.after(load_all_assets));
|
||||||
|
application.add_systems(Startup, setup_lighting);
|
||||||
|
|
||||||
application.add_systems(
|
application.add_systems(
|
||||||
PostStartup,
|
PostStartup,
|
||||||
spawn_firearm_on_player_hands.after(spawn_player),
|
spawn_firearm_on_player_hands,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
|
|
||||||
application.add_systems(Update, capture_input);
|
application.add_systems(Update, capture_input);
|
||||||
|
@ -41,6 +44,4 @@ pub fn load_scene(application: &mut App) {
|
||||||
application.add_systems(Update, asset_loaded);
|
application.add_systems(Update, asset_loaded);
|
||||||
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(Startup, setup_lighting);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,30 @@
|
||||||
// use bevy::prelude::*;
|
use bevy::{prelude::*, gltf::Gltf};
|
||||||
|
|
||||||
// use bevy::gltf::Gltf;
|
use crate::logic::core::guns::firearm::Firearm;
|
||||||
|
|
||||||
// #[derive(Resource)]
|
use super::load_state::GameLoadState;
|
||||||
// pub struct LoadedAssetMap(Handle<Gltf>);
|
|
||||||
|
|
||||||
// /// Loads gltf asset into AssetServer. Inserts Resource as a LoadedAsset
|
#[derive(Resource)]
|
||||||
// pub fn load_gltf(mut commands: Commands, ass: Res<AssetServer>) {
|
pub struct GltfAssets {
|
||||||
// let gltf = ass.load("my_asset_pack.glb");
|
pub assets: Vec<GltfAsset>
|
||||||
// commands.insert_resource(LoadedAsset(gltf));
|
}
|
||||||
// }
|
pub struct GltfAsset {
|
||||||
|
pub id: String,
|
||||||
|
pub asset: Handle<Gltf>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn load_all_assets(
|
||||||
|
mut commands: Commands,
|
||||||
|
asset_server: Res<AssetServer>,
|
||||||
|
mut game_load_state: ResMut<GameLoadState>,
|
||||||
|
) {
|
||||||
|
let m4a1_gltf_asset = GltfAsset { id: Firearm::M4A1.firearm_data().identifier, asset: asset_server.load(Firearm::M4A1.firearm_data().asset_path) } ;
|
||||||
|
|
||||||
|
commands.insert_resource(GltfAssets {
|
||||||
|
assets: Vec::from([
|
||||||
|
m4a1_gltf_asset
|
||||||
|
])
|
||||||
|
});
|
||||||
|
game_load_state.assets_loaded = true;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Resource, Default)]
|
||||||
|
pub struct GameLoadState {
|
||||||
|
pub assets_loaded: bool,
|
||||||
|
pub animations_loaded: bool,
|
||||||
|
}
|
|
@ -1,2 +1,3 @@
|
||||||
pub mod gltf_assets;
|
pub mod gltf_assets;
|
||||||
pub mod animations;
|
pub mod animations;
|
||||||
|
pub mod load_state;
|
Loading…
Reference in New Issue