mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Addressed review comments.
This commit is contained in:
parent
01d1e15be3
commit
6814ce8134
@ -1463,3 +1463,13 @@ pub fn compute_protection(
|
||||
.sum::<Option<f32>>()
|
||||
})
|
||||
}
|
||||
|
||||
/// Used to compute the precision multiplier achieved by flanking a target
|
||||
pub fn precision_mult_from_flank(attack_dir: Vec3<f32>, target_ori: Option<&Ori>) -> Option<f32> {
|
||||
let angle = target_ori.map(|t_ori| t_ori.look_dir().angle_between(attack_dir));
|
||||
match angle {
|
||||
Some(angle) if angle < FULL_FLANK_ANGLE => Some(1.0),
|
||||
Some(angle) if angle < PARTIAL_FLANK_ANGLE => Some(0.5),
|
||||
Some(_) | None => None,
|
||||
}
|
||||
}
|
||||
|
@ -233,19 +233,10 @@ impl<'a> System<'a> for Sys {
|
||||
target,
|
||||
);
|
||||
|
||||
let precision_from_flank = {
|
||||
let beam_dir = beam.bezier.ctrl - beam.bezier.start;
|
||||
let angle = target_info.ori.map_or(std::f32::consts::PI, |t_ori| {
|
||||
t_ori.look_dir().angle_between(beam_dir)
|
||||
});
|
||||
if angle < combat::FULL_FLANK_ANGLE {
|
||||
Some(1.0)
|
||||
} else if angle < combat::PARTIAL_FLANK_ANGLE {
|
||||
Some(0.5)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
let precision_from_flank = combat::precision_mult_from_flank(
|
||||
beam.bezier.ctrl - beam.bezier.start,
|
||||
target_info.ori,
|
||||
);
|
||||
|
||||
let precision_from_time = {
|
||||
if let Some(ticks) = beam.hit_durations.get(&target) {
|
||||
@ -258,8 +249,6 @@ impl<'a> System<'a> for Sys {
|
||||
}
|
||||
};
|
||||
|
||||
// Is there a more idiomatic way to do this (taking the max of 2
|
||||
// options)?
|
||||
let precision_mult = precision_from_flank
|
||||
.map(|flank| {
|
||||
precision_from_time.map_or(flank, |head: f32| head.max(flank))
|
||||
|
@ -220,18 +220,8 @@ impl<'a> System<'a> for Sys {
|
||||
target,
|
||||
);
|
||||
|
||||
let precision_from_flank = {
|
||||
let angle = target_ori.map_or(std::f32::consts::PI, |t_ori| {
|
||||
t_ori.look_dir().angle_between(*ori.look_dir())
|
||||
});
|
||||
if angle < combat::FULL_FLANK_ANGLE {
|
||||
Some(1.0)
|
||||
} else if angle < combat::PARTIAL_FLANK_ANGLE {
|
||||
Some(0.5)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
let precision_from_flank =
|
||||
combat::precision_mult_from_flank(*ori.look_dir(), target_ori);
|
||||
|
||||
let precision_from_poise = {
|
||||
if let Some(CharacterState::Stunned(data)) = target_char_state {
|
||||
@ -241,7 +231,6 @@ impl<'a> System<'a> for Sys {
|
||||
}
|
||||
};
|
||||
|
||||
// Is there a more idiomatic way to do this (taking the max of 2 options)?
|
||||
let precision_mult = precision_from_flank
|
||||
.map(|flank| {
|
||||
precision_from_poise.map_or(flank, |head: f32| head.max(flank))
|
||||
|
@ -346,20 +346,13 @@ fn dispatch_hit(
|
||||
.and_then(|cs| cs.attack_immunities())
|
||||
.map_or(false, |i| i.projectiles);
|
||||
|
||||
let precision_from_flank = {
|
||||
let angle = target_info.ori.map_or(std::f32::consts::PI, |t_ori| {
|
||||
t_ori.look_dir().angle_between(*projectile_dir)
|
||||
});
|
||||
if angle < combat::FULL_FLANK_ANGLE {
|
||||
Some(1.0)
|
||||
} else if angle < combat::PARTIAL_FLANK_ANGLE {
|
||||
Some(0.5)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
let precision_from_flank =
|
||||
combat::precision_mult_from_flank(*projectile_dir, target_info.ori);
|
||||
|
||||
let precision_from_head = {
|
||||
// This performs a cylinder and line segment intersection check. The cylinder is
|
||||
// the upper 10% of an entity's dimensions. The line segment is from the
|
||||
// projectile's positions on the current and previous tick.
|
||||
let curr_pos = projectile_info.pos.0;
|
||||
let last_pos = projectile_info.pos.0 - projectile_info.vel.0 * read_data.dt.0;
|
||||
let vel = projectile_info.vel.0;
|
||||
@ -405,7 +398,6 @@ fn dispatch_hit(
|
||||
if headshot { Some(1.0) } else { None }
|
||||
};
|
||||
|
||||
// Is there a more idiomatic way to do this (taking the max of 2 options)?
|
||||
let precision_mult = precision_from_flank
|
||||
.map(|flank| precision_from_head.map_or(flank, |head: f32| head.max(flank)))
|
||||
.or(precision_from_head);
|
||||
|
@ -1139,8 +1139,8 @@ impl<'a> Widget for ItemTooltip<'a> {
|
||||
.parent(id)
|
||||
.with_style(self.style.desc)
|
||||
.color(text_color)
|
||||
.down_from(state.ids.stats[3], V_PAD_STATS)
|
||||
.set(state.ids.stats[4], ui);
|
||||
.down_from(state.ids.stats[2], V_PAD_STATS)
|
||||
.set(state.ids.stats[3], ui);
|
||||
|
||||
// Energy Efficiency
|
||||
let energy_eff_text = if is_primary {
|
||||
@ -1161,8 +1161,8 @@ impl<'a> Widget for ItemTooltip<'a> {
|
||||
.parent(id)
|
||||
.with_style(self.style.desc)
|
||||
.color(text_color)
|
||||
.down_from(state.ids.stats[4], V_PAD_STATS)
|
||||
.set(state.ids.stats[5], ui);
|
||||
.down_from(state.ids.stats[3], V_PAD_STATS)
|
||||
.set(state.ids.stats[4], ui);
|
||||
|
||||
// Buff Strength
|
||||
let buff_str_text = if is_primary {
|
||||
@ -1183,8 +1183,8 @@ impl<'a> Widget for ItemTooltip<'a> {
|
||||
.parent(id)
|
||||
.with_style(self.style.desc)
|
||||
.color(text_color)
|
||||
.down_from(state.ids.stats[5], V_PAD_STATS)
|
||||
.set(state.ids.stats[6], ui);
|
||||
.down_from(state.ids.stats[4], V_PAD_STATS)
|
||||
.set(state.ids.stats[5], ui);
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
|
Loading…
Reference in New Issue
Block a user