mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Removed most hardcoded ability keys.
This commit is contained in:
parent
f1f5c2b21b
commit
b8f722af8d
@ -452,6 +452,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
swing_duration: *swing_duration,
|
swing_duration: *swing_duration,
|
||||||
recover_duration: *recover_duration,
|
recover_duration: *recover_duration,
|
||||||
is_interruptible: *is_interruptible,
|
is_interruptible: *is_interruptible,
|
||||||
|
ability_key: key,
|
||||||
},
|
},
|
||||||
auto_charge: false,
|
auto_charge: false,
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
@ -489,6 +490,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
speed_increase: 1.0 - *speed_increase,
|
speed_increase: 1.0 - *speed_increase,
|
||||||
max_speed_increase: *max_speed_increase - 1.0,
|
max_speed_increase: *max_speed_increase - 1.0,
|
||||||
is_interruptible: *is_interruptible,
|
is_interruptible: *is_interruptible,
|
||||||
|
ability_key: key,
|
||||||
},
|
},
|
||||||
stage: 1,
|
stage: 1,
|
||||||
combo: 0,
|
combo: 0,
|
||||||
@ -552,6 +554,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
is_interruptible: *is_interruptible,
|
is_interruptible: *is_interruptible,
|
||||||
forward_speed: *forward_speed,
|
forward_speed: *forward_speed,
|
||||||
num_spins: *num_spins,
|
num_spins: *num_spins,
|
||||||
|
ability_key: key,
|
||||||
},
|
},
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
spins_remaining: *num_spins - 1,
|
spins_remaining: *num_spins - 1,
|
||||||
@ -583,6 +586,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
charge_duration: *charge_duration,
|
charge_duration: *charge_duration,
|
||||||
swing_duration: *swing_duration,
|
swing_duration: *swing_duration,
|
||||||
recover_duration: *recover_duration,
|
recover_duration: *recover_duration,
|
||||||
|
ability_key: key,
|
||||||
},
|
},
|
||||||
stage_section: StageSection::Charge,
|
stage_section: StageSection::Charge,
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
@ -619,6 +623,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
projectile_gravity: *projectile_gravity,
|
projectile_gravity: *projectile_gravity,
|
||||||
initial_projectile_speed: *initial_projectile_speed,
|
initial_projectile_speed: *initial_projectile_speed,
|
||||||
max_projectile_speed: *max_projectile_speed,
|
max_projectile_speed: *max_projectile_speed,
|
||||||
|
ability_key: key,
|
||||||
},
|
},
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
|
@ -32,6 +32,8 @@ pub struct StaticData {
|
|||||||
pub swing_duration: Duration,
|
pub swing_duration: Duration,
|
||||||
/// How long the state has until exiting
|
/// How long the state has until exiting
|
||||||
pub recover_duration: Duration,
|
pub recover_duration: Duration,
|
||||||
|
/// What key is used to press ability
|
||||||
|
pub ability_key: AbilityKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -58,7 +60,7 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
match self.stage_section {
|
match self.stage_section {
|
||||||
StageSection::Charge => {
|
StageSection::Charge => {
|
||||||
if data.inputs.secondary.is_pressed()
|
if ability_key_is_pressed(data, self.static_data.ability_key)
|
||||||
&& update.energy.current() >= self.static_data.energy_cost
|
&& update.energy.current() >= self.static_data.energy_cost
|
||||||
&& self.timer < self.static_data.charge_duration
|
&& self.timer < self.static_data.charge_duration
|
||||||
{
|
{
|
||||||
@ -81,7 +83,7 @@ impl CharacterBehavior for Data {
|
|||||||
amount: -(self.static_data.energy_drain as f32 * data.dt.0) as i32,
|
amount: -(self.static_data.energy_drain as f32 * data.dt.0) as i32,
|
||||||
source: EnergySource::Ability,
|
source: EnergySource::Ability,
|
||||||
});
|
});
|
||||||
} else if data.inputs.secondary.is_pressed()
|
} else if ability_key_is_pressed(data, self.static_data.ability_key)
|
||||||
&& update.energy.current() >= self.static_data.energy_cost
|
&& update.energy.current() >= self.static_data.energy_cost
|
||||||
{
|
{
|
||||||
// Maintains charge
|
// Maintains charge
|
||||||
|
@ -37,6 +37,8 @@ pub struct StaticData {
|
|||||||
pub projectile_gravity: Option<Gravity>,
|
pub projectile_gravity: Option<Gravity>,
|
||||||
pub initial_projectile_speed: f32,
|
pub initial_projectile_speed: f32,
|
||||||
pub max_projectile_speed: f32,
|
pub max_projectile_speed: f32,
|
||||||
|
/// What key is used to press ability
|
||||||
|
pub ability_key: AbilityKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -80,7 +82,7 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
StageSection::Charge => {
|
StageSection::Charge => {
|
||||||
if !data.inputs.secondary.is_pressed() && !self.exhausted {
|
if !ability_key_is_pressed(data, self.static_data.ability_key) && !self.exhausted {
|
||||||
let charge_frac = (self.timer.as_secs_f32()
|
let charge_frac = (self.timer.as_secs_f32()
|
||||||
/ self.static_data.charge_duration.as_secs_f32())
|
/ self.static_data.charge_duration.as_secs_f32())
|
||||||
.min(1.0);
|
.min(1.0);
|
||||||
@ -138,7 +140,7 @@ impl CharacterBehavior for Data {
|
|||||||
..*self
|
..*self
|
||||||
});
|
});
|
||||||
} else if self.timer < self.static_data.charge_duration
|
} else if self.timer < self.static_data.charge_duration
|
||||||
&& data.inputs.secondary.is_pressed()
|
&& ability_key_is_pressed(data, self.static_data.ability_key)
|
||||||
{
|
{
|
||||||
// Charges
|
// Charges
|
||||||
update.character = CharacterState::ChargedRanged(Data {
|
update.character = CharacterState::ChargedRanged(Data {
|
||||||
@ -154,7 +156,7 @@ impl CharacterBehavior for Data {
|
|||||||
amount: -(self.static_data.energy_drain as f32 * data.dt.0) as i32,
|
amount: -(self.static_data.energy_drain as f32 * data.dt.0) as i32,
|
||||||
source: EnergySource::Ability,
|
source: EnergySource::Ability,
|
||||||
});
|
});
|
||||||
} else if data.inputs.secondary.is_pressed() {
|
} else if ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
// Holds charge
|
// Holds charge
|
||||||
update.character = CharacterState::ChargedRanged(Data {
|
update.character = CharacterState::ChargedRanged(Data {
|
||||||
timer: self
|
timer: self
|
||||||
|
@ -54,6 +54,8 @@ pub struct StaticData {
|
|||||||
pub max_speed_increase: f32,
|
pub max_speed_increase: f32,
|
||||||
/// Whether the state can be interrupted by other abilities
|
/// Whether the state can be interrupted by other abilities
|
||||||
pub is_interruptible: bool,
|
pub is_interruptible: bool,
|
||||||
|
/// What key is used to press ability
|
||||||
|
pub ability_key: AbilityKey,
|
||||||
}
|
}
|
||||||
/// A sequence of attacks that can incrementally become faster and more
|
/// A sequence of attacks that can incrementally become faster and more
|
||||||
/// damaging.
|
/// damaging.
|
||||||
@ -84,7 +86,9 @@ impl CharacterBehavior for Data {
|
|||||||
let stage_index = (self.stage - 1) as usize;
|
let stage_index = (self.stage - 1) as usize;
|
||||||
|
|
||||||
// Allows for other states to interrupt this state
|
// Allows for other states to interrupt this state
|
||||||
if self.static_data.is_interruptible && !data.inputs.primary.is_pressed() {
|
if self.static_data.is_interruptible
|
||||||
|
&& !ability_key_is_pressed(data, self.static_data.ability_key)
|
||||||
|
{
|
||||||
handle_interrupt(data, &mut update);
|
handle_interrupt(data, &mut update);
|
||||||
match update.character {
|
match update.character {
|
||||||
CharacterState::ComboMelee(_) => {},
|
CharacterState::ComboMelee(_) => {},
|
||||||
@ -183,7 +187,7 @@ impl CharacterBehavior for Data {
|
|||||||
StageSection::Recover => {
|
StageSection::Recover => {
|
||||||
if self.timer < self.static_data.stage_data[stage_index].base_recover_duration {
|
if self.timer < self.static_data.stage_data[stage_index].base_recover_duration {
|
||||||
// Recovers
|
// Recovers
|
||||||
if data.inputs.primary.is_pressed() {
|
if ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
// Checks if state will transition to next stage after recover
|
// Checks if state will transition to next stage after recover
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
static_data: self.static_data.clone(),
|
static_data: self.static_data.clone(),
|
||||||
|
@ -39,6 +39,8 @@ pub struct StaticData {
|
|||||||
pub recover_duration: Duration,
|
pub recover_duration: Duration,
|
||||||
/// Whether the state can be interrupted by other abilities
|
/// Whether the state can be interrupted by other abilities
|
||||||
pub is_interruptible: bool,
|
pub is_interruptible: bool,
|
||||||
|
/// What key is used to press ability
|
||||||
|
pub ability_key: AbilityKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -66,7 +68,9 @@ impl CharacterBehavior for Data {
|
|||||||
handle_move(data, &mut update, 0.1);
|
handle_move(data, &mut update, 0.1);
|
||||||
|
|
||||||
// Allows for other states to interrupt this state
|
// Allows for other states to interrupt this state
|
||||||
if self.static_data.is_interruptible && !data.inputs.secondary.is_pressed() {
|
if self.static_data.is_interruptible
|
||||||
|
&& !ability_key_is_pressed(data, self.static_data.ability_key)
|
||||||
|
{
|
||||||
handle_interrupt(data, &mut update);
|
handle_interrupt(data, &mut update);
|
||||||
match update.character {
|
match update.character {
|
||||||
CharacterState::DashMelee(_) => {},
|
CharacterState::DashMelee(_) => {},
|
||||||
@ -90,7 +94,7 @@ impl CharacterBehavior for Data {
|
|||||||
} else {
|
} else {
|
||||||
// Transitions to charge section of stage
|
// Transitions to charge section of stage
|
||||||
update.character = CharacterState::DashMelee(Data {
|
update.character = CharacterState::DashMelee(Data {
|
||||||
auto_charge: !data.inputs.secondary.is_pressed(),
|
auto_charge: !ability_key_is_pressed(data, self.static_data.ability_key),
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Charge,
|
stage_section: StageSection::Charge,
|
||||||
..*self
|
..*self
|
||||||
@ -100,7 +104,7 @@ impl CharacterBehavior for Data {
|
|||||||
StageSection::Charge => {
|
StageSection::Charge => {
|
||||||
if (self.static_data.infinite_charge
|
if (self.static_data.infinite_charge
|
||||||
|| self.timer < self.static_data.charge_duration)
|
|| self.timer < self.static_data.charge_duration)
|
||||||
&& (data.inputs.secondary.is_pressed()
|
&& (ability_key_is_pressed(data, self.static_data.ability_key)
|
||||||
|| (self.auto_charge && self.timer < self.static_data.charge_duration))
|
|| (self.auto_charge && self.timer < self.static_data.charge_duration))
|
||||||
&& update.energy.current() > 0
|
&& update.energy.current() > 0
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,8 @@ pub struct StaticData {
|
|||||||
pub forward_speed: f32,
|
pub forward_speed: f32,
|
||||||
/// Number of spins
|
/// Number of spins
|
||||||
pub num_spins: u32,
|
pub num_spins: u32,
|
||||||
|
/// What key is used to press ability
|
||||||
|
pub ability_key: AbilityKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -65,7 +67,9 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allows for other states to interrupt this state
|
// Allows for other states to interrupt this state
|
||||||
if self.static_data.is_interruptible && !data.inputs.ability3.is_pressed() {
|
if self.static_data.is_interruptible
|
||||||
|
&& !ability_key_is_pressed(data, self.static_data.ability_key)
|
||||||
|
{
|
||||||
handle_interrupt(data, &mut update);
|
handle_interrupt(data, &mut update);
|
||||||
match update.character {
|
match update.character {
|
||||||
CharacterState::SpinMelee(_) => {},
|
CharacterState::SpinMelee(_) => {},
|
||||||
@ -140,7 +144,8 @@ impl CharacterBehavior for Data {
|
|||||||
});
|
});
|
||||||
} else if update.energy.current() >= self.static_data.energy_cost
|
} else if update.energy.current() >= self.static_data.energy_cost
|
||||||
&& (self.spins_remaining != 0
|
&& (self.spins_remaining != 0
|
||||||
|| (self.static_data.is_infinite && data.inputs.secondary.is_pressed()))
|
|| (self.static_data.is_infinite
|
||||||
|
&& ability_key_is_pressed(data, self.static_data.ability_key)))
|
||||||
{
|
{
|
||||||
let new_spins_remaining = if self.static_data.is_infinite {
|
let new_spins_remaining = if self.static_data.is_infinite {
|
||||||
self.spins_remaining
|
self.spins_remaining
|
||||||
|
Loading…
Reference in New Issue
Block a user