mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Initial work to move combat sfx to outcomes
This commit is contained in:
parent
77d624f640
commit
b3aa454f8e
@ -181,24 +181,24 @@
|
|||||||
],
|
],
|
||||||
threshold: 0.5,
|
threshold: 0.5,
|
||||||
),
|
),
|
||||||
Attack(ComboMelee(Swing, 1), Sword): (
|
//Attack(ComboMelee(Swing, 1), Sword): (
|
||||||
files: [
|
// files: [
|
||||||
"voxygen.audio.sfx.abilities.swing_sword",
|
// "voxygen.audio.sfx.abilities.swing_sword",
|
||||||
],
|
// ],
|
||||||
threshold: 0.7,
|
// threshold: 0.7,
|
||||||
),
|
//),
|
||||||
Attack(ComboMelee(Swing, 2), Sword): (
|
//Attack(ComboMelee(Swing, 2), Sword): (
|
||||||
files: [
|
// files: [
|
||||||
"voxygen.audio.sfx.abilities.separated_second_swing",
|
// "voxygen.audio.sfx.abilities.separated_second_swing",
|
||||||
],
|
// ],
|
||||||
threshold: 0.7,
|
// threshold: 0.7,
|
||||||
),
|
//),
|
||||||
Attack(ComboMelee(Swing, 3), Sword): (
|
//Attack(ComboMelee(Swing, 3), Sword): (
|
||||||
files: [
|
// files: [
|
||||||
"voxygen.audio.sfx.abilities.separated_third_swing",
|
// "voxygen.audio.sfx.abilities.separated_third_swing",
|
||||||
],
|
// ],
|
||||||
threshold: 0.7,
|
// threshold: 0.7,
|
||||||
),
|
//),
|
||||||
Attack(DashMelee(Swing), Sword): (
|
Attack(DashMelee(Swing), Sword): (
|
||||||
files: [
|
files: [
|
||||||
"voxygen.audio.sfx.abilities.sword_dash",
|
"voxygen.audio.sfx.abilities.sword_dash",
|
||||||
@ -319,12 +319,12 @@
|
|||||||
],
|
],
|
||||||
threshold: 0.5,
|
threshold: 0.5,
|
||||||
),
|
),
|
||||||
Attack(BasicBeam, Staff): (
|
//Attack(BasicBeam, Staff): (
|
||||||
files: [
|
// files: [
|
||||||
"voxygen.audio.sfx.abilities.flame_thrower",
|
// "voxygen.audio.sfx.abilities.flame_thrower",
|
||||||
],
|
// ],
|
||||||
threshold: 0.2,
|
// threshold: 0.2,
|
||||||
),
|
//),
|
||||||
Attack(BasicRanged, Staff): (
|
Attack(BasicRanged, Staff): (
|
||||||
files: [
|
files: [
|
||||||
// "voxygen.audio.sfx.abilities.staff_channeling",
|
// "voxygen.audio.sfx.abilities.staff_channeling",
|
||||||
@ -381,12 +381,12 @@
|
|||||||
],
|
],
|
||||||
threshold: 0.5,
|
threshold: 0.5,
|
||||||
),
|
),
|
||||||
Attack(BasicBeam, Sceptre): (
|
//Attack(BasicBeam, Sceptre): (
|
||||||
files: [
|
// files: [
|
||||||
"voxygen.audio.sfx.abilities.staff_channeling",
|
// "voxygen.audio.sfx.abilities.staff_channeling",
|
||||||
],
|
// ],
|
||||||
threshold: 0.6,
|
// threshold: 0.6,
|
||||||
),
|
//),
|
||||||
|
|
||||||
//
|
//
|
||||||
// Dagger
|
// Dagger
|
||||||
|
@ -9,6 +9,8 @@ use std::{collections::VecDeque, ops::DerefMut};
|
|||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
pub enum LocalEvent {
|
pub enum LocalEvent {
|
||||||
|
/// An attack for use with particles and sfx
|
||||||
|
Attack(EcsEntity),
|
||||||
/// Applies upward force to entity's `Vel`
|
/// Applies upward force to entity's `Vel`
|
||||||
Jump(EcsEntity),
|
Jump(EcsEntity),
|
||||||
/// Applies the `impulse` to `entity`'s `Vel`
|
/// Applies the `impulse` to `entity`'s `Vel`
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
use crate::comp;
|
use crate::comp;
|
||||||
use comp::{
|
use comp::{item::Reagent, CharacterState, Loadout};
|
||||||
item::{tool::ToolKind, Reagent},
|
|
||||||
CharacterAbilityType,
|
|
||||||
};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
@ -25,14 +22,18 @@ pub enum Outcome {
|
|||||||
body: comp::Body,
|
body: comp::Body,
|
||||||
vel: Vec3<f32>,
|
vel: Vec3<f32>,
|
||||||
},
|
},
|
||||||
Swing {
|
Attack {
|
||||||
pos: Vec3<f32>,
|
pos: Vec3<f32>,
|
||||||
ability: CharacterAbilityType,
|
character_state: CharacterState,
|
||||||
tool: ToolKind,
|
loadout: Loadout,
|
||||||
},
|
},
|
||||||
LevelUp {
|
LevelUp {
|
||||||
pos: Vec3<f32>,
|
pos: Vec3<f32>,
|
||||||
},
|
},
|
||||||
|
Beam {
|
||||||
|
pos: Vec3<f32>,
|
||||||
|
heal: bool,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Outcome {
|
impl Outcome {
|
||||||
@ -40,8 +41,9 @@ impl Outcome {
|
|||||||
match self {
|
match self {
|
||||||
Outcome::Explosion { pos, .. } => Some(*pos),
|
Outcome::Explosion { pos, .. } => Some(*pos),
|
||||||
Outcome::ProjectileShot { pos, .. } => Some(*pos),
|
Outcome::ProjectileShot { pos, .. } => Some(*pos),
|
||||||
Outcome::Swing { pos, .. } => Some(*pos),
|
Outcome::Attack { pos, .. } => Some(*pos),
|
||||||
Outcome::LevelUp { pos } => Some(*pos),
|
Outcome::LevelUp { pos } => Some(*pos),
|
||||||
|
Outcome::Beam { pos, .. } => Some(*pos),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ use crate::{
|
|||||||
comp,
|
comp,
|
||||||
event::{EventBus, LocalEvent, ServerEvent},
|
event::{EventBus, LocalEvent, ServerEvent},
|
||||||
metrics::{PhysicsMetrics, SysMetrics},
|
metrics::{PhysicsMetrics, SysMetrics},
|
||||||
|
outcome::Outcome,
|
||||||
region::RegionMap,
|
region::RegionMap,
|
||||||
sync::WorldSyncExt,
|
sync::WorldSyncExt,
|
||||||
sys,
|
sys,
|
||||||
@ -187,6 +188,9 @@ impl State {
|
|||||||
ecs.insert(SysMetrics::default());
|
ecs.insert(SysMetrics::default());
|
||||||
ecs.insert(PhysicsMetrics::default());
|
ecs.insert(PhysicsMetrics::default());
|
||||||
|
|
||||||
|
// Register outcomes
|
||||||
|
ecs.insert(Vec::<Outcome>::new());
|
||||||
|
|
||||||
ecs
|
ecs
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,7 +392,28 @@ impl State {
|
|||||||
for event in events {
|
for event in events {
|
||||||
let mut velocities = self.ecs.write_storage::<comp::Vel>();
|
let mut velocities = self.ecs.write_storage::<comp::Vel>();
|
||||||
let mut controllers = self.ecs.write_storage::<comp::Controller>();
|
let mut controllers = self.ecs.write_storage::<comp::Controller>();
|
||||||
|
let positions = self.ecs.read_storage::<comp::Pos>();
|
||||||
|
let character_states = self.ecs.read_storage::<comp::CharacterState>();
|
||||||
|
let loadouts = self.ecs.read_storage::<comp::Loadout>();
|
||||||
match event {
|
match event {
|
||||||
|
LocalEvent::Attack(entity) => {
|
||||||
|
self.ecs
|
||||||
|
.write_resource::<Vec<Outcome>>()
|
||||||
|
.push(Outcome::Attack {
|
||||||
|
pos: positions
|
||||||
|
.get(entity)
|
||||||
|
.expect("Failed to fetch attacking entity")
|
||||||
|
.0,
|
||||||
|
character_state: character_states
|
||||||
|
.get(entity)
|
||||||
|
.expect("Failed to get the character state of the attacking entity")
|
||||||
|
.clone(),
|
||||||
|
loadout: loadouts
|
||||||
|
.get(entity)
|
||||||
|
.expect("Failed to get attacking entity's loadout")
|
||||||
|
.clone(),
|
||||||
|
});
|
||||||
|
},
|
||||||
LocalEvent::Jump(entity) => {
|
LocalEvent::Jump(entity) => {
|
||||||
if let Some(vel) = velocities.get_mut(entity) {
|
if let Some(vel) = velocities.get_mut(entity) {
|
||||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
vel.0.z = HUMANOID_JUMP_ACCEL;
|
||||||
|
@ -56,7 +56,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
let start_time = std::time::Instant::now();
|
let start_time = std::time::Instant::now();
|
||||||
span!(_guard, "run", "melee::Sys::run");
|
span!(_guard, "run", "melee::Sys::run");
|
||||||
let mut server_emitter = server_bus.emitter();
|
let mut server_emitter = server_bus.emitter();
|
||||||
let mut _local_emitter = local_bus.emitter();
|
let mut local_emitter = local_bus.emitter();
|
||||||
// Attacks
|
// Attacks
|
||||||
for (entity, uid, pos, ori, scale_maybe, attack) in (
|
for (entity, uid, pos, ori, scale_maybe, attack) in (
|
||||||
&entities,
|
&entities,
|
||||||
@ -72,6 +72,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
attack.applied = true;
|
attack.applied = true;
|
||||||
|
local_emitter.emit(LocalEvent::Attack(entity));
|
||||||
|
|
||||||
// Go through all other entities
|
// Go through all other entities
|
||||||
for (b, pos_b, scale_b_maybe, health_b, body_b, char_state_b_maybe) in (
|
for (b, pos_b, scale_b_maybe, health_b, body_b, char_state_b_maybe) in (
|
||||||
|
@ -145,6 +145,11 @@ pub fn handle_shockwave(
|
|||||||
|
|
||||||
pub fn handle_beam(server: &mut Server, properties: beam::Properties, pos: Pos, ori: Ori) {
|
pub fn handle_beam(server: &mut Server, properties: beam::Properties, pos: Pos, ori: Ori) {
|
||||||
let state = server.state_mut();
|
let state = server.state_mut();
|
||||||
|
let ecs = state.ecs();
|
||||||
|
ecs.write_resource::<Vec<Outcome>>().push(Outcome::Beam {
|
||||||
|
pos: pos.0,
|
||||||
|
heal: properties.lifesteal_eff > 0.0,
|
||||||
|
});
|
||||||
state.create_beam(properties, pos, ori).build();
|
state.create_beam(properties, pos, ori).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ use common::{
|
|||||||
event::EventBus,
|
event::EventBus,
|
||||||
outcome::Outcome,
|
outcome::Outcome,
|
||||||
state::State,
|
state::State,
|
||||||
|
states::utils::StageSection,
|
||||||
terrain::{BlockKind, TerrainChunk},
|
terrain::{BlockKind, TerrainChunk},
|
||||||
vol::ReadVol,
|
vol::ReadVol,
|
||||||
};
|
};
|
||||||
@ -382,7 +383,63 @@ impl SfxMgr {
|
|||||||
let file_ref = "voxygen.audio.sfx.character.level_up_sound_-_shorter_wind_up";
|
let file_ref = "voxygen.audio.sfx.character.level_up_sound_-_shorter_wind_up";
|
||||||
audio.play_sfx(file_ref, *pos, None);
|
audio.play_sfx(file_ref, *pos, None);
|
||||||
},
|
},
|
||||||
_ => {},
|
Outcome::Beam { pos, heal } => {
|
||||||
|
if *heal {
|
||||||
|
let file_ref = "voxygen.audio.sfx.abilities.staff_channeling";
|
||||||
|
audio.play_sfx(file_ref, *pos, None);
|
||||||
|
} else {
|
||||||
|
let file_ref = "voxygen.audio.sfx.abilities.flame_thrower";
|
||||||
|
audio.play_sfx(file_ref, *pos, None);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Outcome::Attack {
|
||||||
|
pos,
|
||||||
|
character_state,
|
||||||
|
loadout,
|
||||||
|
} => {
|
||||||
|
if let Some(item_config) = &loadout.active_item {
|
||||||
|
if let ItemKind::Tool(data) = item_config.item.kind() {
|
||||||
|
if character_state.is_attack() {
|
||||||
|
match (
|
||||||
|
CharacterAbilityType::from(character_state),
|
||||||
|
data.kind.clone(),
|
||||||
|
) {
|
||||||
|
(
|
||||||
|
CharacterAbilityType::ComboMelee(StageSection::Swing, 1),
|
||||||
|
ToolKind::Sword,
|
||||||
|
) => {
|
||||||
|
audio.play_sfx(
|
||||||
|
"voxygen.audio.sfx.abilities.swing_sword",
|
||||||
|
*pos,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
(
|
||||||
|
CharacterAbilityType::ComboMelee(StageSection::Swing, 2),
|
||||||
|
ToolKind::Sword,
|
||||||
|
) => {
|
||||||
|
audio.play_sfx(
|
||||||
|
"voxygen.audio.sfx.abilities.separated_second_swing",
|
||||||
|
*pos,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
(
|
||||||
|
CharacterAbilityType::ComboMelee(StageSection::Swing, 3),
|
||||||
|
ToolKind::Sword,
|
||||||
|
) => {
|
||||||
|
audio.play_sfx(
|
||||||
|
"voxygen.audio.sfx.abilities.separated_third_swing",
|
||||||
|
*pos,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user