Code quality changes and comments

This commit is contained in:
socksonme 2022-01-29 21:03:04 +02:00 committed by Socksonme
parent c0e78d869e
commit 6c75ad6ef8
6 changed files with 14 additions and 15 deletions

View File

@ -212,8 +212,6 @@ impl Attack {
let is_crit = thread_rng().gen::<f32>() < self.crit_chance;
let mut is_applied = false;
let mut accumulated_damage = 0.0;
// TODO: Issue with shotgun ability
// TODO: Add instance number to AttackDamage?
for damage in self
.damages
.iter()
@ -636,6 +634,7 @@ pub struct AttackDamage {
damage: Damage,
target: Option<GroupTarget>,
effects: Vec<CombatEffect>,
/// A random ID, used to group up attacks
instance: u64,
}
@ -741,7 +740,6 @@ impl From<AttackerInfo<'_>> for DamageContributor {
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub enum DamageSource {
// Could be used to separate DOTs?
Buff(BuffKind),
Melee,
Projectile,

View File

@ -29,10 +29,10 @@ pub struct HealthChange {
/// couldn't have been a crit)
pub crit: Option<bool>,
pub crit_mult: f32,
/// A random instance ID given to every health change
/// Note: Two or more changes could have the same instance number, if they
/// came from the same attack (for example - the extra damage caused by
/// slashing weapons)
/// A random ID, used to group up health changes
// Note: Two or more changes could have the same instance number, if they
// came from the same attack (for example - the extra damage caused by
// slashing weapons)
pub instance: u64,
}

View File

@ -128,7 +128,6 @@ impl<'a> System<'a> for Sys {
// Might make this more nuanced if shockwaves are used for non damage effects
let group = shockwave_owner.and_then(|e| read_data.groups.get(e));
// TODO: Join counter later?
// Go through all other effectable entities
for (target, uid_b, pos_b, health_b, body_b, physics_state_b) in (
&read_data.entities,

View File

@ -82,6 +82,8 @@ pub fn handle_health_change(server: &Server, entity: EcsEntity, change: HealthCh
ecs.read_storage::<Pos>().get(entity),
ecs.read_storage::<Uid>().get(entity),
) {
// If the absolute health change amount was greater than the health epsilon,
// push a new Damage outcome
if changed {
outcomes.push(Outcome::Damage {
pos: pos.0,
@ -863,7 +865,6 @@ pub fn handle_explosion(server: &Server, pos: Vec3<f32>, explosion: Explosion, o
}
},
RadiusEffect::Attack(attack) => {
// TODO: Join counter later?
let energies = &ecs.read_storage::<comp::Energy>();
let combos = &ecs.read_storage::<comp::Combo>();
let inventories = &ecs.read_storage::<comp::Inventory>();

View File

@ -515,6 +515,7 @@ impl SfxMgr {
);
},
Outcome::Damage { pos, info, .. } => {
// Don't emit sound effects from positive damage (healing)
if info.amount < Health::HEALTH_EPSILON {
let sfx_trigger_item = triggers.get_key_value(&SfxEvent::Damage);
audio.emit_sfx(sfx_trigger_item, *pos, Some(1.5), false);

View File

@ -4686,18 +4686,17 @@ impl Hud {
let last_floater = if info.amount < Health::HEALTH_EPSILON {
floater_list.floaters.iter_mut().rev().find(|f| {
f.info.amount < Health::HEALTH_EPSILON
&& info.crit.map_or(f.info.crit.unwrap_or(false), |_| {
!f.info.crit.unwrap_or(false)
})
&& info.crit.unwrap_or(false)
== f.info.crit.unwrap_or(false)
})
} else {
floater_list.floaters.iter_mut().rev().find(|f| {
f.info.amount > Health::HEALTH_EPSILON
&& info.crit.map_or(f.info.crit.unwrap_or(false), |_| {
!f.info.crit.unwrap_or(false)
})
&& info.crit.unwrap_or(false)
== f.info.crit.unwrap_or(false)
})
};
dbg!(&last_floater);
match last_floater {
Some(f)
@ -4711,6 +4710,7 @@ impl Hud {
f.info.crit = Some(f.info.crit.unwrap_or(false) || info.crit.unwrap_or(false));
},
_ => {
dbg!(&info.amount);
floater_list.floaters.push(HpFloater {
timer: 0.0,
info: *info,