Fixed square numbers in stats

This commit is contained in:
Anuken 2022-01-21 00:08:56 -05:00
parent b3d4dc06d4
commit a121c4d042
6 changed files with 19 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -190,7 +190,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
if(block == Blocks.air) block = Blocks.yellowStoneWall;
}
if(floor == Blocks.yellowStonePlates && noise(x + 78 + y, y, 3, 0.8f, 7f, 1f) > 0.41f){
if(floor == Blocks.yellowStonePlates && noise(x + 78 + y, y, 3, 0.8f, 6f, 1f) > 0.44f){
floor = Blocks.yellowStone;
}
});

View File

@ -320,7 +320,7 @@ public class UnitType extends UnlockableContent{
stats.add(Stat.health, health);
stats.add(Stat.armor, armor);
stats.add(Stat.speed, speed * 60f / tilesize, StatUnit.tilesSecond);
stats.add(Stat.size, hitSize / tilesize, StatUnit.blocksSquared);
stats.add(Stat.size, StatValues.squared(hitSize / tilesize, StatUnit.blocksSquared));
stats.add(Stat.itemCapacity, itemCapacity);
stats.add(Stat.range, (int)(maxRange / tilesize), StatUnit.blocks);
stats.add(Stat.commandLimit, commandLimit);
@ -349,7 +349,7 @@ public class UnitType extends UnlockableContent{
stats.addPercent(Stat.buildSpeed, buildSpeed);
}
if(inst instanceof Payloadc){
stats.add(Stat.payloadCapacity, (payloadCapacity / (tilesize * tilesize)), StatUnit.blocksSquared);
stats.add(Stat.payloadCapacity, StatValues.squared(Mathf.sqrt(payloadCapacity / (tilesize * tilesize)), StatUnit.blocksSquared));
}
var reqs = getFirstRequirements();

View File

@ -54,7 +54,7 @@ public class PayloadConveyor extends Block{
public void setStats(){
super.setStats();
stats.add(Stat.payloadCapacity, (payloadLimit), StatUnit.blocksSquared);
stats.add(Stat.payloadCapacity, StatValues.squared(payloadLimit, StatUnit.blocksSquared));
}
@Override

View File

@ -78,7 +78,7 @@ public class PayloadMassDriver extends PayloadBlock{
public void setStats(){
super.setStats();
stats.add(Stat.payloadCapacity, maxPayloadSize, StatUnit.blocksSquared);
stats.add(Stat.payloadCapacity, StatValues.squared(maxPayloadSize, StatUnit.blocksSquared));
stats.add(Stat.reload, 60f / (chargeTime + reloadTime), StatUnit.seconds);
}

View File

@ -34,11 +34,22 @@ public class StatValues{
return table -> table.add(!value ? "@no" : "@yes");
}
public static String fixValue(float value){
int precision = Math.abs((int)value - value) <= 0.001f ? 0 : Math.abs((int)(value * 10) - value * 10) <= 0.001f ? 1 : 2;
return Strings.fixed(value, precision);
}
public static StatValue squared(float value, StatUnit unit){
return table -> {
String fixed = fixValue(value);
table.add(fixed + "x" + fixed);
table.add((unit.space ? " " : "") + unit.localized());
};
}
public static StatValue number(float value, StatUnit unit, boolean merge){
return table -> {
int precision = Math.abs((int)value - value) <= 0.001f ? 0 : Math.abs((int)(value * 10) - value * 10) <= 0.001f ? 1 : 2;
String l1 = Strings.fixed(value, precision), l2 = (unit.space ? " " : "") + unit.localized();
String l1 = fixValue(value), l2 = (unit.space ? " " : "") + unit.localized();
if(merge){
table.add(l1 + l2);