mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Removed buffered inputs
This commit is contained in:
parent
e37e4016d6
commit
c295506ef9
@ -1727,7 +1727,6 @@ impl Client {
|
||||
entry
|
||||
.or_insert_with(|| Controller {
|
||||
inputs: inputs.clone(),
|
||||
held_inputs: BTreeMap::new(),
|
||||
queued_inputs: BTreeMap::new(),
|
||||
events: Vec::new(),
|
||||
actions: Vec::new(),
|
||||
|
@ -29,7 +29,6 @@ pub struct StateUpdate {
|
||||
pub swap_equipped_weapons: bool,
|
||||
pub should_strafe: bool,
|
||||
pub queued_inputs: BTreeMap<InputKind, InputAttr>,
|
||||
pub used_inputs: Vec<InputKind>,
|
||||
pub removed_inputs: Vec<InputKind>,
|
||||
}
|
||||
|
||||
@ -60,7 +59,6 @@ impl From<&JoinData<'_>> for StateUpdate {
|
||||
should_strafe: data.inputs.strafing,
|
||||
character: data.character.clone(),
|
||||
queued_inputs: BTreeMap::new(),
|
||||
used_inputs: Vec::new(),
|
||||
removed_inputs: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ use crate::{
|
||||
invite::{InviteKind, InviteResponse},
|
||||
BuffKind,
|
||||
},
|
||||
resources::Time,
|
||||
trade::{TradeAction, TradeId},
|
||||
uid::Uid,
|
||||
util::Dir,
|
||||
@ -248,8 +247,7 @@ pub struct ControllerInputs {
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Controller {
|
||||
pub inputs: ControllerInputs,
|
||||
pub held_inputs: BTreeMap<InputKind, InputAttr>,
|
||||
pub queued_inputs: BTreeMap<InputKind, (Time, InputAttr)>,
|
||||
pub queued_inputs: BTreeMap<InputKind, InputAttr>,
|
||||
// TODO: consider SmallVec
|
||||
pub events: Vec<ControlEvent>,
|
||||
pub actions: Vec<ControlAction>,
|
||||
@ -285,7 +283,6 @@ impl Controller {
|
||||
pub fn reset(&mut self) {
|
||||
self.inputs = Default::default();
|
||||
self.queued_inputs = Default::default();
|
||||
self.held_inputs = Default::default();
|
||||
}
|
||||
|
||||
pub fn clear_events(&mut self) { self.events.clear(); }
|
||||
@ -313,12 +310,6 @@ impl Controller {
|
||||
pub fn push_cancel_input(&mut self, input: InputKind) {
|
||||
self.push_action(ControlAction::CancelInput(input));
|
||||
}
|
||||
|
||||
pub fn cull_queued_inputs(&mut self, time: Time) {
|
||||
const QUEUED_CULL_DUR: f64 = 0.35;
|
||||
self.queued_inputs
|
||||
.retain(|_, (init_time, _)| init_time.0 + QUEUED_CULL_DUR > time.0);
|
||||
}
|
||||
}
|
||||
|
||||
impl Component for Controller {
|
||||
|
@ -702,9 +702,7 @@ pub fn fly_move(data: &JoinData<'_>, update: &mut StateUpdate, efficiency: f32)
|
||||
/// Checks if an input related to an attack is held. If one is, moves entity
|
||||
/// into wielding state
|
||||
pub fn handle_wield(data: &JoinData<'_>, update: &mut StateUpdate) {
|
||||
if data.controller.queued_inputs.keys().any(|i| i.is_ability())
|
||||
|| data.controller.held_inputs.keys().any(|i| i.is_ability())
|
||||
{
|
||||
if data.controller.queued_inputs.keys().any(|i| i.is_ability()) {
|
||||
attempt_wield(data, update);
|
||||
}
|
||||
}
|
||||
@ -1051,7 +1049,7 @@ pub fn attempt_glide_wield(
|
||||
pub fn handle_jump(
|
||||
data: &JoinData<'_>,
|
||||
output_events: &mut OutputEvents,
|
||||
update: &mut StateUpdate,
|
||||
_update: &mut StateUpdate,
|
||||
strength: f32,
|
||||
) -> bool {
|
||||
(input_is_pressed(data, InputKind::Jump) && data.physics.on_ground.is_some())
|
||||
@ -1062,7 +1060,6 @@ pub fn handle_jump(
|
||||
data.entity,
|
||||
strength * impulse / data.mass.0 * data.stats.move_speed_modifier,
|
||||
));
|
||||
update.used_inputs.push(InputKind::Jump);
|
||||
})
|
||||
.is_some()
|
||||
}
|
||||
@ -1104,7 +1101,6 @@ fn handle_ability(
|
||||
},
|
||||
}
|
||||
}
|
||||
update.used_inputs.push(input);
|
||||
if let CharacterState::Roll(roll) = &mut update.character {
|
||||
if let CharacterState::ComboMelee(c) = data.character {
|
||||
roll.was_combo = Some((c.static_data.ability_info.input, c.stage));
|
||||
@ -1150,13 +1146,7 @@ pub fn attempt_input(
|
||||
update: &mut StateUpdate,
|
||||
) {
|
||||
// TODO: look into using first() when it becomes stable
|
||||
if let Some(input) = data
|
||||
.controller
|
||||
.queued_inputs
|
||||
.keys()
|
||||
.next()
|
||||
.or_else(|| data.controller.held_inputs.keys().next())
|
||||
{
|
||||
if let Some(input) = data.controller.queued_inputs.keys().next() {
|
||||
handle_input(data, output_events, update, *input);
|
||||
}
|
||||
}
|
||||
@ -1176,7 +1166,6 @@ pub fn handle_block_input(data: &JoinData<'_>, update: &mut StateUpdate) -> bool
|
||||
AbilityInfo::from_input(data, false, InputKind::Block, Default::default()),
|
||||
data,
|
||||
));
|
||||
update.used_inputs.push(InputKind::Block);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
@ -1300,7 +1289,6 @@ pub fn get_buff_strength(data: &JoinData<'_>, ai: AbilityInfo) -> f32 {
|
||||
|
||||
pub fn input_is_pressed(data: &JoinData<'_>, input: InputKind) -> bool {
|
||||
data.controller.queued_inputs.contains_key(&input)
|
||||
|| data.controller.held_inputs.contains_key(&input)
|
||||
}
|
||||
|
||||
/// Checked `Duration` addition. Computes `timer` + `dt`, applying relevant stat
|
||||
@ -1439,12 +1427,7 @@ impl AbilityInfo {
|
||||
tool,
|
||||
hand,
|
||||
input,
|
||||
input_attr: data
|
||||
.controller
|
||||
.queued_inputs
|
||||
.get(&input)
|
||||
.map(|x| x.1)
|
||||
.or_else(|| data.controller.held_inputs.get(&input).copied()),
|
||||
input_attr: data.controller.queued_inputs.get(&input).copied(),
|
||||
ability_meta,
|
||||
ability,
|
||||
}
|
||||
|
@ -271,18 +271,11 @@ impl Sys {
|
||||
*join.ori = state_update.ori;
|
||||
|
||||
for (input, attr) in state_update.queued_inputs {
|
||||
join.controller
|
||||
.queued_inputs
|
||||
.insert(input, (Time(0.0), attr));
|
||||
join.controller.held_inputs.insert(input, attr);
|
||||
}
|
||||
for input in state_update.used_inputs {
|
||||
join.controller.queued_inputs.remove(&input);
|
||||
join.controller.queued_inputs.insert(input, attr);
|
||||
}
|
||||
for input in state_update.removed_inputs {
|
||||
join.controller.held_inputs.remove(&input);
|
||||
join.controller.queued_inputs.remove(&input);
|
||||
}
|
||||
join.controller.cull_queued_inputs(Time(0.0));
|
||||
if state_update.swap_equipped_weapons {
|
||||
output_events.emit_server(ServerEvent::InventoryManip(
|
||||
join.entity,
|
||||
|
Loading…
Reference in New Issue
Block a user