* Fix armor plate multiplier + change Math.round to Strings.autoFixed * Missing ability name bundles * Center ability name * SuppressionFieldAbility stats * Is two per row is acceptable? I can revert this commit if not. * LiquidExplodeAbility stat display * MoveLightningAbility stat display * Better SpawnDeathAbility display * Fix multiplier coloring inconsistencies Some had [lightgray] before %/x, some had it after * Consistent content name display Match with bullet status effects * Consistent stat formatting Convert from some being "stat: #" and some being "# stat" to all being "# stat" * Re-order stats * Optimize Imports * Add ability descriptions * Apparently I forgot LiquidRegenAbility * Mention healing allies if displayHeal = true
50 lines
1.5 KiB
Java
50 lines
1.5 KiB
Java
package mindustry.entities.abilities;
|
|
|
|
import arc.*;
|
|
import arc.scene.ui.layout.*;
|
|
import mindustry.gen.*;
|
|
import mindustry.type.*;
|
|
|
|
public abstract class Ability implements Cloneable{
|
|
protected static final float descriptionWidth = 350f;
|
|
/** If false, this ability does not show in unit stats. */
|
|
public boolean display = true;
|
|
//the one and only data variable that is synced.
|
|
public float data;
|
|
|
|
public void update(Unit unit){}
|
|
public void draw(Unit unit){}
|
|
public void death(Unit unit){}
|
|
public void init(UnitType type){}
|
|
public void displayBars(Unit unit, Table bars){}
|
|
public void addStats(Table t){
|
|
if(Core.bundle.has(getBundle() + ".description")){
|
|
t.add(Core.bundle.get(getBundle() + ".description")).wrap().width(descriptionWidth);
|
|
t.row();
|
|
}
|
|
}
|
|
|
|
public String abilityStat(String stat, Object... values){
|
|
return Core.bundle.format("ability.stat." + stat, values);
|
|
}
|
|
|
|
public Ability copy(){
|
|
try{
|
|
return (Ability)clone();
|
|
}catch(CloneNotSupportedException e){
|
|
//I am disgusted
|
|
throw new RuntimeException("java sucks", e);
|
|
}
|
|
}
|
|
|
|
/** @return localized ability name; mods should override this. */
|
|
public String localized(){
|
|
return Core.bundle.get(getBundle());
|
|
}
|
|
|
|
public String getBundle(){
|
|
var type = getClass();
|
|
return "ability." + (type.isAnonymousClass() ? type.getSuperclass() : type).getSimpleName().replace("Ability", "").toLowerCase();
|
|
}
|
|
}
|