veloren_voxygen_anim/crustacean/
combomelee.rs

1use super::{
2    super::{Animation, vek::*},
3    CrustaceanSkeleton, SkeletonAttr,
4};
5use common::states::utils::{AbilityInfo, StageSection};
6
7pub struct ComboAnimation;
8impl Animation for ComboAnimation {
9    type Dependency<'a> = (
10        Option<&'a str>,
11        Option<StageSection>,
12        Option<AbilityInfo>,
13        usize,
14        f32,
15        Vec3<f32>,
16        f32,
17    );
18    type Skeleton = CrustaceanSkeleton;
19
20    #[cfg(feature = "use-dyn-lib")]
21    const UPDATE_FN: &'static [u8] = b"crustacean_combo\0";
22
23    #[cfg_attr(feature = "be-dyn-lib", export_name = "crustacean_combo")]
24    fn update_skeleton_inner(
25        skeleton: &Self::Skeleton,
26        (ability_id, stage_section, _ability_info, current_strike, global_time, velocity, timer): Self::Dependency<'_>,
27        anim_time: f32,
28        rate: &mut f32,
29        _s_a: &SkeletonAttr,
30    ) -> Self::Skeleton {
31        *rate = 1.0;
32        let mut next = (*skeleton).clone();
33
34        let multi_strike_pullback = 1.0
35            - if matches!(stage_section, Some(StageSection::Recover)) {
36                anim_time.powi(4)
37            } else {
38                0.0
39            };
40        for strike in 0..=current_strike {
41            match ability_id {
42                Some("common.abilities.custom.crab.triplestrike") => {
43                    let (movement1base, movement2base, movement3) = match stage_section {
44                        Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0),
45                        Some(StageSection::Action) => (1.0, anim_time.powi(4), 0.0),
46                        Some(StageSection::Recover) => (1.0, 1.0, anim_time),
47                        _ => (0.0, 0.0, 0.0),
48                    };
49                    let pullback = multi_strike_pullback;
50                    let subtract = global_time - timer;
51                    let check = subtract - subtract.trunc();
52                    let mirror = (check - 0.5).signum();
53                    let twitch3 = (mirror * movement3 * 9.0).sin();
54                    let _movement1 = mirror * movement1base * pullback;
55                    let _movement2 = mirror * movement2base * pullback;
56                    let movement1abs = movement1base * pullback;
57                    let movement2abs = movement2base * pullback;
58                    let mirror_var = if strike == 1 { -mirror } else { mirror };
59                    if velocity.xy().magnitude() > 0.1 {
60                        next.chest.orientation = Quaternion::rotation_z(0.0);
61                    }
62
63                    next.chest.orientation = Quaternion::rotation_x(
64                        movement1abs * 0.3 + movement2abs * -0.2 + (twitch3 / 5.0),
65                    );
66                    next.arm_r.orientation =
67                        Quaternion::rotation_z(movement1abs * -0.8 + movement2abs * 1.0)
68                            * Quaternion::rotation_x(movement1abs * 0.4 + movement2abs * 0.3);
69                    next.arm_r.position = Vec3::new(
70                        0.0,
71                        7.0 * movement1abs - 3.0 * movement2abs,
72                        -0.8 * mirror_var,
73                    );
74                    next.pincer_r1.position =
75                        Vec3::new(0.0, -3.0 * movement1abs + 4.0 * movement2abs, 0.0);
76
77                    next.arm_l.orientation =
78                        Quaternion::rotation_z(movement1abs * 0.8 + movement2abs * -1.0)
79                            * Quaternion::rotation_x(movement1abs * 0.4 + movement2abs * 0.3);
80                    next.arm_l.position = Vec3::new(
81                        0.0,
82                        7.0 * movement1abs - 3.0 * movement2abs,
83                        0.8 * mirror_var,
84                    );
85                    next.pincer_l1.position =
86                        Vec3::new(0.0, -3.0 * movement1abs + 4.0 * movement2abs, 0.0);
87                },
88                Some("common.abilities.custom.karkatha.triplestrike") => {
89                    let (movement1base, movement2base, movement3) = match stage_section {
90                        Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0),
91                        Some(StageSection::Action) => (1.0, anim_time.powi(4), 0.0),
92                        Some(StageSection::Recover) => (1.0, 1.0, anim_time),
93                        _ => (0.0, 0.0, 0.0),
94                    };
95                    let pullback = multi_strike_pullback;
96                    let subtract = global_time - timer;
97                    let check = subtract - subtract.trunc();
98                    let mirror = (check - 0.5).signum();
99                    let twitch3 = (mirror * movement3 * 9.0).sin();
100                    let _movement1 = mirror * movement1base * pullback;
101                    let _movement2 = mirror * movement2base * pullback;
102                    let movement1abs = movement1base * pullback;
103                    let movement2abs = movement2base * pullback;
104                    if velocity.xy().magnitude() > 0.1 {
105                        next.chest.orientation = Quaternion::rotation_z(0.0);
106                    }
107
108                    next.chest.orientation = Quaternion::rotation_x(
109                        movement1abs * 0.3 + movement2abs * -0.2 + (twitch3 / 5.0),
110                    );
111                    if mirror < 0.0 {
112                        next.arm_r.orientation =
113                            Quaternion::rotation_z(movement1abs * 0.6 + movement2abs * -1.8);
114
115                        next.pincer_r1.position =
116                            Vec3::new(0.0, -3.0 * movement1abs + 4.0 * movement2abs, 4.0);
117                        next.pincer_r1.orientation =
118                            Quaternion::rotation_x(movement1abs * -0.4 + movement2abs * 0.3);
119                    } else {
120                        next.arm_l.orientation =
121                            Quaternion::rotation_z(movement1abs * -0.6 + movement2abs * 1.6);
122                        next.pincer_l1.position =
123                            Vec3::new(0.0, -3.0 * movement1abs + 4.0 * movement2abs, 4.0);
124                        next.pincer_l1.orientation =
125                            Quaternion::rotation_x(movement1abs * -0.4 + movement2abs * 0.3);
126                        next.pincer_l0.position = Vec3::new(0.0, -4.0, 0.0);
127                        next.pincer_l0.orientation =
128                            Quaternion::rotation_x(movement1abs * 0.4 + movement2abs * -0.6);
129                    }
130                },
131                _ => {},
132            }
133        }
134        next
135    }
136}