diff --git a/assets/weapons/ar_15_rifle_base.glb b/assets/weapons/ar_15_rifle_base.glb new file mode 100644 index 0000000..d3caee4 Binary files /dev/null and b/assets/weapons/ar_15_rifle_base.glb differ diff --git a/src/comps/core/holdable/holdable.rs b/src/comps/core/holdable/holdable.rs new file mode 100644 index 0000000..3bfe080 --- /dev/null +++ b/src/comps/core/holdable/holdable.rs @@ -0,0 +1,36 @@ +use bevy::prelude::*; + +use bevy::gltf::Gltf; + +#[derive(Resource)] +pub struct LoadedAsset(Handle); + +fn load_gltf( + mut commands: Commands, + ass: Res, +) { + let gltf = ass.load("my_asset_pack.glb"); + commands.insert_resource(LoadedAsset(gltf)); +} + +/// Anything that can go in the player's hands. +pub struct HoldableObject { + pub transform: Transform, + /// Initial Rotation in degrees + pub y_rot: f32, + + pub asset_handle: Handle, + +} + +impl HoldableObject { + pub fn spawn_in_world(&mut self, mut commands: Commands) -> Entity { + commands.spawn(SceneBundle { + scene: , + transform: todo!(), + global_transform: todo!(), + visibility: todo!(), + computed_visibility: todo!(), + }).id() + } +} \ No newline at end of file diff --git a/src/comps/core/holdable/mod.rs b/src/comps/core/holdable/mod.rs new file mode 100644 index 0000000..ac1b12d --- /dev/null +++ b/src/comps/core/holdable/mod.rs @@ -0,0 +1 @@ +pub mod holdable; \ No newline at end of file diff --git a/src/comps/core/markers/player.rs b/src/comps/core/markers/player.rs index a9548d3..1bf0f91 100644 --- a/src/comps/core/markers/player.rs +++ b/src/comps/core/markers/player.rs @@ -2,3 +2,6 @@ use bevy::prelude::Component; #[derive(Component)] pub struct Player; + +#[derive(Component)] +pub struct PlayerHand; \ No newline at end of file diff --git a/src/comps/core/mod.rs b/src/comps/core/mod.rs index 4ebd932..869845d 100644 --- a/src/comps/core/mod.rs +++ b/src/comps/core/mod.rs @@ -1,3 +1,4 @@ pub mod camera; pub mod controller; pub mod markers; +pub mod holdable; \ No newline at end of file diff --git a/src/comps/guns/ar_15_rifle.rs b/src/comps/guns/ar_15_rifle.rs new file mode 100644 index 0000000..139597f --- /dev/null +++ b/src/comps/guns/ar_15_rifle.rs @@ -0,0 +1,2 @@ + + diff --git a/src/comps/guns/mod.rs b/src/comps/guns/mod.rs new file mode 100644 index 0000000..2fbc2bf --- /dev/null +++ b/src/comps/guns/mod.rs @@ -0,0 +1 @@ +pub mod ar_15_rifle; \ No newline at end of file diff --git a/src/comps/mod.rs b/src/comps/mod.rs index 5a7ca06..c7ea85a 100644 --- a/src/comps/mod.rs +++ b/src/comps/mod.rs @@ -1 +1,2 @@ pub mod core; +pub mod guns; \ No newline at end of file diff --git a/src/logic/core/player/hands.rs b/src/logic/core/player/hands.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/logic/core/player/hands.rs @@ -0,0 +1 @@ + diff --git a/src/logic/core/player/mod.rs b/src/logic/core/player/mod.rs index b6a75fd..2062422 100644 --- a/src/logic/core/player/mod.rs +++ b/src/logic/core/player/mod.rs @@ -3,3 +3,4 @@ pub mod camera_player_sync; pub mod player_movement; pub mod player_vertical_sync; pub mod spawn_player; +pub mod hands; \ No newline at end of file diff --git a/src/logic/core/player/spawn_player.rs b/src/logic/core/player/spawn_player.rs index 3426b9c..2b981ae 100644 --- a/src/logic/core/player/spawn_player.rs +++ b/src/logic/core/player/spawn_player.rs @@ -2,11 +2,11 @@ use bevy::{core_pipeline::Skybox, prelude::*}; use bevy_rapier3d::prelude::*; use crate::{ - comps::core::{camera::MainCamera, markers::player::Player}, + comps::core::{camera::MainCamera, markers::player::{Player, PlayerHand}}, constants::player_values::{ PLAYER_GRAVITY_SCALE, PLAYER_HEIGHT, PLAYER_INITIAL_WEIGHT, PLAYER_LINEAR_DAMPING, }, - scenes::scene1::skybox::{Cubemap, CUBEMAPS}, + scenes::scene1::skybox::{Cubemap, CUBEMAPS}, utils, }; use super::player_movement::{PlayerLinearXZState, PlayerLinearYState}; @@ -14,13 +14,32 @@ use super::player_movement::{PlayerLinearXZState, PlayerLinearYState}; pub fn spawn_player(mut commands: Commands, asset_server: Res) { let skybox_handle = asset_server.load(CUBEMAPS[0].0); + let mut ar_15_transform = Transform::from_xyz(0.0, 0.0, 0.0); + ar_15_transform.rotate_y(utils::rad_deg::radians_from_degrees(-90.0)); + let ar_15 = commands.spawn(SceneBundle { + scene: asset_server.load("weapons/ar_15_rifle_base.glb#Scene0"), + visibility: Visibility::Inherited, + transform: ar_15_transform, + ..default() + },).id(); + + let player_hand = commands.spawn(PlayerHand).insert(TransformBundle::from(Transform::from_xyz(1.0, -0.25, -3.0))).insert(VisibilityBundle { + visibility: Visibility::Inherited, + ..Default::default() + }).push_children(&[ar_15]).id(); + let camera = commands .spawn(MainCamera) .insert(Camera3dBundle { transform: Transform::from_xyz(0.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y), ..Default::default() }) - .insert(Skybox(skybox_handle.clone())).id(); + .insert(Skybox(skybox_handle.clone())) + .insert(VisibilityBundle { + visibility: Visibility::Inherited, + ..Default::default() + }) + .push_children(&[player_hand]).id(); commands .spawn(Player) @@ -53,6 +72,10 @@ pub fn spawn_player(mut commands: Commands, asset_server: Res) { }) .insert(PlayerLinearYState::Falling) .insert(PlayerLinearXZState::Stopped) + .insert(VisibilityBundle { + visibility: Visibility::Visible, + ..Default::default() + }) .push_children(&[camera]); diff --git a/src/scenes/scene1/obstacles.rs b/src/scenes/scene1/obstacles.rs index 35cecbc..244b218 100644 --- a/src/scenes/scene1/obstacles.rs +++ b/src/scenes/scene1/obstacles.rs @@ -5,6 +5,7 @@ pub fn spawn_obstacles( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, + asset_server: Res ) { let box_1_mesh = shape::Box::new(3.0, 7.0, 3.0).into(); let box_2_mesh = shape::Box::new(3.0, 7.0, 3.0).into();