veloren_voxygen_anim/bird_medium/
shoot.rs1use super::{
2 super::{Animation, vek::*},
3 BirdMediumSkeleton, SkeletonAttr,
4};
5use common::{states::utils::StageSection, util::Dir};
6
7pub struct ShootAnimation;
8
9type ShootAnimationDependency = (Vec3<f32>, f32, Option<StageSection>, f32, Dir, bool);
10
11impl Animation for ShootAnimation {
12 type Dependency<'a> = ShootAnimationDependency;
13 type Skeleton = BirdMediumSkeleton;
14
15 #[cfg(feature = "use-dyn-lib")]
16 const UPDATE_FN: &'static [u8] = b"bird_medium_shoot\0";
17
18 #[cfg_attr(feature = "be-dyn-lib", export_name = "bird_medium_shoot")]
19 fn update_skeleton_inner<'a>(
20 skeleton: &Self::Skeleton,
21 (velocity, global_time, stage_section, timer, look_dir, on_ground): Self::Dependency<'_>,
22 anim_time: f32,
23 _rate: &mut f32,
24 s_a: &SkeletonAttr,
25 ) -> Self::Skeleton {
26 let mut next = (*skeleton).clone();
27
28 let (movement1base, movement3, twitch) = match stage_section {
29 Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0),
30 Some(StageSection::Recover) => (1.0, anim_time.powf(0.25), anim_time),
31 _ => (0.0, 0.0, 0.0),
32 };
33
34 let pullback = 1.0 - movement3;
35 let subtract = global_time - timer;
36 let check = subtract - subtract.trunc();
37 let mirror = (check - 0.5).signum();
38 let twitch2 = mirror * (twitch * 20.0).sin() * pullback;
39 let movement1abs = movement1base * pullback;
40 let movement1mirror = movement1abs * mirror;
41
42 let wave_slow_cos = (anim_time * 4.5).cos();
43
44 next.chest.position = Vec3::new(
45 0.0,
46 s_a.chest.0,
47 s_a.chest.1 + wave_slow_cos * 0.06 + twitch2 * 0.1,
48 );
49
50 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
51 next.head.orientation =
52 Quaternion::rotation_x(movement1abs * 0.5 + look_dir.z * 0.4 + twitch2)
53 * Quaternion::rotation_y(movement1mirror * 0.5);
54
55 if on_ground {
56 next.chest.position = Vec3::new(
57 0.0,
58 s_a.chest.0,
59 s_a.chest.1 + wave_slow_cos * 0.06 + twitch2 * 0.1 + movement1abs * -3.0,
60 );
61
62 next.chest.orientation = Quaternion::rotation_x(movement1abs * 0.1);
63
64 next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
65 next.tail.orientation = Quaternion::rotation_x(-movement1abs * 0.1 + twitch2 * 0.02);
66
67 next.leg_l.orientation = Quaternion::rotation_x(movement1abs * -0.5);
68 next.leg_r.orientation = Quaternion::rotation_x(movement1abs * -0.5);
69 }
70 if velocity.xy().magnitude() < 1.0 {
71 next.wing_in_l.orientation = Quaternion::rotation_y(-1.0 + movement1abs * 0.8)
72 * Quaternion::rotation_z(0.2 - movement1abs * 0.8);
73 next.wing_in_r.orientation = Quaternion::rotation_y(1.0 - movement1abs * 0.8)
74 * Quaternion::rotation_z(-0.2 + movement1abs * 0.8);
75 };
76 next
77 }
78}