mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
clean up
This commit is contained in:
@@ -26,6 +26,7 @@ import mindustry.world.consumers.*;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
import static UnitInfo.SUtils.floatFormat;
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -46,12 +47,6 @@ public class BarInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public static String format(float number){
|
||||
if(number >= 10000) return UI.formatAmount((long)number);
|
||||
if(String.valueOf(number).split("[.]")[1].matches("0")) return String.valueOf(number).split("[.]")[0];
|
||||
return Strings.fixed(number, 1);
|
||||
}
|
||||
|
||||
public static <T extends Teamc> void getInfo(T target) throws IllegalAccessException, NoSuchFieldException {
|
||||
for(int i = 0; i < 6; i++) { //init
|
||||
strings.set(i, "[lightgray]<Empty>[]");
|
||||
@@ -77,14 +72,14 @@ public class BarInfo {
|
||||
float max2 = 0f;
|
||||
ForceFieldAbility ffa;
|
||||
if((ffa = (ForceFieldAbility) unit.type().abilities.find(abil -> abil instanceof ForceFieldAbility)) != null) max2 = ffa.max;
|
||||
strings.set(1, Core.bundle.format("shar-stat.shield", format(unit.shield())));
|
||||
strings.set(1, Core.bundle.format("shar-stat.shield", floatFormat(unit.shield())));
|
||||
colors.set(1, Pal.surge);
|
||||
numbers.set(1, unit.shield() / Math.max(max1, max2));
|
||||
}
|
||||
else if(target instanceof ForceProjector.ForceBuild force){
|
||||
ForceProjector forceBlock = (ForceProjector) force.block;
|
||||
float max = forceBlock.shieldHealth + forceBlock.phaseShieldBoost * force.phaseHeat;
|
||||
strings.set(1, Core.bundle.format("shar-stat.shield", format(max-force.buildup), format(max)));
|
||||
strings.set(1, Core.bundle.format("shar-stat.shield", floatFormat(max-force.buildup), floatFormat(max)));
|
||||
colors.set(1, Pal.shield);
|
||||
numbers.set(1, (max-force.buildup)/max);
|
||||
}
|
||||
@@ -134,25 +129,25 @@ public class BarInfo {
|
||||
|
||||
if(target instanceof ItemTurret.ItemTurretBuild turret) {
|
||||
ItemTurret block = (ItemTurret)turret.block;
|
||||
strings.set(2, bundle.format("shar-stat.itemAmmo", format(turret.totalAmmo), format(block.maxAmmo)));
|
||||
strings.set(2, bundle.format("shar-stat.itemAmmo", floatFormat(turret.totalAmmo), floatFormat(block.maxAmmo)));
|
||||
colors.set(2, turret.hasAmmo() ? block.ammoTypes.findKey(turret.peekAmmo(), true).color : Pal.ammo);
|
||||
numbers.set(2, turret.totalAmmo / (float)block.maxAmmo);
|
||||
}
|
||||
else if(target instanceof LiquidTurret.LiquidTurretBuild turret){
|
||||
strings.set(2, bundle.format("shar-stat.liquidAmmo", format(turret.liquids.get(turret.liquids.current())), format(turret.block.liquidCapacity)));
|
||||
strings.set(2, bundle.format("shar-stat.liquidAmmo", floatFormat(turret.liquids.get(turret.liquids.current())), floatFormat(turret.block.liquidCapacity)));
|
||||
colors.set(2, turret.liquids.current().color);
|
||||
numbers.set(2, turret.liquids.get(turret.liquids.current()) / turret.block.liquidCapacity);
|
||||
}
|
||||
else if(target instanceof PowerTurret.PowerTurretBuild turret){
|
||||
float max = turret.block.consumes.getPower().usage;
|
||||
float v = turret.power.status * turret.power.graph.getLastScaledPowerIn();
|
||||
strings.set(2, bundle.format("shar-stat.power", format(Math.min(v,max) * 60), format(max * 60)));
|
||||
strings.set(2, bundle.format("shar-stat.power", floatFormat(Math.min(v,max) * 60), floatFormat(max * 60)));
|
||||
colors.set(2, Pal.powerBar);
|
||||
numbers.set(2, v/max);
|
||||
}
|
||||
else if(target instanceof Building b && b.block.hasItems) {
|
||||
if(target instanceof CoreBlock.CoreBuild cb){
|
||||
strings.set(2, bundle.format("shar-stat.itemCapacity", format(b.items.total()), format(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
|
||||
strings.set(2, bundle.format("shar-stat.itemCapacity", floatFormat(b.items.total()), floatFormat(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
|
||||
numbers.set(2, cb.items.total() / (cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow) * 1f));
|
||||
}
|
||||
else if(target instanceof StorageBlock.StorageBuild sb && !sb.canPickup()){
|
||||
@@ -162,17 +157,17 @@ public class BarInfo {
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
strings.set(2, bundle.format("shar-stat.itemCapacity", format(sb.items.total()), format(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
|
||||
strings.set(2, bundle.format("shar-stat.itemCapacity", floatFormat(sb.items.total()), floatFormat(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
|
||||
numbers.set(2, sb.items.total() / (cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow) * 1f));
|
||||
}
|
||||
else {
|
||||
strings.set(2, bundle.format("shar-stat.itemCapacity", format(b.items.total()), format(b.block.itemCapacity)));
|
||||
strings.set(2, bundle.format("shar-stat.itemCapacity", floatFormat(b.items.total()), floatFormat(b.block.itemCapacity)));
|
||||
numbers.set(2, b.items.total() / (float) b.block.itemCapacity);
|
||||
}
|
||||
colors.set(2, Pal.items);
|
||||
}
|
||||
else if(target instanceof Unit unit && unit.type != null) {
|
||||
strings.set(2, bundle.format("shar-stat.itemCapacity", format(unit.stack.amount), format(unit.type.itemCapacity)));
|
||||
strings.set(2, bundle.format("shar-stat.itemCapacity", floatFormat(unit.stack.amount), floatFormat(unit.type.itemCapacity)));
|
||||
if(unit.stack.amount > 0 && unit.stack().item != null) colors.set(2, unit.stack.item.color.cpy().lerp(Color.white, 0.15f));
|
||||
numbers.set(2, unit.stack.amount / (unit.type.itemCapacity * 1f));
|
||||
}
|
||||
@@ -181,25 +176,25 @@ public class BarInfo {
|
||||
if(target instanceof Turret.TurretBuild t){
|
||||
Turret turret = (Turret)t.block;
|
||||
if(turret.chargeTime > 0f) {
|
||||
strings.set(3, Core.bundle.format("shar-stat.charge", format((SVars.hud.charge / turret.chargeTime) * 100)));
|
||||
strings.set(3, Core.bundle.format("shar-stat.charge", floatFormat((SVars.hud.charge / turret.chargeTime) * 100)));
|
||||
colors.set(3, Pal.surge.cpy().lerp(Pal.accent, SVars.hud.charge / turret.chargeTime));
|
||||
numbers.set(3, SVars.hud.charge / turret.chargeTime);
|
||||
}
|
||||
}
|
||||
else if(target instanceof Unit unit && unit.type != null) {
|
||||
strings.set(3, Core.bundle.format("shar-stat.commandUnits", format(Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == target)), format(unit.type().commandLimit)));
|
||||
strings.set(3, Core.bundle.format("shar-stat.commandUnits", floatFormat(Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == target)), floatFormat(unit.type().commandLimit)));
|
||||
colors.set(3, Pal.powerBar.cpy().lerp(Pal.surge.cpy().mul(Pal.lighterOrange), Mathf.absin(Time.time, 7f / (1f + Mathf.clamp(Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == target) / (unit.type().commandLimit * 1f))), 1f)));
|
||||
numbers.set(3, Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == target) / (unit.type().commandLimit * 1f));
|
||||
}
|
||||
else if(target instanceof UnitFactory.UnitFactoryBuild factory){
|
||||
strings.set(3, factory.unit() == null ? "[lightgray]" + Iconc.cancel :
|
||||
Core.bundle.format("bar.unitcap", Fonts.getUnicodeStr(factory.unit().name), format(factory.team.data().countType(factory.unit())), format(Units.getCap(factory.team))));
|
||||
Core.bundle.format("bar.unitcap", Fonts.getUnicodeStr(factory.unit().name), floatFormat(factory.team.data().countType(factory.unit())), floatFormat(Units.getCap(factory.team))));
|
||||
colors.set(3, Pal.power);
|
||||
numbers.set(3, factory.unit() == null ? 0f : (float)factory.team.data().countType(factory.unit()) / Units.getCap(factory.team));
|
||||
}
|
||||
else if(target instanceof Reconstructor.ReconstructorBuild reconstruct){
|
||||
strings.set(3, reconstruct.unit() == null ? "[lightgray]" + Iconc.cancel :
|
||||
Core.bundle.format("bar.unitcap", Fonts.getUnicodeStr(reconstruct.unit().name), format(reconstruct.team.data().countType(reconstruct.unit())), format(Units.getCap(reconstruct.team))));
|
||||
Core.bundle.format("bar.unitcap", Fonts.getUnicodeStr(reconstruct.unit().name), floatFormat(reconstruct.team.data().countType(reconstruct.unit())), floatFormat(Units.getCap(reconstruct.team))));
|
||||
colors.set(3, Pal.power);
|
||||
numbers.set(3, reconstruct.unit() == null ? 0f : (float)reconstruct.team.data().countType(reconstruct.unit()) / Units.getCap(reconstruct.team));
|
||||
|
||||
@@ -227,26 +222,26 @@ public class BarInfo {
|
||||
|
||||
|
||||
if(target instanceof Unit unit && target instanceof Payloadc pay && unit.type != null){
|
||||
strings.set(4, Core.bundle.format("shar-stat.payloadCapacity", format(Mathf.round(Mathf.sqrt(pay.payloadUsed()))), format(Mathf.round(Mathf.sqrt(unit.type().payloadCapacity)))));
|
||||
strings.set(4, Core.bundle.format("shar-stat.payloadCapacity", floatFormat(Mathf.round(Mathf.sqrt(pay.payloadUsed()))), floatFormat(Mathf.round(Mathf.sqrt(unit.type().payloadCapacity)))));
|
||||
colors.set(4, Pal.items);
|
||||
numbers.set(4, pay.payloadUsed() / unit.type().payloadCapacity);
|
||||
}
|
||||
else if(target instanceof Building build && build.block.hasLiquids){
|
||||
strings.set(4, Core.bundle.format("shar-stat.liquidCapacity", format(build.liquids.currentAmount()), format(build.block.liquidCapacity)));
|
||||
strings.set(4, Core.bundle.format("shar-stat.liquidCapacity", floatFormat(build.liquids.currentAmount()), floatFormat(build.block.liquidCapacity)));
|
||||
colors.set(4, build.liquids.current().color);
|
||||
numbers.set(4, build.liquids.currentAmount()/build.block.liquidCapacity);
|
||||
}
|
||||
|
||||
|
||||
if(target instanceof Unit unit && state.rules.unitAmmo && unit.type != null){
|
||||
strings.set(5, Core.bundle.format("shar-stat.ammos", format(unit.ammo()), format(unit.type().ammoCapacity)));
|
||||
strings.set(5, Core.bundle.format("shar-stat.ammos", floatFormat(unit.ammo()), floatFormat(unit.type().ammoCapacity)));
|
||||
colors.set(5, unit.type().ammoType.color());
|
||||
numbers.set(5, unit.ammof());
|
||||
}
|
||||
else if(target instanceof Building build && build.block.hasPower && build.block.consumes.hasPower()){
|
||||
ConsumePower cons = build.block.consumes.getPower();
|
||||
if(cons.buffered) strings.set(5, Core.bundle.format("shar-stat.powerCapacity", format(build.power.status * cons.capacity * 60f), format(cons.capacity * 60f)));
|
||||
else strings.set(5, Core.bundle.format("shar-stat.powerUsage", format(build.power.status * cons.usage * 60f), format(cons.usage * 60f)));
|
||||
if(cons.buffered) strings.set(5, Core.bundle.format("shar-stat.powerCapacity", floatFormat(build.power.status * cons.capacity * 60f), floatFormat(cons.capacity * 60f)));
|
||||
else strings.set(5, Core.bundle.format("shar-stat.powerUsage", floatFormat(build.power.status * cons.usage * 60f), floatFormat(cons.usage * 60f)));
|
||||
colors.set(5,Pal.powerBar);
|
||||
numbers.set(5, Mathf.zero(cons.requestedPower(build)) && build.power.graph.getPowerProduced() + build.power.graph.getBatteryStored() > 0f ? 1f : build.power.status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user