veloren_voxygen_anim/biped_large/
beta.rs1use super::{
2 super::{Animation, vek::*},
3 BipedLargeSkeleton, SkeletonAttr, biped_large_beta_axe, biped_large_beta_hammer,
4 biped_large_beta_sword, init_biped_large_beta,
5};
6use common::{
7 comp::item::tool::{AbilitySpec, ToolKind},
8 states::utils::StageSection,
9};
10use std::f32::consts::PI;
11
12pub struct BetaAnimation;
13
14impl Animation for BetaAnimation {
15 type Dependency<'a> = (
16 Option<ToolKind>,
17 (Option<ToolKind>, Option<&'a AbilitySpec>),
18 Vec3<f32>,
19 f32,
20 Option<StageSection>,
21 f32,
22 Option<&'a str>,
23 );
24 type Skeleton = BipedLargeSkeleton;
25
26 #[cfg(feature = "use-dyn-lib")]
27 const UPDATE_FN: &'static [u8] = b"biped_large_beta\0";
28
29 #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_beta")]
30 fn update_skeleton_inner(
31 skeleton: &Self::Skeleton,
32 (
33 active_tool_kind,
34 _second_tool,
35 velocity,
36 _global_time,
37 stage_section,
38 acc_vel,
39 ability_id,
40 ): Self::Dependency<'_>,
41 anim_time: f32,
42 rate: &mut f32,
43 s_a: &SkeletonAttr,
44 ) -> Self::Skeleton {
45 *rate = 1.0;
46 let mut next = (*skeleton).clone();
47
48 let (move1base, move2base, move3) = match stage_section {
49 Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0),
50 Some(StageSection::Action) => (1.0, anim_time, 0.0),
51 Some(StageSection::Recover) => (1.0, 1.0, anim_time.powi(6)),
52 _ => (0.0, 0.0, 0.0),
53 };
54 let pullback = 1.0 - move3;
55 let move1 = move1base * pullback;
56 let move2 = move2base * pullback;
57
58 let speed = Vec2::<f32>::from(velocity).magnitude();
59
60 init_biped_large_beta(&mut next, s_a, speed, acc_vel, move1);
61
62 match active_tool_kind {
63 Some(ToolKind::Sword) => {
64 biped_large_beta_sword(&mut next, s_a, move1base, move1, move2);
65 },
66 Some(ToolKind::Hammer) => {
67 biped_large_beta_hammer(&mut next, s_a, move1, move2);
68 },
69 Some(ToolKind::Axe) => {
70 biped_large_beta_axe(&mut next, s_a, move1, move2);
71 },
72 Some(ToolKind::Natural) => match ability_id {
73 Some("common.abilities.custom.wendigomagic.singlestrike") => {
74 next.torso.position = Vec3::new(0.0, 0.0, move1 * -2.18);
75 next.upper_torso.orientation =
76 Quaternion::rotation_x(move1 * -0.5 + move2 * -0.4);
77 next.lower_torso.orientation =
78 Quaternion::rotation_x(move1 * 0.5 + move2 * 0.4);
79
80 next.control_l.position =
81 Vec3::new(-9.0 + move2 * 6.0, 19.0 + move1 * 6.0, -13.0 + move1 * 10.5);
82 next.control_r.position =
83 Vec3::new(9.0 + move2 * -6.0, 19.0 + move1 * 6.0, -13.0 + move1 * 14.5);
84
85 next.control_l.orientation = Quaternion::rotation_x(PI / 3.0 + move1 * 0.5)
86 * Quaternion::rotation_y(-0.15)
87 * Quaternion::rotation_z(move1 * 0.5 + move2 * -0.6);
88 next.control_r.orientation = Quaternion::rotation_x(PI / 3.0 + move1 * 0.5)
89 * Quaternion::rotation_y(0.15)
90 * Quaternion::rotation_z(move1 * -0.5 + move2 * 0.6);
91 next.head.orientation = Quaternion::rotation_x(move1 * 0.3);
92 },
93 _ => {},
94 },
95 _ => {},
96 }
97 next
98 }
99}