veloren_voxygen_anim/crustacean/
ripostemelee.rs

1use 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(
16        feature = "be-dyn-lib",
17        unsafe(export_name = "crustacean_riposte_melee")
18    )]
19    fn update_skeleton_inner(
20        skeleton: &Self::Skeleton,
21        (_ability_id, stage_section): Self::Dependency<'_>,
22        anim_time: f32,
23        rate: &mut f32,
24        _s_a: &SkeletonAttr,
25    ) -> Self::Skeleton {
26        *rate = 1.0;
27        let mut next = (*skeleton).clone();
28
29        let _slow = (anim_time * 2.0).sin();
30
31        let (move1, move2, move3) = match stage_section {
32            StageSection::Buildup => (anim_time.powf(0.25), 0.0, 0.0),
33            StageSection::Action => (1.0, anim_time, 0.0),
34            StageSection::Recover => (1.0, 1.0, anim_time),
35            _ => (0.0, 0.0, 0.0),
36        };
37        let pullback = 1.0 - move3;
38        let move1 = move1 * pullback;
39        let move2 = move2 * pullback;
40        let _move2fast = move2.max(0.001).powf(0.25) * pullback;
41        let _move2slow = move2.powi(4) * pullback;
42
43        next.chest.position = Vec3::new(0.0, 0.0, 0.0 - move1 * 3.0);
44
45        next.arm_r.orientation = Quaternion::rotation_z(move1 * -1.5 + move2 * 1.6);
46        next.arm_r.position = Vec3::new(0.0 - move1 * 4.0, -4.0, 0.0);
47        next.pincer_r1.position = Vec3::new(0.0, -3.0 * move1 + 4.0 * move2, 4.0);
48        next.pincer_r1.orientation = Quaternion::rotation_x(move1 * -0.4 + move2 * 0.3);
49
50        next.arm_l.orientation = Quaternion::rotation_z(move1 * 0.5 - move2 * 0.5);
51        next.pincer_l1.orientation = Quaternion::rotation_x(move1 * -0.4 + move2 * 0.3);
52        next.pincer_l1.position = Vec3::new(0.0, -3.0 * move1 + 4.0 * move2, 4.0);
53        next.pincer_l0.orientation = Quaternion::rotation_x(move1 * 0.4 + move2 * -0.6);
54
55        next
56    }
57}