More comments

Former-commit-id: 762d6437fa341a33ee80088e2c5dbbdf96387df0
This commit is contained in:
timokoesters
2019-05-24 22:54:40 +02:00
parent 15d1a789d6
commit 73f29e3716

View File

@ -149,11 +149,15 @@ impl<'a> System<'a> for Sys {
for (b, pos_b, mut stat_b, mut vel_b) in for (b, pos_b, mut stat_b, mut vel_b) in
(&entities, &positions, &mut stats, &mut velocities).join() (&entities, &positions, &mut stats, &mut velocities).join()
{ {
// Check if it is a hit
if entity != b if entity != b
&& pos.0.distance_squared(pos_b.0) < 50.0 && pos.0.distance_squared(pos_b.0) < 50.0
&& dir.0.angle_between(pos_b.0 - pos.0).to_degrees() < 70.0 && dir.0.angle_between(pos_b.0 - pos.0).to_degrees() < 70.0
{ {
// Set action
action.attack_time = Some(0.0); action.attack_time = Some(0.0);
// Deal damage
stat_b.hp.change_by(-10); // TODO: variable damage stat_b.hp.change_by(-10); // TODO: variable damage
vel_b.0 += (pos_b.0 - pos.0).normalized() * 20.0; vel_b.0 += (pos_b.0 - pos.0).normalized() * 20.0;
vel_b.0.z = 20.0; vel_b.0.z = 20.0;