Files
Mindustry/core/src/mindustry/entities/abilities/RepairFieldAbility.java
Patrick 'Quezler' Mounier 80f027471c Update RepairFieldAbility.java
2020-11-29 19:35:49 +01:00

47 lines
1.1 KiB
Java

package mindustry.entities.abilities;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
public class RepairFieldAbility extends Ability{
public float amount = 1, reload = 100, range = 60;
public Effect healEffect = Fx.heal;
public Effect activeEffect = Fx.healWaveDynamic;
protected float timer;
protected boolean wasHealed = false;
RepairFieldAbility(){}
public RepairFieldAbility(float amount, float reload, float range){
this.amount = amount;
this.reload = reload;
this.range = range;
}
@Override
public void update(Unit unit){
timer += Time.delta;
if(timer >= reload){
wasHealed = false;
Units.nearby(unit.team, unit.x, unit.y, range, other -> {
if(other.damaged()){
healEffect.at(other);
wasHealed = true;
}
other.heal(amount);
});
if(wasHealed){
activeEffect.at(unit, range);
}
timer = 0f;
}
}
}