move climbing skill adjustment into climb module

This commit is contained in:
Vincent Foulon 2021-03-21 00:22:04 +01:00
parent 8b01abde67
commit d0df01fe51
3 changed files with 36 additions and 41 deletions

View File

@ -1072,39 +1072,24 @@ impl CharacterAbility {
_ => {},
}
},
None => match self {
CharacterAbility::Roll {
ref mut immune_melee,
ref mut energy_cost,
ref mut roll_strength,
ref mut movement_duration,
..
} => {
use skills::RollSkill::*;
*immune_melee = skillset.has_skill(Skill::Roll(ImmuneMelee));
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Cost)) {
*energy_cost *= 0.8_f32.powi(level.into());
}
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Strength)) {
*roll_strength *= 1.2_f32.powi(level.into());
}
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Duration)) {
*movement_duration *= 1.2_f32.powi(level.into());
}
},
CharacterAbility::Climb {
ref mut energy_cost,
ref mut movement_speed,
} => {
use skills::ClimbSkill::*;
if let Ok(Some(level)) = skillset.skill_level(Skill::Climb(Cost)) {
*energy_cost *= 0.8_f32.powi(level.into());
}
if let Ok(Some(level)) = skillset.skill_level(Skill::Climb(Speed)) {
*movement_speed *= 1.2_f32.powi(level.into());
}
},
_ => {},
None => if let CharacterAbility::Roll{
ref mut immune_melee,
ref mut energy_cost,
ref mut roll_strength,
ref mut movement_duration,
..
} = self {
use skills::RollSkill::*;
*immune_melee = skillset.has_skill(Skill::Roll(ImmuneMelee));
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Cost)) {
*energy_cost *= 0.8_f32.powi(level.into());
}
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Strength)) {
*roll_strength *= 1.2_f32.powi(level.into());
}
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Duration)) {
*movement_duration *= 1.2_f32.powi(level.into());
}
},
Some(_) => {},
}

View File

@ -1,5 +1,8 @@
use crate::{
comp::{CharacterState, Climb, EnergySource, InputKind, Ori, StateUpdate},
comp::{
skills::{ClimbSkill::*, Skill},
CharacterState, Climb, EnergySource, InputKind, Ori, StateUpdate,
},
consts::GRAVITY,
event::LocalEvent,
states::{
@ -25,6 +28,19 @@ pub struct Data {
pub static_data: StaticData,
}
impl Data {
pub fn create_adjusted_by_skills(join_data: &JoinData) -> Self {
let mut data = Data::default();
if let Ok(Some(level)) = join_data.stats.skill_set.skill_level(Skill::Climb(Cost)) {
data.static_data.energy_cost *= 0.8_f32.powi(level.into());
}
if let Ok(Some(level)) = join_data.stats.skill_set.skill_level(Skill::Climb(Speed)) {
data.static_data.movement_speed *= 1.2_f32.powi(level.into());
}
data
}
}
impl Default for Data {
fn default() -> Self {
Data {

View File

@ -407,13 +407,7 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) {
&& data.body.can_climb()
&& update.energy.current() > 100
{
let ability = CharacterAbility::Climb {
energy_cost: 5.0,
movement_speed: 5.0,
}
.adjusted_by_skills(&data.stats.skill_set, None);
let ability_info = AbilityInfo::from_input(data, false, InputKind::Roll);
update.character = CharacterState::from((&ability, ability_info));
update.character = CharacterState::Climb(climb::Data::create_adjusted_by_skills(data));
}
}