veloren_voxygen_anim/quadruped_small/
shockwave.rs

1use super::{
2    super::{Animation, vek::*},
3    QuadrupedSmallSkeleton, SkeletonAttr,
4};
5use common::states::utils::StageSection;
6//use std::ops::Rem;
7
8pub struct ShockwaveAnimation;
9
10impl Animation for ShockwaveAnimation {
11    type Dependency<'a> = (f32, f32, Option<StageSection>, f32);
12    type Skeleton = QuadrupedSmallSkeleton;
13
14    #[cfg(feature = "use-dyn-lib")]
15    const UPDATE_FN: &'static [u8] = b"quadruped_small_shockwave\0";
16
17    #[cfg_attr(
18        feature = "be-dyn-lib",
19        unsafe(export_name = "quadruped_small_shockwave")
20    )]
21    fn update_skeleton_inner(
22        skeleton: &Self::Skeleton,
23        (_velocity, global_time, stage_section, timer): 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 (movement1base, movement2base, movement3) = match stage_section {
31            Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0),
32            Some(StageSection::Action) => (1.0, anim_time.powi(4), 0.0),
33            Some(StageSection::Recover) => (1.0, 1.0, anim_time),
34            _ => (0.0, 0.0, 0.0),
35        };
36        let pullback = 1.0 - movement3;
37        let subtract = global_time - timer;
38        let check = subtract - subtract.trunc();
39        let mirror = (check - 0.5).signum();
40        let _movement1 = mirror * movement1base * pullback;
41        let _movement2 = mirror * movement2base * pullback;
42        let _movement1abs = movement1base * pullback;
43        let movement2abs = movement2base * pullback;
44        // used by treant_sapling
45        next.chest.position = Vec3::new(0.0, 0.0, -2.0 + movement2abs * 16.0);
46
47        next
48    }
49}