veloren_voxygen_anim/biped_large/
equip.rs

1use super::{
2    super::{Animation, vek::*},
3    BipedLargeSkeleton, SkeletonAttr,
4};
5use common::comp::item::ToolKind;
6use core::f32::consts::PI;
7
8pub struct EquipAnimation;
9
10impl Animation for EquipAnimation {
11    type Dependency<'a> = (Option<ToolKind>, Option<ToolKind>, f32, f32);
12    type Skeleton = BipedLargeSkeleton;
13
14    #[cfg(feature = "use-dyn-lib")]
15    const UPDATE_FN: &'static [u8] = b"biped_large_equip\0";
16
17    #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_equip")]
18    fn update_skeleton_inner(
19        skeleton: &Self::Skeleton,
20        (active_tool_kind, _second_tool_kind, _velocity, _global_time): 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 equip_slow = 1.0 + (anim_time * 12.0 + PI).cos();
29        let equip_slowa = 1.0 + (anim_time * 12.0 + PI / 4.0).cos();
30        next.hand_l.orientation = Quaternion::rotation_y(-2.3) * Quaternion::rotation_z(-PI / 2.0);
31        next.hand_r.orientation = Quaternion::rotation_y(-2.3) * Quaternion::rotation_z(PI / 2.0);
32        next.control.position = Vec3::new(equip_slowa * -1.5, 0.0, equip_slow * 1.5);
33
34        match active_tool_kind {
35            Some(ToolKind::Sword) => {
36                next.hand_l.position = Vec3::new(-18.0, -8.0, -1.0);
37                next.hand_r.position = Vec3::new(-16.0, -7.5, -4.0);
38            },
39            Some(ToolKind::Axe) => {
40                next.hand_l.position = Vec3::new(-7.0, -5.0, 17.0);
41                next.hand_r.position = Vec3::new(-5.0, -4.5, 14.0);
42            },
43            Some(ToolKind::Hammer) => {
44                next.hand_l.position = Vec3::new(-15.0, -7.0, 3.0);
45                next.hand_r.position = Vec3::new(-13.0, -6.5, 0.0);
46            },
47            Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
48                next.hand_l.position = Vec3::new(4.0, -6.0, 0.0);
49                next.hand_r.position = Vec3::new(6.0, -6.0, 6.0);
50                next.hand_l.orientation =
51                    Quaternion::rotation_y(2.2) * Quaternion::rotation_z(PI / 2.0);
52                next.hand_r.orientation =
53                    Quaternion::rotation_y(2.2) * Quaternion::rotation_z(-PI / 2.0);
54            },
55            Some(ToolKind::Bow) => {
56                next.hand_l.position = Vec3::new(-9.0, -5.0, -8.0);
57                next.hand_r.position = Vec3::new(-7.75, -4.5, -10.0);
58            },
59            _ => {},
60        }
61        next
62    }
63}