veloren_voxygen_anim/crustacean/
ripostemelee.rs1use super::{
2 super::{Animation, vek::*},
3 CrustaceanSkeleton, SkeletonAttr,
4};
5use common::states::utils::StageSection;
6
7pub struct RiposteMeleeAnimation;
8impl Animation for RiposteMeleeAnimation {
9 type Dependency<'a> = (Option<&'a str>, StageSection);
10 type Skeleton = CrustaceanSkeleton;
11
12 #[cfg(feature = "use-dyn-lib")]
13 const UPDATE_FN: &'static [u8] = b"crustacean_riposte_melee\0";
14
15 #[cfg_attr(feature = "be-dyn-lib", export_name = "crustacean_riposte_melee")]
16 fn update_skeleton_inner(
17 skeleton: &Self::Skeleton,
18 (_ability_id, stage_section): Self::Dependency<'_>,
19 anim_time: f32,
20 rate: &mut f32,
21 _s_a: &SkeletonAttr,
22 ) -> Self::Skeleton {
23 *rate = 1.0;
24 let mut next = (*skeleton).clone();
25
26 let _slow = (anim_time * 2.0).sin();
27
28 let (move1, move2, move3) = match stage_section {
29 StageSection::Buildup => (anim_time.powf(0.25), 0.0, 0.0),
30 StageSection::Action => (1.0, anim_time, 0.0),
31 StageSection::Recover => (1.0, 1.0, anim_time),
32 _ => (0.0, 0.0, 0.0),
33 };
34 let pullback = 1.0 - move3;
35 let move1 = move1 * pullback;
36 let move2 = move2 * pullback;
37 let _move2fast = move2.max(0.001).powf(0.25) * pullback;
38 let _move2slow = move2.powi(4) * pullback;
39
40 next.chest.position = Vec3::new(0.0, 0.0, 0.0 - move1 * 3.0);
41
42 next.arm_r.orientation = Quaternion::rotation_z(move1 * -1.5 + move2 * 1.6);
43 next.arm_r.position = Vec3::new(0.0 - move1 * 4.0, -4.0, 0.0);
44 next.pincer_r1.position = Vec3::new(0.0, -3.0 * move1 + 4.0 * move2, 4.0);
45 next.pincer_r1.orientation = Quaternion::rotation_x(move1 * -0.4 + move2 * 0.3);
46
47 next.arm_l.orientation = Quaternion::rotation_z(move1 * 0.5 - move2 * 0.5);
48 next.pincer_l1.orientation = Quaternion::rotation_x(move1 * -0.4 + move2 * 0.3);
49 next.pincer_l1.position = Vec3::new(0.0, -3.0 * move1 + 4.0 * move2, 4.0);
50 next.pincer_l0.orientation = Quaternion::rotation_x(move1 * 0.4 + move2 * -0.6);
51
52 next
53 }
54}