Cleanup
This commit is contained in:
30
core/src/mindustry/entities/def/ShieldComp.java
Normal file
30
core/src/mindustry/entities/def/ShieldComp.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package mindustry.entities.def;
|
||||
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
@Component
|
||||
abstract class ShieldComp implements Healthc{
|
||||
@Import float health, hitTime;
|
||||
@Import boolean dead;
|
||||
|
||||
/** Absorbs health damage. */
|
||||
float shield;
|
||||
|
||||
@Replace
|
||||
@Override
|
||||
public void damage(float amount){
|
||||
hitTime = 1f;
|
||||
|
||||
float shieldDamage = Math.min(shield, amount);
|
||||
shield -= shieldDamage;
|
||||
amount -= shieldDamage;
|
||||
|
||||
if(amount > 0){
|
||||
health -= amount;
|
||||
if(health <= 0 && !dead){
|
||||
kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
private UnitController controller;
|
||||
private UnitType type;
|
||||
|
||||
int level;
|
||||
|
||||
public void moveAt(Vec2 vector){
|
||||
moveAt(vector, type.accel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user