mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Revert "Removed toolCategory"
This reverts commit 5b0ff408176ff00408cc90f2516a90d5cd303e56.
This commit is contained in:
parent
d0ed0d5773
commit
b2ec207979
@ -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},
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ pub struct PhysicsState {
|
||||
pub on_ceiling: bool,
|
||||
pub on_wall: Option<Vec3<f32>>,
|
||||
pub touch_entities: Vec<Uid>,
|
||||
pub in_fluid: Option<f32>, // Depth
|
||||
pub in_liquid: Option<f32>, // Depth
|
||||
}
|
||||
|
||||
impl PhysicsState {
|
||||
|
@ -25,7 +25,7 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
if data
|
||||
.physics
|
||||
.in_fluid
|
||||
.in_liquid
|
||||
.map(|depth| depth > 0.5)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
if data
|
||||
.physics
|
||||
.in_fluid
|
||||
.in_liquid
|
||||
.map(|depth| depth > 0.5)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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));
|
||||
},
|
||||
|
@ -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;
|
||||
|
@ -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())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -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),
|
||||
}
|
||||
},
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user