Ground support unit implementations
This commit is contained in:
8
core/src/mindustry/entities/units/Ability.java
Normal file
8
core/src/mindustry/entities/units/Ability.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package mindustry.entities.units;
|
||||
|
||||
import mindustry.gen.*;
|
||||
|
||||
public interface Ability{
|
||||
default void update(Unit unit){}
|
||||
default void draw(Unit unit){}
|
||||
}
|
||||
45
core/src/mindustry/entities/units/HealFieldAbility.java
Normal file
45
core/src/mindustry/entities/units/HealFieldAbility.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package mindustry.entities.units;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class HealFieldAbility implements Ability{
|
||||
public float amount = 1, reload = 100, range = 60;
|
||||
public Effect healEffect = Fx.heal;
|
||||
public Effect activeEffect = Fx.healWave;
|
||||
|
||||
private boolean wasHealed = false;
|
||||
|
||||
HealFieldAbility(){}
|
||||
|
||||
public HealFieldAbility(float amount, float reload, float range){
|
||||
this.amount = amount;
|
||||
this.reload = reload;
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
unit.timer1 += Time.delta();
|
||||
|
||||
if(unit.timer1 >= reload){
|
||||
wasHealed = false;
|
||||
|
||||
Units.nearby(unit.team, unit.x, unit.y, range, other -> {
|
||||
if(other.damaged()){
|
||||
healEffect.at(unit);
|
||||
wasHealed = true;
|
||||
}
|
||||
other.heal(amount);
|
||||
});
|
||||
|
||||
if(wasHealed){
|
||||
activeEffect.at(unit);
|
||||
}
|
||||
|
||||
unit.timer1 = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
40
core/src/mindustry/entities/units/StatusFieldAbility.java
Normal file
40
core/src/mindustry/entities/units/StatusFieldAbility.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package mindustry.entities.units;
|
||||
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
public class StatusFieldAbility implements Ability{
|
||||
public @NonNull StatusEffect effect;
|
||||
public float duration = 60, reload = 100, range = 20;
|
||||
public Effect applyEffect = Fx.heal;
|
||||
public Effect activeEffect = Fx.healWave;
|
||||
|
||||
StatusFieldAbility(){}
|
||||
|
||||
public StatusFieldAbility(@NonNull StatusEffect effect, float duration, float reload, float range){
|
||||
this.duration = duration;
|
||||
this.reload = reload;
|
||||
this.range = range;
|
||||
this.effect = effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
unit.timer2 += Time.delta();
|
||||
|
||||
if(unit.timer2 >= reload){
|
||||
|
||||
Units.nearby(unit.team, unit.x, unit.y, range, other -> {
|
||||
other.apply(effect, duration);
|
||||
});
|
||||
|
||||
activeEffect.at(unit);
|
||||
|
||||
unit.timer2 = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user