mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fetch InputAttr from controller
This commit is contained in:
parent
b45df7fe10
commit
003e76113f
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
||||||
comp::{tool::ToolKind, CharacterState, InputAttr, Melee, StateUpdate},
|
comp::{tool::ToolKind, CharacterState, Melee, StateUpdate},
|
||||||
states::{
|
states::{
|
||||||
behavior::{CharacterBehavior, JoinData},
|
behavior::{CharacterBehavior, JoinData},
|
||||||
utils::*,
|
utils::*,
|
||||||
@ -189,10 +189,5 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
||||||
handle_input(
|
handle_input(join, update, data.static_data.ability_info.input);
|
||||||
join,
|
|
||||||
update,
|
|
||||||
data.static_data.ability_info.input,
|
|
||||||
InputAttr::default(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{
|
comp::{Body, CharacterState, Gravity, LightEmitter, ProjectileConstructor, StateUpdate},
|
||||||
Body, CharacterState, Gravity, InputAttr, LightEmitter, ProjectileConstructor, StateUpdate,
|
|
||||||
},
|
|
||||||
event::ServerEvent,
|
event::ServerEvent,
|
||||||
states::{
|
states::{
|
||||||
behavior::{CharacterBehavior, JoinData},
|
behavior::{CharacterBehavior, JoinData},
|
||||||
@ -127,10 +125,5 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
||||||
handle_input(
|
handle_input(join, update, data.static_data.ability_info.input);
|
||||||
join,
|
|
||||||
update,
|
|
||||||
data.static_data.ability_info.input,
|
|
||||||
InputAttr::default(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{CharacterState, InputAttr, StateUpdate},
|
comp::{CharacterState, StateUpdate},
|
||||||
states::{
|
states::{
|
||||||
behavior::{CharacterBehavior, JoinData},
|
behavior::{CharacterBehavior, JoinData},
|
||||||
utils::*,
|
utils::*,
|
||||||
@ -59,10 +59,5 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
||||||
handle_input(
|
handle_input(join, update, data.static_data.ability_info.input);
|
||||||
join,
|
|
||||||
update,
|
|
||||||
data.static_data.ability_info.input,
|
|
||||||
InputAttr::default(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
||||||
comp::{tool::ToolKind, CharacterState, InputAttr, Melee, StateUpdate},
|
comp::{tool::ToolKind, CharacterState, Melee, StateUpdate},
|
||||||
states::{
|
states::{
|
||||||
behavior::{CharacterBehavior, JoinData},
|
behavior::{CharacterBehavior, JoinData},
|
||||||
utils::*,
|
utils::*,
|
||||||
@ -296,12 +296,7 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
||||||
handle_input(
|
handle_input(join, update, data.static_data.ability_info.input);
|
||||||
join,
|
|
||||||
update,
|
|
||||||
data.static_data.ability_info.input,
|
|
||||||
InputAttr::default(),
|
|
||||||
);
|
|
||||||
|
|
||||||
if let CharacterState::ComboMelee(c) = &mut update.character {
|
if let CharacterState::ComboMelee(c) = &mut update.character {
|
||||||
c.stage = (data.stage % data.static_data.num_stages) + 1;
|
c.stage = (data.stage % data.static_data.num_stages) + 1;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{CharacterState, InputAttr, InputKind, StateUpdate},
|
comp::{CharacterState, InputKind, StateUpdate},
|
||||||
states::{
|
states::{
|
||||||
behavior::{CharacterBehavior, JoinData},
|
behavior::{CharacterBehavior, JoinData},
|
||||||
utils::*,
|
utils::*,
|
||||||
@ -116,7 +116,7 @@ impl CharacterBehavior for Data {
|
|||||||
// Done
|
// Done
|
||||||
if let Some((input, stage)) = self.was_combo {
|
if let Some((input, stage)) = self.was_combo {
|
||||||
if input_is_pressed(data, input) {
|
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
|
// If other states are introduced that progress through stages, add them
|
||||||
// here
|
// here
|
||||||
if let CharacterState::ComboMelee(c) = &mut update.character {
|
if let CharacterState::ComboMelee(c) = &mut update.character {
|
||||||
|
@ -462,12 +462,7 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_ability(
|
fn handle_ability(data: &JoinData, update: &mut StateUpdate, input: InputKind) {
|
||||||
data: &JoinData,
|
|
||||||
update: &mut StateUpdate,
|
|
||||||
input: InputKind,
|
|
||||||
input_attr: InputAttr,
|
|
||||||
) {
|
|
||||||
let hands = |equip_slot| match data.inventory.equipped(equip_slot).map(|i| i.kind()) {
|
let hands = |equip_slot| match data.inventory.equipped(equip_slot).map(|i| i.kind()) {
|
||||||
Some(ItemKind::Tool(tool)) => Some(tool.hands),
|
Some(ItemKind::Tool(tool)) => Some(tool.hands),
|
||||||
_ => None,
|
_ => None,
|
||||||
@ -521,7 +516,11 @@ fn handle_ability(
|
|||||||
data,
|
data,
|
||||||
matches!(equip_slot, EquipSlot::Offhand),
|
matches!(equip_slot, EquipSlot::Offhand),
|
||||||
input,
|
input,
|
||||||
input_attr,
|
data.controller
|
||||||
|
.queued_inputs
|
||||||
|
.get(&input)
|
||||||
|
.cloned()
|
||||||
|
.unwrap_or_default(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
@ -530,25 +529,20 @@ fn handle_ability(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_ability_input(data: &JoinData, update: &mut StateUpdate) {
|
pub fn handle_ability_input(data: &JoinData, update: &mut StateUpdate) {
|
||||||
if let Some((input, input_attr)) = data
|
if let Some(input) = data
|
||||||
.controller
|
.controller
|
||||||
.queued_inputs
|
.queued_inputs
|
||||||
.iter()
|
.keys()
|
||||||
.find(|(i, _)| i.is_ability())
|
.find(|i| i.is_ability())
|
||||||
{
|
{
|
||||||
handle_ability(data, update, *input, input_attr.clone());
|
handle_ability(data, update, *input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_input(
|
pub fn handle_input(data: &JoinData, update: &mut StateUpdate, input: InputKind) {
|
||||||
data: &JoinData,
|
|
||||||
update: &mut StateUpdate,
|
|
||||||
input: InputKind,
|
|
||||||
input_attr: InputAttr,
|
|
||||||
) {
|
|
||||||
match input {
|
match input {
|
||||||
InputKind::Primary | InputKind::Secondary | InputKind::Ability(_) => {
|
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::Roll => handle_dodge_input(data, update),
|
||||||
InputKind::Jump => handle_jump(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) {
|
pub fn attempt_input(data: &JoinData, update: &mut StateUpdate) {
|
||||||
// TODO: look into using first() when it becomes stable
|
// TODO: look into using first() when it becomes stable
|
||||||
if let Some((input, input_attr)) = data.controller.queued_inputs.iter().next() {
|
if let Some(input) = data.controller.queued_inputs.keys().next() {
|
||||||
handle_input(data, update, *input, input_attr.clone());
|
handle_input(data, update, *input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user