2020-10-21 04:59:11 +00:00
|
|
|
use super::{
|
|
|
|
super::{vek::*, Animation},
|
|
|
|
CharacterSkeleton, SkeletonAttr,
|
|
|
|
};
|
2020-10-25 19:28:38 +00:00
|
|
|
use common::comp::item::ToolKind;
|
2021-07-18 00:31:13 +00:00
|
|
|
use core::f32::consts::PI;
|
2020-03-24 04:24:31 +00:00
|
|
|
|
|
|
|
pub struct EquipAnimation;
|
|
|
|
|
|
|
|
impl Animation for EquipAnimation {
|
2021-04-30 20:06:03 +00:00
|
|
|
type Dependency<'a> = (Option<ToolKind>, Option<ToolKind>, f32, f32);
|
2020-03-24 04:24:31 +00:00
|
|
|
type Skeleton = CharacterSkeleton;
|
|
|
|
|
2020-06-19 03:33:30 +00:00
|
|
|
#[cfg(feature = "use-dyn-lib")]
|
|
|
|
const UPDATE_FN: &'static [u8] = b"character_equip\0";
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_equip")]
|
2022-11-28 13:46:35 +00:00
|
|
|
fn update_skeleton_inner(
|
2020-03-24 04:24:31 +00:00
|
|
|
skeleton: &Self::Skeleton,
|
2022-11-28 13:46:35 +00:00
|
|
|
(active_tool_kind, _second_tool_kind, _velocity, _global_time): Self::Dependency<'_>,
|
2021-02-27 22:21:03 +00:00
|
|
|
anim_time: f32,
|
2020-03-25 04:15:06 +00:00
|
|
|
rate: &mut f32,
|
2020-10-24 18:54:36 +00:00
|
|
|
_s_a: &SkeletonAttr,
|
2020-03-24 04:24:31 +00:00
|
|
|
) -> Self::Skeleton {
|
2020-03-25 04:15:06 +00:00
|
|
|
*rate = 1.0;
|
2020-03-24 04:24:31 +00:00
|
|
|
let mut next = (*skeleton).clone();
|
2021-02-27 22:21:03 +00:00
|
|
|
let equip_slow = 1.0 + (anim_time * 12.0 + PI).cos();
|
2021-07-17 22:04:59 +00:00
|
|
|
let equip_slowa = 1.0 + (anim_time * 12.0 + PI / 4.0).cos();
|
2021-07-18 00:31:13 +00:00
|
|
|
next.hand_l.orientation = Quaternion::rotation_y(-2.3) * Quaternion::rotation_z(PI / 2.0);
|
|
|
|
next.hand_r.orientation = Quaternion::rotation_y(-2.3) * Quaternion::rotation_z(PI / 2.0);
|
2020-10-24 18:54:36 +00:00
|
|
|
next.control.position = Vec3::new(equip_slowa * -1.5, 0.0, equip_slow * 1.5);
|
2020-03-24 04:24:31 +00:00
|
|
|
|
|
|
|
match active_tool_kind {
|
2020-11-06 17:39:49 +00:00
|
|
|
Some(ToolKind::Sword) => {
|
2020-10-24 18:54:36 +00:00
|
|
|
next.hand_l.position = Vec3::new(-8.0, -5.0, 17.0);
|
|
|
|
next.hand_r.position = Vec3::new(-6.0, -4.5, 14.0);
|
2020-03-24 04:24:31 +00:00
|
|
|
},
|
2020-11-06 17:39:49 +00:00
|
|
|
Some(ToolKind::Axe) => {
|
2020-10-24 18:54:36 +00:00
|
|
|
next.hand_l.position = Vec3::new(-7.0, -5.0, 17.0);
|
|
|
|
next.hand_r.position = Vec3::new(-5.0, -4.5, 14.0);
|
2020-03-24 04:24:31 +00:00
|
|
|
},
|
2021-03-21 16:09:16 +00:00
|
|
|
Some(ToolKind::Hammer | ToolKind::Pick) => {
|
2020-10-24 18:54:36 +00:00
|
|
|
next.hand_l.position = Vec3::new(-5.0, -5.0, 13.0);
|
|
|
|
next.hand_r.position = Vec3::new(-3.0, -4.5, 10.0);
|
2020-03-24 04:24:31 +00:00
|
|
|
},
|
2020-11-06 17:39:49 +00:00
|
|
|
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
|
2020-10-24 18:54:36 +00:00
|
|
|
next.hand_l.position = Vec3::new(-3.0, -5.0, 8.0);
|
|
|
|
next.hand_r.position = Vec3::new(-1.75, -4.5, 5.0);
|
2020-03-24 04:24:31 +00:00
|
|
|
},
|
2020-11-06 17:39:49 +00:00
|
|
|
Some(ToolKind::Bow) => {
|
2020-10-24 18:54:36 +00:00
|
|
|
next.hand_l.position = Vec3::new(-3.0, -5.0, 9.0);
|
|
|
|
next.hand_r.position = Vec3::new(-1.75, -4.5, 7.0);
|
2020-03-24 04:24:31 +00:00
|
|
|
},
|
2022-08-28 18:48:18 +00:00
|
|
|
Some(ToolKind::Instrument) => {
|
|
|
|
next.hand_l.position = Vec3::new(-5.0, -5.0, 8.0);
|
|
|
|
},
|
2020-03-24 04:24:31 +00:00
|
|
|
_ => {},
|
|
|
|
}
|
2020-07-01 09:51:06 +00:00
|
|
|
|
2020-03-25 05:22:07 +00:00
|
|
|
next
|
2020-03-24 04:24:31 +00:00
|
|
|
}
|
|
|
|
}
|