Added holdable marker struct and moved things around

This commit is contained in:
Franklin Blanco 2023-09-15 13:46:38 -07:00
parent 3eeff6b11a
commit 5e7f1407f0
11 changed files with 32 additions and 42 deletions

View File

@ -1,35 +0,0 @@
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: todo!(),
transform: todo!(),
global_transform: todo!(),
visibility: todo!(),
computed_visibility: todo!(),
}).id()
}
}

View File

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

View File

@ -0,0 +1,10 @@
use bevy::prelude::*;
/// Anything that can go in the player's hands.
#[derive(Component, Default, Debug)]
pub struct HoldableObject {
/// Where this object should be placed relative to the hand.
pub held_at: Vec3,
/// Initial Rotation in degrees
pub y_rot: f32,
}

View File

@ -1 +1,3 @@
pub mod player;
pub mod holdable;
pub mod camera;

View File

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

View File

@ -2,7 +2,7 @@ use bevy::{input::mouse::MouseMotion, prelude::*};
//use bevy_rapier3d::prelude::*;
use crate::{
comps::core::{camera::MainCamera, markers::player::Player},
comps::core::markers::{player::Player, camera::MainCamera},
constants::player_values::{PLAYER_CAMERA_HEIGHT, PLAYER_CROUCH_HEIGHT, PLAYER_CROUCH_TIME_MS},
};

View File

@ -2,7 +2,7 @@ use bevy::{core_pipeline::Skybox, prelude::*};
use bevy_rapier3d::prelude::*;
use crate::{
comps::core::{camera::MainCamera, markers::player::{Player, PlayerHand}},
comps::core::markers::{player::{Player, PlayerHand}, camera::MainCamera},
constants::player_values::{
PLAYER_GRAVITY_SCALE, PLAYER_HEIGHT, PLAYER_INITIAL_WEIGHT, PLAYER_LINEAR_DAMPING,
},
@ -17,7 +17,7 @@ pub fn spawn_player(mut commands: Commands, asset_server: Res<AssetServer>) {
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"),
scene: asset_server.load("weapons/m4a1_rifle.glb#Scene0"),
visibility: Visibility::Inherited,
transform: ar_15_transform,
..default()

15
src/setup/gltf_assets.rs Normal file
View File

@ -0,0 +1,15 @@
use bevy::prelude::*;
use bevy::gltf::Gltf;
#[derive(Resource)]
pub struct LoadedAsset(Handle<Gltf>);
/// Loads gltf asset into AssetServer. Inserts Resource as a LoadedAsset
pub fn load_gltf(
mut commands: Commands,
ass: Res<AssetServer>,
) {
let gltf = ass.load("my_asset_pack.glb");
commands.insert_resource(LoadedAsset(gltf));
}

View File

@ -1 +1,2 @@
pub mod gltf_assets;