improve projectiles asset loading
and defining projectile in heads-db
This commit is contained in:
@@ -2,6 +2,7 @@ use super::TriggerThrow;
|
||||
use crate::{
|
||||
GameState,
|
||||
billboards::Billboard,
|
||||
heads_database::HeadsDatabase,
|
||||
hitpoints::Hit,
|
||||
loading_assets::GameAssets,
|
||||
physics_layers::GameLayer,
|
||||
@@ -88,6 +89,8 @@ fn on_trigger_thrown(
|
||||
mut commands: Commands,
|
||||
query_transform: Query<&Transform>,
|
||||
assets: Res<GameAssets>,
|
||||
gltf_assets: Res<Assets<Gltf>>,
|
||||
heads_db: Res<HeadsDatabase>,
|
||||
) {
|
||||
let state = trigger.event().0;
|
||||
|
||||
@@ -110,10 +113,12 @@ fn on_trigger_thrown(
|
||||
* (Vec3::new(2., 1., 0.).normalize() * SPEED)
|
||||
};
|
||||
|
||||
let (mesh, explosion_animation) = match state.head {
|
||||
8 => (assets.hammer.clone(), false),
|
||||
_ => (assets.molotov.clone(), true),
|
||||
};
|
||||
let head = heads_db.head_stats(state.head);
|
||||
let mesh = assets.projectiles[format!("{}.glb", head.projectile).as_str()].clone();
|
||||
let asset = gltf_assets.get(&mesh).unwrap();
|
||||
|
||||
//TODO: projectile db?
|
||||
let explosion_animation = !matches!(state.head, 8 | 16);
|
||||
|
||||
commands
|
||||
.spawn((
|
||||
@@ -134,7 +139,7 @@ fn on_trigger_thrown(
|
||||
))
|
||||
.with_child((
|
||||
AutoRotation(Quat::from_rotation_x(0.4) * Quat::from_rotation_z(0.3)),
|
||||
SceneRoot(mesh),
|
||||
SceneRoot(asset.scenes[0].clone()),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ pub struct HeadStats {
|
||||
pub range: f32,
|
||||
#[serde(default)]
|
||||
pub controls: HeadControls,
|
||||
#[serde(default)]
|
||||
pub projectile: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Asset, Reflect, Serialize, Deserialize)]
|
||||
|
||||
@@ -84,12 +84,6 @@ pub struct GameAssets {
|
||||
#[asset(path = "models/cash.glb#Scene0")]
|
||||
pub mesh_cash: Handle<Scene>,
|
||||
|
||||
#[asset(path = "models/head_misc/molotov_cocktail.glb#Scene0")]
|
||||
pub molotov: Handle<Scene>,
|
||||
|
||||
#[asset(path = "models/head_misc/hammer.glb#Scene0")]
|
||||
pub hammer: Handle<Scene>,
|
||||
|
||||
#[asset(path = "models/alien_naked.glb#Scene0")]
|
||||
pub mesh_alien: Handle<Scene>,
|
||||
|
||||
@@ -102,6 +96,9 @@ pub struct GameAssets {
|
||||
collection(mapped, typed)
|
||||
)]
|
||||
pub animations_alien: HashMap<AssetLabel, Handle<AnimationClip>>,
|
||||
|
||||
#[asset(path = "models/projectiles", collection(mapped, typed))]
|
||||
pub projectiles: HashMap<AssetFileName, Handle<Gltf>>,
|
||||
}
|
||||
|
||||
pub struct LoadingPlugin;
|
||||
|
||||
Reference in New Issue
Block a user