veloren_voxygen_anim/biped_small/
rapidmelee.rs1use 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(
16 feature = "be-dyn-lib",
17 unsafe(export_name = "biped_small_rapid_melee")
18 )]
19 fn update_skeleton_inner(
20 skeleton: &Self::Skeleton,
21 (ability_id, stage_section, (_current_strike, _max_strikes)): 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 init_biped_small_alpha(&mut next, s_a);
30
31 match ability_id {
32 Some("common.abilities.haniwa.guard.flurry") => {
33 biped_small_wield_spear(&mut next, s_a, anim_time, 0.0, 0.0);
34
35 let (move1, move2, move3) = match stage_section {
36 StageSection::Buildup => (anim_time.powf(0.25), 0.0, 0.0),
37 StageSection::Action => (1.0, anim_time, 0.0),
38 StageSection::Recover => (1.0, 1.0, anim_time),
39 _ => (0.0, 0.0, 0.0),
40 };
41 let pullback = 1.0 - move3;
42 let move1 = move1 * pullback;
43 let move2 = ((move2 - 0.5).abs() * -2.0 + 1.0) * 0.75;
44 let move2 = move2 * pullback;
45
46 biped_small_alpha_spear(&mut next, s_a, move1, move2, anim_time, 0.0);
47 },
48 _ => {},
49 }
50
51 next
52 }
53}