Fix SFX and Assets

This commit is contained in:
Adam Whitehurst 2020-01-16 05:28:45 -08:00
parent d82e93b39f
commit 5959d2a5c7
12 changed files with 67 additions and 37 deletions

View File

@ -2,7 +2,13 @@ Item(
name: "Crude Mallet",
description: "Breaks bones like sticks and stones.",
kind: Tool(
kind: Hammer,
power: 20,
),
ToolData (
kind: Hammer,
equip_time_millis: 1000,
attack_buildup_millis: 700,
attack_recover_millis: 100,
range: 3,
base_damage: 10,
)
)
)

View File

@ -2,7 +2,13 @@ Item(
name: "Humble Stick",
description: "Walking stick with a sharpened end.",
kind: Tool(
kind: Hammer,
power: 6,
ToolData (
kind: Staff,
equip_time_millis: 800,
attack_buildup_millis: 400,
attack_recover_millis: 300,
range: 3,
base_damage: 10,
)
),
)

View File

@ -23,26 +23,17 @@
],
threshold: 0.5,
),
(
trigger: Attack(Sword(Rapier)),
Attack(Melee): (
files: [
"voxygen.audio.sfx.weapon.sword",
],
threshold: 0.5,
),
(
trigger: Attack(Hammer),
files: [
"voxygen.audio.sfx.weapon.sword",
],
threshold: 0.5,
),
(
trigger: Attack(Bow),
Attack(Bow): (
files: [
"voxygen.audio.sfx.weapon.bow",
],
threshold: 0.5,
),
],
}
)

View File

@ -4,12 +4,12 @@ use crate::{
comp::{Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, Vel},
event::{EventBus, LocalEvent, ServerEvent},
state::DeltaTime,
sync::Uid,
};
use serde::Deserialize;
use serde::Serialize;
use specs::LazyUpdate;
use specs::{Component, Entity, FlaggedStorage, HashMapStorage, NullStorage};
use sphynx::Uid;
use std::time::Duration;
pub struct EcsStateData<'a> {

View File

@ -69,7 +69,7 @@ impl Input {
(self.is_pressed() && self.duration >= DEFAULT_HOLD_DURATION)
}
// Whether input has been pressed for longer than `threshold`
/// Whether input has been pressed for longer than `threshold`
pub fn is_long_press(&self, threshold: Duration) -> bool {
(self.is_pressed() && self.duration >= threshold)
}

View File

@ -20,7 +20,13 @@ impl SfxEventItem {
Self { sfx, pos: None }
}
}
#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Hash, Eq)]
/// Which Kind of Attack Sfx to play,
pub enum AttackSFX {
// Decouples attack sfx assets from attack kinds
Melee,
Bow,
}
#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Hash, Eq)]
pub enum SfxEvent {
Idle,
@ -42,7 +48,7 @@ pub enum SfxEvent {
LevelUp,
LightLantern,
ExtinguishLantern,
Attack(ToolKind),
Attack(AttackSFX),
AttackWolf,
}

View File

@ -70,6 +70,11 @@ impl sync::CompPacket for EcsCompPacket {
EcsCompPacket::Mass(comp) => sync::handle_insert(comp, entity, world),
EcsCompPacket::Gravity(comp) => sync::handle_insert(comp, entity, world),
EcsCompPacket::Sticky(comp) => sync::handle_insert(comp, entity, world),
EcsCompPacket::OverrideAction(comp) => sync::handle_insert(comp, entity, world),
EcsCompPacket::OverrideMove(comp) => sync::handle_insert(comp, entity, world),
EcsCompPacket::OverrideState(comp) => sync::handle_insert(comp, entity, world),
EcsCompPacket::AbilityAction(comp) => sync::handle_insert(comp, entity, world),
EcsCompPacket::AbilityPool(comp) => sync::handle_insert(comp, entity, world),
}
}
fn apply_modify(self, entity: specs::Entity, world: &specs::World) {
@ -87,6 +92,11 @@ impl sync::CompPacket for EcsCompPacket {
EcsCompPacket::Mass(comp) => sync::handle_modify(comp, entity, world),
EcsCompPacket::Gravity(comp) => sync::handle_modify(comp, entity, world),
EcsCompPacket::Sticky(comp) => sync::handle_modify(comp, entity, world),
EcsCompPacket::OverrideAction(comp) => sync::handle_modify(comp, entity, world),
EcsCompPacket::OverrideMove(comp) => sync::handle_modify(comp, entity, world),
EcsCompPacket::OverrideState(comp) => sync::handle_modify(comp, entity, world),
EcsCompPacket::AbilityAction(comp) => sync::handle_modify(comp, entity, world),
EcsCompPacket::AbilityPool(comp) => sync::handle_modify(comp, entity, world),
}
}
fn apply_remove(phantom: Self::Phantom, entity: specs::Entity, world: &specs::World) {
@ -106,6 +116,21 @@ impl sync::CompPacket for EcsCompPacket {
EcsCompPhantom::Mass(_) => sync::handle_remove::<comp::Mass>(entity, world),
EcsCompPhantom::Gravity(_) => sync::handle_remove::<comp::Gravity>(entity, world),
EcsCompPhantom::Sticky(_) => sync::handle_remove::<comp::Sticky>(entity, world),
EcsCompPhantom::OverrideAction(_) => {
sync::handle_remove::<comp::OverrideAction>(entity, world)
}
EcsCompPhantom::OverrideMove(_) => {
sync::handle_remove::<comp::OverrideMove>(entity, world)
}
EcsCompPhantom::OverrideState(_) => {
sync::handle_remove::<comp::OverrideState>(entity, world)
}
EcsCompPhantom::AbilityAction(_) => {
sync::handle_remove::<comp::AbilityAction>(entity, world)
}
EcsCompPhantom::AbilityPool(_) => {
sync::handle_remove::<comp::AbilityPool>(entity, world)
}
}
}
}

View File

@ -5,10 +5,10 @@ use crate::{
},
event::{EventBus, LocalEvent, ServerEvent},
state::DeltaTime,
sync::{Uid, UidAllocator},
};
use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage};
use sphynx::{Uid, UidAllocator};
/// ## Character State System
/// #### Calls updates to `CharacterState`s. Acts on tuples of ( `CharacterState`, `Pos`, `Vel`, and `Ori` ).

View File

@ -8,7 +8,6 @@ use specs::{
saveload::{Marker, MarkerAllocator},
Entities, Join, Read, ReadStorage, System, WriteStorage,
};
use sphynx::{Uid, UidAllocator};
/// # Controller System
/// #### Responsible for validating and updating controller inputs

View File

@ -3,7 +3,6 @@ pub mod agent;
pub mod character_state;
pub mod controller;
mod mount;
pub mod movement;
pub mod phys;
mod projectile;
mod stats;
@ -18,7 +17,6 @@ pub const AGENT_SYS: &str = "agent_sys";
pub const CONTROLLER_SYS: &str = "controller_sys";
pub const MOUNT_SYS: &str = "mount_sys";
pub const PHYS_SYS: &str = "phys_sys";
pub const MOVEMENT_SYS: &str = "movement_sys";
pub const PROJECTILE_SYS: &str = "projectile_sys";
pub const STATS_SYS: &str = "stats_sys";
pub const CLEANUP_SYS: &str = "cleanup_sys";
@ -30,10 +28,6 @@ pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {
dispatch_builder.add(character_state::Sys, CHARACTER_STATE_SYS, &[CONTROLLER_SYS]);
dispatch_builder.add(stats::Sys, STATS_SYS, &[]);
dispatch_builder.add(ability::Sys, ABILITY_SYS, &[CHARACTER_STATE_SYS]);
dispatch_builder.add(
phys::Sys,
PHYS_SYS,
&[CONTROLLER_SYS, MOUNT_SYS, MOVEMENT_SYS, STATS_SYS],
);
dispatch_builder.add(phys::Sys, PHYS_SYS, &[CONTROLLER_SYS, MOUNT_SYS, STATS_SYS]);
dispatch_builder.add(projectile::Sys, PROJECTILE_SYS, &[PHYS_SYS]);
}

View File

@ -126,8 +126,12 @@ impl MovementEventMapper {
/// as opening or closing the glider. These methods translate those entity states with some additional
/// data into more specific `SfxEvent`'s which we attach sounds to
fn map_movement_event(current_event: &CharacterState, previous_event: SfxEvent) -> SfxEvent {
match (current_event.movement, current_event.action, previous_event) {
(_, ActionState::Roll(_), _) => SfxEvent::Roll,
match (
current_event.move_state,
current_event.action_state,
previous_event,
) {
(_, ActionState::Dodge(_), _) => SfxEvent::Roll,
(MoveState::Climb(_), ..) => SfxEvent::Climb,
(MoveState::Swim(_), ..) => SfxEvent::Swim,
(MoveState::Run(_), ..) => SfxEvent::Run,
@ -290,8 +294,8 @@ mod tests {
fn maps_land_on_ground_to_run() {
let result = MovementEventMapper::map_movement_event(
&CharacterState {
movement: MovementState::Stand,
action: ActionState::Idle,
move_state: MoveState::Stand(None),
action_state: ActionState::Idle(None),
},
SfxEvent::Fall,
);
@ -342,8 +346,8 @@ mod tests {
fn maps_glider_close_when_landing() {
let result = MovementEventMapper::map_movement_event(
&CharacterState {
movement: MoveState::Stand(None),
action: ActionState::Idle(None),
move_state: MoveState::Stand(None),
action_state: ActionState::Idle(None),
},
SfxEvent::Glide,
);

View File

@ -119,7 +119,6 @@ impl<'a> Skillbar<'a> {
fonts,
stats,
energy,
global_state,
current_resource: ResourceType::Mana,
common: widget::CommonBuilder::default(),
pulse,