diff --git a/common/src/outcome.rs b/common/src/outcome.rs index afdef6ae47..4690bdb713 100644 --- a/common/src/outcome.rs +++ b/common/src/outcome.rs @@ -68,6 +68,10 @@ pub enum Outcome { pos: Vec3, state: PoiseState, }, + Footstep { + pos: Vec3, + vel: f32, + }, } impl Outcome { @@ -81,6 +85,7 @@ impl Outcome { | Outcome::SummonedCreature { pos, .. } | Outcome::Damage { pos, .. } | Outcome::Block { pos, .. } + | Outcome::Footstep { pos, .. } | Outcome::PoiseChange { pos, .. } => Some(*pos), Outcome::BreakBlock { pos, .. } => Some(pos.map(|e| e as f32 + 0.5)), Outcome::ExpChange { .. } | Outcome::ComboChange { .. } => None, diff --git a/voxygen/anim/src/biped_large/alpha.rs b/voxygen/anim/src/biped_large/alpha.rs index 9859ef8175..85114d869f 100644 --- a/voxygen/anim/src/biped_large/alpha.rs +++ b/voxygen/anim/src/biped_large/alpha.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{ @@ -32,9 +32,10 @@ impl Animation for AlphaAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); let lab: f32 = 0.65 * s_a.tempo; @@ -202,6 +203,6 @@ impl Animation for AlphaAnimation { }, _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/beam.rs b/voxygen/anim/src/biped_large/beam.rs index 2dfa41e767..f57641a9ea 100644 --- a/voxygen/anim/src/biped_large/beam.rs +++ b/voxygen/anim/src/biped_large/beam.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{ @@ -32,9 +32,10 @@ impl Animation for BeamAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); @@ -124,6 +125,6 @@ impl Animation for BeamAnimation { _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/beta.rs b/voxygen/anim/src/biped_large/beta.rs index 258000ff2e..94161cad73 100644 --- a/voxygen/anim/src/biped_large/beta.rs +++ b/voxygen/anim/src/biped_large/beta.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{ @@ -31,9 +31,10 @@ impl Animation for BetaAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); let lab: f32 = 0.65 * s_a.tempo; @@ -203,6 +204,6 @@ impl Animation for BetaAnimation { }, _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/blink.rs b/voxygen/anim/src/biped_large/blink.rs index 6c639c5df2..8427dc7e5a 100644 --- a/voxygen/anim/src/biped_large/blink.rs +++ b/voxygen/anim/src/biped_large/blink.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{ @@ -32,9 +32,10 @@ impl Animation for BlinkAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); let lab: f32 = 0.65 * s_a.tempo; @@ -107,6 +108,7 @@ impl Animation for BlinkAnimation { _ => {}, } - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/charge.rs b/voxygen/anim/src/biped_large/charge.rs index 6982fcb1ca..128c993db0 100644 --- a/voxygen/anim/src/biped_large/charge.rs +++ b/voxygen/anim/src/biped_large/charge.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -27,8 +27,9 @@ impl Animation for ChargeAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 1.0; @@ -147,6 +148,6 @@ impl Animation for ChargeAnimation { Quaternion::rotation_x(stop * 0.1) * Quaternion::rotation_z(stop * 0.1); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/dash.rs b/voxygen/anim/src/biped_large/dash.rs index 575420797d..c88246de07 100644 --- a/voxygen/anim/src/biped_large/dash.rs +++ b/voxygen/anim/src/biped_large/dash.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{comp::item::ToolKind, states::utils::StageSection}; @@ -29,9 +29,10 @@ impl Animation for DashAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 0.65 * s_a.tempo; let speed = Vec2::::from(velocity).magnitude(); @@ -139,6 +140,6 @@ impl Animation for DashAnimation { _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/equip.rs b/voxygen/anim/src/biped_large/equip.rs index d31485ca5e..c7dc2cc746 100644 --- a/voxygen/anim/src/biped_large/equip.rs +++ b/voxygen/anim/src/biped_large/equip.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -22,9 +22,10 @@ impl Animation for EquipAnimation { anim_time: f32, rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let equip_slow = 1.0 + (anim_time * 12.0 + PI).cos(); let equip_slowa = 1.0 + (anim_time * 12.0 + PI / 4.0).cos(); @@ -59,6 +60,7 @@ impl Animation for EquipAnimation { }, _ => {}, } - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/idle.rs b/voxygen/anim/src/biped_large/idle.rs index 620e4241aa..3b5c50d929 100644 --- a/voxygen/anim/src/biped_large/idle.rs +++ b/voxygen/anim/src/biped_large/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -21,8 +21,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 1.0; let torso = (anim_time * lab + 1.5 * PI).sin() * 1.5; @@ -140,6 +141,6 @@ impl Animation for IdleAnimation { next.foot_r.orientation = Quaternion::rotation_x(-0.5 + slow * 0.1); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/jump.rs b/voxygen/anim/src/biped_large/jump.rs index dd5e0ebfa7..13a57e3810 100644 --- a/voxygen/anim/src/biped_large/jump.rs +++ b/voxygen/anim/src/biped_large/jump.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -21,8 +21,9 @@ impl Animation for JumpAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 1.0; let torso = (anim_time * lab + 1.5 * PI).sin(); @@ -113,6 +114,6 @@ impl Animation for JumpAnimation { next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); next.torso.scale = Vec3::one() / 8.0 * s_a.scaler; - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/leapmelee.rs b/voxygen/anim/src/biped_large/leapmelee.rs index e7eada8b2e..42195ee286 100644 --- a/voxygen/anim/src/biped_large/leapmelee.rs +++ b/voxygen/anim/src/biped_large/leapmelee.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{comp::item::ToolKind, states::utils::StageSection}; @@ -26,9 +26,10 @@ impl Animation for LeapAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1, movement2, movement3, movement4) = match stage_section { Some(StageSection::Buildup) => (anim_time, 0.0, 0.0, 0.0), @@ -83,6 +84,6 @@ impl Animation for LeapAnimation { next.foot_r.orientation = Quaternion::rotation_x(0.9 + movement3 * -1.7); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/run.rs b/voxygen/anim/src/biped_large/run.rs index c48f7f8a9f..00fdddb5bf 100644 --- a/voxygen/anim/src/biped_large/run.rs +++ b/voxygen/anim/src/biped_large/run.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -40,8 +40,9 @@ impl Animation for RunAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); let speedavg = Vec2::::from(avg_vel).magnitude(); @@ -433,6 +434,6 @@ impl Animation for RunAnimation { next.foot_r.orientation = Quaternion::rotation_x(-0.5 * speednorm + slow * 0.1); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/shockwave.rs b/voxygen/anim/src/biped_large/shockwave.rs index 07d8d6b76f..c2089e9396 100644 --- a/voxygen/anim/src/biped_large/shockwave.rs +++ b/voxygen/anim/src/biped_large/shockwave.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{comp::item::ToolKind, states::utils::StageSection}; @@ -27,9 +27,10 @@ impl Animation for ShockwaveAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time, 0.0, 0.0), @@ -97,6 +98,6 @@ impl Animation for ShockwaveAnimation { next.foot_r.orientation = Quaternion::rotation_y(movement1 * -0.3 + movement2 * 0.3) * Quaternion::rotation_z(movement1 * 0.4 + movement2 * -0.4); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/shoot.rs b/voxygen/anim/src/biped_large/shoot.rs index fcbed1d63f..0cca90779e 100644 --- a/voxygen/anim/src/biped_large/shoot.rs +++ b/voxygen/anim/src/biped_large/shoot.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{ @@ -43,11 +43,12 @@ impl Animation for ShootAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let speed = Vec2::::from(velocity).magnitude(); let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 0.65 * s_a.tempo; let speednorm = (speed / 12.0).powf(0.4); @@ -209,6 +210,6 @@ impl Animation for ShootAnimation { _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/spin.rs b/voxygen/anim/src/biped_large/spin.rs index 873e816707..e4510211da 100644 --- a/voxygen/anim/src/biped_large/spin.rs +++ b/voxygen/anim/src/biped_large/spin.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{comp::item::ToolKind, states::utils::StageSection}; @@ -26,9 +26,10 @@ impl Animation for SpinAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 1.0; @@ -123,6 +124,6 @@ impl Animation for SpinAnimation { next.foot_r.orientation = Quaternion::rotation_x(foot * 1.2); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/spinmelee.rs b/voxygen/anim/src/biped_large/spinmelee.rs index a23d58dbe2..f511848c2b 100644 --- a/voxygen/anim/src/biped_large/spinmelee.rs +++ b/voxygen/anim/src/biped_large/spinmelee.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{ @@ -32,9 +32,10 @@ impl Animation for SpinMeleeAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); @@ -122,6 +123,6 @@ impl Animation for SpinMeleeAnimation { _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/stunned.rs b/voxygen/anim/src/biped_large/stunned.rs index 674cb164a0..8bba800199 100644 --- a/voxygen/anim/src/biped_large/stunned.rs +++ b/voxygen/anim/src/biped_large/stunned.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{ @@ -24,9 +24,10 @@ impl Animation for StunnedAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); let speed = Vec2::::from(velocity).magnitude(); + let anim_events: Vec = Vec::new(); let lab: f32 = 0.65 * s_a.tempo; //.65 @@ -373,6 +374,6 @@ impl Animation for StunnedAnimation { next.foot_r.orientation = Quaternion::rotation_x(-0.5 + slow * 0.1); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/summon.rs b/voxygen/anim/src/biped_large/summon.rs index 04711738d9..dbbc2c4c3d 100644 --- a/voxygen/anim/src/biped_large/summon.rs +++ b/voxygen/anim/src/biped_large/summon.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; use common::{ @@ -32,9 +32,10 @@ impl Animation for SummonAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); @@ -114,6 +115,6 @@ impl Animation for SummonAnimation { _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_large/wield.rs b/voxygen/anim/src/biped_large/wield.rs index 8ba4bbabed..572fb3c4e7 100644 --- a/voxygen/anim/src/biped_large/wield.rs +++ b/voxygen/anim/src/biped_large/wield.rs @@ -1,8 +1,10 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedLargeSkeleton, SkeletonAttr, }; -use common::comp::item::{ToolKind, UniqueKind}; +use common::{ + comp::item::{ToolKind, UniqueKind}, +}; use std::{f32::consts::PI, ops::Mul}; pub struct WieldAnimation; @@ -21,8 +23,9 @@ impl Animation for WieldAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); let lab: f32 = 0.65 * s_a.tempo; //.65 @@ -412,6 +415,6 @@ impl Animation for WieldAnimation { next.foot_r.orientation = Quaternion::rotation_x(-0.5 + slow * 0.1); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_small/alpha.rs b/voxygen/anim/src/biped_small/alpha.rs index 0ceb8cd59e..414e54eebf 100644 --- a/voxygen/anim/src/biped_small/alpha.rs +++ b/voxygen/anim/src/biped_small/alpha.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedSmallSkeleton, SkeletonAttr, }; use common::{ @@ -47,8 +47,9 @@ impl Animation for AlphaAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); let fast = (anim_time * 10.0).sin(); @@ -140,6 +141,6 @@ impl Animation for AlphaAnimation { }, _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_small/dash.rs b/voxygen/anim/src/biped_small/dash.rs index 5d28232b1d..596b6fa4c3 100644 --- a/voxygen/anim/src/biped_small/dash.rs +++ b/voxygen/anim/src/biped_small/dash.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedSmallSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -42,8 +42,9 @@ impl Animation for DashAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); let fast = (anim_time * 10.0).sin(); @@ -104,6 +105,6 @@ impl Animation for DashAnimation { next.tail.orientation = Quaternion::rotation_x(0.05 * fastalt * speednormcancel) * Quaternion::rotation_z(fast * 0.15 * speednormcancel); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_small/idle.rs b/voxygen/anim/src/biped_small/idle.rs index e179483db4..689a69218b 100644 --- a/voxygen/anim/src/biped_small/idle.rs +++ b/voxygen/anim/src/biped_small/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedSmallSkeleton, SkeletonAttr, }; @@ -22,8 +22,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slow = (anim_time * 4.0).sin(); next.foot_l.scale = Vec3::one() * s_a.scaler / 11.0; @@ -44,6 +45,6 @@ impl Animation for IdleAnimation { next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2) * s_a.scaler / 11.0; next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2) * s_a.scaler / 11.0; - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_small/run.rs b/voxygen/anim/src/biped_small/run.rs index a131a2adbb..f24c684ba9 100644 --- a/voxygen/anim/src/biped_small/run.rs +++ b/voxygen/anim/src/biped_small/run.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedSmallSkeleton, SkeletonAttr, }; use std::{f32::consts::PI, ops::Mul}; @@ -23,8 +23,9 @@ impl Animation for RunAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); *rate = 1.0; let speednorm = (speed / 9.4).powf(0.4); @@ -158,6 +159,6 @@ impl Animation for RunAnimation { next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_small/shoot.rs b/voxygen/anim/src/biped_small/shoot.rs index 361f35dddd..efcff53718 100644 --- a/voxygen/anim/src/biped_small/shoot.rs +++ b/voxygen/anim/src/biped_small/shoot.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedSmallSkeleton, SkeletonAttr, }; use common::{comp::item::ToolKind, states::utils::StageSection}; @@ -44,8 +44,9 @@ impl Animation for ShootAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); let fast = (anim_time * 10.0).sin(); @@ -148,6 +149,6 @@ impl Animation for ShootAnimation { _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_small/stunned.rs b/voxygen/anim/src/biped_small/stunned.rs index 384b0d6e8b..e3b8ffb51b 100644 --- a/voxygen/anim/src/biped_small/stunned.rs +++ b/voxygen/anim/src/biped_small/stunned.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedSmallSkeleton, SkeletonAttr, }; use common::{ @@ -49,8 +49,9 @@ impl Animation for StunnedAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); let speednorm = speed / 9.4; @@ -184,6 +185,7 @@ impl Animation for StunnedAnimation { next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2) * s_a.scaler / 11.0; }; - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/biped_small/wield.rs b/voxygen/anim/src/biped_small/wield.rs index f673ff3bb0..ffc8547b3f 100644 --- a/voxygen/anim/src/biped_small/wield.rs +++ b/voxygen/anim/src/biped_small/wield.rs @@ -1,8 +1,10 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BipedSmallSkeleton, SkeletonAttr, }; -use common::comp::item::{ToolKind, UniqueKind}; +use common::{ + comp::item::{ToolKind, UniqueKind}, +}; use std::f32::consts::PI; pub struct WieldAnimation; @@ -32,8 +34,9 @@ impl Animation for WieldAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); let fastacc = (acc_vel * 2.0).sin(); @@ -158,6 +161,6 @@ impl Animation for WieldAnimation { _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_large/alpha.rs b/voxygen/anim/src/bird_large/alpha.rs index 99f5c56566..482539b9e6 100644 --- a/voxygen/anim/src/bird_large/alpha.rs +++ b/voxygen/anim/src/bird_large/alpha.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdLargeSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -20,8 +20,9 @@ impl Animation for AlphaAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (move1base, move2base, move3) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), @@ -103,6 +104,6 @@ impl Animation for AlphaAnimation { } else { } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_large/breathe.rs b/voxygen/anim/src/bird_large/breathe.rs index 9d9c632619..9baf69cdcd 100644 --- a/voxygen/anim/src/bird_large/breathe.rs +++ b/voxygen/anim/src/bird_large/breathe.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdLargeSkeleton, SkeletonAttr, }; use common::{states::utils::StageSection, util::Dir}; @@ -30,8 +30,9 @@ impl Animation for BreatheAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2base, movement3, twitch) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0, 0.0), @@ -130,6 +131,6 @@ impl Animation for BreatheAnimation { * Quaternion::rotation_y(tilt * 1.8); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_large/feed.rs b/voxygen/anim/src/bird_large/feed.rs index 59daa60311..858811bc29 100644 --- a/voxygen/anim/src/bird_large/feed.rs +++ b/voxygen/anim/src/bird_large/feed.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdLargeSkeleton, SkeletonAttr, }; use std::ops::Mul; @@ -20,8 +20,9 @@ impl Animation for FeedAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let duck_head_look = Vec2::new( (global_time / 2.0 + anim_time / 8.0) @@ -95,6 +96,6 @@ impl Animation for FeedAnimation { next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2); next.foot_r.orientation = Quaternion::rotation_x(0.0); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_large/fly.rs b/voxygen/anim/src/bird_large/fly.rs index 227be64ae0..e87d3ca983 100644 --- a/voxygen/anim/src/bird_large/fly.rs +++ b/voxygen/anim/src/bird_large/fly.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdLargeSkeleton, SkeletonAttr, }; @@ -19,8 +19,9 @@ impl Animation for FlyAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slow = (anim_time * 2.0).sin(); let fast = (anim_time * 4.0).sin(); @@ -172,6 +173,6 @@ impl Animation for FlyAnimation { next.foot_r.orientation = Quaternion::rotation_x(slow * -0.05); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_large/idle.rs b/voxygen/anim/src/bird_large/idle.rs index ced671cb26..0a8a4a362c 100644 --- a/voxygen/anim/src/bird_large/idle.rs +++ b/voxygen/anim/src/bird_large/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdLargeSkeleton, SkeletonAttr, }; use std::ops::Mul; @@ -20,8 +20,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let duck_head_look = Vec2::new( (global_time / 2.0 + anim_time / 8.0) @@ -93,6 +94,6 @@ impl Animation for IdleAnimation { next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2); next.foot_r.orientation = Quaternion::rotation_x(0.0); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_large/run.rs b/voxygen/anim/src/bird_large/run.rs index cde5f7aba5..d3c407cd68 100644 --- a/voxygen/anim/src/bird_large/run.rs +++ b/voxygen/anim/src/bird_large/run.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdLargeSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -20,8 +20,10 @@ impl Animation for RunAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); + let speed = (Vec2::::from(velocity).magnitude()).min(22.0); *rate = 1.0; @@ -154,6 +156,6 @@ impl Animation for RunAnimation { * Quaternion::rotation_y(tilt * -1.0) * Quaternion::rotation_z(tilt * -0.5); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_large/shockwave.rs b/voxygen/anim/src/bird_large/shockwave.rs index c6dd88dd57..461d463ed1 100644 --- a/voxygen/anim/src/bird_large/shockwave.rs +++ b/voxygen/anim/src/bird_large/shockwave.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdLargeSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -21,8 +21,9 @@ impl Animation for ShockwaveAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2base, movement3, _twitch) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.5), 0.0, 0.0, 0.0), @@ -101,6 +102,6 @@ impl Animation for ShockwaveAnimation { } else { } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_large/shoot.rs b/voxygen/anim/src/bird_large/shoot.rs index 23cd8c3f08..11acdec1c1 100644 --- a/voxygen/anim/src/bird_large/shoot.rs +++ b/voxygen/anim/src/bird_large/shoot.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdLargeSkeleton, SkeletonAttr, }; use common::{states::utils::StageSection, util::Dir}; @@ -22,8 +22,9 @@ impl Animation for ShootAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2base, movement3, twitch) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0, 0.0), @@ -105,6 +106,6 @@ impl Animation for ShootAnimation { } else { } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_large/stunned.rs b/voxygen/anim/src/bird_large/stunned.rs index 5377b3cdbb..aabbfbe73e 100644 --- a/voxygen/anim/src/bird_large/stunned.rs +++ b/voxygen/anim/src/bird_large/stunned.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdLargeSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -20,8 +20,9 @@ impl Animation for StunnedAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let wave_slow_cos = (anim_time * 4.5).cos(); @@ -86,6 +87,6 @@ impl Animation for StunnedAnimation { next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2); next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_large/swim.rs b/voxygen/anim/src/bird_large/swim.rs index f914cc20e6..3eb9521437 100644 --- a/voxygen/anim/src/bird_large/swim.rs +++ b/voxygen/anim/src/bird_large/swim.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdLargeSkeleton, SkeletonAttr, }; use std::ops::Mul; @@ -21,8 +21,9 @@ impl Animation for SwimAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let duck_head_look = Vec2::new( (global_time / 2.0 + anim_time / 8.0) @@ -97,6 +98,6 @@ impl Animation for SwimAnimation { next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2); next.foot_r.orientation = Quaternion::rotation_x(0.0); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_medium/feed.rs b/voxygen/anim/src/bird_medium/feed.rs index f717628af0..8c592250fd 100644 --- a/voxygen/anim/src/bird_medium/feed.rs +++ b/voxygen/anim/src/bird_medium/feed.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdMediumSkeleton, SkeletonAttr, }; use std::ops::Mul; @@ -21,8 +21,9 @@ impl Animation for FeedAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let wave_slow = (anim_time * 4.5).sin(); let wave = (anim_time * 8.0).sin(); @@ -66,6 +67,7 @@ impl Animation for FeedAnimation { next.leg_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2) / 11.0; next.leg_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2) / 11.0; - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_medium/fly.rs b/voxygen/anim/src/bird_medium/fly.rs index 49ade48a95..462d4398a4 100644 --- a/voxygen/anim/src/bird_medium/fly.rs +++ b/voxygen/anim/src/bird_medium/fly.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdMediumSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -20,8 +20,9 @@ impl Animation for FlyAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 12.0; //14.0 @@ -61,6 +62,7 @@ impl Animation for FlyAnimation { next.leg_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2) / 11.0; next.leg_r.orientation = Quaternion::rotation_x(-1.3 + footr * 0.06); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_medium/idle.rs b/voxygen/anim/src/bird_medium/idle.rs index f96992a739..0e1b0980b0 100644 --- a/voxygen/anim/src/bird_medium/idle.rs +++ b/voxygen/anim/src/bird_medium/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdMediumSkeleton, SkeletonAttr, }; use std::ops::Mul; @@ -21,8 +21,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let wave_slow = (anim_time * 4.5).sin(); let wave_slow_cos = (anim_time * 4.5).cos(); @@ -63,6 +64,7 @@ impl Animation for IdleAnimation { next.leg_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2) / 11.0; next.leg_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2) / 11.0; - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_medium/run.rs b/voxygen/anim/src/bird_medium/run.rs index fbde0b410d..1aa24cd2e3 100644 --- a/voxygen/anim/src/bird_medium/run.rs +++ b/voxygen/anim/src/bird_medium/run.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, BirdMediumSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -20,8 +20,9 @@ impl Animation for RunAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 16.0; //14.0 @@ -62,6 +63,7 @@ impl Animation for RunAnimation { next.leg_r.position = Vec3::new(s_a.foot.0, s_a.foot.1 + footr * 1.0, s_a.foot.2) / 11.0; next.leg_r.orientation = Quaternion::rotation_x(footr * 0.5); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/bird_small/idle.rs b/voxygen/anim/src/bird_small/idle.rs new file mode 100644 index 0000000000..85b28f3343 --- /dev/null +++ b/voxygen/anim/src/bird_small/idle.rs @@ -0,0 +1,43 @@ +use super::{super::{AnimationEvent, Animation}, BirdSmallSkeleton, SkeletonAttr}; +//use std::{f32::consts::PI, ops::Mul}; +use super::super::vek::*; + +pub struct IdleAnimation; + +impl Animation for IdleAnimation { + type Dependency = f32; + type Skeleton = BirdSmallSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"bird_small_idle\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "bird_small_idle")] + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + _global_time: Self::Dependency, + _anim_time: f32, + _rate: &mut f32, + _skeleton_attr: &SkeletonAttr, + ) -> (Self::Skeleton, Vec) { + let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); + + next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.head.scale = Vec3::one() / 10.88; + + next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.torso.scale = Vec3::one() / 10.88; + + next.wing_l.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.wing_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.wing_l.scale = Vec3::one() / 10.88; + + next.wing_r.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.wing_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.wing_r.scale = Vec3::one() / 10.88; + + (next, anim_events) + } +} diff --git a/voxygen/anim/src/bird_small/jump.rs b/voxygen/anim/src/bird_small/jump.rs new file mode 100644 index 0000000000..d7ddfd57ad --- /dev/null +++ b/voxygen/anim/src/bird_small/jump.rs @@ -0,0 +1,43 @@ +use super::{super::{AnimationEvent, Animation}, BirdSmallSkeleton, SkeletonAttr}; +//use std::f32::consts::PI; +use super::super::vek::*; + +pub struct JumpAnimation; + +impl Animation for JumpAnimation { + type Dependency = (f32, f32); + type Skeleton = BirdSmallSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"bird_small_jump\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "bird_small_jump")] + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + _global_time: Self::Dependency, + _anim_time: f32, + _rate: &mut f32, + _skeleton_attr: &SkeletonAttr, + ) -> (Self::Skeleton, Vec) { + let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); + + next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.head.scale = Vec3::one() / 10.88; + + next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.torso.scale = Vec3::one() / 10.88; + + next.wing_l.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.wing_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.wing_l.scale = Vec3::one() / 10.88; + + next.wing_r.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.wing_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.wing_r.scale = Vec3::one() / 10.88; + + (next, anim_events) + } +} diff --git a/voxygen/anim/src/bird_small/run.rs b/voxygen/anim/src/bird_small/run.rs new file mode 100644 index 0000000000..447c530d60 --- /dev/null +++ b/voxygen/anim/src/bird_small/run.rs @@ -0,0 +1,43 @@ +use super::{super::{AnimationEvent, Animation}, BirdSmallSkeleton, SkeletonAttr}; +//use std::{f32::consts::PI, ops::Mul}; +use super::super::vek::*; + +pub struct RunAnimation; + +impl Animation for RunAnimation { + type Dependency = (f32, f32); + type Skeleton = BirdSmallSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"bird_small_run\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "bird_small_run")] + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + (_velocity, _global_time): Self::Dependency, + _anim_time: f32, + _rate: &mut f32, + _skeleton_attr: &SkeletonAttr, + ) -> (Self::Skeleton, Vec) { + let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); + + next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.head.scale = Vec3::one() / 10.88; + + next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.torso.scale = Vec3::one() / 10.88; + + next.wing_l.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.wing_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.wing_l.scale = Vec3::one() / 10.88; + + next.wing_r.position = Vec3::new(0.0, 7.5, 15.0) / 11.0; + next.wing_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.wing_r.scale = Vec3::one() / 10.88; + + (next, anim_events) + } +} diff --git a/voxygen/anim/src/character/alpha.rs b/voxygen/anim/src/character/alpha.rs index 2ab3349da2..13b0945fc5 100644 --- a/voxygen/anim/src/character/alpha.rs +++ b/voxygen/anim/src/character/alpha.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -30,9 +30,10 @@ impl Animation for AlphaAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (move1, move2, move3, move2h) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0, 0.0), @@ -300,6 +301,6 @@ impl Animation for AlphaAnimation { next.lantern.orientation = next.hand_r.orientation.inverse(); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/beam.rs b/voxygen/anim/src/character/beam.rs index 1741d78b5f..b7778ec543 100644 --- a/voxygen/anim/src/character/beam.rs +++ b/voxygen/anim/src/character/beam.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -32,9 +32,10 @@ impl Animation for BeamAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (move1, move2, move3) = match stage_section { Some(StageSection::Buildup) => (anim_time, 0.0, 0.0), @@ -117,6 +118,6 @@ impl Animation for BeamAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/beta.rs b/voxygen/anim/src/character/beta.rs index c252cb2601..cb8e144b04 100644 --- a/voxygen/anim/src/character/beta.rs +++ b/voxygen/anim/src/character/beta.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -30,9 +30,10 @@ impl Animation for BetaAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (move1, move2, move3) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), @@ -131,6 +132,6 @@ impl Animation for BetaAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/block.rs b/voxygen/anim/src/character/block.rs index 8b582c6da9..4ad5a86296 100644 --- a/voxygen/anim/src/character/block.rs +++ b/voxygen/anim/src/character/block.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -32,9 +32,10 @@ impl Animation for BlockAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); next.main.position = Vec3::new(0.0, 0.0, 0.0); next.main.orientation = Quaternion::rotation_z(0.0); @@ -229,6 +230,6 @@ impl Animation for BlockAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/chargeswing.rs b/voxygen/anim/src/character/chargeswing.rs index 4be709117e..aa6361da32 100644 --- a/voxygen/anim/src/character/chargeswing.rs +++ b/voxygen/anim/src/character/chargeswing.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -31,9 +31,10 @@ impl Animation for ChargeswingAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 1.0; @@ -174,6 +175,6 @@ impl Animation for ChargeswingAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/climb.rs b/voxygen/anim/src/character/climb.rs index 721f3e0182..cbff227136 100644 --- a/voxygen/anim/src/character/climb.rs +++ b/voxygen/anim/src/character/climb.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -27,8 +27,10 @@ impl Animation for ClimbAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); + let lateral = Vec2::::from(velocity).magnitude(); let speed = velocity.z; *rate = speed; @@ -161,6 +163,6 @@ impl Animation for ClimbAnimation { next.torso.position = Vec3::new(0.0, -0.2, 0.4) * s_a.scaler; }; - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/dance.rs b/voxygen/anim/src/character/dance.rs index 2b37170947..2a4ebd359f 100644 --- a/voxygen/anim/src/character/dance.rs +++ b/voxygen/anim/src/character/dance.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -21,8 +21,9 @@ impl Animation for DanceAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); *rate = 1.0; @@ -107,6 +108,6 @@ impl Animation for DanceAnimation { next.torso.position = Vec3::new(0.0, -0.3, 0.0) * s_a.scaler; next.torso.orientation = Quaternion::rotation_z(short * -0.2); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/dash.rs b/voxygen/anim/src/character/dash.rs index 9df25d4a36..efdc37e9d0 100644 --- a/voxygen/anim/src/character/dash.rs +++ b/voxygen/anim/src/character/dash.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -31,9 +31,10 @@ impl Animation for DashAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1, movement2, movement3, move4) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0, 0.0), @@ -175,6 +176,6 @@ impl Animation for DashAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/equip.rs b/voxygen/anim/src/character/equip.rs index 1b01ec063b..c4e5812d87 100644 --- a/voxygen/anim/src/character/equip.rs +++ b/voxygen/anim/src/character/equip.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -22,9 +22,11 @@ impl Animation for EquipAnimation { anim_time: f32, rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); + let equip_slow = 1.0 + (anim_time * 12.0 + PI).cos(); let equip_slowa = 1.0 + (anim_time * 12.0 + PI / 4.0).cos(); next.hand_l.orientation = Quaternion::rotation_y(-2.3) * Quaternion::rotation_z(1.57); @@ -55,6 +57,6 @@ impl Animation for EquipAnimation { _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/glidewield.rs b/voxygen/anim/src/character/glidewield.rs index ac7cb6f85f..ffbf77c055 100644 --- a/voxygen/anim/src/character/glidewield.rs +++ b/voxygen/anim/src/character/glidewield.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; @@ -20,8 +20,10 @@ impl Animation for GlideWieldAnimation { _anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); + *rate = 1.0; next.hand_l.position = Vec3::new(-2.0 - s_a.hand.0, s_a.hand.1, s_a.hand.2 + 15.0); @@ -34,6 +36,6 @@ impl Animation for GlideWieldAnimation { next.glider.position = Vec3::new(0.0, -5.0, 13.0); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/gliding.rs b/voxygen/anim/src/character/gliding.rs index 996d745140..bce70624f8 100644 --- a/voxygen/anim/src/character/gliding.rs +++ b/voxygen/anim/src/character/gliding.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use std::ops::Mul; @@ -23,8 +23,9 @@ impl Animation for GlidingAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speednorm = velocity.magnitude().min(50.0) / 50.0; let slow = (acc_vel * 0.5).sin(); @@ -77,6 +78,6 @@ impl Animation for GlidingAnimation { next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1 + speedlog * -1.0, s_a.foot.2); next.foot_r.orientation = Quaternion::rotation_x(-speedlog + slow * 0.3 * speedlog); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/idle.rs b/voxygen/anim/src/character/idle.rs index 51f700b35a..90f8010503 100644 --- a/voxygen/anim/src/character/idle.rs +++ b/voxygen/anim/src/character/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::comp::item::{Hands, ToolKind}; @@ -27,8 +27,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slow = (anim_time * 1.0).sin(); let head_look = Vec2::new( @@ -146,6 +147,6 @@ impl Animation for IdleAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/jump.rs b/voxygen/anim/src/character/jump.rs index 1a2788e703..808395a5ae 100644 --- a/voxygen/anim/src/character/jump.rs +++ b/voxygen/anim/src/character/jump.rs @@ -1,8 +1,10 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; -use common::comp::item::{Hands, ToolKind}; +use common::{ + comp::item::{Hands, ToolKind}, +}; use std::f32::consts::PI; pub struct JumpAnimation; @@ -30,8 +32,9 @@ impl Animation for JumpAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slow = (anim_time * 7.0).sin(); let subtract = global_time - anim_time as f32; @@ -238,6 +241,6 @@ impl Animation for JumpAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/leapmelee.rs b/voxygen/anim/src/character/leapmelee.rs index 116851439c..b09355a7f3 100644 --- a/voxygen/anim/src/character/leapmelee.rs +++ b/voxygen/anim/src/character/leapmelee.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -30,9 +30,10 @@ impl Animation for LeapAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1, movement2, movement3, move4) = match stage_section { Some(StageSection::Buildup) => (anim_time, 0.0, 0.0, 0.0), @@ -241,6 +242,6 @@ impl Animation for LeapAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/repeater.rs b/voxygen/anim/src/character/repeater.rs index 506f9cfe5d..66b39cad20 100644 --- a/voxygen/anim/src/character/repeater.rs +++ b/voxygen/anim/src/character/repeater.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -30,9 +30,10 @@ impl Animation for RepeaterAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (move1, move2, move3, _move4) = match stage_section { Some(StageSection::Movement) => (anim_time, 0.0, 0.0, 0.0), @@ -104,6 +105,6 @@ impl Animation for RepeaterAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/roll.rs b/voxygen/anim/src/character/roll.rs index bd3b5f095f..3c047742ad 100644 --- a/voxygen/anim/src/character/roll.rs +++ b/voxygen/anim/src/character/roll.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{comp::item::ToolKind, states::utils::StageSection}; @@ -31,9 +31,10 @@ impl Animation for RollAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); @@ -113,6 +114,6 @@ impl Animation for RollAnimation { next.torso.orientation = Quaternion::rotation_x(movement1 * -0.4 + movement2 * -2.0 * PI) * Quaternion::rotation_z(tilt * -10.0); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/run.rs b/voxygen/anim/src/character/run.rs index be92f7d247..633eeabc29 100644 --- a/voxygen/anim/src/character/run.rs +++ b/voxygen/anim/src/character/run.rs @@ -1,8 +1,10 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; -use common::comp::item::{Hands, ToolKind}; +use common::{ + comp::item::{Hands, ToolKind}, +}; use std::{f32::consts::PI, ops::Mul}; pub struct RunAnimation; @@ -44,8 +46,9 @@ impl Animation for RunAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let mut anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); *rate = 1.0; @@ -309,6 +312,13 @@ impl Animation for RunAnimation { next.second = next.main; } - next + if (footvertsl).abs() < 0.1 { + anim_events.push(AnimationEvent::Footstep { pos_offset: (next.foot_l.position + next.torso.position) / 11.0 }); + } + if (footvertsr).abs() < 0.1 { + anim_events.push(AnimationEvent::Footstep { pos_offset: (next.foot_r.position + next.torso.position) / 11.0 }); + } + + (next, anim_events) } } diff --git a/voxygen/anim/src/character/shockwave.rs b/voxygen/anim/src/character/shockwave.rs index 763a43616c..c97291de4b 100644 --- a/voxygen/anim/src/character/shockwave.rs +++ b/voxygen/anim/src/character/shockwave.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -34,9 +34,10 @@ impl Animation for ShockwaveAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (move1, move2, move3) = match stage_section { Some(StageSection::Buildup) => (anim_time, 0.0, 0.0), @@ -113,6 +114,6 @@ impl Animation for ShockwaveAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/shoot.rs b/voxygen/anim/src/character/shoot.rs index c30fbf8651..2a71207f36 100644 --- a/voxygen/anim/src/character/shoot.rs +++ b/voxygen/anim/src/character/shoot.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -45,12 +45,12 @@ impl Animation for ShootAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { + let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); + *rate = 1.0; let speed = Vec2::::from(velocity).magnitude(); - - let mut next = (*skeleton).clone(); - let lab: f32 = 1.0; let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); @@ -183,6 +183,6 @@ impl Animation for ShootAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/sit.rs b/voxygen/anim/src/character/sit.rs index b25cf67135..49a0d5cc6a 100644 --- a/voxygen/anim/src/character/sit.rs +++ b/voxygen/anim/src/character/sit.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -21,8 +21,9 @@ impl Animation for SitAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slow = (anim_time * 1.0).sin(); let slowa = (anim_time * 1.0 + PI / 2.0).sin(); @@ -107,6 +108,6 @@ impl Animation for SitAnimation { * Quaternion::rotation_y(fast2 * 0.1); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/sneak.rs b/voxygen/anim/src/character/sneak.rs index 13897e5a0a..2c5d5982b9 100644 --- a/voxygen/anim/src/character/sneak.rs +++ b/voxygen/anim/src/character/sneak.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -22,8 +22,10 @@ impl Animation for SneakAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); + let speed = Vec2::::from(velocity).magnitude(); *rate = 1.0; let slow = (anim_time * 3.0).sin(); @@ -167,6 +169,6 @@ impl Animation for SneakAnimation { next.lantern.orientation = next.hand_r.orientation.inverse(); } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/spin.rs b/voxygen/anim/src/character/spin.rs index 782ec441c0..18b8f90089 100644 --- a/voxygen/anim/src/character/spin.rs +++ b/voxygen/anim/src/character/spin.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -31,9 +31,10 @@ impl Animation for SpinAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2base, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), @@ -252,6 +253,6 @@ impl Animation for SpinAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/spinmelee.rs b/voxygen/anim/src/character/spinmelee.rs index b85ccea681..fd85d93301 100644 --- a/voxygen/anim/src/character/spinmelee.rs +++ b/voxygen/anim/src/character/spinmelee.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -32,7 +32,10 @@ impl Animation for SpinMeleeAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { + let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); + *rate = 1.0; let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time, 0.0, 0.0), @@ -43,7 +46,6 @@ impl Animation for SpinMeleeAnimation { let pullback = 1.0 - movement3; let move1 = movement1 * pullback; let move2 = movement2 * pullback; - let mut next = (*skeleton).clone(); next.main.position = Vec3::new(0.0, 0.0, 0.0); next.main.orientation = Quaternion::rotation_z(0.0); next.second.position = Vec3::new(0.0, 0.0, 0.0); @@ -209,6 +211,6 @@ impl Animation for SpinMeleeAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/staggered.rs b/voxygen/anim/src/character/staggered.rs index c738a88fc9..b61b05c18b 100644 --- a/voxygen/anim/src/character/staggered.rs +++ b/voxygen/anim/src/character/staggered.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -43,9 +43,10 @@ impl Animation for StaggeredAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0), @@ -260,6 +261,6 @@ impl Animation for StaggeredAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/stand.rs b/voxygen/anim/src/character/stand.rs index 5a634d4ab4..75feaef00d 100644 --- a/voxygen/anim/src/character/stand.rs +++ b/voxygen/anim/src/character/stand.rs @@ -1,8 +1,8 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; -use common::comp::item::{Hands, ToolKind}; +use common::{comp::item::{Hands, ToolKind}}; use std::ops::Mul; pub struct StandAnimation; @@ -28,8 +28,9 @@ impl Animation for StandAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slow = (anim_time * 1.0).sin(); let impact = (avg_vel.z).max(-15.0); @@ -173,6 +174,6 @@ impl Animation for StandAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/stunned.rs b/voxygen/anim/src/character/stunned.rs index fa12b7a934..47ad1438a5 100644 --- a/voxygen/anim/src/character/stunned.rs +++ b/voxygen/anim/src/character/stunned.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -43,9 +43,10 @@ impl Animation for StunnedAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0), @@ -220,6 +221,6 @@ impl Animation for StunnedAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/swim.rs b/voxygen/anim/src/character/swim.rs index 6556313598..6e9f7c51c3 100644 --- a/voxygen/anim/src/character/swim.rs +++ b/voxygen/anim/src/character/swim.rs @@ -1,8 +1,10 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; -use common::comp::item::{Hands, ToolKind}; +use common::{ + comp::item::{Hands, ToolKind}, +}; use std::{f32::consts::PI, ops::Mul}; pub struct SwimAnimation; @@ -42,8 +44,9 @@ impl Animation for SwimAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let avgspeed = Vec2::::from(avg_vel).magnitude(); let avgtotal = avg_vel.magnitude(); @@ -268,6 +271,6 @@ impl Animation for SwimAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/swimwield.rs b/voxygen/anim/src/character/swimwield.rs index d5e0fe87cd..cd730fab63 100644 --- a/voxygen/anim/src/character/swimwield.rs +++ b/voxygen/anim/src/character/swimwield.rs @@ -1,8 +1,8 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; -use common::comp::item::{Hands, ToolKind}; +use common::{comp::item::{Hands, ToolKind}}; use std::{f32::consts::PI, ops::Mul}; pub struct SwimWieldAnimation; @@ -29,8 +29,9 @@ impl Animation for SwimWieldAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); *rate = 1.0; let lab: f32 = 1.0; let speed = Vec3::::from(velocity).magnitude(); @@ -335,6 +336,6 @@ impl Animation for SwimWieldAnimation { next.second = next.main; } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/talk.rs b/voxygen/anim/src/character/talk.rs index 3383a68a69..90a9dfbd10 100644 --- a/voxygen/anim/src/character/talk.rs +++ b/voxygen/anim/src/character/talk.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{comp::item::ToolKind, util::Dir}; @@ -22,9 +22,10 @@ impl Animation for TalkAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slowa = (anim_time * 6.0).sin(); let slowb = (anim_time * 4.0 + PI / 2.0).sin(); @@ -49,6 +50,6 @@ impl Animation for TalkAnimation { next.hand_r.orientation = Quaternion::rotation_y(0.2 + slowa * -0.1 + slowb * 0.07) * Quaternion::rotation_x(1.3 + slowb * -0.15 + slowc * 0.05); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/character/wield.rs b/voxygen/anim/src/character/wield.rs index cc4751481b..40a0748d7f 100644 --- a/voxygen/anim/src/character/wield.rs +++ b/voxygen/anim/src/character/wield.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, CharacterSkeleton, SkeletonAttr, }; use common::{ @@ -44,12 +44,14 @@ impl Animation for WieldAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { + let mut next = (*skeleton).clone(); + let mut anim_events: Vec = Vec::new(); + *rate = 1.0; let lab: f32 = 1.0; let speed = Vec2::::from(velocity).magnitude(); let speednorm = speed / 9.5; - let mut next = (*skeleton).clone(); let head_look = Vec2::new( (global_time + anim_time / 3.0).floor().mul(7331.0).sin() * 0.2, (global_time + anim_time / 3.0).floor().mul(1337.0).sin() * 0.1, @@ -349,7 +351,13 @@ impl Animation for WieldAnimation { tilt * 1.0 * fast + tilt * 1.0 + fast2 * speednorm * 0.25 + fast2 * 0.1, ); } + if (footvertlstatic).abs() < 0.1 { + anim_events.push(AnimationEvent::Footstep { pos_offset: (next.foot_l.position + next.main.position) / 11.0 }); + } + if (footvertrstatic).abs() < 0.1 { + anim_events.push(AnimationEvent::Footstep { pos_offset: (next.foot_r.position + next.main.position) / 11.0 }); + } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/dragon/fly.rs b/voxygen/anim/src/dragon/fly.rs index 3d4670386f..1dc622e2e4 100644 --- a/voxygen/anim/src/dragon/fly.rs +++ b/voxygen/anim/src/dragon/fly.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, DragonSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -20,8 +20,9 @@ impl Animation for FlyAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 12.0; @@ -105,6 +106,6 @@ impl Animation for FlyAnimation { next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2); next.wing_out_r.orientation = Quaternion::rotation_y((-0.35 + wingr * 0.6).min(-0.2)); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/dragon/idle.rs b/voxygen/anim/src/dragon/idle.rs index 22789771e2..0069e99204 100644 --- a/voxygen/anim/src/dragon/idle.rs +++ b/voxygen/anim/src/dragon/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, DragonSkeleton, SkeletonAttr, }; use std::{f32::consts::PI, ops::Mul}; @@ -20,8 +20,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let ultra_slow = (anim_time * 1.0).sin(); let slow = (anim_time * 2.5).sin(); @@ -93,6 +94,6 @@ impl Animation for IdleAnimation { next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2); next.wing_out_r.orientation = Quaternion::rotation_y(2.0 - slow * 0.02); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/dragon/run.rs b/voxygen/anim/src/dragon/run.rs index a3846f3bbc..c4322f5c59 100644 --- a/voxygen/anim/src/dragon/run.rs +++ b/voxygen/anim/src/dragon/run.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, DragonSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -20,8 +20,9 @@ impl Animation for RunAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 0.6; //6 @@ -154,6 +155,6 @@ impl Animation for RunAnimation { next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2); next.wing_out_r.orientation = Quaternion::rotation_y(2.0 + tilt * 1.0); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/fish_medium/idle.rs b/voxygen/anim/src/fish_medium/idle.rs index e99b7d285a..21f3b982f9 100644 --- a/voxygen/anim/src/fish_medium/idle.rs +++ b/voxygen/anim/src/fish_medium/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, FishMediumSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -23,8 +23,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slow = (anim_time * 3.5 + PI).sin(); let slowalt = (anim_time * 3.5 + PI + 0.2).sin(); @@ -51,6 +52,7 @@ impl Animation for IdleAnimation { next.fin_r.position = Vec3::new(s_a.fin.0, s_a.fin.1, s_a.fin.2); next.fin_r.orientation = Quaternion::rotation_z(-slow * 0.1 + 0.1); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/fish_medium/swim.rs b/voxygen/anim/src/fish_medium/swim.rs index 02b3539fc1..1945527e58 100644 --- a/voxygen/anim/src/fish_medium/swim.rs +++ b/voxygen/anim/src/fish_medium/swim.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, FishMediumSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -23,8 +23,9 @@ impl Animation for SwimAnimation { _anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slowalt = (acc_vel * s_a.tempo / 1.5 + PI + 0.2).sin(); let fast = (acc_vel * s_a.tempo + PI).sin(); @@ -69,6 +70,7 @@ impl Animation for SwimAnimation { next.fin_r.position = Vec3::new(s_a.fin.0, s_a.fin.1, s_a.fin.2); next.fin_r.orientation = Quaternion::rotation_z(fast * -slowvel + 0.1 + tilt * -0.5); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/fish_small/idle.rs b/voxygen/anim/src/fish_small/idle.rs index 0f28fc9b9d..5fa260a6fb 100644 --- a/voxygen/anim/src/fish_small/idle.rs +++ b/voxygen/anim/src/fish_small/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, FishSmallSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -23,8 +23,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slow = (anim_time * 3.5 + PI).sin(); @@ -40,6 +41,7 @@ impl Animation for IdleAnimation { next.fin_r.position = Vec3::new(s_a.fin.0, s_a.fin.1, s_a.fin.2); next.fin_r.orientation = Quaternion::rotation_z(-slow * 0.1 + 0.1); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/fish_small/swim.rs b/voxygen/anim/src/fish_small/swim.rs index c0d0c1e30b..cab8605dad 100644 --- a/voxygen/anim/src/fish_small/swim.rs +++ b/voxygen/anim/src/fish_small/swim.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, FishSmallSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -23,8 +23,9 @@ impl Animation for SwimAnimation { _anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let fast = (acc_vel * s_a.tempo + PI).sin(); @@ -59,6 +60,7 @@ impl Animation for SwimAnimation { next.fin_r.position = Vec3::new(s_a.fin.0, s_a.fin.1, s_a.fin.2); next.fin_r.orientation = Quaternion::rotation_z(fast * -0.6 * slowvel + 0.3 + tilt * -0.5); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/golem/alpha.rs b/voxygen/anim/src/golem/alpha.rs index 4a722e744d..3e97756a3e 100644 --- a/voxygen/anim/src/golem/alpha.rs +++ b/voxygen/anim/src/golem/alpha.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, GolemSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -21,8 +21,9 @@ impl Animation for AlphaAnimation { anim_time: f32, _rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (move1base, move2base, move3) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), @@ -80,6 +81,7 @@ impl Animation for AlphaAnimation { Quaternion::rotation_y(0.0) * Quaternion::rotation_x(move1 * -1.0 + move2 * 1.8); }; next.torso.position = Vec3::new(0.0, move1 * 0.7, move1 * -0.3); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/golem/idle.rs b/voxygen/anim/src/golem/idle.rs index 5f170b8144..c690fae2e1 100644 --- a/voxygen/anim/src/golem/idle.rs +++ b/voxygen/anim/src/golem/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, GolemSkeleton, SkeletonAttr, }; use std::{f32::consts::PI, ops::Mul}; @@ -21,8 +21,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 1.0; let breathe = (anim_time * lab + 1.5 * PI).sin(); @@ -82,6 +83,7 @@ impl Animation for IdleAnimation { next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2 + breathe * -0.2); next.torso.position = Vec3::new(0.0, 0.0, 0.0); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/golem/run.rs b/voxygen/anim/src/golem/run.rs index bc5ba1aecf..278637be2d 100644 --- a/voxygen/anim/src/golem/run.rs +++ b/voxygen/anim/src/golem/run.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, GolemSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -21,8 +21,9 @@ impl Animation for RunAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = Vec2::::from(velocity).magnitude(); let mixed_vel = acc_vel + anim_time * 2.0; //sets run frequency using speed, with anim_time setting a floor @@ -136,6 +137,7 @@ impl Animation for RunAnimation { next.torso.position = Vec3::new(0.0, 0.0, 0.0); next.torso.orientation = Quaternion::rotation_x(-0.2 * speednorm); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/golem/shockwave.rs b/voxygen/anim/src/golem/shockwave.rs index 9b40a15c85..9c8f017e60 100644 --- a/voxygen/anim/src/golem/shockwave.rs +++ b/voxygen/anim/src/golem/shockwave.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, GolemSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -22,8 +22,9 @@ impl Animation for ShockwaveAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (move1base, move2base, move3) = match stage_section { Some(StageSection::Buildup) => (anim_time, 0.0, 0.0), @@ -75,6 +76,7 @@ impl Animation for ShockwaveAnimation { next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2 + move2); } else { } - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/golem/spinmelee.rs b/voxygen/anim/src/golem/spinmelee.rs index 9dd87b305d..f22fe17bec 100644 --- a/voxygen/anim/src/golem/spinmelee.rs +++ b/voxygen/anim/src/golem/spinmelee.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, GolemSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -22,8 +22,9 @@ impl Animation for SpinMeleeAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), @@ -83,6 +84,6 @@ impl Animation for SpinMeleeAnimation { next.torso.position = Vec3::new(0.0, 0.0, 0.0); next.torso.orientation = Quaternion::rotation_z(0.0); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/lib.rs b/voxygen/anim/src/lib.rs index 45d7e65e87..0e205648c9 100644 --- a/voxygen/anim/src/lib.rs +++ b/voxygen/anim/src/lib.rs @@ -149,7 +149,7 @@ pub trait Animation { _anim_time: f32, _rate: &mut f32, _skeleton_attr: &<::Skeleton as Skeleton>::Attr, - ) -> Self::Skeleton; + ) -> (Self::Skeleton, Vec); /// Calls `update_skeleton_inner` either directly or via `libloading` to /// generate the new skeleton. @@ -159,7 +159,7 @@ pub trait Animation { anim_time: f32, rate: &mut f32, skeleton_attr: &<::Skeleton as Skeleton>::Attr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { #[cfg(not(feature = "use-dyn-lib"))] { Self::update_skeleton_inner(skeleton, dependency, anim_time, rate, skeleton_attr) @@ -176,7 +176,7 @@ pub trait Animation { f32, &mut f32, &::Attr, - ) -> Self::Skeleton, + ) -> (Self::Skeleton, Vec), > = unsafe { //let start = std::time::Instant::now(); // Overhead of 0.5-5 us (could use hashmap to mitigate if this is an issue) @@ -199,3 +199,12 @@ pub trait Animation { } } } + +pub enum AnimationEvent { + Footstep { + pos_offset: Vec3, + }, + WeaponTrail { + pos_offset: Vec3, + }, +} diff --git a/voxygen/anim/src/object/beam.rs b/voxygen/anim/src/object/beam.rs index 92a1eca9d5..51b70b3fec 100644 --- a/voxygen/anim/src/object/beam.rs +++ b/voxygen/anim/src/object/beam.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, ObjectSkeleton, SkeletonAttr, }; use common::{ @@ -29,10 +29,10 @@ impl Animation for BeamAnimation { _anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; - let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2) / 11.0; next.bone0.orientation = Quaternion::rotation_z(0.0); @@ -40,6 +40,6 @@ impl Animation for BeamAnimation { next.bone1.position = Vec3::new(s_a.bone1.0, s_a.bone1.1, s_a.bone1.2) / 11.0; next.bone1.orientation = Quaternion::rotation_z(0.0); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/object/idle.rs b/voxygen/anim/src/object/idle.rs index 95e96112b7..0c43c806bb 100644 --- a/voxygen/anim/src/object/idle.rs +++ b/voxygen/anim/src/object/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, ObjectSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -21,13 +21,14 @@ impl Animation for IdleAnimation { _anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2) / 11.0; next.bone1.position = Vec3::new(s_a.bone1.0, s_a.bone1.1, s_a.bone1.2) / 11.0; - next + (next, anim_events) } } diff --git a/voxygen/anim/src/object/shoot.rs b/voxygen/anim/src/object/shoot.rs index 04dc211259..43d64e69bf 100644 --- a/voxygen/anim/src/object/shoot.rs +++ b/voxygen/anim/src/object/shoot.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, ObjectSkeleton, SkeletonAttr, }; use common::{ @@ -29,10 +29,11 @@ impl Animation for ShootAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { *rate = 1.0; let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time, 0.0, 0.0), @@ -57,6 +58,6 @@ impl Animation for ShootAnimation { _ => {}, } - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_low/alpha.rs b/voxygen/anim/src/quadruped_low/alpha.rs index e60efa6091..dc9d44ce1b 100644 --- a/voxygen/anim/src/quadruped_low/alpha.rs +++ b/voxygen/anim/src/quadruped_low/alpha.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedLowSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -21,8 +21,9 @@ impl Animation for AlphaAnimation { anim_time: f32, _rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2base, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0), @@ -55,6 +56,7 @@ impl Animation for AlphaAnimation { next.tail_rear.orientation = Quaternion::rotation_x(-0.12) * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_low/beta.rs b/voxygen/anim/src/quadruped_low/beta.rs index 1b8bf831a9..282f90681f 100644 --- a/voxygen/anim/src/quadruped_low/beta.rs +++ b/voxygen/anim/src/quadruped_low/beta.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedLowSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -21,8 +21,9 @@ impl Animation for BetaAnimation { anim_time: f32, _rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2base, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0), @@ -55,6 +56,7 @@ impl Animation for BetaAnimation { next.tail_rear.orientation = Quaternion::rotation_x(-0.12) * Quaternion::rotation_z(movement1 * 0.4 + movement2 * 0.2); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_low/breathe.rs b/voxygen/anim/src/quadruped_low/breathe.rs index 3840db8b3c..276a4f96cc 100644 --- a/voxygen/anim/src/quadruped_low/breathe.rs +++ b/voxygen/anim/src/quadruped_low/breathe.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedLowSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -22,8 +22,9 @@ impl Animation for BreatheAnimation { anim_time: f32, _rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = (Vec2::::from(velocity).magnitude()).min(24.0); let (movement1base, _movement2base, movement3, twitch) = match stage_section { @@ -66,8 +67,8 @@ impl Animation for BreatheAnimation { next.foot_bl.orientation = Quaternion::rotation_y(twitch2 * 0.02); next.foot_br.orientation = Quaternion::rotation_y(twitch2 * 0.02); - } else { - }; - next + } + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_low/dash.rs b/voxygen/anim/src/quadruped_low/dash.rs index 255500cbe0..168ca4d59d 100644 --- a/voxygen/anim/src/quadruped_low/dash.rs +++ b/voxygen/anim/src/quadruped_low/dash.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedLowSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -22,8 +22,9 @@ impl Animation for DashAnimation { anim_time: f32, _rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, chargemovementbase, movement2base, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0, 0.0), @@ -76,6 +77,6 @@ impl Animation for DashAnimation { -0.12 + movement1abs * -0.4 + movement2abs * 0.2 + chargemovementbase * 0.2, ) * Quaternion::rotation_z(shortalt * 0.15 + twitch1fast * 0.3); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_low/idle.rs b/voxygen/anim/src/quadruped_low/idle.rs index df51694acc..a720c8049e 100644 --- a/voxygen/anim/src/quadruped_low/idle.rs +++ b/voxygen/anim/src/quadruped_low/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedLowSkeleton, SkeletonAttr, }; use std::{f32::consts::PI, ops::Mul}; @@ -20,8 +20,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slower = (anim_time * 1.25).sin(); let slow = (anim_time * 2.5).sin(); @@ -80,6 +81,6 @@ impl Animation for IdleAnimation { next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); next.foot_br.orientation = Quaternion::rotation_y(slow * -0.05); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_low/jump.rs b/voxygen/anim/src/quadruped_low/jump.rs index b4b9914adb..14aac9a131 100644 --- a/voxygen/anim/src/quadruped_low/jump.rs +++ b/voxygen/anim/src/quadruped_low/jump.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedLowSkeleton, SkeletonAttr, }; @@ -19,8 +19,9 @@ impl Animation for JumpAnimation { _anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); next.jaw.scale = Vec3::one() * 0.98; next.chest.scale = Vec3::one() * s_a.scaler / 11.0; @@ -47,6 +48,6 @@ impl Animation for JumpAnimation { next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_low/run.rs b/voxygen/anim/src/quadruped_low/run.rs index 241db14e60..6834ab8543 100644 --- a/voxygen/anim/src/quadruped_low/run.rs +++ b/voxygen/anim/src/quadruped_low/run.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedLowSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -20,8 +20,9 @@ impl Animation for RunAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = (Vec2::::from(velocity).magnitude()).min(15.0); let speednorm = (speed / 15.0).powf(0.25); @@ -152,6 +153,6 @@ impl Animation for RunAnimation { * Quaternion::rotation_y(tilt * -1.0) * Quaternion::rotation_z(foothorirb * -0.4 + tilt * -2.0); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_low/shoot.rs b/voxygen/anim/src/quadruped_low/shoot.rs index 4d0ea35ff0..2b8592b623 100644 --- a/voxygen/anim/src/quadruped_low/shoot.rs +++ b/voxygen/anim/src/quadruped_low/shoot.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedLowSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -20,8 +20,9 @@ impl Animation for ShootAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time, 0.0, 0.0), @@ -60,8 +61,8 @@ impl Animation for ShootAnimation { next.foot_bl.position = Vec3::new(-s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); - } else { - }; - next + } + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_low/stunned.rs b/voxygen/anim/src/quadruped_low/stunned.rs index 6218f7cc42..825d1758d5 100644 --- a/voxygen/anim/src/quadruped_low/stunned.rs +++ b/voxygen/anim/src/quadruped_low/stunned.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedLowSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -21,8 +21,9 @@ impl Animation for StunnedAnimation { anim_time: f32, _rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2, twitch) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), @@ -53,6 +54,7 @@ impl Animation for StunnedAnimation { next.tail_rear.orientation = Quaternion::rotation_x(-0.12) * Quaternion::rotation_z(movement1 * -0.4); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_low/tailwhip.rs b/voxygen/anim/src/quadruped_low/tailwhip.rs index f691af7150..0f7ae67e42 100644 --- a/voxygen/anim/src/quadruped_low/tailwhip.rs +++ b/voxygen/anim/src/quadruped_low/tailwhip.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedLowSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -20,8 +20,9 @@ impl Animation for TailwhipAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2base, movement3, twitch1, twitch2) = match stage_section { Some(StageSection::Charge) => { @@ -70,6 +71,7 @@ impl Animation for TailwhipAnimation { + movement2 * 0.7 + twitch2 * 0.3 * mirror, ); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_medium/alpha.rs b/voxygen/anim/src/quadruped_medium/alpha.rs index d1c7ac8072..212a7f533b 100644 --- a/voxygen/anim/src/quadruped_medium/alpha.rs +++ b/voxygen/anim/src/quadruped_medium/alpha.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedMediumSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -20,8 +20,9 @@ impl Animation for AlphaAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = (Vec2::::from(velocity).magnitude()).min(24.0); let (movement1base, movement2base, movement3) = match stage_section { @@ -94,7 +95,8 @@ impl Animation for AlphaAnimation { next.foot_br.orientation = Quaternion::rotation_x(movement1abs * -0.5 + movement2abs * -0.3); - }; - next + } + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_medium/beta.rs b/voxygen/anim/src/quadruped_medium/beta.rs index 09b5a817c5..c13af642a3 100644 --- a/voxygen/anim/src/quadruped_medium/beta.rs +++ b/voxygen/anim/src/quadruped_medium/beta.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedMediumSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -20,8 +20,9 @@ impl Animation for BetaAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = (Vec2::::from(velocity).magnitude()).min(24.0); let (movement1base, movement2base, movement3) = match stage_section { @@ -95,6 +96,7 @@ impl Animation for BetaAnimation { next.foot_br.orientation = Quaternion::rotation_x(movement1abs * -0.5 + movement2abs * -0.3); }; - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_medium/dash.rs b/voxygen/anim/src/quadruped_medium/dash.rs index 10027b6292..d93160244e 100644 --- a/voxygen/anim/src/quadruped_medium/dash.rs +++ b/voxygen/anim/src/quadruped_medium/dash.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedMediumSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -22,8 +22,9 @@ impl Animation for DashAnimation { anim_time: f32, _rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, chargemovementbase, movement2base, movement3, legtell) = match stage_section { @@ -108,6 +109,7 @@ impl Animation for DashAnimation { Quaternion::rotation_x(legswing * -1.1 + legtwitch * 0.5); } }; - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_medium/feed.rs b/voxygen/anim/src/quadruped_medium/feed.rs index 75589aeba1..4ee3a5b406 100644 --- a/voxygen/anim/src/quadruped_medium/feed.rs +++ b/voxygen/anim/src/quadruped_medium/feed.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedMediumSkeleton, SkeletonAttr, }; use std::{f32::consts::PI, ops::Mul}; @@ -20,8 +20,9 @@ impl Animation for FeedAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slower = (anim_time * 1.0 + PI).sin(); let slow = (anim_time * 3.5 + PI).sin(); let fast = (anim_time * 5.0).sin(); @@ -135,6 +136,6 @@ impl Animation for FeedAnimation { next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2 + slower * -0.2); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_medium/hoof.rs b/voxygen/anim/src/quadruped_medium/hoof.rs index 1aa8f53b7f..70090eac6e 100644 --- a/voxygen/anim/src/quadruped_medium/hoof.rs +++ b/voxygen/anim/src/quadruped_medium/hoof.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedMediumSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -21,8 +21,9 @@ impl Animation for HoofAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = (Vec2::::from(velocity).magnitude()).min(24.0); let (movement1base, movement2base, movement3, twitch) = match stage_section { @@ -86,6 +87,7 @@ impl Animation for HoofAnimation { next.foot_br.orientation = Quaternion::rotation_x(movement1abs * -0.2); }; - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_medium/idle.rs b/voxygen/anim/src/quadruped_medium/idle.rs index 231ed7fb82..94207113a3 100644 --- a/voxygen/anim/src/quadruped_medium/idle.rs +++ b/voxygen/anim/src/quadruped_medium/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedMediumSkeleton, SkeletonAttr, }; use std::{f32::consts::PI, ops::Mul}; @@ -20,8 +20,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slower = (anim_time * 1.0 + PI).sin(); let slow = (anim_time * 3.5 + PI).sin(); @@ -120,6 +121,6 @@ impl Animation for IdleAnimation { next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2 + slower * -0.2); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_medium/jump.rs b/voxygen/anim/src/quadruped_medium/jump.rs index 50753cf3a6..c95314fd1e 100644 --- a/voxygen/anim/src/quadruped_medium/jump.rs +++ b/voxygen/anim/src/quadruped_medium/jump.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedMediumSkeleton, SkeletonAttr, }; @@ -19,8 +19,9 @@ impl Animation for JumpAnimation { _anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); next.neck.scale = Vec3::one() * 1.02; next.jaw.scale = Vec3::one() * 1.02; @@ -68,6 +69,6 @@ impl Animation for JumpAnimation { next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_medium/leapmelee.rs b/voxygen/anim/src/quadruped_medium/leapmelee.rs index f89950c6c6..4b043b7136 100644 --- a/voxygen/anim/src/quadruped_medium/leapmelee.rs +++ b/voxygen/anim/src/quadruped_medium/leapmelee.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedMediumSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -20,8 +20,9 @@ impl Animation for LeapMeleeAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); //let speed = (Vec2::::from(velocity).magnitude()).min(24.0); let (movement1base, movement2base, movement3base, movement4) = match stage_section { @@ -84,6 +85,6 @@ impl Animation for LeapMeleeAnimation { next.foot_br.orientation = Quaternion::rotation_x(movement1abs * -1.1); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_medium/run.rs b/voxygen/anim/src/quadruped_medium/run.rs index ed907d3273..07957e2139 100644 --- a/voxygen/anim/src/quadruped_medium/run.rs +++ b/voxygen/anim/src/quadruped_medium/run.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedMediumSkeleton, SkeletonAttr, }; use std::{f32::consts::PI, ops::Mul}; @@ -20,8 +20,9 @@ impl Animation for RunAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = (Vec2::::from(velocity).magnitude()).min(24.0); *rate = 1.0; let lab: f32 = 0.72; @@ -221,6 +222,7 @@ impl Animation for RunAnimation { next.foot_br.orientation = Quaternion::rotation_x(amplitude2 * foot4b * -0.7 - 0.2 * canceler) * Quaternion::rotation_y(tilt * -1.0); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_medium/stunned.rs b/voxygen/anim/src/quadruped_medium/stunned.rs index 87ff05da27..2958bbdb37 100644 --- a/voxygen/anim/src/quadruped_medium/stunned.rs +++ b/voxygen/anim/src/quadruped_medium/stunned.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedMediumSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -20,8 +20,9 @@ impl Animation for StunnedAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2, twitch) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), @@ -84,6 +85,6 @@ impl Animation for StunnedAnimation { next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_small/alpha.rs b/voxygen/anim/src/quadruped_small/alpha.rs index d2de36e5b7..25fbedfdac 100644 --- a/voxygen/anim/src/quadruped_small/alpha.rs +++ b/voxygen/anim/src/quadruped_small/alpha.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedSmallSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -21,8 +21,9 @@ impl Animation for AlphaAnimation { anim_time: f32, _rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2base, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0), @@ -48,6 +49,6 @@ impl Animation for AlphaAnimation { next.tail.orientation = Quaternion::rotation_x(movement1abs * 0.5 + movement2abs * -1.0) * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_small/feed.rs b/voxygen/anim/src/quadruped_small/feed.rs index de98243678..6ef5459f0b 100644 --- a/voxygen/anim/src/quadruped_small/feed.rs +++ b/voxygen/anim/src/quadruped_small/feed.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedSmallSkeleton, SkeletonAttr, }; use std::{f32::consts::PI, ops::Mul}; @@ -20,8 +20,9 @@ impl Animation for FeedAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slow = (anim_time * 5.0).sin(); let quick = (anim_time * 14.0).sin(); @@ -69,6 +70,6 @@ impl Animation for FeedAnimation { next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1); next.tail.orientation = Quaternion::rotation_z(slow * 0.3 + head_look.y * 0.3); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_small/idle.rs b/voxygen/anim/src/quadruped_small/idle.rs index f21d5963e2..af8103faa1 100644 --- a/voxygen/anim/src/quadruped_small/idle.rs +++ b/voxygen/anim/src/quadruped_small/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedSmallSkeleton, SkeletonAttr, }; use std::{f32::consts::PI, ops::Mul}; @@ -20,8 +20,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let slow = (anim_time * 3.5).sin(); @@ -67,6 +68,6 @@ impl Animation for IdleAnimation { next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1); next.tail.orientation = Quaternion::rotation_z(slow * 0.4); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_small/jump.rs b/voxygen/anim/src/quadruped_small/jump.rs index 465d75ac65..7de3461756 100644 --- a/voxygen/anim/src/quadruped_small/jump.rs +++ b/voxygen/anim/src/quadruped_small/jump.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedSmallSkeleton, SkeletonAttr, }; @@ -19,8 +19,9 @@ impl Animation for JumpAnimation { _anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); @@ -41,6 +42,7 @@ impl Animation for JumpAnimation { next.leg_br.orientation = Quaternion::rotation_x(0.0); next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_small/run.rs b/voxygen/anim/src/quadruped_small/run.rs index 591c6dc4a5..c51fbcfc63 100644 --- a/voxygen/anim/src/quadruped_small/run.rs +++ b/voxygen/anim/src/quadruped_small/run.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedSmallSkeleton, SkeletonAttr, }; use std::f32::consts::PI; @@ -20,8 +20,9 @@ impl Animation for RunAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let lab: f32 = 0.42; let speed = (Vec2::::from(velocity).magnitude()).min(12.0); @@ -122,6 +123,7 @@ impl Animation for RunAnimation { next.tail.orientation = Quaternion::rotation_x(vertcancel * short * 0.2 + x_tilt) * Quaternion::rotation_y(tilt * 0.8) * Quaternion::rotation_z(s_a.lateral * -short * 0.2 + tilt * 1.5); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/quadruped_small/stunned.rs b/voxygen/anim/src/quadruped_small/stunned.rs index d99c23dab2..15c69caf2d 100644 --- a/voxygen/anim/src/quadruped_small/stunned.rs +++ b/voxygen/anim/src/quadruped_small/stunned.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, QuadrupedSmallSkeleton, SkeletonAttr, }; use common::states::utils::StageSection; @@ -21,8 +21,9 @@ impl Animation for StunnedAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2, twitch) = match stage_section { Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0), @@ -63,6 +64,6 @@ impl Animation for StunnedAnimation { next.tail.orientation = Quaternion::rotation_x(movement1abs * 0.5) * Quaternion::rotation_z(movement1 * -0.4); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/ship/idle.rs b/voxygen/anim/src/ship/idle.rs index dc819c8988..efd20b6d85 100644 --- a/voxygen/anim/src/ship/idle.rs +++ b/voxygen/anim/src/ship/idle.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, ShipSkeleton, SkeletonAttr, }; use common::comp::item::ToolKind; @@ -28,8 +28,9 @@ impl Animation for IdleAnimation { _anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if ::vek::Vec2::new(ori, last_ori) @@ -53,6 +54,7 @@ impl Animation for IdleAnimation { next.bone3.position = Vec3::new(s_a.bone3.0, s_a.bone3.1, s_a.bone3.2) / 11.0; next.bone3.orientation = Quaternion::rotation_z(tilt * 25.0); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/theropod/alpha.rs b/voxygen/anim/src/theropod/alpha.rs index a420a9832f..d6b33e4f7d 100644 --- a/voxygen/anim/src/theropod/alpha.rs +++ b/voxygen/anim/src/theropod/alpha.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, SkeletonAttr, TheropodSkeleton, }; use common::states::utils::StageSection; @@ -20,8 +20,9 @@ impl Animation for AlphaAnimation { anim_time: f32, _rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2base, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time.powi(2), 0.0, 0.0), @@ -61,6 +62,7 @@ impl Animation for AlphaAnimation { next.tail_back.orientation = Quaternion::rotation_x(0.1 + movement1abs * -0.1 + movement2abs * -0.3) * Quaternion::rotation_z(movement1 * -0.1 + movement2 * -0.2); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/theropod/beta.rs b/voxygen/anim/src/theropod/beta.rs index bdcfebfc57..84d6f6e6ed 100644 --- a/voxygen/anim/src/theropod/beta.rs +++ b/voxygen/anim/src/theropod/beta.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, SkeletonAttr, TheropodSkeleton, }; use common::states::utils::StageSection; @@ -21,8 +21,9 @@ impl Animation for BetaAnimation { anim_time: f32, _rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, movement2base, movement3) = match stage_section { Some(StageSection::Buildup) => (anim_time.powi(2), 0.0, 0.0), @@ -60,6 +61,7 @@ impl Animation for BetaAnimation { next.tail_back.orientation = Quaternion::rotation_x(0.1 + movement1abs * -0.1 + movement2abs * -0.3); - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/theropod/dash.rs b/voxygen/anim/src/theropod/dash.rs index e028f8f4c2..815b5b7ddf 100644 --- a/voxygen/anim/src/theropod/dash.rs +++ b/voxygen/anim/src/theropod/dash.rs @@ -1,5 +1,5 @@ use super::{ - super::{vek::*, Animation}, + super::{AnimationEvent, vek::*, Animation}, SkeletonAttr, TheropodSkeleton, }; use common::states::utils::StageSection; @@ -20,8 +20,9 @@ impl Animation for DashAnimation { anim_time: f32, _rate: &mut f32, _s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let (movement1base, chargemovementbase, movement2base, movement3, legtell) = match stage_section { @@ -91,6 +92,7 @@ impl Animation for DashAnimation { next.foot_r.orientation = Quaternion::rotation_x(legswing * -1.1 + legtwitch * 0.5); } }; - next + + (next, anim_events) } } diff --git a/voxygen/anim/src/theropod/idle.rs b/voxygen/anim/src/theropod/idle.rs index 1f49f8e197..17db013d37 100644 --- a/voxygen/anim/src/theropod/idle.rs +++ b/voxygen/anim/src/theropod/idle.rs @@ -1,4 +1,4 @@ -use super::{super::Animation, SkeletonAttr, TheropodSkeleton}; +use super::{super::{AnimationEvent, Animation}, SkeletonAttr, TheropodSkeleton}; //use std::{f32::consts::PI, ops::Mul}; use super::super::vek::*; use std::ops::Mul; @@ -19,8 +19,9 @@ impl Animation for IdleAnimation { anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let breathe = (anim_time * 0.8).sin(); let head_look = Vec2::new( @@ -90,6 +91,6 @@ impl Animation for IdleAnimation { next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2 + breathe * -0.15); next.foot_r.orientation = Quaternion::rotation_z(0.0); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/theropod/jump.rs b/voxygen/anim/src/theropod/jump.rs index fae7303037..64fe4e8e2a 100644 --- a/voxygen/anim/src/theropod/jump.rs +++ b/voxygen/anim/src/theropod/jump.rs @@ -1,4 +1,4 @@ -use super::{super::Animation, SkeletonAttr, TheropodSkeleton}; +use super::{super::{AnimationEvent, Animation}, SkeletonAttr, TheropodSkeleton}; //use std::f32::consts::PI; use super::super::vek::*; @@ -18,8 +18,9 @@ impl Animation for JumpAnimation { _anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); next.head.scale = Vec3::one() * 1.02; next.neck.scale = Vec3::one() * 0.98; @@ -59,6 +60,6 @@ impl Animation for JumpAnimation { next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2); - next + (next, anim_events) } } diff --git a/voxygen/anim/src/theropod/run.rs b/voxygen/anim/src/theropod/run.rs index c446e87184..2376451534 100644 --- a/voxygen/anim/src/theropod/run.rs +++ b/voxygen/anim/src/theropod/run.rs @@ -1,4 +1,4 @@ -use super::{super::Animation, SkeletonAttr, TheropodSkeleton}; +use super::{super::{AnimationEvent, Animation}, SkeletonAttr, TheropodSkeleton}; //use std::{f32::consts::PI, ops::Mul}; use super::super::vek::*; use std::f32::consts::PI; @@ -19,8 +19,9 @@ impl Animation for RunAnimation { anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, - ) -> Self::Skeleton { + ) -> (Self::Skeleton, Vec) { let mut next = (*skeleton).clone(); + let anim_events: Vec = Vec::new(); let speed = (Vec2::::from(velocity).magnitude()).min(22.0); *rate = 1.0; @@ -145,6 +146,6 @@ impl Animation for RunAnimation { next.foot_r.orientation = Quaternion::rotation_x(-0.2 * speednorm + foot2b * -0.35) * Quaternion::rotation_y(tilt * -1.0); - next + (next, anim_events) } } diff --git a/voxygen/src/audio/sfx/event_mapper/mod.rs b/voxygen/src/audio/sfx/event_mapper/mod.rs index 844c472ad9..7a1cb466b2 100644 --- a/voxygen/src/audio/sfx/event_mapper/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/mod.rs @@ -1,7 +1,7 @@ mod block; mod campfire; mod combat; -mod movement; +//mod movement; use client::Client; use common::terrain::TerrainChunk; @@ -10,7 +10,7 @@ use common_state::State; use block::BlockEventMapper; use campfire::CampfireEventMapper; use combat::CombatEventMapper; -use movement::MovementEventMapper; +//use movement::MovementEventMapper; use super::SfxTriggers; use crate::{ @@ -40,7 +40,7 @@ impl SfxEventMapper { Self { mappers: vec![ Box::new(CombatEventMapper::new()), - Box::new(MovementEventMapper::new()), + //Box::new(MovementEventMapper::new()), Box::new(BlockEventMapper::new()), Box::new(CampfireEventMapper::new()), ], diff --git a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs index d4300e1610..4d4e1bc21c 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs @@ -12,7 +12,6 @@ use common::{ comp::{Body, CharacterState, PhysicsState, Pos, Vel}, resources::DeltaTime, terrain::{BlockKind, TerrainChunk}, - vol::ReadVol, }; use common_state::State; use hashbrown::HashMap; @@ -100,23 +99,23 @@ impl EventMapper for MovementEventMapper { }; // Check for SFX config entry for this movement - if Self::should_emit(internal_state, triggers.get_key_value(&mapped_event)) { - let underwater = state - .terrain() - .get(cam_pos.map(|e| e.floor() as i32)) - .map(|b| b.is_liquid()) - .unwrap_or(false); + //if Self::should_emit(internal_state, triggers.get_key_value(&mapped_event)) { + // let underwater = state + // .terrain() + // .get(cam_pos.map(|e| e.floor() as i32)) + // .map(|b| b.is_liquid()) + // .unwrap_or(false); - let sfx_trigger_item = triggers.get_key_value(&mapped_event); - audio.emit_sfx( - sfx_trigger_item, - pos.0, - Some(Self::get_volume_for_body_type(body)), - underwater, - ); - internal_state.time = Instant::now(); - internal_state.distance_travelled = 0.0; - } + // let sfx_trigger_item = triggers.get_key_value(&mapped_event); + // audio.emit_sfx( + // sfx_trigger_item, + // pos.0, + // Some(Self::get_volume_for_body_type(body)), + // underwater, + // ); + // internal_state.time = Instant::now(); + // internal_state.distance_travelled = 0.0; + //} // update state to determine the next event. We only record the time (above) if // it was dispatched @@ -160,24 +159,24 @@ impl MovementEventMapper { /// file(s) to play) 2. The sfx has not been played since it's timeout /// threshold has elapsed, which prevents firing every tick. For movement, /// threshold is not a time, but a distance. - fn should_emit( - previous_state: &PreviousEntityState, - sfx_trigger_item: Option<(&SfxEvent, &SfxTriggerItem)>, - ) -> bool { - if let Some((event, item)) = sfx_trigger_item { - if &previous_state.event == event { - match event { - SfxEvent::Run(_) => previous_state.distance_travelled >= item.threshold, - SfxEvent::QuadRun(_) => previous_state.distance_travelled >= item.threshold, - _ => previous_state.time.elapsed().as_secs_f32() >= item.threshold, - } - } else { - true - } - } else { - false - } - } + //fn should_emit( + // previous_state: &PreviousEntityState, + // sfx_trigger_item: Option<(&SfxEvent, &SfxTriggerItem)>, + //) -> bool { + // if let Some((event, item)) = sfx_trigger_item { + // if &previous_state.event == event { + // match event { + // SfxEvent::Run(_) => previous_state.distance_travelled >= item.threshold, + // SfxEvent::QuadRun(_) => previous_state.distance_travelled >= item.threshold, + // _ => previous_state.time.elapsed().as_secs_f32() >= item.threshold, + // } + // } else { + // true + // } + // } else { + // false + // } + //} /// Voxygen has an existing list of character states however that list does /// not provide enough resolution to target specific entity events, such @@ -272,20 +271,20 @@ impl MovementEventMapper { } } - /// Returns a relative volume value for a body type. This helps us emit sfx - /// at a volume appropriate fot the entity we are emitting the event for - fn get_volume_for_body_type(body: &Body) -> f32 { - match body { - Body::Humanoid(_) => 0.9, - Body::QuadrupedSmall(_) => 0.3, - Body::QuadrupedMedium(_) => 0.7, - Body::QuadrupedLow(_) => 0.7, - Body::BirdMedium(_) => 0.3, - Body::BirdLarge(_) => 0.2, - Body::BipedLarge(_) => 1.0, - _ => 0.9, - } - } + ///// Returns a relative volume value for a body type. This helps us emit sfx + ///// at a volume appropriate fot the entity we are emitting the event for + //fn get_volume_for_body_type(body: &Body) -> f32 { + // match body { + // Body::Humanoid(_) => 0.9, + // Body::QuadrupedSmall(_) => 0.3, + // Body::QuadrupedMedium(_) => 0.7, + // Body::QuadrupedLow(_) => 0.7, + // Body::BirdMedium(_) => 0.3, + // Body::BirdLarge(_) => 0.2, + // Body::BipedLarge(_) => 1.0, + // _ => 0.9, + // } + //} } #[cfg(test)] mod tests; diff --git a/voxygen/src/audio/sfx/mod.rs b/voxygen/src/audio/sfx/mod.rs index 60bf4b4594..0d4bc7d8ab 100644 --- a/voxygen/src/audio/sfx/mod.rs +++ b/voxygen/src/audio/sfx/mod.rs @@ -313,9 +313,22 @@ impl SfxMgr { return; } let triggers = self.triggers.read(); + println!("outcome: {:?}", outcome); // TODO handle underwater match outcome { + Outcome::Footstep { + pos, + .. + } => { + let sfx_trigger_item = triggers.get_key_value(&SfxEvent::Run(BlockKind::Grass)); + audio.emit_sfx( + sfx_trigger_item, + *pos, + Some(1.0), + false, + ); + }, Outcome::Explosion { pos, power, .. } => { let sfx_trigger_item = triggers.get_key_value(&SfxEvent::Explosion); audio.emit_sfx( diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 32c91928df..182d04c006 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -23,7 +23,7 @@ use anim::{ dragon::DragonSkeleton, fish_medium::FishMediumSkeleton, fish_small::FishSmallSkeleton, golem::GolemSkeleton, object::ObjectSkeleton, quadruped_low::QuadrupedLowSkeleton, quadruped_medium::QuadrupedMediumSkeleton, quadruped_small::QuadrupedSmallSkeleton, - ship::ShipSkeleton, theropod::TheropodSkeleton, Animation, Skeleton, + ship::ShipSkeleton, theropod::TheropodSkeleton, AnimationEvent, Animation, Skeleton, }; use common::{ comp::{ @@ -32,6 +32,7 @@ use common::{ Body, CharacterState, Controller, Health, Inventory, Item, Last, LightAnimation, LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale, Vel, }, + outcome::Outcome, resources::DeltaTime, states::utils::StageSection, terrain::TerrainChunk, @@ -489,6 +490,7 @@ impl FigureMgr { visible_psr_bounds: math::Aabr, camera: &Camera, terrain: Option<&Terrain>, + outcomes: &mut Vec, ) -> anim::vek::Aabb { span!(_guard, "maintain", "FigureManager::maintain"); let state = scene_data.state; @@ -791,7 +793,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -859,7 +861,7 @@ impl FigureMgr { skeleton_attr, ), }; - let target_bones = match &character { + let (target_bones, anim_events) = match &character { CharacterState::Roll(s) => { let stage_time = s.timer.as_secs_f32(); @@ -1526,9 +1528,23 @@ impl FigureMgr { skeleton_attr, ) }, - _ => target_base, + _ => (target_base, anim_events), }; + // Append new outcomes to the outcome resource + for anim_event in anim_events { + match anim_event { + AnimationEvent::Footstep { pos_offset } => { + let pos = pos.0 + pos_offset; + outcomes.push(Outcome::Footstep { + pos: Vec3::new(pos.x, pos.y, pos.z), + vel: vel.0.magnitude_squared(), + }); + }, + _ => {}, + } + } + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); state.update( renderer, @@ -1581,7 +1597,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -1646,7 +1662,7 @@ impl FigureMgr { skeleton_attr, ), }; - let target_bones = match &character { + let (target_bones, _anim_events) = match &character { CharacterState::ComboMelee(s) => { let stage_index = (s.stage - 1) as usize; let stage_time = s.timer.as_secs_f32(); @@ -1728,7 +1744,7 @@ impl FigureMgr { ) }, // TODO! - _ => target_base, + _ => (target_base, anim_events), }; state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); @@ -1783,7 +1799,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > 0.25, // Moving physics.in_liquid().is_some(), // In water @@ -1850,7 +1866,7 @@ impl FigureMgr { skeleton_attr, ), }; - let target_bones = match &character { + let (target_bones, _anim_events) = match &character { CharacterState::BasicMelee(s) => { let stage_time = s.timer.as_secs_f32(); @@ -2055,7 +2071,7 @@ impl FigureMgr { ) }, // TODO! - _ => target_base, + _ => (target_base, anim_events), }; state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); @@ -2110,7 +2126,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -2173,7 +2189,7 @@ impl FigureMgr { skeleton_attr, ), }; - let target_bones = match &character { + let (target_bones, _anim_events) = match &character { CharacterState::BasicRanged(s) => { let stage_time = s.timer.as_secs_f32(); @@ -2415,7 +2431,7 @@ impl FigureMgr { ) }, // TODO! - _ => target_base, + _ => (target_base, anim_events), }; state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); @@ -2469,7 +2485,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -2514,7 +2530,7 @@ impl FigureMgr { skeleton_attr, ), }; - let target_bones = match &character { + let (target_bones, _anim_events) = match &character { CharacterState::Sit { .. } => { anim::bird_medium::FeedAnimation::update_skeleton( &target_base, @@ -2525,7 +2541,7 @@ impl FigureMgr { ) }, // TODO! - _ => target_base, + _ => (target_base, anim_events), }; state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); @@ -2579,7 +2595,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, _anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -2668,7 +2684,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -2747,7 +2763,7 @@ impl FigureMgr { ), }; - let target_bones = match &character { + let (target_bones, _anim_events) = match &character { CharacterState::Wielding { .. } => { anim::biped_small::WieldAnimation::update_skeleton( &target_base, @@ -2962,7 +2978,7 @@ impl FigureMgr { } }, // TODO! - _ => target_base, + _ => (target_base, anim_events), }; state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); @@ -3013,7 +3029,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, _anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -3108,7 +3124,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -3160,7 +3176,7 @@ impl FigureMgr { skeleton_attr, ), }; - let target_bones = match &character { + let (target_bones, _anim_events) = match &character { CharacterState::ComboMelee(s) => { let stage_index = (s.stage - 1) as usize; let stage_time = s.timer.as_secs_f32(); @@ -3243,7 +3259,7 @@ impl FigureMgr { ) }, // TODO! - _ => target_base, + _ => (target_base, anim_events), }; state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); @@ -3294,7 +3310,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -3351,7 +3367,7 @@ impl FigureMgr { skeleton_attr, ), }; - let target_bones = match &character { + let (target_bones, _anim_events) = match &character { CharacterState::Sit { .. } => { anim::bird_large::FeedAnimation::update_skeleton( &target_base, @@ -3504,7 +3520,7 @@ impl FigureMgr { } }, // TODO! - _ => target_base, + _ => (target_base, anim_events), }; state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); @@ -3558,7 +3574,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, _anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -3647,7 +3663,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -3686,7 +3702,7 @@ impl FigureMgr { skeleton_attr, ), }; - let target_bones = match &character { + let (target_bones, _anim_events) = match &character { CharacterState::Equipping { .. } => { anim::biped_large::EquipAnimation::update_skeleton( &target_base, @@ -4117,7 +4133,7 @@ impl FigureMgr { ) }, // TODO! - _ => target_base, + _ => (target_base, anim_events), }; state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); @@ -4168,7 +4184,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -4219,7 +4235,7 @@ impl FigureMgr { skeleton_attr, ), }; - let target_bones = match &character { + let (target_bones, _anim_events) = match &character { CharacterState::ComboMelee(s) => { let stage_index = (s.stage - 1) as usize; let stage_time = s.timer.as_secs_f32(); @@ -4301,7 +4317,7 @@ impl FigureMgr { ) }, // TODO! - _ => target_base, + _ => (target_base, anim_events), }; state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); @@ -4354,7 +4370,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -4376,7 +4392,7 @@ impl FigureMgr { ), }; - let target_bones = match &character { + let (target_bones, _anim_events) = match &character { CharacterState::BasicRanged(s) => { let stage_time = s.timer.as_secs_f32(); @@ -4429,7 +4445,7 @@ impl FigureMgr { ) }, // TODO! - _ => target_base, + _ => (target_base, anim_events), }; state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); @@ -4483,7 +4499,7 @@ impl FigureMgr { state.state_time = 0.0; } - let target_base = match ( + let (target_base, anim_events) = match ( physics.on_ground, rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving physics.in_liquid().is_some(), // In water @@ -4520,9 +4536,9 @@ impl FigureMgr { }; #[allow(clippy::match_single_binding)] - let target_bones = match &character { + let (target_bones, _anim_events) = match &character { // TODO! - _ => target_base, + _ => (target_base, anim_events), }; state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index daff82a064..aae49307ff 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -459,6 +459,7 @@ impl Scene { audio: &mut AudioFrontend, scene_data: &SceneData, client: &Client, + outcomes: &mut Vec, ) { span!(_guard, "maintain", "Scene::maintain"); // Get player position. @@ -705,6 +706,7 @@ impl Scene { visible_psr_bounds, &self.camera, Some(&self.terrain), + outcomes, ); let sun_dir = scene_data.get_sun_dir(); diff --git a/voxygen/src/scene/particle.rs b/voxygen/src/scene/particle.rs index 53ae2aea42..8cceae33a8 100644 --- a/voxygen/src/scene/particle.rs +++ b/voxygen/src/scene/particle.rs @@ -215,6 +215,11 @@ impl ParticleMgr { }); } }, + Outcome::Footstep { pos, .. } => { + self.particles.resize_with(self.particles.len() + 30, || { + Particle::new(Duration::from_millis(250), time, ParticleMode::Blood, *pos) + }); + }, Outcome::ProjectileShot { .. } | Outcome::Beam { .. } | Outcome::ExpChange { .. } diff --git a/voxygen/src/scene/simple.rs b/voxygen/src/scene/simple.rs index 4901a5972c..2f9162d748 100644 --- a/voxygen/src/scene/simple.rs +++ b/voxygen/src/scene/simple.rs @@ -331,7 +331,7 @@ impl Scene { let hands = (active_tool_hand, second_tool_hand); if let Some(body) = scene_data.body { - let tgt_skeleton = IdleAnimation::update_skeleton( + let (tgt_skeleton, _outcomes) = IdleAnimation::update_skeleton( self.figure_state.skeleton_mut(), ( active_tool_kind, diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index 57f293f0d7..3a0b485ed7 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -1263,6 +1263,7 @@ impl PlayState for SessionState { &mut global_state.audio, &scene_data, &client, + &mut outcomes, ); // Process outcomes from client