veloren_voxygen_anim/bird_large/
shoot.rs1use super::{
2 super::{Animation, vek::*},
3 BirdLargeSkeleton, SkeletonAttr,
4};
5use common::{states::utils::StageSection, util::Dir};
6
7pub struct ShootAnimation;
8
9type ShootAnimationDependency<'a> = (
10 Vec3<f32>,
11 f32,
12 Option<StageSection>,
13 f32,
14 Dir,
15 bool,
16 Option<&'a str>,
17);
18
19impl Animation for ShootAnimation {
20 type Dependency<'a> = ShootAnimationDependency<'a>;
21 type Skeleton = BirdLargeSkeleton;
22
23 #[cfg(feature = "use-dyn-lib")]
24 const UPDATE_FN: &'static [u8] = b"bird_large_shoot\0";
25
26 #[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_shoot")]
27 fn update_skeleton_inner(
28 skeleton: &Self::Skeleton,
29 (velocity, global_time, stage_section, timer, look_dir, on_ground, ability_id,
30 ): Self::Dependency<'_>,
31 anim_time: f32,
32 _rate: &mut f32,
33 s_a: &SkeletonAttr,
34 ) -> Self::Skeleton {
35 let mut next = (*skeleton).clone();
36
37 match ability_id {
38 Some("common.abilities.custom.birdlargefire.firerain") => {
39 let (movement1base, movement2base, movement3, _twitch) = match stage_section {
40 Some(StageSection::Buildup) => (anim_time.powf(0.5), 0.0, 0.0, 0.0),
41 Some(StageSection::Action) => {
42 (1.0, anim_time.min(1.0).powf(0.1), 0.0, anim_time)
43 },
44 Some(StageSection::Recover) => (1.0, 1.0, anim_time, 1.0),
45 _ => (0.0, 0.0, 0.0, 0.0),
46 };
47
48 let pullback = 1.0 - movement3;
49 let movement1abs = movement1base * pullback;
50 let _movement2abs = movement2base * pullback;
51 let wave_slow_cos = (anim_time * 4.5).cos();
52
53 next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + movement1abs * 2.5);
54 next.chest.orientation = Quaternion::rotation_x(movement1abs * 1.0);
55
56 next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1);
57 next.neck.orientation = Quaternion::rotation_x(-0.2);
58
59 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
60 next.head.orientation = Quaternion::rotation_x(wave_slow_cos * 0.01);
61
62 next.beak.position = Vec3::new(0.0, s_a.beak.0, s_a.beak.1);
63 next.beak.orientation = Quaternion::rotation_x(wave_slow_cos * -0.02 - 0.02);
64
65 next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
66 next.tail_front.orientation = Quaternion::rotation_x(0.6);
67 next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
68 next.tail_rear.orientation = Quaternion::rotation_x(-0.2);
69
70 if on_ground {
71 next.wing_in_l.position =
72 Vec3::new(-s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
73 next.wing_in_r.position =
74 Vec3::new(s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
75
76 next.wing_in_l.orientation = Quaternion::rotation_y(-0.8 + movement1abs * 1.6)
77 * Quaternion::rotation_z(0.2 + movement1abs * -0.8);
78 next.wing_in_r.orientation = Quaternion::rotation_y(0.8 + movement1abs * -1.6)
79 * Quaternion::rotation_z(-0.2 + movement1abs * 0.8);
80
81 next.wing_mid_l.position =
82 Vec3::new(-s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
83 next.wing_mid_r.position =
84 Vec3::new(s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
85 next.wing_mid_l.orientation =
86 Quaternion::rotation_y(-0.1) * Quaternion::rotation_z(0.7);
87 next.wing_mid_r.orientation =
88 Quaternion::rotation_y(0.1) * Quaternion::rotation_z(-0.7);
89
90 next.wing_out_l.position =
91 Vec3::new(-s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
92 next.wing_out_r.position =
93 Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
94 next.wing_out_l.orientation =
95 Quaternion::rotation_y(-0.4) * Quaternion::rotation_z(0.2);
96 next.wing_out_r.orientation =
97 Quaternion::rotation_y(0.4) * Quaternion::rotation_z(-0.2);
98
99 next.leg_l.position = Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2);
100 next.leg_l.orientation = Quaternion::rotation_x(0.0);
101 next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2);
102 next.leg_r.orientation = Quaternion::rotation_x(0.0);
103
104 next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
105 next.foot_l.orientation = Quaternion::rotation_x(0.0);
106 next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
107 next.foot_r.orientation = Quaternion::rotation_x(0.0);
108 }
109 },
110 _ => {
111 let (movement1base, movement3, twitch) = match stage_section {
112 Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0),
113 Some(StageSection::Recover) => (1.0, anim_time.powf(0.25), anim_time),
114 _ => (0.0, 0.0, 0.0),
115 };
116
117 let pullback = 1.0 - movement3;
118 let subtract = global_time - timer;
119 let check = subtract - subtract.trunc();
120 let mirror = (check - 0.5).signum();
121 let twitch2 = mirror * (twitch * 20.0).sin() * pullback;
122 let movement1abs = movement1base * pullback;
123 let movement1mirror = movement1abs * mirror;
124
125 let wave_slow_cos = (anim_time * 4.5).cos();
126 next.chest.position = Vec3::new(
127 0.0,
128 s_a.chest.0,
129 s_a.chest.1 + wave_slow_cos * 0.06 + twitch2 * 0.1,
130 );
131
132 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
133 next.head.orientation =
134 Quaternion::rotation_x(movement1abs * 0.5 + look_dir.z * 0.4 + twitch2)
135 * Quaternion::rotation_y(movement1mirror * 0.5);
136
137 next.beak.position = Vec3::new(0.0, s_a.beak.0, s_a.beak.1);
138 next.beak.orientation = Quaternion::rotation_x(movement1abs * -0.7 + twitch2 * 0.1);
139
140 if on_ground {
141 next.chest.position = Vec3::new(
142 0.0,
143 s_a.chest.0,
144 s_a.chest.1 + wave_slow_cos * 0.06 + twitch2 * 0.1 + movement1abs * -3.0,
145 );
146 next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1);
147 next.neck.orientation = Quaternion::rotation_x(movement1abs * 0.5)
148 * Quaternion::rotation_y(movement1mirror * 0.2);
149
150 next.chest.orientation = Quaternion::rotation_x(movement1abs * 0.1);
151
152 next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
153 next.tail_front.orientation =
154 Quaternion::rotation_x(-movement1abs * 0.1 + twitch2 * 0.02);
155 next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
156 next.tail_rear.orientation =
157 Quaternion::rotation_x(-movement1abs * 0.1 + twitch2 * 0.02);
158
159 next.leg_l.orientation = Quaternion::rotation_x(movement1abs * -0.5);
160 next.leg_r.orientation = Quaternion::rotation_x(movement1abs * -0.5);
161
162 next.foot_l.orientation = Quaternion::rotation_x(movement1abs * 0.3);
163 next.foot_r.orientation = Quaternion::rotation_x(movement1abs * 0.3);
164 }
165 if velocity.xy().magnitude() < 1.0 {
166 next.wing_in_l.orientation = Quaternion::rotation_y(-1.0 + movement1abs * 0.8)
167 * Quaternion::rotation_z(0.2 - movement1abs * 0.8);
168 next.wing_in_r.orientation = Quaternion::rotation_y(1.0 - movement1abs * 0.8)
169 * Quaternion::rotation_z(-0.2 + movement1abs * 0.8);
170 }
171 },
172 };
173 next
174 }
175}