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

@@ -5,19 +5,26 @@ import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.gen.*;
import static mindustry.Vars.minArmorDamage;
@Component
abstract class ShieldComp implements Healthc, Posc{
@Import float health, hitTime;
@Import float health, hitTime, x, y;
@Import boolean dead;
/** Absorbs health damage. */
float shield;
/** Absorbs percentage of damage, up to 90% */
float armor;
/** Shield opacity. */
transient float shieldAlpha = 0f;
@Replace
@Override
public void damage(float amount){
//apply armor
amount *= Math.max(1f - armor, minArmorDamage);
hitTime = 1f;
boolean hadShields = shield > 0.0001f;
@@ -37,7 +44,7 @@ abstract class ShieldComp implements Healthc, Posc{
}
if(hadShields && shield <= 0.0001f){
Fx.unitShieldBreak.at(x(), y(), 0, this);
Fx.unitShieldBreak.at(x, y, 0, this);
}
}
}