Implemented ground mech boosting

This commit is contained in:
Anuken
2020-05-20 18:48:04 -04:00
parent 78f24b8840
commit 5b445c59c1
62 changed files with 610 additions and 638 deletions

View File

@@ -0,0 +1,50 @@
package mindustry.entities.comp;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.gen.*;
@Component
abstract class ShieldComp implements Healthc, Posc{
@Import float health, hitTime;
@Import boolean dead;
/** Absorbs health damage. */
float shield;
/** Shield opacity. */
transient float shieldAlpha = 0f;
@Replace
@Override
public void damage(float amount){
hitTime = 1f;
boolean hadShields = shield > 0.0001f;
if(hadShields){
shieldAlpha = 1f;
}
float shieldDamage = Math.min(shield, amount);
shield -= shieldDamage;
amount -= shieldDamage;
if(amount > 0){
health -= amount;
if(health <= 0 && !dead){
kill();
}
if(hadShields && shield <= 0.0001f){
Fx.unitShieldBreak.at(x(), y(), 0, this);
}
}
}
@Override
public void update(){
shieldAlpha -= Time.delta() / 15f;
if(shieldAlpha < 0) shieldAlpha = 0f;
}
}