improve projectiles asset loading

and defining projectile in heads-db
This commit is contained in:
2025-04-13 16:33:10 +02:00
parent 9779e4e6cb
commit b5ac2a9875
7 changed files with 33 additions and 29 deletions

View File

@@ -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()),
));
}