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