Changed Damage Outcome to store more data

This commit is contained in:
socksonme 2022-01-20 09:36:45 +02:00 committed by Socksonme
parent 10bbea89e2
commit bf6c6fb33d
3 changed files with 21 additions and 1 deletions

View File

@ -238,7 +238,12 @@ impl Attack {
);
let applied_damage = -change.amount;
accumulated_damage += applied_damage;
emit_outcome(Outcome::Damage { pos: target.pos });
emit_outcome(Outcome::Damage {
pos: target.pos,
uid: target.uid,
amount: applied_damage,
crit: is_crit,
});
if change.amount.abs() > Health::HEALTH_EPSILON {
emit(ServerEvent::HealthChange {
entity: target.entity,

View File

@ -60,6 +60,11 @@ pub enum Outcome {
},
Damage {
pos: Vec3<f32>,
/// The exact amount of damage delt,
/// excluding any sources of healing
amount: f32,
uid: Uid,
crit: bool,
},
Death {
pos: Vec3<f32>,

View File

@ -1416,6 +1416,8 @@ impl Hud {
&mut self.ids.player_scts,
&mut ui_widgets.widget_id_generator(),
);
// TODO: Change to use Outcome
// Calculate total change
// Ignores healing
let hp_damage: f32 = floaters.iter().map(|f| f.hp_change.min(0.0)).sum();
@ -4470,6 +4472,14 @@ impl Hud {
timer: 1.0,
})
},
Outcome::Damage {
uid, crit, amount, ..
} => {
dbg!(uid);
dbg!(crit);
dbg!(amount);
},
_ => {},
}
}