Unified stat system

This commit is contained in:
Anuken
2020-10-19 11:12:40 -04:00
parent 59e1fd1eb6
commit 2ff749bd17
101 changed files with 1815 additions and 1815 deletions

View File

@@ -23,7 +23,7 @@ public class GameState{
/** The current game rules. */
public Rules rules = new Rules();
/** Statistics for this save/game. Displayed after game over. */
public Stats stats = new Stats();
public GameStats stats = new GameStats();
/** Global attributes of the environment, calculated by weather. */
public Attributes envAttrs = new Attributes();
/** Sector information. Only valid in the campaign. */

View File

@@ -10,11 +10,14 @@ import mindustry.game.EventType.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
/** Base interface for an unlockable content type. */
public abstract class UnlockableContent extends MappableContent{
/** Stat storage for this content. Initialized on demand. */
public Stats stats = new Stats();
/** Localized, formal name. Never null. Set to internal name if not found in bundle. */
public String localizedName;
/** Localized description. May be null. */
@@ -38,6 +41,20 @@ public abstract class UnlockableContent extends MappableContent{
return minfo.mod == null ? description : description + "\n" + Core.bundle.format("mod.display", minfo.mod.meta.displayName());
}
/** Checks stat initialization state. Call before displaying stats. */
public void checkStats(){
if(!stats.intialized){
setStats();
stats.intialized = true;
}
}
/** Intializes stats on demand. Should only be called once. Only called before something is displayed. */
@CallSuper
public void setStats(){
stats.intialized = true;
}
/** Generate any special icons for this content. Called asynchronously.*/
@CallSuper
public void createIcons(MultiPacker packer){
@@ -73,7 +90,9 @@ public abstract class UnlockableContent extends MappableContent{
}
/** This should show all necessary info about this content in the specified table. */
public abstract void displayInfo(Table table);
public void display(Table table){
}
/** Called when this content is unlocked. Use this to unlock other related content. */
public void onUnlock(){

View File

@@ -6,7 +6,7 @@ import mindustry.type.*;
//TODO more stats:
//- units constructed
public class Stats{
public class GameStats{
/** Total items delivered to global resoure counter. Campaign only. */
public ObjectIntMap<Item> itemsDelivered = new ObjectIntMap<>();
/** Enemy (red team) units destroyed. */

View File

@@ -352,6 +352,8 @@ public class DesktopInput extends InputHandler{
table.button(Icon.map, Styles.clearPartiali, () -> {
ui.planet.show();
}).visible(() -> state.isCampaign()).tooltip("@planetmap");
table.add();
}
void pollInput(){

View File

@@ -105,7 +105,7 @@ public abstract class SaveVersion extends SaveFileReader{
state.wave = map.getInt("wave");
state.wavetime = map.getFloat("wavetime", state.rules.waveSpacing);
state.stats = JsonIO.read(Stats.class, map.get("stats", "{}"));
state.stats = JsonIO.read(GameStats.class, map.get("stats", "{}"));
state.rules = JsonIO.read(Rules.class, map.get("rules", "{}"));
if(state.rules.spawns.isEmpty()) state.rules.spawns = defaultWaves.get();
lastReadBuild = map.getInt("build", -1);

View File

@@ -1,11 +1,10 @@
package mindustry.type;
import arc.graphics.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import mindustry.ctype.*;
import mindustry.ui.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
@@ -36,8 +35,10 @@ public class Item extends UnlockableContent{
}
@Override
public void displayInfo(Table table){
ContentDisplay.displayItem(table, this);
public void setStats(){
stats.addPercent(Stat.explosiveness, explosiveness);
stats.addPercent(Stat.flammability, flammability);
stats.addPercent(Stat.radioactivity, radioactivity);
}
@Override

View File

@@ -1,11 +1,10 @@
package mindustry.type;
import arc.graphics.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.ctype.*;
import mindustry.ui.*;
import mindustry.world.meta.*;
public class Liquid extends UnlockableContent{
/** Color used in pipes and on the ground. */
@@ -46,8 +45,12 @@ public class Liquid extends UnlockableContent{
}
@Override
public void displayInfo(Table table){
ContentDisplay.displayLiquid(table, this);
public void setStats(){
stats.addPercent(Stat.explosiveness, explosiveness);
stats.addPercent(Stat.flammability, flammability);
stats.addPercent(Stat.temperature, temperature);
stats.addPercent(Stat.heatCapacity, heatCapacity);
stats.addPercent(Stat.viscosity, viscosity);
}
@Override

View File

@@ -5,7 +5,6 @@ import arc.func.*;
import arc.graphics.*;
import arc.math.*;
import arc.math.geom.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import arc.util.noise.*;
@@ -259,11 +258,6 @@ public class Planet extends UnlockableContent{
return true;
}
@Override
public void displayInfo(Table table){
}
@Override
public ContentType getContentType(){
return ContentType.planet;

View File

@@ -2,7 +2,6 @@ package mindustry.type;
import arc.func.*;
import arc.graphics.g2d.*;
import arc.scene.ui.layout.*;
import mindustry.ctype.*;
import mindustry.game.*;
import mindustry.gen.*;
@@ -39,11 +38,6 @@ public class SectorPreset extends UnlockableContent{
return true;
}
//neither of these are implemented, as zones are not displayed in a normal fashion... yet
@Override
public void displayInfo(Table table){
}
@Override
public ContentType getContentType(){
return ContentType.sector;

View File

@@ -29,6 +29,7 @@ import mindustry.world.blocks.payloads.*;
import mindustry.world.blocks.units.*;
import mindustry.world.consumers.*;
import mindustry.world.meta.*;
import mindustry.world.meta.values.*;
import static mindustry.Vars.*;
@@ -42,7 +43,7 @@ public class UnitType extends UnlockableContent{
public Prov<? extends UnitController> defaultController = () -> !flying ? new GroundAI() : new FlyingAI();
public float speed = 1.1f, boostMultiplier = 1f, rotateSpeed = 5f, baseRotateSpeed = 5f;
public float drag = 0.3f, accel = 0.5f, landShake = 0f, rippleScale = 1f, fallSpeed = 0.018f;
public float health = 200f, range = -1, armor = 0f;
public float health = 200f, range = -1, armor = 0f, maxRange = -1f;
public float crashDamageMultiplier = 1f;
public boolean targetAir = true, targetGround = true;
public boolean faceTarget = true, rotateShooting = true, isCounted = true, lowAltitude = false;
@@ -190,10 +191,21 @@ public class UnitType extends UnlockableContent{
}
}
@Override
public void displayInfo(Table table){
ContentDisplay.displayUnit(table, this);
public void setStats(){
Unit inst = constructor.get();
stats.add(Stat.health, health);
stats.add(Stat.speed, speed);
stats.add(Stat.itemCapacity, health);
stats.add(Stat.range, (int)(maxRange / tilesize), StatUnit.blocks);
//TODO abilities, maybe try something like DPS
if(inst instanceof Minerc && mineTier >= 1){
stats.addPercent(Stat.mineSpeed, mineSpeed);
stats.add(Stat.mineTier, new BlockFilterValue(b -> b instanceof Floor f && f.itemDrop != null && f.itemDrop.hardness <= mineTier && !f.playerUnmineable));
}
if(inst instanceof Builderc) stats.addPercent(Stat.buildSpeed, buildSpeed);
}
@CallSuper
@@ -219,8 +231,10 @@ public class UnitType extends UnlockableContent{
//set up default range
if(range < 0){
range = Float.MAX_VALUE;
maxRange = 0f;
for(Weapon weapon : weapons){
range = Math.min(range, weapon.bullet.range() + hitSize /2f);
maxRange = Math.max(maxRange, weapon.bullet.range() + hitSize /2f);
}
}
@@ -324,7 +338,7 @@ public class UnitType extends UnlockableContent{
if(stacks != null){
ItemStack[] out = new ItemStack[stacks.length];
for(int i = 0; i < out.length; i++){
out[i] = new ItemStack(stacks[i].item, UI.roundAmount((int)(Math.pow(stacks[i].amount, 1.1) * 50)));
out[i] = new ItemStack(stacks[i].item, UI.roundAmount((int)(Math.pow(stacks[i].amount, 1) * 50)));
}
return out;

View File

@@ -4,7 +4,6 @@ import arc.func.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
@@ -91,11 +90,6 @@ public abstract class Weather extends UnlockableContent{
}
@Override
public void displayInfo(Table table){
//do not
}
@Override
public boolean isHidden(){
return true;

View File

@@ -1,165 +0,0 @@
package mindustry.ui;
import arc.*;
import arc.graphics.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.meta.*;
public class ContentDisplay{
public static void displayBlock(Table table, Block block){
table.table(title -> {
int size = 8 * 6;
title.image(block.icon(Cicon.xlarge)).size(size);
title.add("[accent]" + block.localizedName).padLeft(5);
});
table.row();
table.image().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.row();
if(block.description != null){
table.add(block.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.image().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.row();
}
BlockStats stats = block.stats;
for(StatCategory cat : stats.toMap().keys()){
OrderedMap<BlockStat, Seq<StatValue>> map = stats.toMap().get(cat);
if(map.size == 0) continue;
table.add("@category." + cat.name()).color(Pal.accent).fillX();
table.row();
for(BlockStat stat : map.keys()){
table.table(inset -> {
inset.left();
inset.add("[lightgray]" + stat.localized() + ":[] ").left();
Seq<StatValue> arr = map.get(stat);
for(StatValue value : arr){
value.display(inset);
inset.add().size(10f);
}
}).fillX().padLeft(10);
table.row();
}
}
}
public static void displayItem(Table table, Item item){
table.table(title -> {
title.image(item.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + item.localizedName).padLeft(5);
});
table.row();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
if(item.description != null){
table.add(item.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
table.left().defaults().fillX();
table.add(Core.bundle.format("item.explosiveness", (int)(item.explosiveness * 100)));
table.row();
table.add(Core.bundle.format("item.flammability", (int)(item.flammability * 100)));
table.row();
table.add(Core.bundle.format("item.radioactivity", (int)(item.radioactivity * 100)));
table.row();
}
public static void displayLiquid(Table table, Liquid liquid){
table.table(title -> {
title.image(liquid.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + liquid.localizedName).padLeft(5);
});
table.row();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
if(liquid.description != null){
table.add(liquid.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
table.left().defaults().fillX();
table.add(Core.bundle.format("item.explosiveness", (int)(liquid.explosiveness * 100)));
table.row();
table.add(Core.bundle.format("item.flammability", (int)(liquid.flammability * 100)));
table.row();
table.add(Core.bundle.format("liquid.heatcapacity", (int)(liquid.heatCapacity * 100)));
table.row();
table.add(Core.bundle.format("liquid.temperature", (int)(liquid.temperature * 100)));
table.row();
table.add(Core.bundle.format("liquid.viscosity", (int)(liquid.viscosity * 100)));
table.row();
}
public static void displayUnit(Table table, UnitType unit){
table.table(title -> {
title.image(unit.icon(Cicon.xlarge)).size(8 * 6).scaling(Scaling.fit);
title.add("[accent]" + unit.localizedName).padLeft(5);
});
table.row();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
if(unit.description != null){
table.add(unit.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
table.left().defaults().fillX();
Unit inst = unit.constructor.get();
//TODO more stats
table.add(Core.bundle.format("unit.health", unit.health)).row();
table.add(Core.bundle.format("unit.speed", Strings.fixed(unit.speed, 1))).row();
table.add(Core.bundle.format("unit.itemcapacity", unit.itemCapacity)).row();
if(inst instanceof Minerc) table.add(Core.bundle.format("unit.minespeed", (int)(unit.mineSpeed * 100f))).row();
if(inst instanceof Builderc) table.add(Core.bundle.format("unit.buildspeed", (int)(unit.buildSpeed * 100f))).row();
table.row();
}
}

View File

@@ -1,8 +1,14 @@
package mindustry.ui.dialogs;
import arc.graphics.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.ctype.*;
import mindustry.graphics.*;
import mindustry.ui.*;
import mindustry.world.meta.*;
public class ContentInfoDialog extends BaseDialog{
@@ -18,11 +24,62 @@ public class ContentInfoDialog extends BaseDialog{
Table table = new Table();
table.margin(10);
content.displayInfo(table);
//initialize stats if they haven't been yet
content.checkStats();
table.table(title1 -> {
int size = 8 * 6;
title1.image(content.icon(Cicon.xlarge)).size(size).scaling(Scaling.fit);
title1.add("[accent]" + content.localizedName).padLeft(5);
});
table.row();
table.image().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.row();
if(content.description != null){
table.add(content.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.image().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.row();
}
Stats stats = content.stats;
for(StatCat cat : stats.toMap().keys()){
OrderedMap<Stat, Seq<StatValue>> map = stats.toMap().get(cat);
if(map.size == 0) continue;
//TODO check
if(stats.useCategories){
table.add("@category." + cat.name()).color(Pal.accent).fillX();
table.row();
}
for(Stat stat : map.keys()){
table.table(inset -> {
inset.left();
inset.add("[lightgray]" + stat.localized() + ":[] ").left();
Seq<StatValue> arr = map.get(stat);
for(StatValue value : arr){
value.display(inset);
inset.add().size(10f);
}
}).fillX().padLeft(10);
table.row();
}
}
ScrollPane pane = new ScrollPane(table);
cont.add(pane);
show();
}
}

View File

@@ -2,7 +2,7 @@ package mindustry.ui.dialogs;
import arc.*;
import mindustry.game.EventType.*;
import mindustry.game.Stats.*;
import mindustry.game.GameStats.*;
import mindustry.game.*;
import mindustry.type.*;
import mindustry.ui.*;

View File

@@ -51,7 +51,6 @@ public class Block extends UnlockableContent{
public float liquidCapacity = 10f;
public float liquidPressure = 1f;
public final BlockStats stats = new BlockStats();
public final BlockBars bars = new BlockBars();
public final Consumers consumes = new Consumers();
@@ -321,23 +320,26 @@ public class Block extends UnlockableContent{
return update || destructible;
}
@Override
public void setStats(){
stats.add(BlockStat.size, "@x@", size, size);
stats.add(BlockStat.health, health, StatUnit.none);
super.setStats();
stats.add(Stat.size, "@x@", size, size);
stats.add(Stat.health, health, StatUnit.none);
if(canBeBuilt()){
stats.add(BlockStat.buildTime, buildCost / 60, StatUnit.seconds);
stats.add(BlockStat.buildCost, new ItemListValue(false, requirements));
stats.add(Stat.buildTime, buildCost / 60, StatUnit.seconds);
stats.add(Stat.buildCost, new ItemListValue(false, requirements));
}
if(instantTransfer){
stats.add(BlockStat.maxConsecutive, 2, StatUnit.none);
stats.add(Stat.maxConsecutive, 2, StatUnit.none);
}
consumes.display(stats);
// Note: Power stats are added by the consumers.
if(hasLiquids) stats.add(BlockStat.liquidCapacity, liquidCapacity, StatUnit.liquidUnits);
if(hasItems && itemCapacity > 0) stats.add(BlockStat.itemCapacity, itemCapacity, StatUnit.items);
//Note: Power stats are added by the consumers.
if(hasLiquids) stats.add(Stat.liquidCapacity, liquidCapacity, StatUnit.liquidUnits);
if(hasItems && itemCapacity > 0) stats.add(Stat.itemCapacity, itemCapacity, StatUnit.items);
}
public void setBars(){
@@ -634,11 +636,6 @@ public class Block extends UnlockableContent{
}
}
@Override
public void displayInfo(Table table){
ContentDisplay.displayBlock(table, this);
}
@Override
public ContentType getContentType(){
return ContentType.block;
@@ -669,9 +666,10 @@ public class Block extends UnlockableContent{
if(consumes.has(ConsumeType.item)) hasItems = true;
if(consumes.has(ConsumeType.liquid)) hasLiquids = true;
setStats();
setBars();
stats.useCategories = true;
consumes.init();
if(!outputsPower && consumes.hasPower() && consumes.getPower().buffered){

View File

@@ -42,7 +42,7 @@ public class LaunchPad extends Block{
public void setStats(){
super.setStats();
stats.add(BlockStat.launchTime, launchTime / 60f, StatUnit.seconds);
stats.add(Stat.launchTime, launchTime / 60f, StatUnit.seconds);
}
@Override

View File

@@ -61,11 +61,11 @@ public class ForceProjector extends Block{
@Override
public void setStats(){
super.setStats();
stats.add(BlockStat.shieldHealth, breakage, StatUnit.none);
stats.add(BlockStat.cooldownTime, (int) (breakage / cooldownBrokenBase / 60f), StatUnit.seconds);
stats.add(BlockStat.powerUse, basePowerDraw * 60f, StatUnit.powerSecond);
stats.add(BlockStat.boostEffect, phaseRadiusBoost / tilesize, StatUnit.blocks);
stats.add(BlockStat.boostEffect, phaseShieldBoost, StatUnit.shieldHealth);
stats.add(Stat.shieldHealth, breakage, StatUnit.none);
stats.add(Stat.cooldownTime, (int) (breakage / cooldownBrokenBase / 60f), StatUnit.seconds);
stats.add(Stat.powerUse, basePowerDraw * 60f, StatUnit.powerSecond);
stats.add(Stat.boostEffect, phaseRadiusBoost / tilesize, StatUnit.blocks);
stats.add(Stat.boostEffect, phaseShieldBoost, StatUnit.shieldHealth);
}
@Override

View File

@@ -44,11 +44,11 @@ public class MendProjector extends Block{
public void setStats(){
super.setStats();
stats.add(BlockStat.repairTime, (int)(100f / healPercent * reload / 60f), StatUnit.seconds);
stats.add(BlockStat.range, range / tilesize, StatUnit.blocks);
stats.add(Stat.repairTime, (int)(100f / healPercent * reload / 60f), StatUnit.seconds);
stats.add(Stat.range, range / tilesize, StatUnit.blocks);
stats.add(BlockStat.boostEffect, phaseRangeBoost / tilesize, StatUnit.blocks);
stats.add(BlockStat.boostEffect, (phaseBoost + healPercent) / healPercent, StatUnit.timesSpeed);
stats.add(Stat.boostEffect, phaseRangeBoost / tilesize, StatUnit.blocks);
stats.add(Stat.boostEffect, (phaseBoost + healPercent) / healPercent, StatUnit.timesSpeed);
}
@Override

View File

@@ -51,13 +51,13 @@ public class OverdriveProjector extends Block{
public void setStats(){
super.setStats();
stats.add(BlockStat.speedIncrease, (int)(100f * speedBoost), StatUnit.percent);
stats.add(BlockStat.range, range / tilesize, StatUnit.blocks);
stats.add(BlockStat.productionTime, useTime / 60f, StatUnit.seconds);
stats.add(Stat.speedIncrease, (int)(100f * speedBoost), StatUnit.percent);
stats.add(Stat.range, range / tilesize, StatUnit.blocks);
stats.add(Stat.productionTime, useTime / 60f, StatUnit.seconds);
if(hasBoost){
stats.add(BlockStat.boostEffect, phaseRangeBoost / tilesize, StatUnit.blocks);
stats.add(BlockStat.boostEffect, (int)((speedBoost + speedBoostPhase) * 100f), StatUnit.percent);
stats.add(Stat.boostEffect, phaseRangeBoost / tilesize, StatUnit.blocks);
stats.add(Stat.boostEffect, (int)((speedBoost + speedBoostPhase) * 100f), StatUnit.percent);
}
}

View File

@@ -48,7 +48,7 @@ public abstract class BaseTurret extends Block{
public void setStats(){
super.setStats();
stats.add(BlockStat.shootRange, range / tilesize, StatUnit.blocks);
stats.add(Stat.shootRange, range / tilesize, StatUnit.blocks);
}
public class BaseTurretBuild extends Building implements Ranged{

View File

@@ -35,8 +35,8 @@ public class ItemTurret extends Turret{
public void setStats(){
super.setStats();
stats.remove(BlockStat.itemCapacity);
stats.add(BlockStat.ammo, new AmmoListValue<>(ammoTypes));
stats.remove(Stat.itemCapacity);
stats.add(Stat.ammo, new AmmoListValue<>(ammoTypes));
consumes.add(new ConsumeItemFilter(i -> ammoTypes.containsKey(i)){
@Override
public void build(Building tile, Table table){
@@ -54,7 +54,7 @@ public class ItemTurret extends Turret{
}
@Override
public void display(BlockStats stats){
public void display(Stats stats){
//don't display
}
});

View File

@@ -33,11 +33,11 @@ public class LaserTurret extends PowerTurret{
public void setStats(){
super.setStats();
stats.remove(BlockStat.booster);
stats.add(BlockStat.input, new BoosterListValue(reloadTime, consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount, coolantMultiplier, false, l -> consumes.liquidfilters.get(l.id)));
stats.remove(BlockStat.damage);
stats.remove(Stat.booster);
stats.add(Stat.input, new BoosterListValue(reloadTime, consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount, coolantMultiplier, false, l -> consumes.liquidfilters.get(l.id)));
stats.remove(Stat.damage);
//damages every 5 ticks, at least in meltdown's case
stats.add(BlockStat.damage, shootType.damage * 60f / 5f, StatUnit.perSecond);
stats.add(Stat.damage, shootType.damage * 60f / 5f, StatUnit.perSecond);
}
public class LaserTurretBuild extends PowerTurretBuild{

View File

@@ -36,7 +36,7 @@ public class LiquidTurret extends Turret{
public void setStats(){
super.setStats();
stats.add(BlockStat.ammo, new AmmoListValue<>(ammoTypes));
stats.add(Stat.ammo, new AmmoListValue<>(ammoTypes));
consumes.add(new ConsumeLiquidFilter(i -> ammoTypes.containsKey(i), 1f){
@Override
public boolean valid(Building entity){
@@ -49,7 +49,7 @@ public class LiquidTurret extends Turret{
}
@Override
public void display(BlockStats stats){
public void display(Stats stats){
}
});

View File

@@ -48,7 +48,7 @@ public class PointDefenseTurret extends ReloadTurret{
public void setStats(){
super.setStats();
stats.add(BlockStat.reload, 60f / reloadTime, StatUnit.none);
stats.add(Stat.reload, 60f / reloadTime, StatUnit.none);
}
public class PointDefenseBuild extends ReloadTurretBuild{

View File

@@ -16,7 +16,7 @@ public class PowerTurret extends Turret{
@Override
public void setStats(){
super.setStats();
stats.add(BlockStat.damage, shootType.damage, StatUnit.none);
stats.add(Stat.damage, shootType.damage, StatUnit.none);
}
@Override

View File

@@ -21,7 +21,7 @@ public abstract class ReloadTurret extends BaseTurret{
super.setStats();
if(acceptCoolant){
stats.add(BlockStat.booster, new BoosterListValue(reloadTime, consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount, coolantMultiplier, true, l -> consumes.liquidfilters.get(l.id)));
stats.add(Stat.booster, new BoosterListValue(reloadTime, consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount, coolantMultiplier, true, l -> consumes.liquidfilters.get(l.id)));
}
}

View File

@@ -50,9 +50,9 @@ public class TractorBeamTurret extends BaseTurret{
public void setStats(){
super.setStats();
stats.add(BlockStat.targetsAir, targetAir);
stats.add(BlockStat.targetsGround, targetGround);
stats.add(BlockStat.damage, damage * 60f, StatUnit.perSecond);
stats.add(Stat.targetsAir, targetAir);
stats.add(Stat.targetsGround, targetGround);
stats.add(Stat.damage, damage * 60f, StatUnit.perSecond);
}
public class TractorBeamBuild extends BaseTurretBuild{

View File

@@ -101,13 +101,13 @@ public abstract class Turret extends ReloadTurret{
public void setStats(){
super.setStats();
stats.add(BlockStat.inaccuracy, (int)inaccuracy, StatUnit.degrees);
stats.add(BlockStat.reload, 60f / reloadTime * shots, StatUnit.none);
stats.add(BlockStat.targetsAir, targetAir);
stats.add(BlockStat.targetsGround, targetGround);
stats.add(Stat.inaccuracy, (int)inaccuracy, StatUnit.degrees);
stats.add(Stat.reload, 60f / reloadTime * shots, StatUnit.none);
stats.add(Stat.targetsAir, targetAir);
stats.add(Stat.targetsGround, targetGround);
if(acceptCoolant){
stats.add(BlockStat.booster, new BoosterListValue(reloadTime, consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount, coolantMultiplier, true, l -> consumes.liquidfilters.get(l.id)));
stats.add(Stat.booster, new BoosterListValue(reloadTime, consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount, coolantMultiplier, true, l -> consumes.liquidfilters.get(l.id)));
}
}

View File

@@ -52,7 +52,7 @@ public class Conveyor extends Block implements Autotiler{
super.setStats();
//have to add a custom calculated speed, since the actual movement speed is apparently not linear
stats.add(BlockStat.itemsMoved, displayedSpeed, StatUnit.itemsSecond);
stats.add(Stat.itemsMoved, displayedSpeed, StatUnit.itemsSecond);
}
@Override

View File

@@ -53,7 +53,7 @@ public class StackConveyor extends Block implements Autotiler{
public void setStats(){
super.setStats();
stats.add(BlockStat.itemsMoved, Mathf.round(itemCapacity * speed * 60), StatUnit.itemsSecond);
stats.add(Stat.itemsMoved, Mathf.round(itemCapacity * speed * 60), StatUnit.itemsSecond);
}
@Override

View File

@@ -14,7 +14,7 @@ public class LiquidJunction extends LiquidBlock{
@Override
public void setStats(){
super.setStats();
stats.remove(BlockStat.liquidCapacity);
stats.remove(Stat.liquidCapacity);
}
@Override

View File

@@ -117,8 +117,8 @@ public class LogicBlock extends Block{
public void setStats(){
super.setStats();
stats.add(BlockStat.linkRange, range / 8, StatUnit.blocks);
stats.add(BlockStat.instructions, instructionsPerTick * 60, StatUnit.perSecond);
stats.add(Stat.linkRange, range / 8, StatUnit.blocks);
stats.add(Stat.instructions, instructionsPerTick * 60, StatUnit.perSecond);
}
@Override

View File

@@ -38,7 +38,7 @@ public class LogicDisplay extends Block{
public void setStats(){
super.setStats();
stats.add(BlockStat.displaySize, "@x@", displaySize, displaySize);
stats.add(Stat.displaySize, "@x@", displaySize, displaySize);
}
public class LogicDisplayBuild extends Building{

View File

@@ -18,7 +18,7 @@ public class MemoryBlock extends Block{
public void setStats(){
super.setStats();
stats.add(BlockStat.memoryCapacity, memoryCapacity, StatUnit.none);
stats.add(Stat.memoryCapacity, memoryCapacity, StatUnit.none);
}
public class MemoryBuild extends Building{

View File

@@ -55,7 +55,7 @@ public class ImpactReactor extends PowerGenerator{
super.setStats();
if(hasItems){
stats.add(BlockStat.productionTime, itemDuration / 60f, StatUnit.seconds);
stats.add(Stat.productionTime, itemDuration / 60f, StatUnit.seconds);
}
}

View File

@@ -72,7 +72,7 @@ public class ItemLiquidGenerator extends PowerGenerator{
super.setStats();
if(hasItems){
stats.add(BlockStat.productionTime, itemDuration / 60f, StatUnit.seconds);
stats.add(Stat.productionTime, itemDuration / 60f, StatUnit.seconds);
}
}

View File

@@ -56,7 +56,7 @@ public class NuclearReactor extends PowerGenerator{
super.setStats();
if(hasItems){
stats.add(BlockStat.productionTime, itemDuration / 60f, StatUnit.seconds);
stats.add(Stat.productionTime, itemDuration / 60f, StatUnit.seconds);
}
}

View File

@@ -12,7 +12,7 @@ import mindustry.world.meta.*;
public class PowerGenerator extends PowerDistributor{
/** The amount of power produced per tick in case of an efficiency of 1.0, which represents 100%. */
public float powerProduction;
public BlockStat generationType = BlockStat.basePowerGeneration;
public Stat generationType = Stat.basePowerGeneration;
public PowerGenerator(String name){
super(name);

View File

@@ -124,8 +124,8 @@ public class PowerNode extends PowerBlock{
public void setStats(){
super.setStats();
stats.add(BlockStat.powerRange, laserRange, StatUnit.blocks);
stats.add(BlockStat.powerConnections, maxNodes, StatUnit.none);
stats.add(Stat.powerRange, laserRange, StatUnit.blocks);
stats.add(Stat.powerConnections, maxNodes, StatUnit.none);
}
@Override

View File

@@ -22,7 +22,7 @@ public class ThermalGenerator extends PowerGenerator{
public void setStats(){
super.setStats();
stats.add(BlockStat.tiles, attribute, floating);
stats.add(Stat.tiles, attribute, floating);
}
@Override

View File

@@ -37,7 +37,7 @@ public class AttributeSmelter extends GenericSmelter{
public void setStats(){
super.setStats();
stats.add(BlockStat.affinities, attribute, boostScale);
stats.add(Stat.affinities, attribute, boostScale);
}
public class AttributeSmelterBuild extends SmelterBuild{

View File

@@ -42,7 +42,7 @@ public class Cultivator extends GenericCrafter{
public void setStats(){
super.setStats();
stats.add(BlockStat.affinities, attribute);
stats.add(Stat.affinities, attribute);
}
@Override

View File

@@ -16,7 +16,9 @@ import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.meta.*;
import mindustry.world.meta.values.*;
import static mindustry.Vars.*;
@@ -135,29 +137,11 @@ public class Drill extends Block{
public void setStats(){
super.setStats();
stats.add(BlockStat.drillTier, table -> {
Seq<Block> list = content.blocks().select(b -> b.isFloor() && b.asFloor().itemDrop != null && b.asFloor().itemDrop.hardness <= tier);
stats.add(Stat.drillTier, new BlockFilterValue(b -> b instanceof Floor f && f.itemDrop != null && f.itemDrop.hardness <= tier));
table.table(l -> {
l.left();
for(int i = 0; i < list.size; i++){
Block item = list.get(i);
l.image(item.icon(Cicon.small)).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
l.add(item.localizedName).left().padLeft(1).padRight(4);
if(i % 5 == 4){
l.row();
}
}
});
});
stats.add(BlockStat.drillSpeed, 60f / drillTime * size * size, StatUnit.itemsSecond);
stats.add(Stat.drillSpeed, 60f / drillTime * size * size, StatUnit.itemsSecond);
if(liquidBoostIntensity != 1){
stats.add(BlockStat.boostEffect, liquidBoostIntensity * liquidBoostIntensity, StatUnit.timesSpeed);
stats.add(Stat.boostEffect, liquidBoostIntensity * liquidBoostIntensity, StatUnit.timesSpeed);
}
}

View File

@@ -21,7 +21,7 @@ public class Fracker extends SolidPump{
public void setStats(){
super.setStats();
stats.add(BlockStat.productionTime, itemUseTime / 60f, StatUnit.seconds);
stats.add(Stat.productionTime, itemUseTime / 60f, StatUnit.seconds);
}
@Override

View File

@@ -43,14 +43,14 @@ public class GenericCrafter extends Block{
}
super.setStats();
stats.add(BlockStat.productionTime, craftTime / 60f, StatUnit.seconds);
stats.add(Stat.productionTime, craftTime / 60f, StatUnit.seconds);
if(outputItem != null){
stats.add(BlockStat.output, outputItem);
stats.add(Stat.output, outputItem);
}
if(outputLiquid != null){
stats.add(BlockStat.output, outputLiquid.liquid, outputLiquid.amount, false);
stats.add(Stat.output, outputLiquid.liquid, outputLiquid.amount, false);
}
}

View File

@@ -26,8 +26,8 @@ public class LiquidConverter extends GenericCrafter{
@Override
public void setStats(){
super.setStats();
stats.remove(BlockStat.output);
stats.add(BlockStat.output, outputLiquid.liquid, outputLiquid.amount * craftTime, false);
stats.remove(Stat.output);
stats.add(Stat.output, outputLiquid.liquid, outputLiquid.amount * craftTime, false);
}
public class LiquidConverterBuild extends GenericCrafterBuild{

View File

@@ -26,7 +26,7 @@ public class Pump extends LiquidBlock{
@Override
public void setStats(){
super.setStats();
stats.add(BlockStat.output, 60f * pumpAmount * size * size, StatUnit.liquidSecond);
stats.add(Stat.output, 60f * pumpAmount * size * size, StatUnit.liquidSecond);
}
@Override

View File

@@ -41,14 +41,14 @@ public class Separator extends Block{
super.setStats();
stats.add(BlockStat.output, new ItemFilterValue(item -> {
stats.add(Stat.output, new ItemFilterValue(item -> {
for(ItemStack i : results){
if(item == i.item) return true;
}
return false;
}));
stats.add(BlockStat.productionTime, craftTime / 60f, StatUnit.seconds);
stats.add(Stat.productionTime, craftTime / 60f, StatUnit.seconds);
}
public class SeparatorBuild extends Building{

View File

@@ -53,10 +53,10 @@ public class SolidPump extends Pump{
public void setStats(){
super.setStats();
stats.remove(BlockStat.output);
stats.add(BlockStat.output, result, 60f * pumpAmount, true);
stats.remove(Stat.output);
stats.add(Stat.output, result, 60f * pumpAmount, true);
if(attribute != null){
stats.add(baseEfficiency > 0.0001f ? BlockStat.affinities : BlockStat.tiles, attribute);
stats.add(baseEfficiency > 0.0001f ? Stat.affinities : Stat.tiles, attribute);
}
}

View File

@@ -11,8 +11,8 @@ public class PowerVoid extends PowerBlock{
}
@Override
public void init(){
super.init();
stats.remove(BlockStat.powerUse);
public void setStats(){
super.setStats();
stats.remove(Stat.powerUse);
}
}

View File

@@ -77,12 +77,16 @@ public class CoreBlock extends StorageBlock{
public void setStats(){
super.setStats();
stats.add(BlockStat.buildTime, 0, StatUnit.seconds);
stats.add(Stat.buildTime, 0, StatUnit.seconds);
}
bars.add("capacity", (CoreBuild e) ->
new Bar(
() -> Core.bundle.format("bar.capacity", UI.formatAmount(e.storageCapacity)),
() -> Pal.items,
@Override
public void setBars(){
super.setBars();
bars.add("capacity", (CoreBuild e) -> new Bar(
() -> Core.bundle.format("bar.capacity", UI.formatAmount(e.storageCapacity)),
() -> Pal.items,
() -> e.items.total() / ((float)e.storageCapacity * content.items().count(i -> i.unlockedNow()))
));
}

View File

@@ -63,8 +63,8 @@ public class Reconstructor extends UnitBlock{
public void setStats(){
super.setStats();
stats.add(BlockStat.productionTime, constructTime / 60f, StatUnit.seconds);
stats.add(BlockStat.output, table -> {
stats.add(Stat.productionTime, constructTime / 60f, StatUnit.seconds);
stats.add(Stat.output, table -> {
table.row();
for(var upgrade : upgrades){
float size = 8*3;

View File

@@ -42,7 +42,7 @@ public class RepairPoint extends Block{
@Override
public void setStats(){
super.setStats();
stats.add(BlockStat.range, repairRadius / tilesize, StatUnit.blocks);
stats.add(Stat.range, repairRadius / tilesize, StatUnit.blocks);
}
@Override

View File

@@ -87,7 +87,7 @@ public class UnitFactory extends UnitBlock{
public void setStats(){
super.setStats();
stats.remove(BlockStat.itemCapacity);
stats.remove(Stat.itemCapacity);
}
@Override

View File

@@ -69,5 +69,5 @@ public abstract class Consume{
public abstract boolean valid(Building entity);
public abstract void display(BlockStats stats);
public abstract void display(Stats stats);
}

View File

@@ -73,7 +73,7 @@ public class ConsumeItemDynamic extends Consume{
}
@Override
public void display(BlockStats stats){
public void display(Stats stats){
//should be handled by the block
}
}

View File

@@ -70,7 +70,7 @@ public class ConsumeItemFilter extends Consume{
}
@Override
public void display(BlockStats stats){
stats.add(booster ? BlockStat.booster : BlockStat.input, new ItemFilterValue(filter));
public void display(Stats stats){
stats.add(booster ? Stat.booster : Stat.input, new ItemFilterValue(filter));
}
}

View File

@@ -63,7 +63,7 @@ public class ConsumeItems extends Consume{
}
@Override
public void display(BlockStats stats){
stats.add(booster ? BlockStat.booster : BlockStat.input, new ItemListValue(items));
public void display(Stats stats){
stats.add(booster ? Stat.booster : Stat.input, new ItemListValue(items));
}
}

View File

@@ -45,7 +45,7 @@ public class ConsumeLiquid extends ConsumeLiquidBase{
}
@Override
public void display(BlockStats stats){
stats.add(booster ? BlockStat.booster : BlockStat.input, liquid, amount * timePeriod, timePeriod == 60);
public void display(Stats stats){
stats.add(booster ? Stat.booster : Stat.input, liquid, amount * timePeriod, timePeriod == 60);
}
}

View File

@@ -49,7 +49,7 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{
}
@Override
public void display(BlockStats stats){
stats.add(booster ? BlockStat.booster : BlockStat.input, new LiquidFilterValue(filter, amount * timePeriod, timePeriod == 60f));
public void display(Stats stats){
stats.add(booster ? Stat.booster : Stat.input, new LiquidFilterValue(filter, amount * timePeriod, timePeriod == 60f));
}
}

View File

@@ -54,11 +54,11 @@ public class ConsumePower extends Consume{
}
@Override
public void display(BlockStats stats){
public void display(Stats stats){
if(buffered){
stats.add(BlockStat.powerCapacity, capacity, StatUnit.none);
stats.add(Stat.powerCapacity, capacity, StatUnit.none);
}else{
stats.add(BlockStat.powerUse, usage * 60f, StatUnit.powerSecond);
stats.add(Stat.powerUse, usage * 60f, StatUnit.powerSecond);
}
}

View File

@@ -109,7 +109,7 @@ public class Consumers{
return optionalResults;
}
public void display(BlockStats stats){
public void display(Stats stats){
for(Consume c : map){
if(c != null){
c.display(stats);

View File

@@ -1,68 +0,0 @@
package mindustry.world.meta;
import arc.*;
import java.util.*;
/** Describes one type of stat for a block. */
public enum BlockStat{
health(StatCategory.general),
size(StatCategory.general),
displaySize(StatCategory.general),
buildTime(StatCategory.general),
buildCost(StatCategory.general),
memoryCapacity(StatCategory.general),
itemCapacity(StatCategory.items),
itemsMoved(StatCategory.items),
launchTime(StatCategory.items),
maxConsecutive(StatCategory.items),
liquidCapacity(StatCategory.liquids),
powerCapacity(StatCategory.power),
powerUse(StatCategory.power),
powerDamage(StatCategory.power),
powerRange(StatCategory.power),
powerConnections(StatCategory.power),
basePowerGeneration(StatCategory.power),
tiles(StatCategory.crafting),
input(StatCategory.crafting),
output(StatCategory.crafting),
productionTime(StatCategory.crafting),
drillTier(StatCategory.crafting),
drillSpeed(StatCategory.crafting),
maxUnits(StatCategory.crafting),
linkRange(StatCategory.crafting),
instructions(StatCategory.crafting),
speedIncrease(StatCategory.shooting),
repairTime(StatCategory.shooting),
range(StatCategory.shooting),
shootRange(StatCategory.shooting),
inaccuracy(StatCategory.shooting),
shots(StatCategory.shooting),
reload(StatCategory.shooting),
powerShot(StatCategory.shooting),
targetsAir(StatCategory.shooting),
targetsGround(StatCategory.shooting),
damage(StatCategory.shooting),
ammo(StatCategory.shooting),
shieldHealth(StatCategory.shooting),
cooldownTime(StatCategory.shooting),
booster(StatCategory.optional),
boostEffect(StatCategory.optional),
affinities(StatCategory.optional);
public final StatCategory category;
BlockStat(StatCategory category){
this.category = category;
}
public String localized(){
return Core.bundle.get("blocks." + name().toLowerCase(Locale.ROOT));
}
}

View File

@@ -0,0 +1,82 @@
package mindustry.world.meta;
import arc.*;
import java.util.*;
/** Describes one type of stat for content. */
public enum Stat{
health,
size,
displaySize,
buildTime,
buildCost,
memoryCapacity,
explosiveness,
flammability,
radioactivity,
heatCapacity,
viscosity,
temperature,
speed,
buildSpeed,
mineSpeed,
mineTier,
itemCapacity(StatCat.items),
itemsMoved(StatCat.items),
launchTime(StatCat.items),
maxConsecutive(StatCat.items),
liquidCapacity(StatCat.liquids),
powerCapacity(StatCat.power),
powerUse(StatCat.power),
powerDamage(StatCat.power),
powerRange(StatCat.power),
powerConnections(StatCat.power),
basePowerGeneration(StatCat.power),
tiles(StatCat.crafting),
input(StatCat.crafting),
output(StatCat.crafting),
productionTime(StatCat.crafting),
drillTier(StatCat.crafting),
drillSpeed(StatCat.crafting),
maxUnits(StatCat.crafting),
linkRange(StatCat.crafting),
instructions(StatCat.crafting),
speedIncrease(StatCat.shooting),
repairTime(StatCat.shooting),
range(StatCat.shooting),
shootRange(StatCat.shooting),
inaccuracy(StatCat.shooting),
shots(StatCat.shooting),
reload(StatCat.shooting),
powerShot(StatCat.shooting),
targetsAir(StatCat.shooting),
targetsGround(StatCat.shooting),
damage(StatCat.shooting),
ammo(StatCat.shooting),
shieldHealth(StatCat.shooting),
cooldownTime(StatCat.shooting),
booster(StatCat.optional),
boostEffect(StatCat.optional),
affinities(StatCat.optional);
public final StatCat category;
Stat(StatCat category){
this.category = category;
}
Stat(){
this.category = StatCat.general;
}
public String localized(){
return Core.bundle.get("stat." + name().toLowerCase(Locale.ROOT));
}
}

View File

@@ -3,7 +3,7 @@ package mindustry.world.meta;
import arc.*;
/** A specific category for a stat. */
public enum StatCategory{
public enum StatCat{
general,
power,
liquids,

View File

@@ -2,54 +2,71 @@ package mindustry.world.meta;
import arc.struct.ObjectMap.*;
import arc.struct.*;
import arc.util.*;
import mindustry.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.meta.values.*;
/** Hold and organizes a list of block stats. */
public class BlockStats{
private final OrderedMap<StatCategory, OrderedMap<BlockStat, Seq<StatValue>>> map = new OrderedMap<>();
public class Stats{
/** Whether to display stats with categories. If false, categories are completely ignored during display. */
public boolean useCategories = false;
/** Whether these stats are initialized yet. */
public boolean intialized = false;
@Nullable
private OrderedMap<StatCat, OrderedMap<Stat, Seq<StatValue>>> map;
private boolean dirty;
/** Adds a single float value with this stat, formatted to 2 decimal places. */
public void add(BlockStat stat, float value, StatUnit unit){
public void add(Stat stat, float value, StatUnit unit){
add(stat, new NumberValue(value, unit));
}
/** Adds a single float value with this stat and no unit. */
public void add(Stat stat, float value){
add(stat, value, StatUnit.none);
}
/** Adds an integer percent stat value. Value is assumed to be in the 0-1 range. */
public void addPercent(Stat stat, float value){
add(stat, new NumberValue((int)(value * 100), StatUnit.percent));
}
/** Adds a single y/n boolean value. */
public void add(BlockStat stat, boolean value){
public void add(Stat stat, boolean value){
add(stat, new BooleanValue(value));
}
/** Adds an item value. */
public void add(BlockStat stat, Item item){
public void add(Stat stat, Item item){
add(stat, new ItemListValue(new ItemStack(item, 1)));
}
/** Adds an item value. */
public void add(BlockStat stat, ItemStack item){
public void add(Stat stat, ItemStack item){
add(stat, new ItemListValue(item));
}
/** Adds an item value. */
public void add(BlockStat stat, Liquid liquid, float amount, boolean perSecond){
public void add(Stat stat, Liquid liquid, float amount, boolean perSecond){
add(stat, new LiquidValue(liquid, amount, perSecond));
}
public void add(BlockStat stat, Attribute attr){
public void add(Stat stat, Attribute attr){
add(stat, attr, false, 1f);
}
public void add(BlockStat stat, Attribute attr, float scale){
public void add(Stat stat, Attribute attr, float scale){
add(stat, attr, false, scale);
}
public void add(BlockStat stat, Attribute attr, boolean floating){
public void add(Stat stat, Attribute attr, boolean floating){
add(stat, attr, floating, 1f);
}
public void add(BlockStat stat, Attribute attr, boolean floating, float scale){
public void add(Stat stat, Attribute attr, boolean floating, float scale){
for(Block block : Vars.content.blocks()){
if(!block.isFloor() || block.asFloor().attributes.get(attr) == 0 || (block.asFloor().isLiquid && !floating)) continue;
add(stat, new FloorEfficiencyValue(block.asFloor(), block.asFloor().attributes.get(attr) * scale));
@@ -57,12 +74,14 @@ public class BlockStats{
}
/** Adds a single string value with this stat. */
public void add(BlockStat stat, String format, Object... args){
public void add(Stat stat, String format, Object... args){
add(stat, new StringValue(format, args));
}
/** Adds a stat value. */
public void add(BlockStat stat, StatValue value){
public void add(Stat stat, StatValue value){
if(map == null) map = new OrderedMap<>();
if(!map.containsKey(stat.category)){
map.put(stat.category, new OrderedMap<>());
}
@@ -73,7 +92,9 @@ public class BlockStats{
}
/** Removes a stat, if it exists. */
public void remove(BlockStat stat){
public void remove(Stat stat){
if(map == null) map = new OrderedMap<>();
if(!map.containsKey(stat.category) || !map.get(stat.category).containsKey(stat)){
throw new RuntimeException("No stat entry found: \"" + stat + "\" in block.");
}
@@ -83,11 +104,13 @@ public class BlockStats{
dirty = true;
}
public OrderedMap<StatCategory, OrderedMap<BlockStat, Seq<StatValue>>> toMap(){
public OrderedMap<StatCat, OrderedMap<Stat, Seq<StatValue>>> toMap(){
if(map == null) map = new OrderedMap<>();
//sort stats by index if they've been modified
if(dirty){
map.orderedKeys().sort();
for(Entry<StatCategory, OrderedMap<BlockStat, Seq<StatValue>>> entry : map.entries()){
for(Entry<StatCat, OrderedMap<Stat, Seq<StatValue>>> entry : map.entries()){
entry.value.orderedKeys().sort();
}

View File

@@ -0,0 +1,37 @@
package mindustry.world.meta.values;
import arc.func.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class BlockFilterValue implements StatValue{
public final Boolf<Block> pred;
public BlockFilterValue(Boolf<Block> pred){
this.pred = pred;
}
@Override
public void display(Table table){
Seq<Block> list = content.blocks().select(pred);
table.table(l -> {
l.left();
for(int i = 0; i < list.size; i++){
Block item = list.get(i);
l.image(item.icon(Cicon.small)).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
l.add(item.localizedName).left().padLeft(1).padRight(4);
if(i % 5 == 4){
l.row();
}
}
});
}
}

View File

@@ -0,0 +1,33 @@
package mindustry.world.meta.values;
import arc.scene.ui.layout.*;
import arc.struct.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.meta.*;
public class BlockListValue implements StatValue{
public final Seq<Block> list;
public BlockListValue(Seq<Block> list){
this.list = list;
}
@Override
public void display(Table table){
table.table(l -> {
l.left();
for(int i = 0; i < list.size; i++){
Block item = list.get(i);
l.image(item.icon(Cicon.small)).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
l.add(item.localizedName).left().padLeft(1).padRight(4);
if(i % 5 == 4){
l.row();
}
}
});
}
}