Updated to continue on other machine

This commit is contained in:
Franklin 2023-09-14 19:46:49 -04:00
parent 4f5b98a35f
commit d40c2546e2
12 changed files with 74 additions and 3 deletions

Binary file not shown.

View File

@ -0,0 +1,36 @@
use bevy::prelude::*;
use bevy::gltf::Gltf;
#[derive(Resource)]
pub struct LoadedAsset(Handle<Gltf>);
fn load_gltf(
mut commands: Commands,
ass: Res<AssetServer>,
) {
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<Gltf>,
}
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()
}
}

View File

@ -0,0 +1 @@
pub mod holdable;

View File

@ -2,3 +2,6 @@ use bevy::prelude::Component;
#[derive(Component)]
pub struct Player;
#[derive(Component)]
pub struct PlayerHand;

View File

@ -1,3 +1,4 @@
pub mod camera;
pub mod controller;
pub mod markers;
pub mod holdable;

View File

@ -0,0 +1,2 @@

1
src/comps/guns/mod.rs Normal file
View File

@ -0,0 +1 @@
pub mod ar_15_rifle;

View File

@ -1 +1,2 @@
pub mod core;
pub mod guns;

View File

@ -0,0 +1 @@

View File

@ -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;

View File

@ -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<AssetServer>) {
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<AssetServer>) {
})
.insert(PlayerLinearYState::Falling)
.insert(PlayerLinearXZState::Stopped)
.insert(VisibilityBundle {
visibility: Visibility::Visible,
..Default::default()
})
.push_children(&[camera]);

View File

@ -5,6 +5,7 @@ pub fn spawn_obstacles(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
asset_server: Res<AssetServer>
) {
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();