resolve conflicts merging master -> clientstates

This commit is contained in:
Adam Whitehurst 2020-03-07 12:49:48 -08:00
parent 096d3b691e
commit 54a7112ad9
15 changed files with 24 additions and 74 deletions

View File

@ -50,7 +50,7 @@ pub enum CharacterState {
}
impl CharacterState {
pub fn is_wielded(&self) -> bool {
pub fn is_wield(&self) -> bool {
match self {
CharacterState::Wielding { .. } => true,
CharacterState::BasicAttack { .. } => true,

View File

@ -1,7 +1,7 @@
pub mod item;
// Reexports
pub use item::{Consumable, Debug, Item, ItemKind, Tool};
pub use item::{Consumable, Debug, Item, ItemKind, SwordKind, ToolData, ToolKind};
use crate::assets;
use specs::{Component, FlaggedStorage, HashMapStorage};

View File

@ -1,5 +1,5 @@
use crate::{comp, sync::Uid};
use comp::{item::Tool, InventoryUpdateEvent};
use comp::{item::ToolData, InventoryUpdateEvent};
use parking_lot::Mutex;
use serde::Deserialize;
use specs::Entity as EcsEntity;
@ -40,8 +40,8 @@ pub enum SfxEvent {
Fall,
ExperienceGained,
LevelUp,
Wield(Tool),
Unwield(Tool),
Wield(ToolData),
Unwield(ToolData),
Inventory(InventoryUpdateEvent),
}

View File

@ -38,7 +38,7 @@ pub fn handle_ground_move(data: &JoinData, update: &mut StateUpdate) {
}
// Set direction based on move direction
let ori_dir = if update.character.is_wielded()
let ori_dir = if update.character.is_wield()
|| update.character.is_attack()
|| update.character.is_block()
{

View File

@ -121,7 +121,7 @@ impl<'a> System<'a> for Sys {
let inputs = &controller.inputs;
if character.action.is_roll() {
if character.action.is_dodge() {
vel.0 = Vec3::new(0.0, 0.0, vel.0.z)
+ (vel.0 * Vec3::new(1.0, 1.0, 0.0)
+ 1.5 * inputs.move_dir.try_normalized().unwrap_or_default())

View File

@ -62,7 +62,7 @@ impl Animation for AttackAnimation {
match active_tool_kind {
//TODO: Inventory
Some(Tool::Sword(_)) => {
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;

View File

@ -62,7 +62,7 @@ impl Animation for BlockAnimation {
match active_tool_kind {
//TODO: Inventory
Some(Tool::Sword(_)) => {
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;

View File

@ -61,7 +61,7 @@ impl Animation for BlockIdleAnimation {
match active_tool_kind {
//TODO: Inventory
Some(Tool::Sword(_)) => {
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;

View File

@ -62,7 +62,7 @@ impl Animation for CidleAnimation {
match active_tool_kind {
//TODO: Inventory
Some(Tool::Sword(_)) => {
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.l_hand.scale = Vec3::one() * 1.04;

View File

@ -37,9 +37,9 @@ impl Animation for WieldAnimation {
* 0.1,
);
match Tool::Bow {
match ToolKind::Bow {
//TODO: Inventory
Some(Tool::Sword(_)) => {
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
@ -58,7 +58,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
},
Tool::Axe => {
ToolKind::Axe => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
@ -75,7 +75,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
},
Tool::Hammer => {
ToolKind::Hammer => {
next.l_hand.offset = Vec3::new(-7.0, 8.25, 3.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.2)
@ -96,7 +96,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(wave * -0.25);
next.weapon.scale = Vec3::one();
},
Tool::Staff => {
ToolKind::Staff => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
@ -113,7 +113,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
},
Tool::SwordShield => {
ToolKind::SwordShield => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
@ -130,7 +130,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
},
Tool::Bow => {
ToolKind::Bow => {
next.l_hand.offset = Vec3::new(-4.0, 5.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.9)
@ -151,7 +151,7 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.85 + 3.14);
next.weapon.scale = Vec3::one();
},
Tool::Daggers => {
ToolKind::Daggers => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;

View File

@ -1,5 +1,5 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::Tool;
use common::comp::item::ToolKind;
use std::ops::Mul;
use vek::*;

View File

@ -29,7 +29,7 @@ impl Animation for WieldAnimation {
let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0).sin();
match active_tool_kind {
//TODO: Inventory
Some(Tool::Sword(_)) => {
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;

View File

@ -158,54 +158,6 @@ impl MovementEventMapper {
vel: Vec3<f32>,
stats: &Stats,
) -> SfxEvent {
// Handle any weapon wielding changes up front. Doing so here first simplifies
// handling the movement/action state later, since they don't require querying
// stats or previous wield state.
if let Some(Item {
kind: ItemKind::Tool(ToolData { kind, .. }),
..
}) = stats.equipment.main
{
if let Some(wield_event) = match (
previous_event.weapon_drawn,
current_event.action.is_roll(),
Self::has_weapon_drawn(current_event.action),
) {
(false, false, true) => Some(SfxEvent::Wield(kind)),
(true, false, false) => Some(SfxEvent::Unwield(kind)),
_ => None,
} {
return wield_event;
}
}
// Match all other Movemement and Action states
match (
current_event.movement,
current_event.action,
previous_event.event.clone(),
) {
(_, ActionState::Roll { .. }, _) => SfxEvent::Roll,
(MovementState::Climb, ..) => SfxEvent::Climb,
(MovementState::Swim, ..) => SfxEvent::Swim,
(MovementState::Run, ..) => {
// If the entitys's velocity is very low, they may be stuck, or walking into a
// solid object. We should not trigger the run SFX in this case,
// even if their move state indicates running. The 0.1 value is
// an approximation from playtesting scenarios where this can occur.
if vel.magnitude() > 0.1 {
SfxEvent::Run
} else {
Some(SfxEvent::Run)
}
},
(false, true) => Some(SfxEvent::Jump),
_ => None,
}
{
return jump_or_fall_event;
}
// Match run state
if physics_state.on_ground && vel.magnitude() > 0.1 {
return SfxEvent::Run;
@ -241,7 +193,7 @@ impl MovementEventMapper {
/// ::Equipping to mean the weapon is drawn. This will need updating if the
/// animations change to match the wield_duration associated with the weapon
fn weapon_drawn(character: &CharacterState) -> bool {
character.is_wielded()
character.is_wield()
|| match character {
CharacterState::Equipping { .. } => true,
_ => false,

View File

@ -183,9 +183,7 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
if camera_mode != CameraMode::FirstPerson
|| character_state
.map(|cs| {
cs.action.is_attack()
|| cs.action.is_block()
|| cs.action.is_wield()
cs.is_attack() || cs.is_block() || cs.is_wield()
})
.unwrap_or_default()
{

View File

@ -173,7 +173,7 @@ impl Scene {
.ecs()
.read_storage::<comp::CharacterState>()
.get(scene_data.player_entity)
.map_or(false, |cs| cs.action.is_roll());
.map_or(false, |cs| cs.is_dodge());
let player_scale = match scene_data
.state