Make character anims conditional by Tool held

This commit is contained in:
Adam Whitehurst 2019-11-10 15:36:47 -08:00
parent 5fe1eecf1f
commit 64a0d8d91f
17 changed files with 114 additions and 107 deletions

View File

@ -2,6 +2,7 @@ use super::{
super::{Animation, SkeletonAttr},
CharacterSkeleton,
};
use common::comp::item::Tool;
use std::f32::consts::PI;
use vek::*;
@ -12,11 +13,11 @@ pub struct AttackAnimation;
impl Animation for AttackAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = f64;
type Dependency = (Option<Tool>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
_global_time: f64,
(_active_tool_kind, _global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,

View File

@ -13,11 +13,11 @@ pub struct BlockAnimation;
impl Animation for BlockAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = f64;
type Dependency = (Option<Tool>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
global_time: f64,
(active_tool_kind, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
@ -63,9 +63,9 @@ impl Animation for BlockAnimation {
next.shorts.ori = Quaternion::rotation_x(0.1);
next.shorts.scale = Vec3::one();
match Tool::Hammer {
match active_tool_kind {
//TODO: Inventory
Tool::Sword => {
Some(Tool::Sword) => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0 + wave_ultra_slow * 1.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
@ -82,7 +82,7 @@ impl Animation for BlockAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Axe => {
Some(Tool::Axe) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -107,7 +107,7 @@ impl Animation for BlockAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Hammer => {
Some(Tool::Hammer) => {
next.l_hand.offset = Vec3::new(-7.0, 3.5, 6.5);
next.l_hand.ori = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
@ -128,7 +128,7 @@ impl Animation for BlockAnimation {
* Quaternion::rotation_z(-0.85);
next.weapon.scale = Vec3::one();
}
Tool::Staff => {
Some(Tool::Staff) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -153,7 +153,7 @@ impl Animation for BlockAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Shield => {
Some(Tool::Shield) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -178,7 +178,7 @@ impl Animation for BlockAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Bow => {
Some(Tool::Bow) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -203,7 +203,7 @@ impl Animation for BlockAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Dagger => {
Some(Tool::Dagger) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -224,7 +224,7 @@ impl Animation for BlockAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Debug(_) => {
Some(Tool::Debug(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 3.5, 6.5);
next.l_hand.ori = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
@ -245,6 +245,7 @@ impl Animation for BlockAnimation {
* Quaternion::rotation_z(-0.85);
next.weapon.scale = Vec3::one();
}
_ => {}
}
//next.l_foot.offset = Vec3::new(-3.4, 0.3, 8.0 + wave_ultra_slow_cos * 0.1);
//next.l_foot.ori = Quaternion::rotation_x(-0.3);

View File

@ -13,11 +13,11 @@ pub struct BlockIdleAnimation;
impl Animation for BlockIdleAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = f64;
type Dependency = (Option<Tool>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
global_time: f64,
(active_tool_kind, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
@ -62,9 +62,9 @@ impl Animation for BlockIdleAnimation {
next.shorts.ori = Quaternion::rotation_x(0.1);
next.shorts.scale = Vec3::one();
match Tool::Hammer {
match active_tool_kind {
//TODO: Inventory
Tool::Sword => {
Some(Tool::Sword) => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0 + wave_ultra_slow * 1.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
@ -81,7 +81,7 @@ impl Animation for BlockIdleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Axe => {
Some(Tool::Axe) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -106,7 +106,7 @@ impl Animation for BlockIdleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Hammer => {
Some(Tool::Hammer) => {
next.l_hand.offset = Vec3::new(-7.0, 3.5 + wave_ultra_slow * 2.0, 6.5);
next.l_hand.ori = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
@ -127,7 +127,7 @@ impl Animation for BlockIdleAnimation {
* Quaternion::rotation_z(-0.85);
next.weapon.scale = Vec3::one();
}
Tool::Staff => {
Some(Tool::Staff) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -152,7 +152,7 @@ impl Animation for BlockIdleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Shield => {
Some(Tool::Shield) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -177,7 +177,7 @@ impl Animation for BlockIdleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Bow => {
Some(Tool::Bow) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -202,7 +202,7 @@ impl Animation for BlockIdleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Dagger => {
Some(Tool::Dagger) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -223,7 +223,7 @@ impl Animation for BlockIdleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Debug(_) => {
Some(Tool::Debug(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 3.5 + wave_ultra_slow * 2.0, 6.5);
next.l_hand.ori = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
@ -244,6 +244,7 @@ impl Animation for BlockIdleAnimation {
* Quaternion::rotation_z(-0.85);
next.weapon.scale = Vec3::one();
}
_ => {}
}
next.l_foot.offset = Vec3::new(-3.4, 0.3, 8.0 + wave_ultra_slow_cos * 0.1);
next.l_foot.ori = Quaternion::rotation_x(-0.3);

View File

@ -2,6 +2,7 @@ use super::{
super::{Animation, SkeletonAttr},
CharacterSkeleton,
};
use common::comp::item::Tool;
use std::{f32::consts::PI, ops::Mul};
use vek::*;
@ -13,11 +14,11 @@ pub struct CidleAnimation;
impl Animation for CidleAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = f64;
type Dependency = (Option<Tool>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
global_time: f64,
(active_tool_kind, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
@ -62,9 +63,9 @@ impl Animation for CidleAnimation {
next.shorts.ori = Quaternion::rotation_x(0.0);
next.shorts.scale = Vec3::one();
match Tool::Bow {
match active_tool_kind {
//TODO: Inventory
Tool::Sword => {
Some(Tool::Sword) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -89,7 +90,7 @@ impl Animation for CidleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Axe => {
Some(Tool::Axe) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -114,7 +115,7 @@ impl Animation for CidleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Hammer => {
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_ultra_slow * -0.1)
* Quaternion::rotation_y(0.0)
@ -135,7 +136,7 @@ impl Animation for CidleAnimation {
* Quaternion::rotation_z(wave_ultra_slow * 0.2);
next.weapon.scale = Vec3::one();
}
Tool::Staff => {
Some(Tool::Staff) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -160,7 +161,7 @@ impl Animation for CidleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Shield => {
Some(Tool::Shield) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -185,7 +186,7 @@ impl Animation for CidleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Bow => {
Some(Tool::Bow) => {
next.l_hand.offset = Vec3::new(
-4.0 + wave_ultra_slow_cos * 1.0,
5.0 + wave_ultra_slow_cos * 0.5,
@ -214,7 +215,7 @@ impl Animation for CidleAnimation {
* Quaternion::rotation_z(0.85);
next.weapon.scale = Vec3::one();
}
Tool::Dagger => {
Some(Tool::Dagger) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
@ -235,7 +236,7 @@ impl Animation for CidleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Debug(_) => {
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_ultra_slow * -0.1)
* Quaternion::rotation_y(0.0)
@ -256,6 +257,7 @@ impl Animation for CidleAnimation {
* Quaternion::rotation_z(wave_ultra_slow * 0.2);
next.weapon.scale = Vec3::one();
}
_ => {}
}
next.l_foot.offset = Vec3::new(-3.4, -1.5, 8.0 + wave_slow * 0.2);
next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.015);

View File

@ -2,17 +2,18 @@ use super::{
super::{Animation, SkeletonAttr},
CharacterSkeleton,
};
use common::comp::item::Tool;
use vek::*;
pub struct ClimbAnimation;
impl Animation for ClimbAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = (Vec3<f32>, Vec3<f32>, f64);
type Dependency = (Option<Tool>, Vec3<f32>, Vec3<f32>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
(velocity, _orientation, _global_time): Self::Dependency,
(_active_tool_kind, velocity, _orientation, _global_time): Self::Dependency,
anim_time: f64,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,

View File

@ -9,7 +9,7 @@ use vek::*;
pub struct WieldAnimation;
impl Animation for WieldAnimation {
impl Animation<'_>for WieldAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = (f32, f64);
@ -133,20 +133,12 @@ impl Animation for WieldAnimation {
next.weapon.scale = Vec3::one();
}
Tool::Bow => {
next.l_hand.offset = Vec3::new(
-4.0,
5.0,
0.0,
);
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.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);
@ -158,7 +150,7 @@ impl Animation for WieldAnimation {
);
next.weapon.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.7)
* Quaternion::rotation_z(0.85+3.14);
* Quaternion::rotation_z(0.85 + 3.14);
next.weapon.scale = Vec3::one();
}
Tool::Daggers => {

View File

@ -2,6 +2,7 @@ use super::{
super::{Animation, SkeletonAttr},
CharacterSkeleton,
};
use common::comp::item::Tool;
use std::{f32::consts::PI, ops::Mul};
use vek::*;
@ -9,11 +10,11 @@ pub struct GlidingAnimation;
impl Animation for GlidingAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
type Dependency = (Option<Tool>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
(velocity, orientation, last_ori, global_time): Self::Dependency,
(_active_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,

View File

@ -2,6 +2,7 @@ use super::{
super::{Animation, SkeletonAttr},
CharacterSkeleton,
};
use common::comp::item::Tool;
use std::f32::consts::PI;
use vek::*;
@ -9,11 +10,11 @@ pub struct JumpAnimation;
impl Animation for JumpAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = f64;
type Dependency = (Option<Tool>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
_global_time: f64,
(_active_tool_kind, _global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,

View File

@ -2,6 +2,7 @@ use super::{
super::{Animation, SkeletonAttr},
CharacterSkeleton,
};
use common::comp::item::Tool;
use std::f32::consts::PI;
use vek::*;
@ -9,11 +10,11 @@ pub struct RollAnimation;
impl Animation for RollAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = f64;
type Dependency = (Option<Tool>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
_global_time: f64,
(_active_tool_kind, _global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,

View File

@ -8,7 +8,7 @@ use vek::*;
pub struct SneakAnimation;
impl Animation for SneakAnimation {
impl Animation<'_>for SneakAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);

View File

@ -2,6 +2,7 @@ use super::{
super::{Animation, SkeletonAttr},
CharacterSkeleton,
};
use common::comp::item::Tool;
use std::f32::consts::PI;
use std::ops::Mul;
use vek::*;
@ -10,11 +11,11 @@ pub struct RunAnimation;
impl Animation for RunAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
type Dependency = (Option<Tool>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
(velocity, orientation, last_ori, global_time): Self::Dependency,
(_active_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
anim_time: f64,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,

View File

@ -2,6 +2,7 @@ use super::{
super::{Animation, SkeletonAttr},
CharacterSkeleton,
};
use common::comp::item::Tool;
use std::{f32::consts::PI, ops::Mul};
use vek::*;
@ -9,11 +10,11 @@ pub struct SitAnimation;
impl Animation for SitAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = f64;
type Dependency = (Option<Tool>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
global_time: f64,
(_active_tool_kind, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,

View File

@ -8,7 +8,7 @@ use vek::*;
pub struct SneakAnimation;
impl Animation for SneakAnimation {
impl Animation<'_>for SneakAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
@ -45,12 +45,12 @@ impl Animation for SneakAnimation {
let wave_diff = (anim_time as f32 * 0.6).sin();
let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0).sin();
let head_look = Vec2::new(
((global_time + anim_time) as f32 *0.25)
((global_time + anim_time) as f32 * 0.25)
.floor()
.mul(7331.0)
.sin()
* 0.4,
((global_time + anim_time) as f32 *0.25)
((global_time + anim_time) as f32 * 0.25)
.floor()
.mul(1337.0)
.sin()
@ -81,7 +81,7 @@ impl Animation for SneakAnimation {
* Quaternion::rotation_x(head_look.y + 0.05);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, -1.5, 3.0 +wave_slow * 2.0);
next.chest.offset = Vec3::new(0.0, -1.5, 3.0 + wave_slow * 2.0);
next.chest.ori = Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(wave * 0.15);
next.chest.scale = Vec3::one();
@ -90,32 +90,24 @@ impl Animation for SneakAnimation {
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 1.0, -1.0 + wave_cos * 0.3);
next.shorts.ori = Quaternion::rotation_x(0.2) *Quaternion::rotation_z(wave * 0.4);
next.shorts.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(wave * 0.4);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(
-5.0 + wave_stop * -0.5,
2.25,
4.0 - wave * 1.0,
);
next.l_hand.offset = Vec3::new(-5.0 + wave_stop * -0.5, 2.25, 4.0 - wave * 1.0);
next.l_hand.ori =
Quaternion::rotation_x(1.5 + wave_cos * 0.1) * Quaternion::rotation_y(wave_stop * 0.1);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
5.0 + wave_stop * 0.5,
2.25,
4.0 + wave * 1.0,
);
next.r_hand.offset = Vec3::new(5.0 + wave_stop * 0.5, 2.25, 4.0 + wave * 1.0);
next.r_hand.ori = Quaternion::rotation_x(1.5 + wave_cos * -0.1)
* Quaternion::rotation_y(wave_stop * -0.1);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-3.4, 5.0+ wave * -3.0, 4.0);
next.l_foot.offset = Vec3::new(-3.4, 5.0 + wave * -3.0, 4.0);
next.l_foot.ori = Quaternion::rotation_x(-0.8 + wavecos * 0.15);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, 5.0+ wave * 3.0, 4.0);
next.r_foot.offset = Vec3::new(3.4, 5.0 + wave * 3.0, 4.0);
next.r_foot.ori = Quaternion::rotation_x(-0.8 - wavecos * 0.15);
next.r_foot.scale = Vec3::one();

View File

@ -2,6 +2,7 @@ use super::{
super::{Animation, SkeletonAttr},
CharacterSkeleton,
};
use common::comp::item::Tool;
use std::{f32::consts::PI, ops::Mul};
use vek::*;
@ -9,11 +10,10 @@ pub struct StandAnimation;
impl Animation for StandAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = f64;
type Dependency = (Option<Tool>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
global_time: f64,
(_active_tool_kind, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,

View File

@ -2,6 +2,7 @@ use super::{
super::{Animation, SkeletonAttr},
CharacterSkeleton,
};
use common::comp::item::Tool;
use std::f32::consts::PI;
use std::ops::Mul;
use vek::*;
@ -10,11 +11,11 @@ pub struct SwimAnimation;
impl Animation for SwimAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = (f32, f32, f64);
type Dependency = (Option<Tool>, f32, f32, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
(velocity, orientation, global_time): Self::Dependency,
(_active_tool_kind, velocity, orientation, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,

View File

@ -9,11 +9,11 @@ pub struct WieldAnimation;
impl Animation for WieldAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = (f32, f64);
type Dependency = (Option<Tool>, f32, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
(_velocity, _global_time): Self::Dependency,
(active_tool_kind, _velocity, _global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
@ -22,9 +22,9 @@ impl Animation for WieldAnimation {
let wave = (anim_time as f32 * 12.0).sin();
match Tool::Bow {
match active_tool_kind {
//TODO: Inventory
Tool::Sword => {
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;
@ -41,7 +41,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Axe => {
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;
@ -58,7 +58,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Hammer => {
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)
@ -79,7 +79,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(wave * -0.25);
next.weapon.scale = Vec3::one();
}
Tool::Staff => {
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;
@ -96,7 +96,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Shield => {
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;
@ -113,7 +113,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Bow => {
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)
@ -134,7 +134,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.85);
next.weapon.scale = Vec3::one();
}
Tool::Dagger => {
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;
@ -151,7 +151,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::Debug(_) => {
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)
@ -172,6 +172,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(wave * -0.25);
next.weapon.scale = Vec3::one();
}
_ => {}
}
next

View File

@ -18,7 +18,8 @@ use crate::{
use client::Client;
use common::{
comp::{
ActionState::*, Body, CharacterState, Last, MovementState::*, Ori, Pos, Scale, Stats, Vel,
ActionState::*, Body, CharacterState, ItemKind, Last, MovementState::*, Ori, Pos, Scale,
Stats, Vel,
},
terrain::TerrainChunk,
vol::RectRasterableVol,
@ -168,6 +169,15 @@ impl FigureMgr {
.cloned()
.unwrap_or_default();
let active_tool_kind = if let Some(ItemKind::Tool { kind, .. }) = stats
.and_then(|s| s.equipment.main.as_ref())
.map(|i| &i.kind)
{
Some(*kind)
} else {
None
};
match body {
Body::Humanoid(_) => {
let state = self
@ -189,56 +199,56 @@ impl FigureMgr {
let target_base = match &character.movement {
Stand => anim::character::StandAnimation::update_skeleton(
&CharacterSkeleton::new(),
time,
(active_tool_kind, time),
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Run => anim::character::RunAnimation::update_skeleton(
&CharacterSkeleton::new(),
(vel.0, ori.0, state.last_ori, time),
(active_tool_kind, vel.0, ori.0, state.last_ori, time),
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Jump => anim::character::JumpAnimation::update_skeleton(
&CharacterSkeleton::new(),
time,
(active_tool_kind, time),
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Roll { .. } => anim::character::RollAnimation::update_skeleton(
&CharacterSkeleton::new(),
time,
(active_tool_kind, time),
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Glide => anim::character::GlidingAnimation::update_skeleton(
&CharacterSkeleton::new(),
(vel.0, ori.0, state.last_ori, time),
(active_tool_kind, vel.0, ori.0, state.last_ori, time),
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Swim => anim::character::SwimAnimation::update_skeleton(
&CharacterSkeleton::new(),
(vel.0.magnitude(), ori.0.magnitude(), time),
(active_tool_kind, vel.0.magnitude(), ori.0.magnitude(), time),
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Climb => anim::character::ClimbAnimation::update_skeleton(
&CharacterSkeleton::new(),
(vel.0, ori.0, time),
(active_tool_kind, vel.0, ori.0, time),
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Sit => anim::character::SitAnimation::update_skeleton(
&CharacterSkeleton::new(),
time,
(active_tool_kind, time),
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
@ -248,7 +258,7 @@ impl FigureMgr {
let target_bones = match (&character.movement, &character.action) {
(Stand, Wield { .. }) => anim::character::CidleAnimation::update_skeleton(
&target_base,
time,
(active_tool_kind, time),
state.action_time,
&mut action_animation_rate,
skeleton_attr,
@ -256,7 +266,7 @@ impl FigureMgr {
(Stand, Block { .. }) => {
anim::character::BlockIdleAnimation::update_skeleton(
&target_base,
time,
(active_tool_kind, time),
state.action_time,
&mut action_animation_rate,
skeleton_attr,
@ -264,21 +274,21 @@ impl FigureMgr {
}
(_, Attack { .. }) => anim::character::AttackAnimation::update_skeleton(
&target_base,
time,
(active_tool_kind, time),
state.action_time,
&mut action_animation_rate,
skeleton_attr,
),
(_, Wield { .. }) => anim::character::WieldAnimation::update_skeleton(
&target_base,
(vel.0.magnitude(), time),
(active_tool_kind, vel.0.magnitude(), time),
state.action_time,
&mut action_animation_rate,
skeleton_attr,
),
(_, Block { .. }) => anim::character::BlockAnimation::update_skeleton(
&target_base,
time,
(active_tool_kind, time),
state.action_time,
&mut action_animation_rate,
skeleton_attr,