This commit is contained in:
jshipsey 2021-06-25 22:48:48 -04:00 committed by Sam
parent 9ff7ecea81
commit 37c6fe9ee8
8 changed files with 240 additions and 12 deletions

View File

@ -177,6 +177,7 @@ impl CharacterState {
| CharacterState::Shockwave(_)
| CharacterState::BasicBeam(_)
| CharacterState::Stunned(_)
| CharacterState::UseItem(_)
| CharacterState::Wielding
| CharacterState::Talk
| CharacterState::HealingBeam(_)

View File

@ -588,14 +588,14 @@ pub fn handle_manipulate_loadout(
// (buildup, use, recover)
let durations = match item_kind {
ItemUseKind::Consumable(ConsumableKind::Potion) => (
Duration::from_secs_f32(0.25),
Duration::from_secs_f32(1.0),
Duration::from_secs_f32(0.25),
Duration::from_secs_f32(0.1),
Duration::from_secs_f32(1.1),
Duration::from_secs_f32(0.1),
),
ItemUseKind::Consumable(ConsumableKind::Food) => (
Duration::from_secs_f32(1.0),
Duration::from_secs_f32(5.0),
Duration::from_secs_f32(1.0),
Duration::from_secs_f32(0.5),
),
};
// If item returns a valid kind for item use, do into use item character state

View File

@ -0,0 +1,29 @@
{
"traceEvents": [
{ "pid":1, "tid":1, "ts":1624490729402630.3, "dur":4148.4832763671875, "ph":"X", "name":"frame" },
{ "pid":1, "tid":1, "ts":1624490729402665, "dur":160.45570373535156, "ph":"X", "name":"shadow_pass" },
{ "pid":1, "tid":1, "ts":1624490729402665.8, "dur":149.25003051757813, "ph":"X", "name":"direcred_terrain_shadows" },
{ "pid":1, "tid":1, "ts":1624490729402815.5, "dur":9.5367431640625, "ph":"X", "name":"direcred_figure_shadows" },
{ "pid":1, "tid":1, "ts":1624490729402828, "dur":200.74844360351563, "ph":"X", "name":"point shadows" },
{ "pid":1, "tid":1, "ts":1624490729402845.8, "dur":18.835067749023438, "ph":"X", "name":"point shadow face-0 pass" },
{ "pid":1, "tid":1, "ts":1624490729402876.8, "dur":20.02716064453125, "ph":"X", "name":"point shadow face-1 pass" },
{ "pid":1, "tid":1, "ts":1624490729402908.8, "dur":21.219253540039063, "ph":"X", "name":"point shadow face-2 pass" },
{ "pid":1, "tid":1, "ts":1624490729402942.3, "dur":20.503997802734375, "ph":"X", "name":"point shadow face-3 pass" },
{ "pid":1, "tid":1, "ts":1624490729402975, "dur":18.358230590820313, "ph":"X", "name":"point shadow face-4 pass" },
{ "pid":1, "tid":1, "ts":1624490729403005.5, "dur":20.503997802734375, "ph":"X", "name":"point shadow face-5 pass" },
{ "pid":1, "tid":1, "ts":1624490729403062.5, "dur":2062.7975463867188, "ph":"X", "name":"first_pass" },
{ "pid":1, "tid":1, "ts":1624490729403063, "dur":51.021575927734375, "ph":"X", "name":"figures" },
{ "pid":1, "tid":1, "ts":1624490729403114.3, "dur":1763.3438110351563, "ph":"X", "name":"terrain" },
{ "pid":1, "tid":1, "ts":1624490729404879, "dur":56.02836608886719, "ph":"X", "name":"figures" },
{ "pid":1, "tid":1, "ts":1624490729404936, "dur":116.58668518066406, "ph":"X", "name":"lod_terrain" },
{ "pid":1, "tid":1, "ts":1624490729405053.5, "dur":0.2384185791015625, "ph":"X", "name":"skybox" },
{ "pid":1, "tid":1, "ts":1624490729405055, "dur":31.232833862304688, "ph":"X", "name":"sprites" },
{ "pid":1, "tid":1, "ts":1624490729405086.5, "dur":1.1920928955078125, "ph":"X", "name":"fluid" },
{ "pid":1, "tid":1, "ts":1624490729405088.5, "dur":34.809112548828125, "ph":"X", "name":"particles" },
{ "pid":1, "tid":1, "ts":1624490729405124.8, "dur":0.7152557373046875, "ph":"X", "name":"debug" },
{ "pid":1, "tid":1, "ts":1624490729405145.3, "dur":1360.6548309326172, "ph":"X", "name":"second_pass" },
{ "pid":1, "tid":1, "ts":1624490729406520, "dur":255.34629821777344, "ph":"X", "name":"third_pass" },
{ "pid":1, "tid":1, "ts":1624490729406520, "dur":229.12025451660156, "ph":"X", "name":"postprocess" },
{ "pid":1, "tid":1, "ts":1624490729406749.5, "dur":24.557113647460938, "ph":"X", "name":"ui" }
]
}

View File

@ -0,0 +1,19 @@
{
"traceEvents": [
{ "pid":1, "tid":1, "ts":1624496546983163, "dur":5097.150802612305, "ph":"X", "name":"frame" },
{ "pid":1, "tid":1, "ts":1624496546983189.5, "dur":2680.7785034179688, "ph":"X", "name":"first_pass" },
{ "pid":1, "tid":1, "ts":1624496546983190.8, "dur":49.591064453125, "ph":"X", "name":"figures" },
{ "pid":1, "tid":1, "ts":1624496546983241.5, "dur":371.69456481933594, "ph":"X", "name":"terrain" },
{ "pid":1, "tid":1, "ts":1624496546983614.3, "dur":0.7152557373046875, "ph":"X", "name":"figures" },
{ "pid":1, "tid":1, "ts":1624496546983615.3, "dur":335.45494079589844, "ph":"X", "name":"lod_terrain" },
{ "pid":1, "tid":1, "ts":1624496546983951.3, "dur":22.649765014648438, "ph":"X", "name":"skybox" },
{ "pid":1, "tid":1, "ts":1624496546983973.8, "dur":22.172927856445313, "ph":"X", "name":"sprites" },
{ "pid":1, "tid":1, "ts":1624496546983996, "dur":1871.347427368164, "ph":"X", "name":"fluid" },
{ "pid":1, "tid":1, "ts":1624496546985868, "dur":0, "ph":"X", "name":"particles" },
{ "pid":1, "tid":1, "ts":1624496546985869.5, "dur":0.7152557373046875, "ph":"X", "name":"debug" },
{ "pid":1, "tid":1, "ts":1624496546985886.3, "dur":2170.562744140625, "ph":"X", "name":"second_pass" },
{ "pid":1, "tid":1, "ts":1624496546988067.5, "dur":190.73486328125, "ph":"X", "name":"third_pass" },
{ "pid":1, "tid":1, "ts":1624496546988067.8, "dur":188.35067749023438, "ph":"X", "name":"postprocess" },
{ "pid":1, "tid":1, "ts":1624496546988255.8, "dur":1.6689300537109375, "ph":"X", "name":"ui" }
]
}

View File

@ -0,0 +1,29 @@
{
"traceEvents": [
{ "pid":1, "tid":1, "ts":1624499189977124.5, "dur":5191.564559936523, "ph":"X", "name":"frame" },
{ "pid":1, "tid":1, "ts":1624499189977170.8, "dur":362.396240234375, "ph":"X", "name":"shadow_pass" },
{ "pid":1, "tid":1, "ts":1624499189977171.8, "dur":352.3826599121094, "ph":"X", "name":"direcred_terrain_shadows" },
{ "pid":1, "tid":1, "ts":1624499189977524.8, "dur":7.8678131103515625, "ph":"X", "name":"direcred_figure_shadows" },
{ "pid":1, "tid":1, "ts":1624499189977535.5, "dur":323.29559326171875, "ph":"X", "name":"point shadows" },
{ "pid":1, "tid":1, "ts":1624499189977546.8, "dur":39.81590270996094, "ph":"X", "name":"point shadow face-0 pass" },
{ "pid":1, "tid":1, "ts":1624499189977605, "dur":44.58427429199219, "ph":"X", "name":"point shadow face-1 pass" },
{ "pid":1, "tid":1, "ts":1624499189977656, "dur":46.96846008300781, "ph":"X", "name":"point shadow face-2 pass" },
{ "pid":1, "tid":1, "ts":1624499189977711.3, "dur":43.15376281738281, "ph":"X", "name":"point shadow face-3 pass" },
{ "pid":1, "tid":1, "ts":1624499189977762.8, "dur":40.29273986816406, "ph":"X", "name":"point shadow face-4 pass" },
{ "pid":1, "tid":1, "ts":1624499189977809.5, "dur":46.96846008300781, "ph":"X", "name":"point shadow face-5 pass" },
{ "pid":1, "tid":1, "ts":1624499189977879.5, "dur":2310.2760314941406, "ph":"X", "name":"first_pass" },
{ "pid":1, "tid":1, "ts":1624499189977881.3, "dur":10.251998901367188, "ph":"X", "name":"figures" },
{ "pid":1, "tid":1, "ts":1624499189977892.5, "dur":1368.2842254638672, "ph":"X", "name":"terrain" },
{ "pid":1, "tid":1, "ts":1624499189979261.5, "dur":159.5020294189453, "ph":"X", "name":"figures" },
{ "pid":1, "tid":1, "ts":1624499189979421.5, "dur":728.607177734375, "ph":"X", "name":"lod_terrain" },
{ "pid":1, "tid":1, "ts":1624499189980150.5, "dur":18.596649169921875, "ph":"X", "name":"skybox" },
{ "pid":1, "tid":1, "ts":1624499189980170.5, "dur":0.476837158203125, "ph":"X", "name":"sprites" },
{ "pid":1, "tid":1, "ts":1624499189980171, "dur":1.1920928955078125, "ph":"X", "name":"fluid" },
{ "pid":1, "tid":1, "ts":1624499189980172.8, "dur":14.543533325195313, "ph":"X", "name":"particles" },
{ "pid":1, "tid":1, "ts":1624499189980188.5, "dur":0.476837158203125, "ph":"X", "name":"debug" },
{ "pid":1, "tid":1, "ts":1624499189980201.8, "dur":1928.3294677734375, "ph":"X", "name":"second_pass" },
{ "pid":1, "tid":1, "ts":1624499189982139.3, "dur":174.04556274414063, "ph":"X", "name":"third_pass" },
{ "pid":1, "tid":1, "ts":1624499189982140.3, "dur":171.18453979492188, "ph":"X", "name":"postprocess" },
{ "pid":1, "tid":1, "ts":1624499189982312.8, "dur":0.476837158203125, "ph":"X", "name":"ui" }
]
}

View File

@ -0,0 +1,128 @@
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::{
comp::item::ConsumableKind,
states::{use_item::ItemUseKind, utils::StageSection},
};
pub struct ConsumeAnimation;
impl Animation for ConsumeAnimation {
type Dependency<'a> = (f32, Option<StageSection>, Option<ItemUseKind>);
type Skeleton = CharacterSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"character_consume\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_consume")]
fn update_skeleton_inner<'a>(
skeleton: &Self::Skeleton,
(_global_time, stage_section, item_kind): Self::Dependency<'a>,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
match item_kind {
Some(ItemUseKind::Consumable(ConsumableKind::Potion)) => {
let (move1, move2, move3) = match stage_section {
Some(StageSection::Buildup) => (anim_time, 0.0, 0.0),
Some(StageSection::Use) => (1.0, (anim_time * 8.0).sin(), 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time.powf(0.25)),
_ => (0.0, 0.0, 0.0),
};
let pullback = 1.0 - move3;
let move2 = move2 * pullback;
let move1 = move1 * pullback;
next.head.orientation = Quaternion::rotation_x(move1 * 0.5 + move2 * -0.05);
next.hand_r.position = Vec3::new(
s_a.hand.0 + move1 * -4.0,
s_a.hand.1 + move1 * 6.0,
s_a.hand.2 + move1 * 10.0 + move2 * -1.0,
);
next.hand_r.orientation = Quaternion::rotation_x(move1 * 2.3 + move2 * -0.2)
* Quaternion::rotation_y(move1 * 1.2);
next.chest.orientation = Quaternion::rotation_x(move1 * 0.25);
next.hand_l.position = Vec3::new(
-s_a.hand.0 + move1 * 3.0,
s_a.hand.1 + move1 * 2.0,
s_a.hand.2,
);
next.hand_l.orientation =
Quaternion::rotation_x(move1 * 0.8) * Quaternion::rotation_y(move1 * -0.5);
},
Some(ItemUseKind::Consumable(ConsumableKind::Food)) => {
let (move1, move2, move3) = match stage_section {
Some(StageSection::Buildup) => (anim_time, 0.0, 0.0),
Some(StageSection::Use) => (1.0, (anim_time * 12.0).sin(), 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time.powf(0.25)),
_ => (0.0, 0.0, 0.0),
};
let pullback = 1.0 - move3;
let move2 = move2 * pullback;
let move1 = move1 * pullback;
next.head.position =
Vec3::new(0.0, s_a.head.0 + move1 * 2.0, s_a.head.1 + move1 * 1.0);
next.head.orientation =
Quaternion::rotation_x(move1 * -0.3) * Quaternion::rotation_z(move2 * -0.15);
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + move1 * -3.0);
next.chest.orientation =
Quaternion::rotation_x(move1 * 0.3) * Quaternion::rotation_z(move2 * 0.05);
next.belt.position = Vec3::new(0.0, s_a.belt.0 + move1 * 1.0, s_a.belt.1);
next.belt.orientation = Quaternion::rotation_x(move1 * 0.2);
next.back.position = Vec3::new(0.0, s_a.back.0, s_a.back.1);
next.shorts.position = Vec3::new(0.0, s_a.shorts.0 + move1 * 3.0, s_a.shorts.1);
next.shorts.orientation = Quaternion::rotation_x(move1 * 0.7);
next.hand_l.position = Vec3::new(
-s_a.hand.0 + move1 * 3.0 + move2 * -1.0,
s_a.hand.1 + move1 * 5.0,
s_a.hand.2 + move1 * 3.0 + move2 * -2.0,
);
next.hand_l.orientation = Quaternion::rotation_x(move1 * 1.2)
* Quaternion::rotation_y(move1 * -0.5 + move2 * 0.3);
next.hand_r.position = Vec3::new(
s_a.hand.0 + move1 * -3.0 + move2 * -1.0,
s_a.hand.1 + move1 * 5.0,
s_a.hand.2 + move1 * 3.0 + move2 * 2.0,
);
next.hand_r.orientation = Quaternion::rotation_x(move1 * 1.2)
* Quaternion::rotation_y(move1 * 0.5 + move2 * 0.3);
next.foot_l.position = Vec3::new(
-s_a.foot.0,
s_a.foot.1 + move1 * 5.0,
s_a.foot.2 + move1 * 2.0,
);
next.foot_l.orientation = Quaternion::rotation_x(move1 * 1.2);
next.foot_r.position = Vec3::new(
s_a.foot.0,
s_a.foot.1 + move1 * 5.0,
s_a.foot.2 + move1 * 2.0,
);
next.foot_r.orientation = Quaternion::rotation_x(move1 * 1.2);
next.shoulder_l.position =
Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_r.position =
Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
},
_ => {},
}
next
}
}

View File

@ -4,6 +4,7 @@ pub mod beta;
pub mod block;
pub mod chargeswing;
pub mod climb;
pub mod consume;
pub mod dance;
pub mod dash;
pub mod equip;
@ -32,14 +33,14 @@ pub mod wield;
// Reexports
pub use self::{
alpha::AlphaAnimation, beam::BeamAnimation, beta::BetaAnimation, block::BlockAnimation,
chargeswing::ChargeswingAnimation, climb::ClimbAnimation, dance::DanceAnimation,
dash::DashAnimation, equip::EquipAnimation, glidewield::GlideWieldAnimation,
gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, leapmelee::LeapAnimation,
repeater::RepeaterAnimation, roll::RollAnimation, run::RunAnimation,
shockwave::ShockwaveAnimation, shoot::ShootAnimation, sit::SitAnimation, sneak::SneakAnimation,
spin::SpinAnimation, spinmelee::SpinMeleeAnimation, staggered::StaggeredAnimation,
stand::StandAnimation, stunned::StunnedAnimation, swim::SwimAnimation,
swimwield::SwimWieldAnimation, talk::TalkAnimation, wield::WieldAnimation,
chargeswing::ChargeswingAnimation, climb::ClimbAnimation, consume::ConsumeAnimation,
dance::DanceAnimation, dash::DashAnimation, equip::EquipAnimation,
glidewield::GlideWieldAnimation, gliding::GlidingAnimation, idle::IdleAnimation,
jump::JumpAnimation, leapmelee::LeapAnimation, repeater::RepeaterAnimation,
roll::RollAnimation, run::RunAnimation, shockwave::ShockwaveAnimation, shoot::ShootAnimation,
sit::SitAnimation, sneak::SneakAnimation, spin::SpinAnimation, spinmelee::SpinMeleeAnimation,
staggered::StaggeredAnimation, stand::StandAnimation, stunned::StunnedAnimation,
swim::SwimAnimation, swimwield::SwimWieldAnimation, talk::TalkAnimation, wield::WieldAnimation,
};
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
use common::comp;

View File

@ -1426,6 +1426,27 @@ impl FigureMgr {
skeleton_attr,
)
},
CharacterState::UseItem(s) => {
let stage_time = s.timer.as_secs_f32();
let item_kind = s.static_data.item_kind;
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time / s.static_data.buildup_duration.as_secs_f32()
},
StageSection::Use => stage_time,
StageSection::Recover => {
stage_time / s.static_data.recover_duration.as_secs_f32()
},
_ => 0.0,
};
anim::character::ConsumeAnimation::update_skeleton(
&target_base,
(time, Some(s.stage_section), Some(item_kind)),
stage_progress,
&mut state_animation_rate,
skeleton_attr,
)
},
CharacterState::Equipping { .. } => {
anim::character::EquipAnimation::update_skeleton(
&target_base,