mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
address comments
This commit is contained in:
parent
7dad972632
commit
8b01abde67
@ -1072,46 +1072,39 @@ impl CharacterAbility {
|
|||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => {
|
None => match self {
|
||||||
use skills::{
|
CharacterAbility::Roll {
|
||||||
ClimbSkill::{self, *},
|
ref mut immune_melee,
|
||||||
RollSkill::{self, *},
|
ref mut energy_cost,
|
||||||
};
|
ref mut roll_strength,
|
||||||
match self {
|
ref mut movement_duration,
|
||||||
CharacterAbility::Roll {
|
..
|
||||||
ref mut immune_melee,
|
} => {
|
||||||
ref mut energy_cost,
|
use skills::RollSkill::*;
|
||||||
ref mut roll_strength,
|
*immune_melee = skillset.has_skill(Skill::Roll(ImmuneMelee));
|
||||||
ref mut movement_duration,
|
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Cost)) {
|
||||||
..
|
*energy_cost *= 0.8_f32.powi(level.into());
|
||||||
} => {
|
}
|
||||||
*immune_melee = skillset.has_skill(Skill::Roll(ImmuneMelee));
|
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Strength)) {
|
||||||
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(RollSkill::Cost))
|
*roll_strength *= 1.2_f32.powi(level.into());
|
||||||
{
|
}
|
||||||
*energy_cost *= 0.8_f32.powi(level.into());
|
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Duration)) {
|
||||||
}
|
*movement_duration *= 1.2_f32.powi(level.into());
|
||||||
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Strength)) {
|
}
|
||||||
*roll_strength *= 1.2_f32.powi(level.into());
|
},
|
||||||
}
|
CharacterAbility::Climb {
|
||||||
if let Ok(Some(level)) = skillset.skill_level(Skill::Roll(Duration)) {
|
ref mut energy_cost,
|
||||||
*movement_duration *= 1.2_f32.powi(level.into());
|
ref mut movement_speed,
|
||||||
}
|
} => {
|
||||||
},
|
use skills::ClimbSkill::*;
|
||||||
CharacterAbility::Climb {
|
if let Ok(Some(level)) = skillset.skill_level(Skill::Climb(Cost)) {
|
||||||
ref mut energy_cost,
|
*energy_cost *= 0.8_f32.powi(level.into());
|
||||||
ref mut movement_speed,
|
}
|
||||||
} => {
|
if let Ok(Some(level)) = skillset.skill_level(Skill::Climb(Speed)) {
|
||||||
if let Ok(Some(level)) =
|
*movement_speed *= 1.2_f32.powi(level.into());
|
||||||
skillset.skill_level(Skill::Climb(ClimbSkill::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());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Some(_) => {},
|
Some(_) => {},
|
||||||
}
|
}
|
||||||
@ -1253,8 +1246,10 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
|
|||||||
energy_cost,
|
energy_cost,
|
||||||
movement_speed,
|
movement_speed,
|
||||||
} => CharacterState::Climb(climb::Data {
|
} => CharacterState::Climb(climb::Data {
|
||||||
energy_cost: *energy_cost,
|
static_data: climb::StaticData {
|
||||||
movement_speed: *movement_speed,
|
energy_cost: *energy_cost,
|
||||||
|
movement_speed: *movement_speed,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
CharacterAbility::ComboMelee {
|
CharacterAbility::ComboMelee {
|
||||||
stage_data,
|
stage_data,
|
||||||
|
@ -11,17 +11,27 @@ use crate::{
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
|
/// Separated out to condense update portions of character state
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Data {
|
pub struct StaticData {
|
||||||
pub energy_cost: f32,
|
pub energy_cost: f32,
|
||||||
pub movement_speed: f32,
|
pub movement_speed: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub struct Data {
|
||||||
|
/// Struct containing data that does not change over the course of the
|
||||||
|
/// character state
|
||||||
|
pub static_data: StaticData,
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for Data {
|
impl Default for Data {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Data {
|
Data {
|
||||||
energy_cost: 5.0,
|
static_data: StaticData {
|
||||||
movement_speed: 5.0,
|
energy_cost: 5.0,
|
||||||
|
movement_speed: 5.0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,15 +60,15 @@ impl CharacterBehavior for Data {
|
|||||||
// Move player
|
// Move player
|
||||||
update.vel.0 += Vec2::broadcast(data.dt.0)
|
update.vel.0 += Vec2::broadcast(data.dt.0)
|
||||||
* data.inputs.move_dir
|
* data.inputs.move_dir
|
||||||
* if update.vel.0.magnitude_squared() < self.movement_speed.powi(2) {
|
* if update.vel.0.magnitude_squared() < self.static_data.movement_speed.powi(2) {
|
||||||
self.movement_speed.powi(2)
|
self.static_data.movement_speed.powi(2)
|
||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
};
|
};
|
||||||
|
|
||||||
// Expend energy if climbing
|
// Expend energy if climbing
|
||||||
let energy_use = match climb {
|
let energy_use = match climb {
|
||||||
Climb::Up => self.energy_cost as i32,
|
Climb::Up => self.static_data.energy_cost as i32,
|
||||||
Climb::Down => 1,
|
Climb::Down => 1,
|
||||||
Climb::Hold => 1,
|
Climb::Hold => 1,
|
||||||
};
|
};
|
||||||
@ -82,8 +92,12 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
// Apply Vertical Climbing Movement
|
// Apply Vertical Climbing Movement
|
||||||
match climb {
|
match climb {
|
||||||
Climb::Down => update.vel.0.z += data.dt.0 * (GRAVITY - self.movement_speed.powi(2)),
|
Climb::Down => {
|
||||||
Climb::Up => update.vel.0.z += data.dt.0 * (GRAVITY + self.movement_speed.powi(2)),
|
update.vel.0.z += data.dt.0 * (GRAVITY - self.static_data.movement_speed.powi(2))
|
||||||
|
},
|
||||||
|
Climb::Up => {
|
||||||
|
update.vel.0.z += data.dt.0 * (GRAVITY + self.static_data.movement_speed.powi(2))
|
||||||
|
},
|
||||||
Climb::Hold => update.vel.0.z += data.dt.0 * GRAVITY,
|
Climb::Hold => update.vel.0.z += data.dt.0 * GRAVITY,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ use common::{
|
|||||||
consts::{FRIC_GROUND, GRAVITY},
|
consts::{FRIC_GROUND, GRAVITY},
|
||||||
event::{EventBus, ServerEvent},
|
event::{EventBus, ServerEvent},
|
||||||
resources::DeltaTime,
|
resources::DeltaTime,
|
||||||
states::*,
|
|
||||||
terrain::{Block, TerrainGrid},
|
terrain::{Block, TerrainGrid},
|
||||||
uid::Uid,
|
uid::Uid,
|
||||||
vol::{BaseVol, ReadVol},
|
vol::{BaseVol, ReadVol},
|
||||||
@ -670,9 +669,8 @@ impl<'a> PhysicsData<'a> {
|
|||||||
|
|
||||||
let was_on_ground = physics_state.on_ground;
|
let was_on_ground = physics_state.on_ground;
|
||||||
let block_snap = body.map_or(false, |body| body.jump_impulse().is_some());
|
let block_snap = body.map_or(false, |body| body.jump_impulse().is_some());
|
||||||
let climbing = character_state.map_or(false, |cs| {
|
let climbing =
|
||||||
matches!(cs, CharacterState::Climb(climb::Data { .. }))
|
character_state.map_or(false, |cs| matches!(cs, CharacterState::Climb(_)));
|
||||||
});
|
|
||||||
|
|
||||||
match &collider {
|
match &collider {
|
||||||
Collider::Voxel { .. } => {
|
Collider::Voxel { .. } => {
|
||||||
|
@ -134,8 +134,8 @@ pub fn skill_to_db_string(skill: comp::skills::Skill) -> String {
|
|||||||
Roll(RollSkill::Cost) => "Roll Cost",
|
Roll(RollSkill::Cost) => "Roll Cost",
|
||||||
Roll(RollSkill::Strength) => "Roll Strength",
|
Roll(RollSkill::Strength) => "Roll Strength",
|
||||||
Roll(RollSkill::Duration) => "Roll Duration",
|
Roll(RollSkill::Duration) => "Roll Duration",
|
||||||
Climb(ClimbSkill::Cost) => "Climbing Cost",
|
Climb(ClimbSkill::Cost) => "Climb Cost",
|
||||||
Climb(ClimbSkill::Speed) => "Climbing Speed",
|
Climb(ClimbSkill::Speed) => "Climb Speed",
|
||||||
UnlockGroup(SkillGroupKind::Weapon(ToolKind::Sword)) => "Unlock Weapon Sword",
|
UnlockGroup(SkillGroupKind::Weapon(ToolKind::Sword)) => "Unlock Weapon Sword",
|
||||||
UnlockGroup(SkillGroupKind::Weapon(ToolKind::Axe)) => "Unlock Weapon Axe",
|
UnlockGroup(SkillGroupKind::Weapon(ToolKind::Axe)) => "Unlock Weapon Axe",
|
||||||
UnlockGroup(SkillGroupKind::Weapon(ToolKind::Hammer)) => "Unlock Weapon Hammer",
|
UnlockGroup(SkillGroupKind::Weapon(ToolKind::Hammer)) => "Unlock Weapon Hammer",
|
||||||
@ -259,8 +259,8 @@ pub fn db_string_to_skill(skill_string: &str) -> comp::skills::Skill {
|
|||||||
"Roll Cost" => Roll(RollSkill::Cost),
|
"Roll Cost" => Roll(RollSkill::Cost),
|
||||||
"Roll Strength" => Roll(RollSkill::Strength),
|
"Roll Strength" => Roll(RollSkill::Strength),
|
||||||
"Roll Duration" => Roll(RollSkill::Duration),
|
"Roll Duration" => Roll(RollSkill::Duration),
|
||||||
"Climbing Cost" => Climb(ClimbSkill::Cost),
|
"Climb Cost" => Climb(ClimbSkill::Cost),
|
||||||
"Climbing Speed" => Climb(ClimbSkill::Speed),
|
"Climb Speed" => Climb(ClimbSkill::Speed),
|
||||||
"Unlock Weapon Sword" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Sword)),
|
"Unlock Weapon Sword" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Sword)),
|
||||||
"Unlock Weapon Axe" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Axe)),
|
"Unlock Weapon Axe" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Axe)),
|
||||||
"Unlock Weapon Hammer" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Hammer)),
|
"Unlock Weapon Hammer" => UnlockGroup(SkillGroupKind::Weapon(ToolKind::Hammer)),
|
||||||
|
Loading…
Reference in New Issue
Block a user