veloren_voxygen_anim/crustacean/
alpha.rs1use super::{
2 super::{Animation, vek::*},
3 CrustaceanSkeleton, SkeletonAttr,
4};
5use common::states::utils::StageSection;
6
7pub struct AlphaAnimation;
8
9impl Animation for AlphaAnimation {
10 type Dependency<'a> = (f32, f32, Option<StageSection>, f32);
11 type Skeleton = CrustaceanSkeleton;
12
13 #[cfg(feature = "use-dyn-lib")]
14 const UPDATE_FN: &'static [u8] = b"crustacean_alpha\0";
15
16 #[cfg_attr(feature = "be-dyn-lib", export_name = "crustacean_alpha")]
17 fn update_skeleton_inner(
18 skeleton: &Self::Skeleton,
19 (_velocity, global_time, stage_section, timer): Self::Dependency<'_>,
20 anim_time: f32,
21 _rate: &mut f32,
22 s_a: &SkeletonAttr,
23 ) -> Self::Skeleton {
24 let mut next = (*skeleton).clone();
25
26 let (movement1, movement2, movement3) = match stage_section {
27 Some(StageSection::Buildup) => (anim_time.powi(2), 0.0, 0.0),
28 Some(StageSection::Action) => (1.0, anim_time.powi(4), 0.0),
29 Some(StageSection::Recover) => (1.0, 1.0, anim_time),
30 _ => (0.0, 0.0, 0.0),
31 };
32 let pullback = 1.0 - movement3;
33 let subtract = global_time - timer;
34 let check = subtract - subtract.trunc();
35 let _mirror = (check - 0.5).signum();
36 let _movement1abs = movement1 * pullback;
37 let _movement2abs = movement2 * pullback;
38 let _movement3abs = movement3 * pullback;
39
40 next.arm_l.orientation = Quaternion::rotation_x(anim_time);
41
42 next.chest.scale = Vec3::one() * s_a.scaler;
43
44 next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1);
45
46 next.leg_fl.position = Vec3::new(-s_a.leg_f.0, s_a.leg_f.1, s_a.leg_f.2);
47 next.leg_fr.position = Vec3::new(s_a.leg_f.0, s_a.leg_f.1, s_a.leg_f.2);
48
49 next.leg_cl.position = Vec3::new(-s_a.leg_c.0, s_a.leg_c.1, s_a.leg_c.2);
50 next.leg_cr.position = Vec3::new(s_a.leg_c.0, s_a.leg_c.1, s_a.leg_c.2);
51
52 next.leg_bl.position = Vec3::new(-s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2);
53 next.leg_br.position = Vec3::new(s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2);
54 next
55 }
56}