veloren_voxygen_anim/quadruped_small/
combomelee.rs1use super::{
2 super::{Animation, vek::*},
3 QuadrupedSmallSkeleton, SkeletonAttr,
4};
5use common::states::utils::{AbilityInfo, StageSection};
6
7pub struct ComboAnimation;
8impl Animation for ComboAnimation {
9 type Dependency<'a> = (
10 Option<&'a str>,
11 Option<StageSection>,
12 Option<AbilityInfo>,
13 usize,
14 f32,
15 f32,
16 );
17 type Skeleton = QuadrupedSmallSkeleton;
18
19 #[cfg(feature = "use-dyn-lib")]
20 const UPDATE_FN: &'static [u8] = b"quadruped_small_combo\0";
21
22 #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_small_combo")]
23 fn update_skeleton_inner(
24 skeleton: &Self::Skeleton,
25 (ability_id, stage_section, _ability_info, current_strike, global_time, timer): Self::Dependency<'_>,
26 anim_time: f32,
27 rate: &mut f32,
28 _s_a: &SkeletonAttr,
29 ) -> Self::Skeleton {
30 *rate = 1.0;
31 let mut next = (*skeleton).clone();
32
33 let _multi_strike_pullback = 1.0
34 - if matches!(stage_section, Some(StageSection::Recover)) {
35 anim_time.powi(4)
36 } else {
37 0.0
38 };
39
40 for strike in 0..=current_strike {
41 match ability_id {
42 Some("common.abilities.custom.mossy_snail.headbutt") => {
43 let (movement1base, movement2base, movement3) = match stage_section {
44 Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0),
45 Some(StageSection::Action) => (1.0, anim_time.powi(4), 0.0),
46 Some(StageSection::Recover) => (1.0, 1.0, anim_time),
47 _ => (0.0, 0.0, 0.0),
48 };
49 let pullback = 1.0 - movement3;
50 let subtract = global_time - timer;
51 let check = subtract - subtract.trunc();
52 let mirror = (check - 0.5).signum();
53 let _twitch3 = (mirror * movement3 * 9.0).sin();
54 let movement1 = mirror * movement1base * pullback;
55 let movement2 = mirror * movement2base * pullback;
56 let movement1abs = movement1base * pullback;
57 let movement2abs = movement2base * pullback;
58
59 match strike {
60 0 => {
61 next.head.orientation =
62 Quaternion::rotation_x(movement1abs * -0.7 + movement2abs * 2.0)
63 * Quaternion::rotation_y(movement1 * -0.6 + movement2 * 1.2);
64
65 next.chest.orientation =
66 Quaternion::rotation_y(movement1 * -0.08 + movement2 * 0.15)
67 * Quaternion::rotation_z(movement1 * 0.2 + movement2 * -0.6);
68
69 next.tail.orientation =
70 Quaternion::rotation_x(movement1abs * 0.5 + movement2abs * -1.0)
71 * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2);
72 },
73 _ => {},
74 }
75 },
76 _ => {},
77 }
78 }
79 next
80 }
81}