From b8daa422eead70afcf7c2d7c5638027041ad6b80 Mon Sep 17 00:00:00 2001 From: genNAowl <68400583+genNAowl@users.noreply.github.com> Date: Fri, 4 Jun 2021 05:31:33 -0700 Subject: [PATCH] I Like Stats (#5347) Co-authored-by: Leonwang4234 --- core/src/mindustry/type/Weapon.java | 14 ++++++++++++++ .../mindustry/type/weapons/RepairBeamWeapon.java | 8 ++++++++ core/src/mindustry/world/meta/StatValues.java | 10 ++-------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index 1389bd238a..ca002353bc 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -7,6 +7,8 @@ import arc.graphics.*; import arc.graphics.g2d.*; import arc.math.*; import arc.math.geom.*; +import arc.scene.ui.layout.*; +import arc.struct.*; import arc.util.*; import mindustry.audio.*; import mindustry.content.*; @@ -15,6 +17,7 @@ import mindustry.entities.bullet.*; import mindustry.entities.units.*; import mindustry.gen.*; import mindustry.graphics.*; +import mindustry.world.meta.*; import static mindustry.Vars.*; @@ -119,6 +122,17 @@ public class Weapon implements Cloneable{ this(""); } + public void addStats(UnitType u, Table t){ + if(inaccuracy > 0){ + t.row(); + t.add("[lightgray]" + Stat.inaccuracy.localized() + ": [white]" + (int)inaccuracy + " " + StatUnit.degrees.localized()); + } + t.row(); + t.add("[lightgray]" + Stat.reload.localized() + ": " + (mirror ? "2x " : "") + "[white]" + Strings.autoFixed(60f / reload * shots, 2)); + + StatValues.ammo(ObjectMap.of(u, bullet)).display(t); + } + public float dps(){ return (bullet.estimateDPS() / reload) * shots * 60f; } diff --git a/core/src/mindustry/type/weapons/RepairBeamWeapon.java b/core/src/mindustry/type/weapons/RepairBeamWeapon.java index c2938207f0..44f76f680f 100644 --- a/core/src/mindustry/type/weapons/RepairBeamWeapon.java +++ b/core/src/mindustry/type/weapons/RepairBeamWeapon.java @@ -5,12 +5,14 @@ import arc.graphics.*; import arc.graphics.g2d.*; import arc.math.*; import arc.math.geom.*; +import arc.scene.ui.layout.*; import arc.util.*; import mindustry.entities.*; import mindustry.entities.units.*; import mindustry.gen.*; import mindustry.type.*; import mindustry.world.blocks.units.*; +import mindustry.world.meta.*; /** * Note that this weapon requires a bullet with a positive maxRange. @@ -47,6 +49,12 @@ public class RepairBeamWeapon extends Weapon{ recoil = 0f; } + @Override + public void addStats(UnitType u, Table w){ + w.row(); + w.add("[lightgray]" + Stat.repairSpeed.localized() + ": " + (mirror ? "2x " : "") + "[white]" + (int)(repairSpeed * 60) + " " + StatUnit.perSecond.localized()); + } + @Override public float dps(){ return 0f; diff --git a/core/src/mindustry/world/meta/StatValues.java b/core/src/mindustry/world/meta/StatValues.java index 5499cc1ca1..319dd27eb3 100644 --- a/core/src/mindustry/world/meta/StatValues.java +++ b/core/src/mindustry/world/meta/StatValues.java @@ -198,15 +198,10 @@ public class StatValues{ table.image(region).size(60).scaling(Scaling.bounded).right().top(); - table.table(Tex.underline, w -> { + table.table(Tex.underline, w -> { w.left().defaults().padRight(3).left(); - if(weapon.inaccuracy > 0){ - sep(w, "[lightgray]" + Stat.inaccuracy.localized() + ": [white]" + (int)weapon.inaccuracy + " " + StatUnit.degrees.localized()); - } - sep(w, "[lightgray]" + Stat.reload.localized() + ": " + (weapon.mirror ? "2x " : "") + "[white]" + Strings.autoFixed(60f / weapon.reload * weapon.shots, 2)); - - ammo(ObjectMap.of(unit, weapon.bullet)).display(w); + weapon.addStats(unit, w); }).padTop(-9).left(); table.row(); } @@ -298,7 +293,6 @@ public class StatValues{ } //for AmmoListValue - private static void sep(Table table, String text){ table.row(); table.add(text);