mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Introduce a ToolCategory so we can ignore the specific type of weapon
when deciding on the SFX to play when wielding/attacking.
This commit is contained in:
@ -23,7 +23,7 @@
|
|||||||
],
|
],
|
||||||
threshold: 0.5,
|
threshold: 0.5,
|
||||||
),
|
),
|
||||||
Attack(DashMelee, Sword(BasicSword)): (
|
Attack(DashMelee, Sword): (
|
||||||
files: [
|
files: [
|
||||||
"voxygen.audio.sfx.weapon.whoosh_normal_01",
|
"voxygen.audio.sfx.weapon.whoosh_normal_01",
|
||||||
"voxygen.audio.sfx.weapon.whoosh_normal_02",
|
"voxygen.audio.sfx.weapon.whoosh_normal_02",
|
||||||
@ -32,7 +32,7 @@
|
|||||||
],
|
],
|
||||||
threshold: 1.2,
|
threshold: 1.2,
|
||||||
),
|
),
|
||||||
Attack(TripleStrike, Sword(BasicSword)): (
|
Attack(TripleStrike, Sword): (
|
||||||
files: [
|
files: [
|
||||||
"voxygen.audio.sfx.weapon.sword_triple_strike_01",
|
"voxygen.audio.sfx.weapon.sword_triple_strike_01",
|
||||||
"voxygen.audio.sfx.weapon.sword_triple_strike_02",
|
"voxygen.audio.sfx.weapon.sword_triple_strike_02",
|
||||||
@ -40,14 +40,14 @@
|
|||||||
],
|
],
|
||||||
threshold: 0.8,
|
threshold: 0.8,
|
||||||
),
|
),
|
||||||
Attack(BasicRanged, Bow(BasicBow)): (
|
Attack(BasicRanged, Bow): (
|
||||||
files: [
|
files: [
|
||||||
"voxygen.audio.sfx.weapon.bow_attack_01",
|
"voxygen.audio.sfx.weapon.bow_attack_01",
|
||||||
"voxygen.audio.sfx.weapon.bow_attack_02",
|
"voxygen.audio.sfx.weapon.bow_attack_02",
|
||||||
],
|
],
|
||||||
threshold: 0.5,
|
threshold: 0.5,
|
||||||
),
|
),
|
||||||
Attack(BasicMelee, Hammer(BasicHammer)): (
|
Attack(BasicMelee, Hammer): (
|
||||||
files: [
|
files: [
|
||||||
"voxygen.audio.sfx.weapon.whoosh_low_01",
|
"voxygen.audio.sfx.weapon.whoosh_low_01",
|
||||||
"voxygen.audio.sfx.weapon.whoosh_low_02",
|
"voxygen.audio.sfx.weapon.whoosh_low_02",
|
||||||
@ -55,7 +55,7 @@
|
|||||||
],
|
],
|
||||||
threshold: 0.5,
|
threshold: 0.5,
|
||||||
),
|
),
|
||||||
Attack(BasicMelee, Staff(BasicStaff)): (
|
Attack(BasicMelee, Staff): (
|
||||||
files: [
|
files: [
|
||||||
"voxygen.audio.sfx.weapon.whoosh_normal_01",
|
"voxygen.audio.sfx.weapon.whoosh_normal_01",
|
||||||
"voxygen.audio.sfx.weapon.whoosh_normal_02",
|
"voxygen.audio.sfx.weapon.whoosh_normal_02",
|
||||||
@ -64,13 +64,13 @@
|
|||||||
],
|
],
|
||||||
threshold: 0.5,
|
threshold: 0.5,
|
||||||
),
|
),
|
||||||
Wield(Sword(BasicSword)): (
|
Wield(Sword): (
|
||||||
files: [
|
files: [
|
||||||
"voxygen.audio.sfx.weapon.sword_out",
|
"voxygen.audio.sfx.weapon.sword_out",
|
||||||
],
|
],
|
||||||
threshold: 0.5,
|
threshold: 0.5,
|
||||||
),
|
),
|
||||||
Unwield(Sword(BasicSword)): (
|
Unwield(Sword): (
|
||||||
files: [
|
files: [
|
||||||
"voxygen.audio.sfx.weapon.sword_in",
|
"voxygen.audio.sfx.weapon.sword_in",
|
||||||
],
|
],
|
||||||
|
@ -2,7 +2,7 @@ pub mod armor;
|
|||||||
pub mod tool;
|
pub mod tool;
|
||||||
|
|
||||||
// Reexports
|
// Reexports
|
||||||
pub use tool::{DebugKind, SwordKind, Tool, ToolKind};
|
pub use tool::{DebugKind, SwordKind, Tool, ToolCategory, ToolKind};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
assets::{self, Asset},
|
assets::{self, Asset},
|
||||||
|
@ -115,6 +115,35 @@ pub enum ToolKind {
|
|||||||
Empty,
|
Empty,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum ToolCategory {
|
||||||
|
Sword,
|
||||||
|
Axe,
|
||||||
|
Hammer,
|
||||||
|
Bow,
|
||||||
|
Dagger,
|
||||||
|
Staff,
|
||||||
|
Shield,
|
||||||
|
Debug,
|
||||||
|
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::Shield(_) => ToolCategory::Shield,
|
||||||
|
ToolKind::Debug(_) => ToolCategory::Debug,
|
||||||
|
ToolKind::Empty => ToolCategory::Empty,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
pub struct Tool {
|
pub struct Tool {
|
||||||
pub kind: ToolKind,
|
pub kind: ToolKind,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{comp, sync::Uid, util::Dir};
|
use crate::{comp, sync::Uid, util::Dir};
|
||||||
use comp::{item::ToolKind, CharacterAbilityType, InventoryUpdateEvent};
|
use comp::{item::ToolCategory, CharacterAbilityType, InventoryUpdateEvent};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use specs::Entity as EcsEntity;
|
use specs::Entity as EcsEntity;
|
||||||
@ -39,9 +39,9 @@ pub enum SfxEvent {
|
|||||||
Fall,
|
Fall,
|
||||||
ExperienceGained,
|
ExperienceGained,
|
||||||
LevelUp,
|
LevelUp,
|
||||||
Attack(CharacterAbilityType, ToolKind),
|
Attack(CharacterAbilityType, ToolCategory),
|
||||||
Wield(ToolKind),
|
Wield(ToolCategory),
|
||||||
Unwield(ToolKind),
|
Unwield(ToolCategory),
|
||||||
Inventory(InventoryUpdateEvent),
|
Inventory(InventoryUpdateEvent),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use crate::audio::sfx::{SfxTriggerItem, SfxTriggers};
|
|||||||
|
|
||||||
use common::{
|
use common::{
|
||||||
comp::{
|
comp::{
|
||||||
item::{Item, ItemKind},
|
item::{Item, ItemKind, ToolCategory},
|
||||||
CharacterAbilityType, CharacterState, ItemConfig, Loadout, Pos,
|
CharacterAbilityType, CharacterState, ItemConfig, Loadout, Pos,
|
||||||
},
|
},
|
||||||
event::{EventBus, SfxEvent, SfxEventItem},
|
event::{EventBus, SfxEvent, SfxEventItem},
|
||||||
@ -145,7 +145,7 @@ impl CombatEventMapper {
|
|||||||
if character_state.is_attack() {
|
if character_state.is_attack() {
|
||||||
return SfxEvent::Attack(
|
return SfxEvent::Attack(
|
||||||
CharacterAbilityType::from(character_state),
|
CharacterAbilityType::from(character_state),
|
||||||
data.kind,
|
ToolCategory::from(data.kind),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if let Some(wield_event) = match (
|
if let Some(wield_event) = match (
|
||||||
@ -153,8 +153,12 @@ impl CombatEventMapper {
|
|||||||
character_state.is_dodge(),
|
character_state.is_dodge(),
|
||||||
Self::weapon_drawn(character_state),
|
Self::weapon_drawn(character_state),
|
||||||
) {
|
) {
|
||||||
(false, false, true) => Some(SfxEvent::Wield(data.kind)),
|
(false, false, true) => {
|
||||||
(true, false, false) => Some(SfxEvent::Unwield(data.kind)),
|
Some(SfxEvent::Wield(ToolCategory::from(data.kind)))
|
||||||
|
},
|
||||||
|
(true, false, false) => {
|
||||||
|
Some(SfxEvent::Unwield(ToolCategory::from(data.kind)))
|
||||||
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
} {
|
} {
|
||||||
return wield_event;
|
return wield_event;
|
||||||
|
@ -2,7 +2,7 @@ use super::*;
|
|||||||
use common::{
|
use common::{
|
||||||
assets,
|
assets,
|
||||||
comp::{
|
comp::{
|
||||||
item::tool::{AxeKind, BowKind, SwordKind, ToolKind},
|
item::tool::{AxeKind, BowKind, SwordKind, ToolCategory, ToolKind},
|
||||||
CharacterAbilityType, CharacterState, ItemConfig, Loadout,
|
CharacterAbilityType, CharacterState, ItemConfig, Loadout,
|
||||||
},
|
},
|
||||||
event::SfxEvent,
|
event::SfxEvent,
|
||||||
@ -35,7 +35,7 @@ fn maps_wield_while_equipping() {
|
|||||||
Some(&loadout),
|
Some(&loadout),
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(result, SfxEvent::Wield(ToolKind::Axe(AxeKind::BasicAxe)));
|
assert_eq!(result, SfxEvent::Wield(ToolCategory::Axe));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -61,7 +61,7 @@ fn maps_unwield() {
|
|||||||
Some(&loadout),
|
Some(&loadout),
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(result, SfxEvent::Unwield(ToolKind::Bow(BowKind::BasicBow)));
|
assert_eq!(result, SfxEvent::Unwield(ToolCategory::Bow));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -96,10 +96,7 @@ fn maps_basic_melee() {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result,
|
result,
|
||||||
SfxEvent::Attack(
|
SfxEvent::Attack(CharacterAbilityType::BasicMelee, ToolCategory::Axe)
|
||||||
CharacterAbilityType::BasicMelee,
|
|
||||||
ToolKind::Axe(AxeKind::BasicAxe)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,9 +134,6 @@ fn maps_triple_strike() {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result,
|
result,
|
||||||
SfxEvent::Attack(
|
SfxEvent::Attack(CharacterAbilityType::TripleStrike, ToolCategory::Sword)
|
||||||
CharacterAbilityType::TripleStrike,
|
|
||||||
ToolKind::Sword(SwordKind::BasicSword)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
use crate::audio::sfx::{SfxTriggerItem, SfxTriggers};
|
use crate::audio::sfx::{SfxTriggerItem, SfxTriggers};
|
||||||
|
|
||||||
use common::{
|
use common::{
|
||||||
comp::{
|
comp::{Body, CharacterState, PhysicsState, Pos, Vel},
|
||||||
Body, CharacterState, PhysicsState, Pos, Vel,
|
|
||||||
},
|
|
||||||
event::{EventBus, SfxEvent, SfxEventItem},
|
event::{EventBus, SfxEvent, SfxEventItem},
|
||||||
state::State,
|
state::State,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user