diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 9e06a15b27..6ef4d82215 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -2,7 +2,7 @@ pub mod armor; pub mod tool; // Reexports -pub use tool::{Hands, Tool, ToolCategory, ToolKind}; +pub use tool::{Hands, Tool, ToolKind}; use crate::{ assets::{self, Asset, Error}, diff --git a/common/src/comp/inventory/item/tool.rs b/common/src/comp/inventory/item/tool.rs index aa015b2d9a..d094c1c11c 100644 --- a/common/src/comp/inventory/item/tool.rs +++ b/common/src/comp/inventory/item/tool.rs @@ -55,41 +55,6 @@ pub enum Hands { TwoHand, } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum ToolCategory { - Sword, - Axe, - Hammer, - Bow, - Dagger, - Staff, - Sceptre, - Shield, - NpcWeapon, - Debug, - Farming, - Empty, -} - -impl From<&ToolKind> for ToolCategory { - fn from(kind: &ToolKind) -> ToolCategory { - match kind { - ToolKind::Sword(_) => ToolCategory::Sword, - ToolKind::Axe(_) => ToolCategory::Axe, - ToolKind::Hammer(_) => ToolCategory::Hammer, - ToolKind::Bow(_) => ToolCategory::Bow, - ToolKind::Dagger(_) => ToolCategory::Dagger, - ToolKind::Staff(_) => ToolCategory::Staff, - ToolKind::Sceptre(_) => ToolCategory::Sceptre, - ToolKind::Shield(_) => ToolCategory::Shield, - ToolKind::NpcWeapon(_) => ToolCategory::NpcWeapon, - ToolKind::Debug(_) => ToolCategory::Debug, - ToolKind::Farming(_) => ToolCategory::Farming, - ToolKind::Empty => ToolCategory::Empty, - } - } -} - #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] pub struct Stats { equip_time_millis: u32, @@ -658,11 +623,4 @@ impl Tool { }], } } - - /// Determines whether two tools are superficially equivalent to one another - /// (i.e: one may be substituted for the other in crafting recipes or - /// item possession checks). - pub fn superficially_eq(&self, other: &Self) -> bool { - ToolCategory::from(&self.kind) == ToolCategory::from(&other.kind) - } } diff --git a/common/src/comp/phys.rs b/common/src/comp/phys.rs index 902d391737..be854c54c6 100644 --- a/common/src/comp/phys.rs +++ b/common/src/comp/phys.rs @@ -106,7 +106,7 @@ pub struct PhysicsState { pub on_ceiling: bool, pub on_wall: Option>, pub touch_entities: Vec, - pub in_fluid: Option, // Depth + pub in_liquid: Option, // Depth } impl PhysicsState { diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 4a5040449b..864dae2f20 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -25,7 +25,7 @@ impl CharacterBehavior for Data { } if data .physics - .in_fluid + .in_liquid .map(|depth| depth > 0.5) .unwrap_or(false) { diff --git a/common/src/states/glide_wield.rs b/common/src/states/glide_wield.rs index cb32fbe509..0344ebf156 100644 --- a/common/src/states/glide_wield.rs +++ b/common/src/states/glide_wield.rs @@ -21,7 +21,7 @@ impl CharacterBehavior for Data { } if data .physics - .in_fluid + .in_liquid .map(|depth| depth > 0.5) .unwrap_or(false) { diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index c744d9a485..b121b5005f 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -79,7 +79,7 @@ impl Body { /// Handles updating `Components` to move player based on state of `JoinData` pub fn handle_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { - if let Some(depth) = data.physics.in_fluid { + if let Some(depth) = data.physics.in_liquid { swim_move(data, update, efficiency, depth); } else if data.inputs.fly.is_pressed() && !data.physics.on_ground && data.body.can_fly() { fly_move(data, update, efficiency); @@ -261,7 +261,7 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { && !data.physics.on_ground && !data .physics - .in_fluid + .in_liquid .map(|depth| depth > 1.0) .unwrap_or(false) //&& update.vel.0.z < 0.0 @@ -285,7 +285,7 @@ pub fn attempt_glide_wield(data: &JoinData, update: &mut StateUpdate) { && data.loadout.glider.is_some() && !data .physics - .in_fluid + .in_liquid .map(|depth| depth > 1.0) .unwrap_or(false) && data.body.is_humanoid() @@ -300,7 +300,7 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) { && data.physics.on_ground && !data .physics - .in_fluid + .in_liquid .map(|depth| depth > 1.0) .unwrap_or(false) { diff --git a/common/src/sys/phys.rs b/common/src/sys/phys.rs index f8d8bd5f3c..54a1f30499 100644 --- a/common/src/sys/phys.rs +++ b/common/src/sys/phys.rs @@ -380,7 +380,7 @@ impl<'a> System<'a> for Sys { } else { 0.0 }) - .max(if physics_state.in_fluid.is_some() { + .max(if physics_state.in_liquid.is_some() { FRIC_FLUID } else { 0.0 @@ -391,7 +391,7 @@ impl<'a> System<'a> for Sys { let downward_force = if !in_loaded_chunk { 0.0 // No gravity in unloaded chunks } else if physics_state - .in_fluid + .in_liquid .map(|depth| depth > 0.75) .unwrap_or(false) { @@ -694,7 +694,7 @@ impl<'a> System<'a> for Sys { } // Figure out if we're in water - physics_state.in_fluid = collision_iter( + physics_state.in_liquid = collision_iter( pos.0, &terrain, &|block| block.is_liquid(), @@ -743,7 +743,7 @@ impl<'a> System<'a> for Sys { } } - physics_state.in_fluid = terrain.get(pos.0.map(|e| e.floor() as i32)) + physics_state.in_liquid = terrain.get(pos.0.map(|e| e.floor() as i32)) .ok() .and_then(|vox| vox.is_liquid().then_some(1.0)); }, diff --git a/voxygen/src/audio/sfx/event_mapper/combat/mod.rs b/voxygen/src/audio/sfx/event_mapper/combat/mod.rs index 50c78cbf6c..e46c19b21b 100644 --- a/voxygen/src/audio/sfx/event_mapper/combat/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/combat/mod.rs @@ -8,10 +8,7 @@ use crate::{ use super::EventMapper; use common::{ - comp::{ - item::{ItemKind, ToolCategory}, - CharacterAbilityType, CharacterState, Loadout, Pos, - }, + comp::{item::ItemKind, CharacterAbilityType, CharacterState, Loadout, Pos}, event::EventBus, state::State, }; @@ -140,19 +137,15 @@ impl CombatEventMapper { if character_state.is_attack() { return SfxEvent::Attack( CharacterAbilityType::from(character_state), - ToolCategory::from(&data.kind), + data.kind.clone(), ); } else if let Some(wield_event) = match ( previous_state.weapon_drawn, character_state.is_dodge(), Self::weapon_drawn(character_state), ) { - (false, false, true) => { - Some(SfxEvent::Wield(ToolCategory::from(&data.kind))) - }, - (true, false, false) => { - Some(SfxEvent::Unwield(ToolCategory::from(&data.kind))) - }, + (false, false, true) => Some(SfxEvent::Wield(data.kind.clone())), + (true, false, false) => Some(SfxEvent::Unwield(data.kind.clone())), _ => None, } { return wield_event; diff --git a/voxygen/src/audio/sfx/event_mapper/combat/tests.rs b/voxygen/src/audio/sfx/event_mapper/combat/tests.rs index 5a01451d15..8d2e393663 100644 --- a/voxygen/src/audio/sfx/event_mapper/combat/tests.rs +++ b/voxygen/src/audio/sfx/event_mapper/combat/tests.rs @@ -1,9 +1,7 @@ use super::*; use crate::audio::sfx::SfxEvent; use common::{ - comp::{ - item::tool::ToolCategory, CharacterAbilityType, CharacterState, Item, ItemConfig, Loadout, - }, + comp::{item::tool::ToolKind, CharacterAbilityType, CharacterState, Item, ItemConfig, Loadout}, states, }; use std::time::{Duration, Instant}; @@ -36,7 +34,10 @@ fn maps_wield_while_equipping() { Some(&loadout), ); - assert_eq!(result, SfxEvent::Wield(ToolCategory::Axe)); + assert_eq!( + result, + SfxEvent::Wield(ToolKind::Axe("BasicAxe".to_string())) + ); } #[test] @@ -62,7 +63,10 @@ fn maps_unwield() { Some(&loadout), ); - assert_eq!(result, SfxEvent::Unwield(ToolCategory::Bow)); + assert_eq!( + result, + SfxEvent::Unwield(ToolKind::Bow("ShortBow0".to_string())) + ); } #[test] @@ -103,7 +107,10 @@ fn maps_basic_melee() { assert_eq!( result, - SfxEvent::Attack(CharacterAbilityType::BasicMelee, ToolCategory::Axe) + SfxEvent::Attack( + CharacterAbilityType::BasicMelee, + ToolKind::Axe("BasicAxe".to_string()) + ) ); } @@ -163,7 +170,7 @@ fn matches_ability_stage() { result, SfxEvent::Attack( CharacterAbilityType::ComboMelee(states::utils::StageSection::Swing, 1), - ToolCategory::Sword + ToolKind::Sword("BasicSword".to_string()) ) ); } @@ -224,7 +231,7 @@ fn ignores_different_ability_stage() { result, SfxEvent::Attack( CharacterAbilityType::ComboMelee(states::utils::StageSection::Swing, 2), - ToolCategory::Sword + ToolKind::Sword("BasicSword".to_string()) ) ); } diff --git a/voxygen/src/audio/sfx/mod.rs b/voxygen/src/audio/sfx/mod.rs index 6f08f2b718..fe76a43b27 100644 --- a/voxygen/src/audio/sfx/mod.rs +++ b/voxygen/src/audio/sfx/mod.rs @@ -87,7 +87,7 @@ use crate::{audio::AudioFrontend, scene::Camera}; use common::{ assets, comp::{ - item::{ItemKind, ToolCategory}, + item::{ItemKind, ToolKind}, object, Body, CharacterAbilityType, InventoryUpdateEvent, }, event::EventBus, @@ -99,7 +99,6 @@ use hashbrown::HashMap; use rand::prelude::*; use serde::Deserialize; use specs::WorldExt; -use std::convert::TryFrom; use tracing::{debug, warn}; use vek::*; @@ -144,9 +143,9 @@ pub enum SfxEvent { Fall, ExperienceGained, LevelUp, - Attack(CharacterAbilityType, ToolCategory), - Wield(ToolCategory), - Unwield(ToolCategory), + Attack(CharacterAbilityType, ToolKind), + Wield(ToolKind), + Unwield(ToolKind), Inventory(SfxInventoryEvent), Explosion, ProjectileShot, @@ -155,7 +154,7 @@ pub enum SfxEvent { #[derive(Clone, Debug, PartialEq, Deserialize, Hash, Eq)] pub enum SfxInventoryEvent { Collected, - CollectedTool(ToolCategory), + CollectedTool(ToolKind), CollectFailed, Consumed(String), Debug, @@ -171,9 +170,9 @@ impl From<&InventoryUpdateEvent> for SfxEvent { // Handle sound effects for types of collected items, falling back to the // default Collected event match &item.kind() { - ItemKind::Tool(tool) => SfxEvent::Inventory(SfxInventoryEvent::CollectedTool( - ToolCategory::try_from(&tool.kind).unwrap(), - )), + ItemKind::Tool(tool) => { + SfxEvent::Inventory(SfxInventoryEvent::CollectedTool(tool.kind.clone())) + }, _ => SfxEvent::Inventory(SfxInventoryEvent::Collected), } }, diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index e265152427..f177138093 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -732,7 +732,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Standing (true, false, false) => anim::character::StandAnimation::update_skeleton( @@ -1218,7 +1218,7 @@ impl FigureMgr { ) }, CharacterState::Wielding { .. } => { - if physics.in_fluid.is_some() { + if physics.in_liquid.is_some() { anim::character::SwimWieldAnimation::update_skeleton( &target_base, (active_tool_kind, second_tool_kind, vel.0.magnitude(), time), @@ -1348,7 +1348,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Standing (true, false, false) => { @@ -1458,7 +1458,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > 0.25, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Standing (true, false, false) => { @@ -1579,7 +1579,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Standing (true, false, false) => { @@ -1686,7 +1686,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Standing (true, false, false) => anim::bird_medium::IdleAnimation::update_skeleton( @@ -1791,7 +1791,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Standing (true, false, false) => anim::fish_medium::IdleAnimation::update_skeleton( @@ -1874,7 +1874,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Standing (true, false, false) => anim::dragon::IdleAnimation::update_skeleton( @@ -1957,7 +1957,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Standing (true, false, false) => anim::theropod::IdleAnimation::update_skeleton( @@ -2043,7 +2043,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Standing (true, false, false) => anim::bird_small::IdleAnimation::update_skeleton( @@ -2129,7 +2129,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Standing (true, false, false) => anim::fish_small::IdleAnimation::update_skeleton( @@ -2215,7 +2215,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Running (true, true, false) => anim::biped_large::RunAnimation::update_skeleton( @@ -2610,7 +2610,7 @@ impl FigureMgr { let target_base = match ( physics.on_ground, vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving - physics.in_fluid.is_some(), // In water + physics.in_liquid.is_some(), // In water ) { // Standing (true, false, false) => anim::golem::IdleAnimation::update_skeleton(