veloren_voxygen_anim/quadruped_medium/
rapid_melee.rs1use super::{
2 super::{Animation, vek::*},
3 QuadrupedMediumSkeleton, SkeletonAttr,
4};
5use common::states::utils::StageSection;
6use std::f32::consts::PI;
7
8pub struct RapidMeleeAnimation;
9
10impl Animation for RapidMeleeAnimation {
11 type Dependency<'a> = (Option<&'a str>, Option<StageSection>);
12 type Skeleton = QuadrupedMediumSkeleton;
13
14 #[cfg(feature = "use-dyn-lib")]
15 const UPDATE_FN: &'static [u8] = b"quadruped_medium_rapidmelee\0";
16
17 #[cfg_attr(
18 feature = "be-dyn-lib",
19 unsafe(export_name = "quadruped_medium_rapidmelee")
20 )]
21 fn update_skeleton_inner(
22 skeleton: &Self::Skeleton,
23 (ability_id, stage_section): Self::Dependency<'_>,
24 anim_time: f32,
25 _rate: &mut f32,
26 _s_a: &SkeletonAttr,
27 ) -> Self::Skeleton {
28 let mut next = (*skeleton).clone();
29
30 let (buildup, _action, recover) = match stage_section {
31 Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0),
32 Some(StageSection::Action) => (1.0, anim_time.min(1.0), 0.0),
33 Some(StageSection::Recover) => (1.0, 1.0, anim_time.powi(3)),
34 _ => (0.0, 0.0, 0.0),
35 };
36 let pullback = 1.0 - recover;
37 let buildup = buildup * pullback;
38 let buildup_overshoot = (1.5 - (2.5 * (buildup - 0.6)).abs()) * pullback;
39
40 match ability_id {
41 Some("common.abilities.custom.elephant.vacuum") => {
42 next.head.orientation.rotate_x(PI / 6.0 * buildup);
43 next.jaw.orientation.rotate_x(PI / 5.0 * buildup_overshoot);
44 next.ears.position += Vec3::new(0.0, -4.0, -2.0) * buildup_overshoot;
45 next.ears.orientation.rotate_x(PI / 4.0 * buildup_overshoot);
46 },
47 _ => {},
48 }
49
50 next
51 }
52}