veloren_voxygen_anim/biped_small/
rapidmelee.rs

1use super::{
2    super::Animation, BipedSmallSkeleton, SkeletonAttr, biped_small_alpha_spear,
3    biped_small_wield_spear, init_biped_small_alpha,
4};
5use common::states::utils::StageSection;
6
7pub struct RapidMeleeAnimation;
8impl Animation for RapidMeleeAnimation {
9    type Dependency<'a> = (Option<&'a str>, StageSection, (u32, Option<u32>));
10    type Skeleton = BipedSmallSkeleton;
11
12    #[cfg(feature = "use-dyn-lib")]
13    const UPDATE_FN: &'static [u8] = b"biped_small_rapid_melee\0";
14
15    #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_small_rapid_melee")]
16    fn update_skeleton_inner(
17        skeleton: &Self::Skeleton,
18        (ability_id, stage_section, (_current_strike, _max_strikes)): 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        init_biped_small_alpha(&mut next, s_a);
27
28        match ability_id {
29            Some("common.abilities.haniwa.guard.flurry") => {
30                biped_small_wield_spear(&mut next, s_a, anim_time, 0.0, 0.0);
31
32                let (move1, move2, move3) = match stage_section {
33                    StageSection::Buildup => (anim_time.powf(0.25), 0.0, 0.0),
34                    StageSection::Action => (1.0, anim_time, 0.0),
35                    StageSection::Recover => (1.0, 1.0, anim_time),
36                    _ => (0.0, 0.0, 0.0),
37                };
38                let pullback = 1.0 - move3;
39                let move1 = move1 * pullback;
40                let move2 = ((move2 - 0.5).abs() * -2.0 + 1.0) * 0.75;
41                let move2 = move2 * pullback;
42
43                biped_small_alpha_spear(&mut next, s_a, move1, move2, anim_time, 0.0);
44            },
45            _ => {},
46        }
47
48        next
49    }
50}