veloren_voxygen_anim/biped_large/
explosion.rs

1use super::{
2    super::{Animation, vek::*},
3    BipedLargeSkeleton, SkeletonAttr, init_biped_large_alpha, init_gigas_fire,
4};
5use common::states::utils::StageSection;
6use core::f32::consts::PI;
7
8pub struct ExplosionAnimation;
9
10impl Animation for ExplosionAnimation {
11    type Dependency<'a> = (Vec3<f32>, f32, 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_explosion\0";
16
17    #[cfg_attr(feature = "be-dyn-lib", unsafe(export_name = "biped_large_explosion"))]
18    fn update_skeleton_inner(
19        skeleton: &Self::Skeleton,
20        (velocity, acc_vel, stage_section, ability_id): Self::Dependency<'_>,
21        anim_time: f32,
22        rate: &mut f32,
23        s_a: &SkeletonAttr,
24    ) -> Self::Skeleton {
25        *rate = 1.0;
26        let mut next = (*skeleton).clone();
27
28        let (move1base, move2base, move3base) = match stage_section {
29            Some(StageSection::Buildup) => (anim_time, 0.0, 0.0),
30            Some(StageSection::Action) => (1.0, anim_time, 0.0),
31            Some(StageSection::Recover) => (1.0, 1.0, anim_time),
32            _ => (0.0, 0.0, 0.0),
33        };
34        let pullback = 1.0 - move3base;
35
36        let speed = Vec2::<f32>::from(velocity).magnitude();
37
38        match ability_id {
39            Some("common.abilities.custom.gigas_fire.explosive_strike") => {
40                let (pre_move1base, move1base) = if move1base < 0.2 {
41                    (5.0 * move1base, 0.0)
42                } else {
43                    (1.0, 1.25 * (move1base - 0.2))
44                };
45
46                let pre_move1 = pre_move1base * pullback;
47                let move2 = move2base * pullback;
48
49                init_biped_large_alpha(&mut next, s_a, speed, acc_vel, pre_move1);
50                init_gigas_fire(&mut next);
51
52                next.torso.orientation.rotate_z(PI / 8.0 * pre_move1base);
53                next.lower_torso
54                    .orientation
55                    .rotate_z(-PI / 16.0 * pre_move1);
56                next.shoulder_l
57                    .orientation
58                    .rotate_x(PI / 3.0 * pre_move1base);
59                next.shoulder_r
60                    .orientation
61                    .rotate_x(PI / 3.0 * pre_move1base);
62                next.shoulder_r.position += Vec3::new(-2.0, 8.0, 0.0) * pre_move1base;
63                next.shoulder_r
64                    .orientation
65                    .rotate_z(PI / 5.0 * pre_move1base);
66                next.control.position +=
67                    Vec3::new(-15.0 * pre_move1base, 0.0, 25.0 * pre_move1base);
68                next.control.orientation.rotate_x(PI / 2.5 * pre_move1);
69                next.leg_l.position += Vec3::new(0.0, -2.5, 0.0) * pre_move1base;
70                next.leg_l.orientation.rotate_x(-PI / 8.0 * pre_move1base);
71                next.foot_l.position += Vec3::new(0.0, -5.0, 0.0) * pre_move1base;
72                next.foot_l.orientation.rotate_z(PI / 4.0 * pre_move1base);
73
74                next.torso.orientation.rotate_z(-PI / 8.0 * move1base);
75                next.control.orientation.rotate_z(2.0 * PI * move1base);
76                next.leg_l.position += Vec3::new(0.0, 2.5, 0.0) * move1base;
77                next.leg_l.orientation.rotate_x(PI / 8.0 * move1base);
78                next.foot_l.position += Vec3::new(0.0, 5.0, 0.0) * move1base;
79
80                next.torso.position += Vec3::new(0.0, -10.0, 0.0) * move2;
81                next.torso.orientation.rotate_z(-PI / 8.0 * move2);
82                next.torso.orientation.rotate_x(-PI / 8.0 * move2);
83                next.lower_torso.orientation.rotate_z(PI / 8.0 * move2);
84                next.lower_torso.orientation.rotate_x(PI / 8.0 * move2);
85                next.torso.position += Vec3::new(0.0, 0.0, 1.5) * move2;
86                next.shoulder_l.orientation.rotate_x(-PI / 3.0 * move2base);
87                next.shoulder_l.orientation.rotate_z(-PI / 4.0 * move2);
88                next.shoulder_r.position += Vec3::new(2.0, -8.0, 0.0) * move2base;
89                next.shoulder_r.orientation.rotate_z(-PI / 5.0 * move2base);
90                next.shoulder_r.orientation.rotate_x(-PI / 3.0 * move2base);
91                next.control.position +=
92                    Vec3::new(15.0 * move2base, 0.0, -25.0 * move2base - 20.0 * move2);
93                next.control.orientation.rotate_x(-PI * move2);
94                next.leg_l.position += Vec3::new(0.0, 1.0, 0.0) * move2;
95                next.foot_l.position += Vec3::new(0.0, 2.5, 0.0) * move2;
96                next.foot_l.orientation.rotate_z(-PI / 4.0 * move2base);
97            },
98            _ => {},
99        }
100
101        next
102    }
103}