Avian & BTB upgrade (#40)
This commit is contained in:
@@ -4,13 +4,31 @@ use crate::{
|
||||
use bevy::{
|
||||
ecs::system::SystemParam, platform::collections::HashMap, prelude::*, scene::SceneInstanceReady,
|
||||
};
|
||||
use std::time::Duration;
|
||||
use std::{f32::consts::PI, time::Duration};
|
||||
|
||||
#[derive(Component, Debug)]
|
||||
pub struct ProjectileOrigin;
|
||||
|
||||
#[derive(Component, Debug)]
|
||||
pub struct AnimatedCharacter(pub usize);
|
||||
pub struct AnimatedCharacter {
|
||||
head: usize,
|
||||
rotate_180: bool,
|
||||
}
|
||||
|
||||
impl AnimatedCharacter {
|
||||
pub fn new(head: usize) -> Self {
|
||||
Self {
|
||||
head,
|
||||
rotate_180: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_rotation(self) -> Self {
|
||||
let mut s = self;
|
||||
s.rotate_180 = true;
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component, Debug)]
|
||||
struct AnimatedCharacterAsset(pub Handle<Gltf>);
|
||||
@@ -59,7 +77,7 @@ fn spawn(
|
||||
heads_db: Res<HeadsDatabase>,
|
||||
) {
|
||||
for (entity, character) in query.iter() {
|
||||
let key = heads_db.head_key(character.0);
|
||||
let key = heads_db.head_key(character.head);
|
||||
|
||||
let handle = assets
|
||||
.characters
|
||||
@@ -71,10 +89,17 @@ fn spawn(
|
||||
});
|
||||
let asset = gltf_assets.get(handle).unwrap();
|
||||
|
||||
let mut t =
|
||||
Transform::from_translation(Vec3::new(0., -1.45, 0.)).with_scale(Vec3::splat(1.2));
|
||||
|
||||
if character.rotate_180 {
|
||||
t.rotate_y(PI);
|
||||
}
|
||||
|
||||
commands
|
||||
.entity(entity)
|
||||
.insert((
|
||||
Transform::from_translation(Vec3::new(0., -1.45, 0.)).with_scale(Vec3::splat(1.2)),
|
||||
t,
|
||||
SceneRoot(asset.scenes[0].clone()),
|
||||
AnimatedCharacterAsset(handle.clone()),
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user