most ability displays (#8981)
* works * why not * idk if that changes it but * json * destringening * automatic imports and leftover marker * uirfirf
This commit is contained in:
@@ -15,6 +15,8 @@ public abstract class Ability implements Cloneable{
|
||||
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){}
|
||||
|
||||
public Ability copy(){
|
||||
try{
|
||||
@@ -25,10 +27,6 @@ public abstract class Ability implements Cloneable{
|
||||
}
|
||||
}
|
||||
|
||||
public void displayBars(Unit unit, Table bars){
|
||||
|
||||
}
|
||||
|
||||
/** @return localized ability name; mods should override this. */
|
||||
public String localized(){
|
||||
var type = getClass();
|
||||
|
||||
@@ -4,9 +4,11 @@ import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.Table;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class ArmorPlateAbility extends Ability{
|
||||
public TextureRegion plateRegion;
|
||||
@@ -25,6 +27,11 @@ public class ArmorPlateAbility extends Ability{
|
||||
unit.healthMultiplier += warmup * healthMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStats(Table t){
|
||||
t.add("[lightgray]" + Stat.healthMultiplier.localized() + ": [white]" + Math.round(healthMultiplier * 100f) + 100 + "%");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Unit unit){
|
||||
if(warmup > 0.001f){
|
||||
|
||||
@@ -5,15 +5,16 @@ import arc.audio.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -31,6 +32,7 @@ public class EnergyFieldAbility extends Ability{
|
||||
public float healPercent = 3f;
|
||||
/** Multiplies healing to units of the same type by this amount. */
|
||||
public float sameTypeHealMult = 1f;
|
||||
public boolean displayHeal = true;
|
||||
|
||||
public float layer = Layer.bullet - 0.001f, blinkScl = 20f, blinkSize = 0.1f;
|
||||
public float effectRadius = 5f, sectorRad = 0.14f, rotateSpeed = 0.5f;
|
||||
@@ -50,8 +52,25 @@ public class EnergyFieldAbility extends Ability{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String localized(){
|
||||
return Core.bundle.format("ability.energyfield", damage, range / Vars.tilesize, maxTargets);
|
||||
public void addStats(Table t){
|
||||
t.add(Core.bundle.format("bullet.damage", damage));
|
||||
t.row();
|
||||
t.add("[lightgray]" + Stat.reload.localized() + ": [white]" + Strings.autoFixed(60f / reload, 2) + " " + StatUnit.perSecond.localized());
|
||||
t.row();
|
||||
t.add("[lightgray]" + Stat.shootRange.localized() + ": [white]" + Strings.autoFixed(range / tilesize, 2) + " " + StatUnit.blocks.localized());
|
||||
t.row();
|
||||
t.add(Core.bundle.format("ability.energyfield.maxtargets", maxTargets));
|
||||
|
||||
if(displayHeal){
|
||||
t.row();
|
||||
t.add(Core.bundle.format("bullet.healpercent", Strings.autoFixed(healPercent, 2)));
|
||||
t.row();
|
||||
t.add(Core.bundle.format("ability.energyfield.sametypehealmultiplier", Math.round(sameTypeHealMult * 100f)));
|
||||
}
|
||||
if(status != StatusEffects.none){
|
||||
t.row();
|
||||
t.add(status.emoji() + " " + status.localizedName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,9 @@ import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class ForceFieldAbility extends Ability{
|
||||
/** Shield radius. */
|
||||
@@ -68,6 +71,18 @@ public class ForceFieldAbility extends Ability{
|
||||
|
||||
ForceFieldAbility(){}
|
||||
|
||||
@Override
|
||||
public void addStats(Table t){
|
||||
t.add("[lightgray]" + Stat.health.localized() + ": [white]" + Math.round(max));
|
||||
t.row();
|
||||
t.add("[lightgray]" + Stat.shootRange.localized() + ": [white]" + Strings.autoFixed(radius / tilesize, 2) + " " + StatUnit.blocks.localized());
|
||||
t.row();
|
||||
t.add("[lightgray]" + Stat.repairSpeed.localized() + ": [white]" + Strings.autoFixed(regen * 60f, 2) + StatUnit.perSecond.localized());
|
||||
t.row();
|
||||
t.add("[lightgray]" + Stat.cooldownTime.localized() + ": [white]" + Strings.autoFixed(cooldown / 60f, 2) + " " + StatUnit.seconds.localized());
|
||||
t.row();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
if(unit.shield < max){
|
||||
|
||||
@@ -30,6 +30,7 @@ public class MoveEffectAbility extends Ability{
|
||||
}
|
||||
|
||||
public MoveEffectAbility(){
|
||||
display = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package mindustry.entities.abilities;
|
||||
|
||||
import arc.Core;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class RegenAbility extends Ability{
|
||||
/** Amount healed as percent per tick. */
|
||||
@@ -9,6 +12,18 @@ public class RegenAbility extends Ability{
|
||||
/** Amount healed as a flat amount per tick. */
|
||||
public float amount = 0f;
|
||||
|
||||
@Override
|
||||
public void addStats(Table t){
|
||||
if(amount > 0.01f){
|
||||
t.add("[lightgray]" + Stat.repairSpeed.localized() + ": [white]" + Strings.autoFixed(amount * 60f, 2) + StatUnit.perSecond.localized());
|
||||
t.row();
|
||||
}
|
||||
|
||||
if(percentAmount > 0.01f){
|
||||
t.add(Core.bundle.format("bullet.healpercent", Strings.autoFixed(percentAmount * 60f, 2)) + StatUnit.perSecond.localized()); //stupid but works
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
unit.heal((unit.maxHealth * percentAmount / 100f + amount) * Time.delta);
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package mindustry.entities.abilities;
|
||||
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.tilesize;
|
||||
|
||||
public class RepairFieldAbility extends Ability{
|
||||
public float amount = 1, reload = 100, range = 60;
|
||||
@@ -22,6 +26,13 @@ public class RepairFieldAbility extends Ability{
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStats(Table t){
|
||||
t.add("[lightgray]" + Stat.repairSpeed.localized() + ": [white]" + Strings.autoFixed(amount * 60f / reload, 2) + StatUnit.perSecond.localized());
|
||||
t.row();
|
||||
t.add("[lightgray]" + Stat.shootRange.localized() + ": [white]" + Strings.autoFixed(range / tilesize, 2) + " " + StatUnit.blocks.localized());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
timer += Time.delta;
|
||||
|
||||
@@ -13,6 +13,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class ShieldArcAbility extends Ability{
|
||||
private static Unit paramUnit;
|
||||
@@ -66,6 +67,16 @@ public class ShieldArcAbility extends Ability{
|
||||
/** State. */
|
||||
protected float widthScale, alpha;
|
||||
|
||||
@Override
|
||||
public void addStats(Table t){
|
||||
t.add("[lightgray]" + Stat.health.localized() + ": [white]" + Math.round(max));
|
||||
t.row();
|
||||
t.add("[lightgray]" + Stat.repairSpeed.localized() + ": [white]" + Strings.autoFixed(regen * 60f, 2) + StatUnit.perSecond.localized());
|
||||
t.row();
|
||||
t.add("[lightgray]" + Stat.cooldownTime.localized() + ": [white]" + Strings.autoFixed(cooldown / 60f, 2) + " " + StatUnit.seconds.localized());
|
||||
t.row();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
if(data < max){
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package mindustry.entities.abilities;
|
||||
|
||||
import arc.Core;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.tilesize;
|
||||
|
||||
public class ShieldRegenFieldAbility extends Ability{
|
||||
public float amount = 1, max = 100f, reload = 100, range = 60;
|
||||
@@ -23,6 +28,16 @@ public class ShieldRegenFieldAbility extends Ability{
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStats(Table t){
|
||||
t.add("[lightgray]" + Core.bundle.get("waves.shields") + ": [white]" + Math.round(max)); //extremely stupid usage
|
||||
t.row();
|
||||
t.add("[lightgray]" + Stat.shootRange.localized() + ": [white]" + Strings.autoFixed(range / tilesize, 2) + " " + StatUnit.blocks.localized());
|
||||
t.row();
|
||||
t.add("[lightgray]" + Stat.reload.localized() + ": [white]" + Strings.autoFixed(60f / reload, 2) + " " + StatUnit.perSecond.localized());
|
||||
t.row();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
timer += Time.delta;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mindustry.entities.abilities;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.gen.*;
|
||||
@@ -24,6 +25,11 @@ public class SpawnDeathAbility extends Ability{
|
||||
public SpawnDeathAbility(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStats(Table t){
|
||||
t.add((randAmount > 0 ? amount + "-" + (amount + randAmount) : amount) + " " + unit.emoji() + " " + unit.localizedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void death(Unit unit){
|
||||
if(!Vars.net.client()){
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
package mindustry.entities.abilities;
|
||||
|
||||
import arc.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.Table;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.tilesize;
|
||||
|
||||
public class StatusFieldAbility extends Ability{
|
||||
public StatusEffect effect;
|
||||
public float duration = 60, reload = 100, range = 20;
|
||||
public float duration = 60, reload = 100, range = 20; //
|
||||
public boolean onShoot = false;
|
||||
public Effect applyEffect = Fx.none;
|
||||
public Effect activeEffect = Fx.overdriveWave;
|
||||
@@ -29,8 +32,12 @@ public class StatusFieldAbility extends Ability{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String localized(){
|
||||
return Core.bundle.format("ability.statusfield", effect.emoji());
|
||||
public void addStats(Table t){
|
||||
t.add("[lightgray]" + Stat.reload.localized() + ": [white]" + Strings.autoFixed(60f / reload, 2) + " " + StatUnit.perSecond.localized());
|
||||
t.row();
|
||||
t.add("[lightgray]" + Stat.shootRange.localized() + ": [white]" + Strings.autoFixed(range / tilesize, 2) + " " + StatUnit.blocks.localized());
|
||||
t.row();
|
||||
t.add(effect.emoji() + " " + effect.localizedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package mindustry.entities.abilities;
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
@@ -11,6 +12,7 @@ import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -32,6 +34,13 @@ public class UnitSpawnAbility extends Ability{
|
||||
public UnitSpawnAbility(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStats(Table t){
|
||||
t.add("[lightgray]" + Stat.buildTime.localized() + ": [white]" + Strings.autoFixed(spawnTime / 60f, 2) + " " + StatUnit.seconds.localized());
|
||||
t.row();
|
||||
t.add(unit.emoji() + " " + unit.localizedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
timer += Time.delta * state.rules.unitBuildSpeed(unit.team);
|
||||
|
||||
@@ -603,13 +603,7 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
stats.add(Stat.range, (int)(maxRange / tilesize), StatUnit.blocks);
|
||||
|
||||
if(abilities.any()){
|
||||
var unique = new ObjectSet<String>();
|
||||
|
||||
for(Ability a : abilities){
|
||||
if(a.display && unique.add(a.localized())){
|
||||
stats.add(Stat.abilities, a.localized());
|
||||
}
|
||||
}
|
||||
stats.add(Stat.abilities, StatValues.abilities(abilities));
|
||||
}
|
||||
|
||||
stats.add(Stat.flying, flying);
|
||||
|
||||
@@ -12,6 +12,7 @@ import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.abilities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.maps.*;
|
||||
@@ -348,7 +349,7 @@ public class StatValues{
|
||||
public static StatValue weapons(UnitType unit, Seq<Weapon> weapons){
|
||||
return table -> {
|
||||
table.row();
|
||||
for(int i = 0; i < weapons.size;i ++){
|
||||
for(int i = 0; i < weapons.size; i++){
|
||||
Weapon weapon = weapons.get(i);
|
||||
|
||||
if(weapon.flipSprite || !weapon.hasStats(unit)){
|
||||
@@ -370,6 +371,23 @@ public class StatValues{
|
||||
};
|
||||
}
|
||||
|
||||
public static StatValue abilities(Seq<Ability> abilities){
|
||||
return table -> {
|
||||
table.row();
|
||||
table.table(t -> abilities.each(ability -> {
|
||||
if(ability.display){
|
||||
t.row();
|
||||
t.table(Styles.grayPanel, a -> {
|
||||
a.add("[accent]" + ability.localized()).padBottom(4);
|
||||
a.row();
|
||||
a.left().top().defaults().left();
|
||||
ability.addStats(a);
|
||||
}).pad(5).margin(10).growX();
|
||||
}
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
||||
public static <T extends UnlockableContent> StatValue ammo(ObjectMap<T, BulletType> map){
|
||||
return ammo(map, 0, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user