improve projectiles asset loading
and defining projectile in heads-db
This commit is contained in:
@@ -1,20 +1,20 @@
|
|||||||
([
|
([
|
||||||
(key:"angry demonstrator", ability:Thrown, range:80),
|
(key:"angry demonstrator", ability:Thrown, range:80, projectile:"molotov"),//0
|
||||||
(key:"carnival knife thrower", range:60),
|
(key:"carnival knife thrower", range:60),//1
|
||||||
(key:"chicago gangster", ability:Gun, range:60),
|
(key:"chicago gangster", ability:Gun, range:60),//2
|
||||||
(key:"commando", ability:Gun, range:60),
|
(key:"commando", ability:Gun, range:60),//3
|
||||||
(key:"field medic"),
|
(key:"field medic"),//4
|
||||||
(key:"geisha"),
|
(key:"geisha"),//5
|
||||||
(key:"goblin", ability:Arrow, range:60),
|
(key:"goblin", ability:Arrow, range:60),//6
|
||||||
(key:"green grocer", range:60),
|
(key:"green grocer", range:60),//7
|
||||||
(key:"highland hammer thrower", ability:Thrown, range:80),
|
(key:"highland hammer thrower", ability:Thrown, range:80, projectile:"hammer"),//8
|
||||||
(key:"legionnaire", ability:Gun, range:60),
|
(key:"legionnaire", ability:Gun, range:60),//9
|
||||||
(key:"mig pilot", ability:Gun, range:60, controls:Plane),
|
(key:"mig pilot", ability:Gun, range:60, controls:Plane),//10
|
||||||
(key:"nanny", ability:Thrown, range:60),
|
(key:"nanny", ability:Thrown, range:60),//11
|
||||||
(key:"panic attack"),
|
(key:"panic attack"),//12
|
||||||
(key:"salty sea dog"),
|
(key:"salty sea dog"),//13
|
||||||
(key:"snow plough operator"),
|
(key:"snow plough operator"),//14
|
||||||
(key:"soldier ant"),
|
(key:"soldier ant"),//15
|
||||||
(key:"super market shopper", ability:Thrown, range:80),
|
(key:"super market shopper", ability:Thrown, range:80, projectile:"handbag"),//16
|
||||||
(key:"troll", ability:Thrown, range:80),
|
(key:"troll", ability:Thrown, range:80),//17
|
||||||
])
|
])
|
||||||
|
|||||||
BIN
assets/models/projectiles/handbag.glb
Normal file
BIN
assets/models/projectiles/handbag.glb
Normal file
Binary file not shown.
@@ -2,6 +2,7 @@ use super::TriggerThrow;
|
|||||||
use crate::{
|
use crate::{
|
||||||
GameState,
|
GameState,
|
||||||
billboards::Billboard,
|
billboards::Billboard,
|
||||||
|
heads_database::HeadsDatabase,
|
||||||
hitpoints::Hit,
|
hitpoints::Hit,
|
||||||
loading_assets::GameAssets,
|
loading_assets::GameAssets,
|
||||||
physics_layers::GameLayer,
|
physics_layers::GameLayer,
|
||||||
@@ -88,6 +89,8 @@ fn on_trigger_thrown(
|
|||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
query_transform: Query<&Transform>,
|
query_transform: Query<&Transform>,
|
||||||
assets: Res<GameAssets>,
|
assets: Res<GameAssets>,
|
||||||
|
gltf_assets: Res<Assets<Gltf>>,
|
||||||
|
heads_db: Res<HeadsDatabase>,
|
||||||
) {
|
) {
|
||||||
let state = trigger.event().0;
|
let state = trigger.event().0;
|
||||||
|
|
||||||
@@ -110,10 +113,12 @@ fn on_trigger_thrown(
|
|||||||
* (Vec3::new(2., 1., 0.).normalize() * SPEED)
|
* (Vec3::new(2., 1., 0.).normalize() * SPEED)
|
||||||
};
|
};
|
||||||
|
|
||||||
let (mesh, explosion_animation) = match state.head {
|
let head = heads_db.head_stats(state.head);
|
||||||
8 => (assets.hammer.clone(), false),
|
let mesh = assets.projectiles[format!("{}.glb", head.projectile).as_str()].clone();
|
||||||
_ => (assets.molotov.clone(), true),
|
let asset = gltf_assets.get(&mesh).unwrap();
|
||||||
};
|
|
||||||
|
//TODO: projectile db?
|
||||||
|
let explosion_animation = !matches!(state.head, 8 | 16);
|
||||||
|
|
||||||
commands
|
commands
|
||||||
.spawn((
|
.spawn((
|
||||||
@@ -134,7 +139,7 @@ fn on_trigger_thrown(
|
|||||||
))
|
))
|
||||||
.with_child((
|
.with_child((
|
||||||
AutoRotation(Quat::from_rotation_x(0.4) * Quat::from_rotation_z(0.3)),
|
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,
|
pub range: f32,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub controls: HeadControls,
|
pub controls: HeadControls,
|
||||||
|
#[serde(default)]
|
||||||
|
pub projectile: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Asset, Reflect, Serialize, Deserialize)]
|
#[derive(Debug, Asset, Reflect, Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -84,12 +84,6 @@ pub struct GameAssets {
|
|||||||
#[asset(path = "models/cash.glb#Scene0")]
|
#[asset(path = "models/cash.glb#Scene0")]
|
||||||
pub mesh_cash: Handle<Scene>,
|
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")]
|
#[asset(path = "models/alien_naked.glb#Scene0")]
|
||||||
pub mesh_alien: Handle<Scene>,
|
pub mesh_alien: Handle<Scene>,
|
||||||
|
|
||||||
@@ -102,6 +96,9 @@ pub struct GameAssets {
|
|||||||
collection(mapped, typed)
|
collection(mapped, typed)
|
||||||
)]
|
)]
|
||||||
pub animations_alien: HashMap<AssetLabel, Handle<AnimationClip>>,
|
pub animations_alien: HashMap<AssetLabel, Handle<AnimationClip>>,
|
||||||
|
|
||||||
|
#[asset(path = "models/projectiles", collection(mapped, typed))]
|
||||||
|
pub projectiles: HashMap<AssetFileName, Handle<Gltf>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LoadingPlugin;
|
pub struct LoadingPlugin;
|
||||||
|
|||||||
Reference in New Issue
Block a user