diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index 49161893ff..3eeaa21e19 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -1,6 +1,6 @@ use crate::{ combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement}, - comp::{tool::ToolKind, CharacterState, InputAttr, Melee, StateUpdate}, + comp::{tool::ToolKind, CharacterState, Melee, StateUpdate}, states::{ behavior::{CharacterBehavior, JoinData}, utils::*, @@ -189,10 +189,5 @@ impl CharacterBehavior for Data { } fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) { - handle_input( - join, - update, - data.static_data.ability_info.input, - InputAttr::default(), - ); + handle_input(join, update, data.static_data.ability_info.input); } diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index 2b018043ee..501f92d3a6 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -1,7 +1,5 @@ use crate::{ - comp::{ - Body, CharacterState, Gravity, InputAttr, LightEmitter, ProjectileConstructor, StateUpdate, - }, + comp::{Body, CharacterState, Gravity, LightEmitter, ProjectileConstructor, StateUpdate}, event::ServerEvent, states::{ behavior::{CharacterBehavior, JoinData}, @@ -127,10 +125,5 @@ impl CharacterBehavior for Data { } fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) { - handle_input( - join, - update, - data.static_data.ability_info.input, - InputAttr::default(), - ); + handle_input(join, update, data.static_data.ability_info.input); } diff --git a/common/src/states/boost.rs b/common/src/states/boost.rs index 6f23ddd92b..415e4c9d6b 100644 --- a/common/src/states/boost.rs +++ b/common/src/states/boost.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{CharacterState, InputAttr, StateUpdate}, + comp::{CharacterState, StateUpdate}, states::{ behavior::{CharacterBehavior, JoinData}, utils::*, @@ -59,10 +59,5 @@ impl CharacterBehavior for Data { } fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) { - handle_input( - join, - update, - data.static_data.ability_info.input, - InputAttr::default(), - ); + handle_input(join, update, data.static_data.ability_info.input); } diff --git a/common/src/states/combo_melee.rs b/common/src/states/combo_melee.rs index 3a059f8230..37c2da82a8 100644 --- a/common/src/states/combo_melee.rs +++ b/common/src/states/combo_melee.rs @@ -1,6 +1,6 @@ use crate::{ combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement}, - comp::{tool::ToolKind, CharacterState, InputAttr, Melee, StateUpdate}, + comp::{tool::ToolKind, CharacterState, Melee, StateUpdate}, states::{ behavior::{CharacterBehavior, JoinData}, utils::*, @@ -296,12 +296,7 @@ impl CharacterBehavior for Data { } fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) { - handle_input( - join, - update, - data.static_data.ability_info.input, - InputAttr::default(), - ); + handle_input(join, update, data.static_data.ability_info.input); if let CharacterState::ComboMelee(c) = &mut update.character { c.stage = (data.stage % data.static_data.num_stages) + 1; diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index 939cc36c1b..d96cdddee1 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{CharacterState, InputAttr, InputKind, StateUpdate}, + comp::{CharacterState, InputKind, StateUpdate}, states::{ behavior::{CharacterBehavior, JoinData}, utils::*, @@ -116,7 +116,7 @@ impl CharacterBehavior for Data { // Done if let Some((input, stage)) = self.was_combo { if input_is_pressed(data, input) { - handle_input(data, &mut update, input, InputAttr::default()); + handle_input(data, &mut update, input); // If other states are introduced that progress through stages, add them // here if let CharacterState::ComboMelee(c) = &mut update.character { diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 64529a54b7..e800a3d3e3 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -462,12 +462,7 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) { } } -fn handle_ability( - data: &JoinData, - update: &mut StateUpdate, - input: InputKind, - input_attr: InputAttr, -) { +fn handle_ability(data: &JoinData, update: &mut StateUpdate, input: InputKind) { let hands = |equip_slot| match data.inventory.equipped(equip_slot).map(|i| i.kind()) { Some(ItemKind::Tool(tool)) => Some(tool.hands), _ => None, @@ -521,7 +516,11 @@ fn handle_ability( data, matches!(equip_slot, EquipSlot::Offhand), input, - input_attr, + data.controller + .queued_inputs + .get(&input) + .cloned() + .unwrap_or_default(), ), ) .into(); @@ -530,25 +529,20 @@ fn handle_ability( } pub fn handle_ability_input(data: &JoinData, update: &mut StateUpdate) { - if let Some((input, input_attr)) = data + if let Some(input) = data .controller .queued_inputs - .iter() - .find(|(i, _)| i.is_ability()) + .keys() + .find(|i| i.is_ability()) { - handle_ability(data, update, *input, input_attr.clone()); + handle_ability(data, update, *input); } } -pub fn handle_input( - data: &JoinData, - update: &mut StateUpdate, - input: InputKind, - input_attr: InputAttr, -) { +pub fn handle_input(data: &JoinData, update: &mut StateUpdate, input: InputKind) { match input { InputKind::Primary | InputKind::Secondary | InputKind::Ability(_) => { - handle_ability(data, update, input, input_attr) + handle_ability(data, update, input) }, InputKind::Roll => handle_dodge_input(data, update), InputKind::Jump => handle_jump(data, update), @@ -558,8 +552,8 @@ pub fn handle_input( pub fn attempt_input(data: &JoinData, update: &mut StateUpdate) { // TODO: look into using first() when it becomes stable - if let Some((input, input_attr)) = data.controller.queued_inputs.iter().next() { - handle_input(data, update, *input, input_attr.clone()); + if let Some(input) = data.controller.queued_inputs.keys().next() { + handle_input(data, update, *input); } }