veloren_voxygen_anim/golem/
shoot.rs1use super::{
2 super::{Animation, vek::*},
3 GolemSkeleton, SkeletonAttr,
4};
5use common::{states::utils::StageSection, util::Dir};
6use core::f32::consts::PI;
7
8pub struct ShootAnimation;
9
10impl Animation for ShootAnimation {
11 type Dependency<'a> = (Option<StageSection>, f32, f32, Dir, Option<&'a str>);
12 type Skeleton = GolemSkeleton;
13
14 #[cfg(feature = "use-dyn-lib")]
15 const UPDATE_FN: &'static [u8] = b"golem_shoot\0";
16
17 #[cfg_attr(feature = "be-dyn-lib", export_name = "golem_shoot")]
18
19 fn update_skeleton_inner(
20 skeleton: &Self::Skeleton,
21 (stage_section, _global_time, _timer, look_dir, ability_id): Self::Dependency<'_>,
22 anim_time: f32,
23 _rate: &mut f32,
24 _s_a: &SkeletonAttr,
25 ) -> Self::Skeleton {
26 let mut next = (*skeleton).clone();
27
28 let (move1base, move2base, move3) = match stage_section {
29 Some(StageSection::Buildup) => (anim_time.powf(0.4), 0.0, 0.0),
30 Some(StageSection::Action) => (1.0, anim_time, 0.0),
31 Some(StageSection::Recover) => (1.0, 1.0, anim_time.powf(4.0)),
32 _ => (0.0, 0.0, 0.0),
33 };
34
35 if let Some("common.abilities.custom.ancienteffigy.blast") = ability_id {
37 next.upper_torso.scale = Vec3::one() * (1.0 - move1base);
38 }
39
40 let pullback = 1.0 - move3;
41
42 let move1 = move1base * pullback;
43 let move2 = move2base * pullback;
44
45 next.head.orientation = Quaternion::rotation_x(-0.2) * Quaternion::rotation_z(move1 * -0.5);
46
47 next.upper_torso.orientation =
48 Quaternion::rotation_x(0.0) * Quaternion::rotation_z(move1 * 0.5);
49
50 next.lower_torso.orientation =
51 Quaternion::rotation_z(move1 * -0.5) * Quaternion::rotation_x(0.0);
52
53 next.shoulder_l.orientation =
54 Quaternion::rotation_y(0.0) * Quaternion::rotation_z(move1 * 0.7);
55
56 next.shoulder_r.orientation = Quaternion::rotation_x(move1 * (look_dir.z * 1.2 + PI / 2.0))
57 * Quaternion::rotation_y(move1 * 0.0);
58
59 next.hand_l.orientation =
60 Quaternion::rotation_z(move1 * -0.3) * Quaternion::rotation_x(move1 * 1.3);
61
62 next.hand_r.orientation = Quaternion::rotation_y(move1 * -0.3)
63 * Quaternion::rotation_z(move1 * -0.9 + move2 * -1.6);
64
65 next.torso.position = Vec3::new(0.0, 0.0, 0.0);
66 next
67 }
68}