Cleanup / Armor support

This commit is contained in:
Anuken
2020-05-21 14:57:15 -04:00
parent b562c30381
commit 61d9fd3d72
31 changed files with 481 additions and 455 deletions

View File

@@ -2,6 +2,7 @@ package mindustry.entities.comp;
import arc.math.*;
import arc.util.*;
import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
@@ -49,6 +50,20 @@ abstract class HealthComp implements Entityc{
return health < maxHealth - 0.001f;
}
/** Damage and pierce armor. */
void damagePierce(float amount, boolean withEffect){
if(this instanceof Shieldc){
damage(amount / Math.max(1f - ((Shieldc)this).armor(), Vars.minArmorDamage), withEffect);
}else{
damage(amount, withEffect);
}
}
/** Damage and pierce armor. */
void damagePierce(float amount){
damagePierce(amount, true);
}
void damage(float amount){
health -= amount;
hitTime = 1f;
@@ -71,6 +86,10 @@ abstract class HealthComp implements Entityc{
damage(amount * Time.delta(), hitTime <= -20 + hitDuration);
}
void damageContinuousPierce(float amount){
damagePierce(amount * Time.delta(), hitTime <= -20 + hitDuration);
}
void clampHealth(){
health = Mathf.clamp(health, 0, maxHealth);
}