mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added wielding for wallrunning
This commit is contained in:
parent
64cb9b099d
commit
e293de5bae
@ -177,6 +177,7 @@ impl CharacterState {
|
||||
was_wielded: true,
|
||||
..
|
||||
})
|
||||
| CharacterState::Wallrun(wallrun::Data { was_wielded: true })
|
||||
| CharacterState::Stunned(stunned::Data {
|
||||
was_wielded: true,
|
||||
..
|
||||
@ -194,6 +195,7 @@ impl CharacterState {
|
||||
CharacterState::Stunned(data) => data.was_wielded,
|
||||
CharacterState::SpriteInteract(data) => data.static_data.was_wielded,
|
||||
CharacterState::UseItem(data) => data.static_data.was_wielded,
|
||||
CharacterState::Wallrun(data) => data.was_wielded,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -895,7 +895,9 @@ pub fn handle_wallrun(data: &JoinData<'_>, update: &mut StateUpdate) -> bool {
|
||||
&& data.physics.in_liquid().is_none()
|
||||
&& data.body.can_climb()
|
||||
{
|
||||
update.character = CharacterState::Wallrun(wallrun::Data);
|
||||
update.character = CharacterState::Wallrun(wallrun::Data {
|
||||
was_wielded: data.character.is_wield() || data.character.was_wielded(),
|
||||
});
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
@ -3,7 +3,7 @@ use crate::{
|
||||
comp::{character_state::OutputEvents, CharacterState, StateUpdate},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
idle,
|
||||
idle, wielding,
|
||||
},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -12,7 +12,10 @@ use vek::Vec2;
|
||||
const WALLRUN_ANTIGRAV: f32 = crate::consts::GRAVITY * 0.5;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct Data;
|
||||
pub struct Data {
|
||||
/// Had weapon
|
||||
pub was_wielded: bool,
|
||||
}
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
||||
@ -36,7 +39,11 @@ impl CharacterBehavior for Data {
|
||||
|| data.physics.on_ground.is_some()
|
||||
|| data.physics.in_liquid().is_some()
|
||||
{
|
||||
update.character = CharacterState::Idle(idle::Data::default());
|
||||
update.character = if self.was_wielded {
|
||||
CharacterState::Wielding(wielding::Data { is_sneaking: false })
|
||||
} else {
|
||||
CharacterState::Idle(idle::Data::default())
|
||||
};
|
||||
}
|
||||
|
||||
update
|
||||
|
@ -26,6 +26,7 @@ impl CharacterBehavior for Data {
|
||||
handle_climb(data, &mut update);
|
||||
attempt_input(data, output_events, &mut update);
|
||||
handle_jump(data, output_events, &mut update, 1.0);
|
||||
handle_wallrun(data, &mut update);
|
||||
|
||||
if self.is_sneaking
|
||||
&& (data.physics.on_ground.is_none() || data.physics.in_liquid().is_some())
|
||||
|
@ -195,9 +195,9 @@ impl Animation for RunAnimation {
|
||||
(1.0 - sideabs) * (foothoril + 0.4 * (1.0 - sideabs)) * -1.5 * speednorm
|
||||
+ sideabs * -0.5,
|
||||
) * Quaternion::rotation_y(
|
||||
tilt * -0.5 + side * 0.3 + side * (foothoril * 0.3),
|
||||
tilt * -0.5 + side * (foothoril * 0.3) + footstrafer * side * 0.5,
|
||||
) * Quaternion::rotation_z(
|
||||
side * 0.9 * orientation.xy().dot(velocity.xy() / (speed + 0.01)),
|
||||
side * 1.3 * orientation.xy().dot(velocity.xy() / (speed + 0.01)),
|
||||
);
|
||||
|
||||
next.foot_r.position = Vec3::new(
|
||||
@ -211,9 +211,9 @@ impl Animation for RunAnimation {
|
||||
(1.0 - sideabs) * (foothorir + 0.4 * (1.0 - sideabs)) * -1.5 * speednorm
|
||||
+ sideabs * -0.5,
|
||||
) * Quaternion::rotation_y(
|
||||
tilt * -0.5 + side * 0.3 + side * (foothorir * 0.3),
|
||||
tilt * -0.5 + side * (foothorir * 0.3) - footstrafer * side * 0.5,
|
||||
) * Quaternion::rotation_z(
|
||||
side * 0.9 * orientation.xy().dot(velocity.xy() / (speed + 0.01)),
|
||||
side * 1.3 * orientation.xy().dot(velocity.xy() / (speed + 0.01)),
|
||||
);
|
||||
//
|
||||
|
||||
|
@ -2,14 +2,21 @@ use super::{
|
||||
super::{vek::*, Animation},
|
||||
CharacterSkeleton, SkeletonAttr,
|
||||
};
|
||||
use common::comp::item::{AbilitySpec, Hands, ToolKind};
|
||||
use core::f32::consts::PI;
|
||||
|
||||
pub struct WallrunAnimation;
|
||||
|
||||
type WallrunAnimationDependency = (Vec3<f32>, f32, Option<Vec3<f32>>);
|
||||
|
||||
impl Animation for WallrunAnimation {
|
||||
type Dependency<'a> = WallrunAnimationDependency;
|
||||
type Dependency<'a> = (
|
||||
(Option<ToolKind>, Option<&'a AbilitySpec>),
|
||||
Option<ToolKind>,
|
||||
(Option<Hands>, Option<Hands>),
|
||||
Vec3<f32>,
|
||||
f32,
|
||||
Option<Vec3<f32>>,
|
||||
bool,
|
||||
);
|
||||
type Skeleton = CharacterSkeleton;
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
@ -19,7 +26,15 @@ impl Animation for WallrunAnimation {
|
||||
|
||||
fn update_skeleton_inner(
|
||||
skeleton: &Self::Skeleton,
|
||||
(orientation, acc_vel, wall): Self::Dependency<'_>,
|
||||
(
|
||||
(active_tool_kind, active_tool_spec),
|
||||
second_tool_kind,
|
||||
hands,
|
||||
orientation,
|
||||
acc_vel,
|
||||
wall,
|
||||
was_wielded,
|
||||
): Self::Dependency<'_>,
|
||||
_anim_time: f32,
|
||||
rate: &mut f32,
|
||||
s_a: &SkeletonAttr,
|
||||
@ -185,6 +200,173 @@ impl Animation for WallrunAnimation {
|
||||
* Quaternion::rotation_x(-0.1);
|
||||
};
|
||||
|
||||
if was_wielded {
|
||||
next.main.position = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.main.orientation = Quaternion::rotation_x(0.0);
|
||||
next.second.position = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.second.orientation = Quaternion::rotation_x(0.0);
|
||||
next.hold.scale = Vec3::one() * 0.0;
|
||||
|
||||
match (hands, active_tool_kind, second_tool_kind) {
|
||||
((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => {
|
||||
match tool {
|
||||
Some(ToolKind::Sword) => {
|
||||
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(s_a.shl.3)
|
||||
* Quaternion::rotation_y(s_a.shl.4);
|
||||
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
|
||||
next.hand_r.orientation = Quaternion::rotation_x(s_a.shr.3)
|
||||
* Quaternion::rotation_y(s_a.shr.4);
|
||||
|
||||
next.control.position = Vec3::new(s_a.sc.0, s_a.sc.1 - 3.0, s_a.sc.2);
|
||||
next.control.orientation =
|
||||
Quaternion::rotation_x(s_a.sc.3) * Quaternion::rotation_z(0.0);
|
||||
},
|
||||
Some(ToolKind::Axe) => {
|
||||
next.main.position = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.main.orientation = Quaternion::rotation_x(0.0);
|
||||
|
||||
next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(s_a.ahl.3)
|
||||
* Quaternion::rotation_y(s_a.ahl.4);
|
||||
next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1, s_a.ahr.2);
|
||||
next.hand_r.orientation = Quaternion::rotation_x(s_a.ahr.3)
|
||||
* Quaternion::rotation_z(s_a.ahr.5);
|
||||
|
||||
next.control.position = Vec3::new(s_a.ac.0, s_a.ac.1, s_a.ac.2);
|
||||
next.control.orientation = Quaternion::rotation_x(s_a.ac.3)
|
||||
* Quaternion::rotation_y(s_a.ac.4)
|
||||
* Quaternion::rotation_z(s_a.ac.5);
|
||||
},
|
||||
Some(ToolKind::Hammer | ToolKind::Pick | ToolKind::Shovel) => {
|
||||
next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3)
|
||||
* Quaternion::rotation_y(s_a.hhl.4)
|
||||
* Quaternion::rotation_z(s_a.hhl.5);
|
||||
next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1, s_a.hhr.2);
|
||||
next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3)
|
||||
* Quaternion::rotation_y(s_a.hhr.4)
|
||||
* Quaternion::rotation_z(s_a.hhr.5);
|
||||
|
||||
next.control.position = Vec3::new(s_a.hc.0, s_a.hc.1, s_a.hc.2 + 6.0);
|
||||
next.control.orientation = Quaternion::rotation_x(s_a.hc.3)
|
||||
* Quaternion::rotation_y(s_a.hc.4)
|
||||
* Quaternion::rotation_z(s_a.hc.5);
|
||||
},
|
||||
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
|
||||
next.hand_r.position = Vec3::new(s_a.sthr.0, s_a.sthr.1, s_a.sthr.2);
|
||||
next.hand_r.orientation = Quaternion::rotation_x(s_a.sthr.3)
|
||||
* Quaternion::rotation_y(s_a.sthr.4);
|
||||
|
||||
next.control.position =
|
||||
Vec3::new(s_a.stc.0, s_a.stc.1 - 2.0, s_a.stc.2 + 4.0);
|
||||
|
||||
next.hand_l.position = Vec3::new(s_a.sthl.0, s_a.sthl.1, s_a.sthl.2);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(s_a.sthl.3);
|
||||
|
||||
next.control.orientation = Quaternion::rotation_x(s_a.stc.3)
|
||||
* Quaternion::rotation_y(s_a.stc.4)
|
||||
* Quaternion::rotation_z(s_a.stc.5);
|
||||
},
|
||||
Some(ToolKind::Bow) => {
|
||||
next.main.position = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.main.orientation = Quaternion::rotation_x(0.0);
|
||||
next.hand_l.position = Vec3::new(s_a.bhl.0, s_a.bhl.1, s_a.bhl.2);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(s_a.bhl.3);
|
||||
next.hand_r.position = Vec3::new(s_a.bhr.0, s_a.bhr.1, s_a.bhr.2);
|
||||
next.hand_r.orientation = Quaternion::rotation_x(s_a.bhr.3);
|
||||
|
||||
next.hold.position = Vec3::new(0.0, -1.0, -5.2);
|
||||
next.hold.orientation = Quaternion::rotation_x(-PI / 2.0);
|
||||
next.hold.scale = Vec3::one() * 1.0;
|
||||
|
||||
next.control.position =
|
||||
Vec3::new(s_a.bc.0 + 2.0, s_a.bc.1, s_a.bc.2 + 5.0);
|
||||
next.control.orientation = Quaternion::rotation_x(0.8)
|
||||
* Quaternion::rotation_y(s_a.bc.4)
|
||||
* Quaternion::rotation_z(s_a.bc.5);
|
||||
},
|
||||
Some(ToolKind::Instrument) => {
|
||||
if let Some(AbilitySpec::Custom(spec)) = active_tool_spec {
|
||||
match spec.as_str() {
|
||||
"Washboard" => {
|
||||
next.hand_l.position = Vec3::new(-7.0, 0.0, 3.0);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(1.27);
|
||||
next.main.position = Vec3::new(-5.0, -4.5, -5.0);
|
||||
next.main.orientation = Quaternion::rotation_x(5.5);
|
||||
},
|
||||
_ => {
|
||||
next.hand_l.position = Vec3::new(-7.0, 4.0, 3.0);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(1.27);
|
||||
next.main.position = Vec3::new(-5.0, 5.0, 23.0);
|
||||
next.main.orientation = Quaternion::rotation_x(PI);
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
Some(ToolKind::Debug) => {
|
||||
next.hand_l.position = Vec3::new(-7.0, 4.0, 3.0);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(1.27);
|
||||
next.main.position = Vec3::new(-5.0, 5.0, 23.0);
|
||||
next.main.orientation = Quaternion::rotation_x(PI);
|
||||
},
|
||||
Some(ToolKind::Farming) => {
|
||||
next.head.orientation = Quaternion::rotation_x(-0.2);
|
||||
next.hand_l.position = Vec3::new(9.0, 1.0, 1.0);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
|
||||
next.hand_r.position = Vec3::new(9.0, 1.0, 11.0);
|
||||
next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0);
|
||||
next.main.position = Vec3::new(7.5, 7.5, 13.2);
|
||||
next.main.orientation = Quaternion::rotation_y(PI);
|
||||
|
||||
next.control.position = Vec3::new(-11.0, 1.8, 4.0);
|
||||
next.control.orientation = Quaternion::rotation_x(0.0)
|
||||
* Quaternion::rotation_y(0.6)
|
||||
* Quaternion::rotation_z(0.0);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
},
|
||||
((_, _), _, _) => {},
|
||||
};
|
||||
match hands {
|
||||
(Some(Hands::One), _) => {
|
||||
next.control_l.position = Vec3::new(-7.0, 6.0, 5.0);
|
||||
next.control_l.orientation =
|
||||
Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.2);
|
||||
next.hand_l.position = Vec3::new(-1.0, -0.5, 0.0);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0)
|
||||
},
|
||||
(_, _) => {},
|
||||
};
|
||||
match hands {
|
||||
(None | Some(Hands::One), Some(Hands::One)) => {
|
||||
next.control_r.position = Vec3::new(7.0, 6.0, 5.0);
|
||||
next.control_r.orientation =
|
||||
Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(-0.2);
|
||||
next.hand_r.position = Vec3::new(1.0, -0.5, 0.0);
|
||||
next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
|
||||
},
|
||||
(_, _) => {},
|
||||
};
|
||||
match hands {
|
||||
(None, None) | (None, Some(Hands::One)) => {
|
||||
next.hand_l.position = Vec3::new(-8.0, 2.0, 1.0);
|
||||
next.hand_l.orientation =
|
||||
Quaternion::rotation_x(0.5) * Quaternion::rotation_y(0.25);
|
||||
},
|
||||
(_, _) => {},
|
||||
};
|
||||
match hands {
|
||||
(None, None) | (Some(Hands::One), None) => {
|
||||
next.hand_r.position = Vec3::new(8.0, 2.0, 1.0);
|
||||
next.hand_r.orientation =
|
||||
Quaternion::rotation_x(0.5) * Quaternion::rotation_y(-0.25);
|
||||
},
|
||||
(_, _) => {},
|
||||
};
|
||||
}
|
||||
|
||||
next
|
||||
}
|
||||
}
|
||||
|
@ -2060,13 +2060,17 @@ impl FigureMgr {
|
||||
skeleton_attr,
|
||||
)
|
||||
},
|
||||
CharacterState::Wallrun { .. } => {
|
||||
CharacterState::Wallrun(data) => {
|
||||
anim::character::WallrunAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(
|
||||
(active_tool_kind, active_tool_spec),
|
||||
second_tool_kind,
|
||||
hands,
|
||||
ori * anim::vek::Vec3::<f32>::unit_y(),
|
||||
state.acc_vel,
|
||||
wall_dir,
|
||||
data.was_wielded,
|
||||
),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
|
Loading…
Reference in New Issue
Block a user