use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; use common::comp::item::Tool; use vek::*; pub struct WieldAnimation; impl Animation for WieldAnimation { type Skeleton = CharacterSkeleton; type Dependency = (Option, f32, f64); fn update_skeleton( skeleton: &Self::Skeleton, (active_tool_kind, _velocity, _global_time): Self::Dependency, anim_time: f64, _rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); let wave = (anim_time as f32 * 12.0).sin(); match active_tool_kind { //TODO: Inventory Some(Tool::Sword) => { next.l_hand.offset = Vec3::new(-6.0, 3.75, 0.25); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); next.r_hand.ori = Quaternion::rotation_x(-0.3); next.r_hand.scale = Vec3::one() * 1.01; next.weapon.offset = Vec3::new( -6.0 + skeleton_attr.weapon_x, 4.0 + skeleton_attr.weapon_y, 0.0, ); next.weapon.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.weapon.scale = Vec3::one(); } Some(Tool::Axe) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); next.r_hand.ori = Quaternion::rotation_x(-0.3); next.r_hand.scale = Vec3::one() * 1.01; next.weapon.offset = Vec3::new( -6.0 + skeleton_attr.weapon_x, 4.5 + skeleton_attr.weapon_y, 0.0, ); next.weapon.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.weapon.scale = Vec3::one(); } Some(Tool::Hammer) => { next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.l_hand.scale = Vec3::one() * 1.01; next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25); next.r_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(-0.3); next.r_hand.scale = Vec3::one() * 1.01; next.weapon.offset = Vec3::new( 5.0 + skeleton_attr.weapon_x, 8.75 + skeleton_attr.weapon_y, -2.0, ); next.weapon.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(-1.27) * Quaternion::rotation_z(wave * -0.25); next.weapon.scale = Vec3::one(); } Some(Tool::Staff) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); next.r_hand.ori = Quaternion::rotation_x(-0.3); next.r_hand.scale = Vec3::one() * 1.01; next.weapon.offset = Vec3::new( -6.0 + skeleton_attr.weapon_x, 4.5 + skeleton_attr.weapon_y, 0.0, ); next.weapon.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.weapon.scale = Vec3::one(); } Some(Tool::Shield) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); next.r_hand.ori = Quaternion::rotation_x(-0.3); next.r_hand.scale = Vec3::one() * 1.01; next.weapon.offset = Vec3::new( -6.0 + skeleton_attr.weapon_x, 4.5 + skeleton_attr.weapon_y, 0.0, ); next.weapon.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.weapon.scale = Vec3::one(); } Some(Tool::Bow) => { next.l_hand.offset = Vec3::new(-4.0, 5.0, 0.0); next.l_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(-1.9) * Quaternion::rotation_z(0.85); next.l_hand.scale = Vec3::one() * 1.01; next.r_hand.offset = Vec3::new(2.0, 8.0, -3.5); next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(-1.7) * Quaternion::rotation_z(0.85); next.r_hand.scale = Vec3::one() * 1.01; next.weapon.offset = Vec3::new( 9.0 + skeleton_attr.weapon_x, 10.0 + skeleton_attr.weapon_y, -3.0, ); next.weapon.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(-1.7) * Quaternion::rotation_z(0.85); next.weapon.scale = Vec3::one(); } Some(Tool::Dagger) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); next.r_hand.ori = Quaternion::rotation_x(-0.3); next.r_hand.scale = Vec3::one() * 1.01; next.weapon.offset = Vec3::new( -6.0 + skeleton_attr.weapon_x, 4.5 + skeleton_attr.weapon_y, 0.0, ); next.weapon.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.weapon.scale = Vec3::one(); } Some(Tool::Debug(_)) => { next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.l_hand.scale = Vec3::one() * 1.01; next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25); next.r_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(-0.3); next.r_hand.scale = Vec3::one() * 1.01; next.weapon.offset = Vec3::new( 5.0 + skeleton_attr.weapon_x, 8.75 + skeleton_attr.weapon_y, -2.0, ); next.weapon.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(-1.27) * Quaternion::rotation_z(wave * -0.25); next.weapon.scale = Vec3::one(); } _ => {} } next } }