veloren_voxygen_anim/biped_large/
leapexplosionshockwave.rs

1use super::{
2    super::{Animation, vek::*},
3    BipedLargeSkeleton, SkeletonAttr,
4};
5use common::states::utils::StageSection;
6use core::f32::consts::PI;
7
8pub struct LeapExplosionShockAnimation;
9
10impl Animation for LeapExplosionShockAnimation {
11    type Dependency<'a> = (Option<StageSection>, Option<&'a str>);
12    type Skeleton = BipedLargeSkeleton;
13
14    #[cfg(feature = "use-dyn-lib")]
15    const UPDATE_FN: &'static [u8] = b"biped_large_leapexplosionshockwave\0";
16
17    #[cfg_attr(
18        feature = "be-dyn-lib",
19        unsafe(export_name = "biped_large_leapexplosionshockwave")
20    )]
21    fn update_skeleton_inner(
22        skeleton: &Self::Skeleton,
23        (stage_section, ability_id): Self::Dependency<'_>,
24        anim_time: f32,
25        rate: &mut f32,
26        s_a: &SkeletonAttr,
27    ) -> Self::Skeleton {
28        *rate = 1.0;
29        let mut next = (*skeleton).clone();
30
31        let (move1, move2, move3, move4) = match stage_section {
32            Some(StageSection::Buildup) => (anim_time, 0.0, 0.0, 0.0),
33            Some(StageSection::Movement) => (1.0, anim_time.powf(0.25), 0.0, 0.0),
34            Some(StageSection::Action) => (1.0, 1.0, anim_time.powf(0.25), 0.0),
35            Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time),
36            _ => (0.0, 0.0, 0.0, 0.0),
37        };
38
39        match ability_id {
40            Some("common.abilities.custom.gigas_fire.lava_leap") => {
41                let move1 = (PI * move1).sin();
42                let move2 = move2 * (1.0 - move3);
43                let move3 = move3 * (1.0 - move4.powi(3));
44
45                next.control.position = Vec3::new(s_a.sc.0, s_a.sc.1, s_a.sc.2);
46                next.control.orientation = Quaternion::rotation_x(s_a.sc.3)
47                    * Quaternion::rotation_y(s_a.sc.4)
48                    * Quaternion::rotation_z(s_a.sc.5);
49                next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
50                next.hand_l.orientation =
51                    Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
52                next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
53                next.hand_r.orientation =
54                    Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
55                next.main.position = Vec3::new(1.0, 10.0, 0.0);
56                next.main.orientation = Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
57
58                next.torso.position += Vec3::new(0.0, -3.0, -3.0) * move1;
59                next.leg_l.position += Vec3::new(0.0, 1.5, 1.5) * move1;
60                next.leg_l.orientation.rotate_x(PI / 3.0 * move1);
61                next.foot_l.position += Vec3::new(0.0, 3.0, 3.0) * move1;
62                next.leg_r.position += Vec3::new(0.0, 1.5, 1.5) * move1;
63                next.leg_r.orientation.rotate_x(PI / 3.0 * move1);
64                next.foot_r.position += Vec3::new(0.0, 3.0, 3.0) * move1;
65
66                next.torso.orientation.rotate_x(PI / 5.0 * move2);
67                next.torso.position += Vec3::new(0.0, 5.0, 0.0) * move2;
68                next.foot_l.orientation.rotate_x(-PI / 8.0 * move2);
69                next.leg_r.position += Vec3::new(0.0, 5.0, 0.0) * move2;
70                next.leg_r.orientation.rotate_x(PI / 8.0 * move2);
71                next.foot_r.position += Vec3::new(0.0, 2.0, 0.0) * move2;
72                next.foot_r.orientation.rotate_x(-PI / 6.0 * move2);
73                next.shoulder_l.orientation.rotate_x(PI / 2.5 * move2);
74                next.shoulder_r.position += Vec3::new(-3.0, 7.0, 0.0) * move2;
75                next.shoulder_r.orientation.rotate_x(PI / 1.5 * move2);
76                next.shoulder_r.orientation.rotate_z(PI / 4.0 * move2);
77                next.control.position += Vec3::new(-8.0, 0.0, 15.0) * move2;
78                next.control.orientation.rotate_x(PI / 3.0 * move2);
79                next.control.orientation.rotate_z(-PI / 10.0 * move2);
80                next.control_r.position += Vec3::new(13.0, 4.0, -8.0) * move2;
81                next.control_r.orientation.rotate_x(PI / 8.0 * move2);
82                next.control_r.orientation.rotate_z(PI / 3.0 * move2);
83                next.control_l.position += Vec3::new(0.0, 0.0, -7.0) * move2;
84                next.control_l.orientation.rotate_x(PI / 8.0 * move2);
85
86                next.torso.position += Vec3::new(0.0, -9.0, 0.0) * move3;
87                next.torso.orientation.rotate_x(-PI / 8.0 * move3);
88                next.lower_torso.position += Vec3::new(0.0, 0.0, 1.0) * move3;
89                next.lower_torso.orientation.rotate_x(PI / 8.0 * move3);
90                next.shoulder_r.position += Vec3::new(-3.0, 6.0, 0.0) * move3;
91                next.shoulder_r.orientation.rotate_z(PI / 4.0 * move3);
92                next.shoulder_l.position += Vec3::new(3.0, 6.0, 0.0) * move3;
93                next.shoulder_l.orientation.rotate_z(-PI / 4.0 * move3);
94                next.control.position += Vec3::new(0.0, 0.0, 0.0) * move3;
95                next.control.orientation.rotate_x(-PI / 2.5 * move3);
96            },
97            _ => {},
98        }
99
100        next
101    }
102}