Partial 7.0 merge - API preview

This commit is contained in:
Anuken
2021-06-02 11:08:08 -04:00
parent ea75a357ca
commit 28b235ef07
531 changed files with 12356 additions and 6286 deletions

View File

@@ -2,23 +2,47 @@ package mindustry.world.meta;
import mindustry.*;
public enum Attribute{
/** Heat of this block. Used for calculating output of thermal generators. */
heat,
/** Spore content of this block. Used for increasing cultivator yield. */
spores,
/** Water content of this block. Used for increasing water extractor yield. */
water,
/** Oil content of this block. Used for increasing oil extractor yield. */
oil,
public class Attribute{
public static Attribute[] all = {};
public static final Attribute
/** Heat content. Used for thermal generator yield. */
heat = add("heat"),
/** Spore content. Used for cultivator yield. */
spores = add("spores"),
/** Water content. Used for water extractor yield. */
water = add("water"),
/** Oil content. Used for oil extractor yield. */
oil = add("oil"),
/** Light coverage. Negative values decrease solar panel efficiency. */
light;
light = add("light");
public static final Attribute[] all = values();
public final int id;
public final String name;
/** @return the envrionmental value for this attribute. */
/** @return the environmental value for this attribute. */
public float env(){
if(Vars.state == null) return 0;
return Vars.state.envAttrs.get(this);
}
Attribute(int id, String name){
this.id = id;
this.name = name;
}
@Override
public String toString(){
return name;
}
/** Automatically registers this attribute for use. Do not call after mod init. */
public static Attribute add(String name){
Attribute a = new Attribute(all.length, name);
Attribute[] prev = all;
all = new Attribute[all.length + 1];
System.arraycopy(prev, 0, all, 0, a.id);
all[a.id] = a;
return a;
}
}

View File

@@ -22,10 +22,13 @@ public enum BlockFlag{
resupply,
/** Any reactor block. */
reactor,
/** Any block that boosts unit capacity. */
/** This flag is unused, and will be removed. */
@Deprecated
unitModifier,
/** Blocks that extinguishes fires. */
extinguisher;
extinguisher,
/** Just a launch pad. */
launchPad;
public final static BlockFlag[] all = values();

View File

@@ -0,0 +1,14 @@
package mindustry.world.meta;
/** Environmental flags for different types of locations. */
public class Env{
public static final int
terrestrial = 1,
space = 1 << 1,
underwater = 1 << 2,
spores = 1 << 3,
scorching = 1 << 4,
groundOil = 1 << 5,
groundWater = 1 << 6,
any = 0xffffffff;
}

View File

@@ -70,6 +70,7 @@ public enum Stat{
speedIncrease(StatCat.function),
repairTime(StatCat.function),
repairSpeed(StatCat.function),
range(StatCat.function),
shootRange(StatCat.function),
inaccuracy(StatCat.function),

View File

@@ -0,0 +1,310 @@
package mindustry.world.meta;
import arc.*;
import arc.func.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.ctype.*;
import mindustry.entities.bullet.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.blocks.defense.turrets.*;
import mindustry.world.blocks.environment.*;
import static mindustry.Vars.*;
/** Utilities for displaying certain stats in a table. */
public class StatValues{
public static StatValue string(String value, Object... args){
String result = Strings.format(value, args);
return table -> table.add(result);
}
public static StatValue bool(boolean value){
return table -> table.add(!value ? "@no" : "@yes");
}
public static StatValue number(float value, StatUnit unit){
return table -> {
int precision = Math.abs((int)value - value) <= 0.001f ? 0 : Math.abs((int)(value * 10) - value * 10) <= 0.001f ? 1 : 2;
table.add(Strings.fixed(value, precision));
table.add((unit.space ? " " : "") + unit.localized());
};
}
public static StatValue liquid(Liquid liquid, float amount, boolean perSecond){
return table -> table.add(new LiquidDisplay(liquid, amount, perSecond));
}
public static StatValue liquids(Boolf<Liquid> filter, float amount, boolean perSecond){
return table -> {
Seq<Liquid> list = new Seq<>();
for(Liquid item : content.liquids()){
if(!item.isHidden() && filter.get(item)) list.add(item);
}
for(int i = 0; i < list.size; i++){
table.add(new LiquidDisplay(list.get(i), amount, perSecond)).padRight(5);
if(i != list.size - 1){
table.add("/");
}
}
};
}
public static StatValue items(ItemStack... stacks){
return items(true, stacks);
}
public static StatValue items(boolean displayName, ItemStack... stacks){
return table -> {
for(ItemStack stack : stacks){
table.add(new ItemDisplay(stack.item, stack.amount, displayName)).padRight(5);
}
};
}
public static StatValue items(float timePeriod, ItemStack... stacks){
return table -> {
for(ItemStack stack : stacks){
table.add(new ItemDisplay(stack.item, stack.amount, timePeriod, true)).padRight(5);
}
};
}
public static StatValue items(Boolf<Item> filter){
return items(-1, filter);
}
public static StatValue items(float timePeriod, Boolf<Item> filter){
return table -> {
Seq<Item> list = content.items().select(filter);
for(int i = 0; i < list.size; i++){
Item item = list.get(i);
table.add(timePeriod <= 0 ? new ItemDisplay(item) : new ItemDisplay(item, 0, timePeriod, true)).padRight(5);
if(i != list.size - 1){
table.add("/");
}
}
};
}
public static StatValue content(UnlockableContent content){
return table -> {
table.add(new Image(content.uiIcon)).size(iconSmall).padRight(3);
table.add(content.localizedName).padRight(3);
};
}
public static StatValue floorEfficiency(Floor floor, float multiplier, boolean startZero){
return table -> table.stack(
new Image(floor.uiIcon).setScaling(Scaling.fit),
new Table(t -> t.top().right().add((multiplier < 0 ? "[scarlet]" : startZero ? "[accent]" : "[accent]+") + (int)((multiplier) * 100) + "%").style(Styles.outlineLabel))
);
}
public static StatValue blocks(Boolf<Block> pred){
return blocks(content.blocks().select(pred));
}
public static StatValue blocks(Seq<Block> list){
return table -> table.table(l -> {
l.left();
for(int i = 0; i < list.size; i++){
Block item = list.get(i);
l.image(item.uiIcon).size(iconSmall).padRight(2).padLeft(2).padTop(3).padBottom(3);
l.add(item.localizedName).left().padLeft(1).padRight(4);
if(i % 5 == 4){
l.row();
}
}
});
}
public static StatValue boosters(float reload, float maxUsed, float multiplier, boolean baseReload, Boolf<Liquid> filter){
return table -> {
table.row();
table.table(c -> {
for(Liquid liquid : content.liquids()){
if(!filter.get(liquid)) continue;
c.image(liquid.uiIcon).size(3 * 8).padRight(4).right().top();
c.add(liquid.localizedName).padRight(10).left().top();
c.table(Tex.underline, bt -> {
bt.left().defaults().padRight(3).left();
float reloadRate = (baseReload ? 1f : 0f) + maxUsed * multiplier * liquid.heatCapacity;
float standardReload = baseReload ? reload : reload / (maxUsed * multiplier * 0.4f);
float result = standardReload / (reload / reloadRate);
bt.add(Core.bundle.format("bullet.reload", Strings.autoFixed(result, 2)));
}).left().padTop(-9);
c.row();
}
}).colspan(table.getColumns());
table.row();
};
}
public static StatValue strengthBoosters(float multiplier, Boolf<Liquid> filter){
return table -> {
table.row();
table.table(c -> {
for(Liquid liquid : content.liquids()){
if(!filter.get(liquid)) continue;
c.image(liquid.uiIcon).size(3 * 8).padRight(4).right().top();
c.add(liquid.localizedName).padRight(10).left().top();
c.table(Tex.underline, bt -> {
bt.left().defaults().padRight(3).left();
float newRate = (1f + multiplier * liquid.heatCapacity);
bt.add(Core.bundle.format("bar.strength", Strings.autoFixed(newRate, 2)));
}).left().padTop(-9);
c.row();
}
}).colspan(table.getColumns());
table.row();
};
}
public static StatValue weapons(UnitType unit, Seq<Weapon> weapons){
return table -> {
table.row();
for(int i = 0; i < weapons.size;i ++){
Weapon weapon = weapons.get(i);
if(weapon.flipSprite){
//flipped weapons are not given stats
continue;
}
TextureRegion region = !weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : unit.fullIcon;
table.image(region).size(60).scaling(Scaling.bounded).right().top();
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);
}).padTop(-9).left();
table.row();
}
};
}
public static <T extends UnlockableContent> StatValue ammo(ObjectMap<T, BulletType> map){
return table -> {
table.row();
var orderedKeys = map.keys().toSeq();
orderedKeys.sort();
for(T t : orderedKeys){
boolean unit = t instanceof UnitType;
BulletType type = map.get(t);
//no point in displaying unit icon twice
if(!unit & !(t instanceof PowerTurret)){
table.image(icon(t)).size(3 * 8).padRight(4).right().top();
table.add(t.localizedName).padRight(10).left().top();
}
table.table(bt -> {
bt.left().defaults().padRight(3).left();
if(type.damage > 0 && (type.collides || type.splashDamage <= 0)){
if(type.continuousDamage() > 0){
bt.add(Core.bundle.format("bullet.damage", type.continuousDamage()) + StatUnit.perSecond.localized());
}else{
bt.add(Core.bundle.format("bullet.damage", type.damage));
}
}
if(type.buildingDamageMultiplier != 1){
sep(bt, Core.bundle.format("bullet.buildingdamage", (int)(type.buildingDamageMultiplier * 100)));
}
if(type.splashDamage > 0){
sep(bt, Core.bundle.format("bullet.splashdamage", (int)type.splashDamage, Strings.fixed(type.splashDamageRadius / tilesize, 1)));
}
if(!unit && !Mathf.equal(type.ammoMultiplier, 1f)){
sep(bt, Core.bundle.format("bullet.multiplier", (int)type.ammoMultiplier));
}
if(!Mathf.equal(type.reloadMultiplier, 1f)){
sep(bt, Core.bundle.format("bullet.reload", Strings.autoFixed(type.reloadMultiplier, 2)));
}
if(type.knockback > 0){
sep(bt, Core.bundle.format("bullet.knockback", Strings.autoFixed(type.knockback, 2)));
}
if(type.healPercent > 0f){
sep(bt, Core.bundle.format("bullet.healpercent", (int)type.healPercent));
}
if(type.pierce || type.pierceCap != -1){
sep(bt, type.pierceCap == -1 ? "@bullet.infinitepierce" : Core.bundle.format("bullet.pierce", type.pierceCap));
}
if(type.incendAmount > 0){
sep(bt, "@bullet.incendiary");
}
if(type.status != StatusEffects.none){
sep(bt, (type.minfo.mod == null ? type.status.emoji() : "") + "[stat]" + type.status.localizedName);
}
if(type.homingPower > 0.01f){
sep(bt, "@bullet.homing");
}
if(type.lightning > 0){
sep(bt, Core.bundle.format("bullet.lightning", type.lightning, type.lightningDamage < 0 ? type.damage : type.lightningDamage));
}
if(type.fragBullet != null){
sep(bt, "@bullet.frag");
}
}).padTop(unit ? 0 : -9).left().get().background(unit ? null : Tex.underline);
table.row();
}
};
}
//for AmmoListValue
private static void sep(Table table, String text){
table.row();
table.add(text);
}
private static TextureRegion icon(UnlockableContent t){
return t.uiIcon;
}
}

View File

@@ -6,7 +6,6 @@ import arc.util.*;
import mindustry.*;
import mindustry.type.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.meta.values.*;
/** Hold and organizes a list of block stats. */
public class Stats{
@@ -14,6 +13,8 @@ public class Stats{
public boolean useCategories = false;
/** Whether these stats are initialized yet. */
public boolean intialized = false;
/** Production time period in ticks. Used for crafters. **/
public float timePeriod = -1;
@Nullable
private OrderedMap<StatCat, OrderedMap<Stat, Seq<StatValue>>> map;
@@ -21,7 +22,7 @@ public class Stats{
/** Adds a single float value with this stat, formatted to 2 decimal places. */
public void add(Stat stat, float value, StatUnit unit){
add(stat, new NumberValue(value, unit));
add(stat, StatValues.number(value, unit));
}
/** Adds a single float value with this stat and no unit. */
@@ -31,27 +32,27 @@ public class Stats{
/** 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));
add(stat, StatValues.number((int)(value * 100), StatUnit.percent));
}
/** Adds a single y/n boolean value. */
public void add(Stat stat, boolean value){
add(stat, new BooleanValue(value));
add(stat, StatValues.bool(value));
}
/** Adds an item value. */
public void add(Stat stat, Item item){
add(stat, new ItemListValue(new ItemStack(item, 1)));
add(stat, StatValues.items(new ItemStack(item, 1)));
}
/** Adds an item value. */
public void add(Stat stat, ItemStack item){
add(stat, new ItemListValue(item));
add(stat, StatValues.items(item));
}
/** Adds an item value. */
public void add(Stat stat, Liquid liquid, float amount, boolean perSecond){
add(stat, new LiquidValue(liquid, amount, perSecond));
add(stat, StatValues.liquid(liquid, amount, perSecond));
}
public void add(Stat stat, Attribute attr){
@@ -70,13 +71,13 @@ public class Stats{
for(var block : Vars.content.blocks()
.select(block -> block instanceof Floor f && f.attributes.get(attr) != 0 && !(f.isLiquid && !floating))
.<Floor>as().with(s -> s.sort(f -> f.attributes.get(attr)))){
add(stat, new FloorEfficiencyValue(block, block.attributes.get(attr) * scale, startZero));
add(stat, StatValues.floorEfficiency(block, block.attributes.get(attr) * scale, startZero));
}
}
/** Adds a single string value with this stat. */
public void add(Stat stat, String format, Object... args){
add(stat, new StringValue(format, args));
add(stat, StatValues.string(format, args));
}
/** Adds a stat value. */

View File

@@ -1,115 +0,0 @@
package mindustry.world.meta.values;
import arc.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.ctype.*;
import mindustry.entities.bullet.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.blocks.defense.turrets.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class AmmoListValue<T extends UnlockableContent> implements StatValue{
private final ObjectMap<T, BulletType> map;
public AmmoListValue(ObjectMap<T, BulletType> map){
this.map = map;
}
@Override
public void display(Table table){
table.row();
for(T t : map.keys()){
boolean unit = t instanceof UnitType;
BulletType type = map.get(t);
//no point in displaying unit icon twice
if(!unit & !(t instanceof PowerTurret)){
table.image(icon(t)).size(3 * 8).padRight(4).right().top();
table.add(t.localizedName).padRight(10).left().top();
}
table.table(bt -> {
bt.left().defaults().padRight(3).left();
if(type.damage > 0 && (type.collides || type.splashDamage <= 0)){
if(type.continuousDamage() > 0){
bt.add(Core.bundle.format("bullet.damage", type.continuousDamage()) + StatUnit.perSecond.localized());
}else{
bt.add(Core.bundle.format("bullet.damage", type.damage));
}
}
if(type.buildingDamageMultiplier != 1){
sep(bt, Core.bundle.format("bullet.buildingdamage", (int)(type.buildingDamageMultiplier * 100)));
}
if(type.splashDamage > 0){
sep(bt, Core.bundle.format("bullet.splashdamage", (int)type.splashDamage, Strings.fixed(type.splashDamageRadius / tilesize, 1)));
}
if(!unit && !Mathf.equal(type.ammoMultiplier, 1f) && !(type instanceof LiquidBulletType)){
sep(bt, Core.bundle.format("bullet.multiplier", (int)type.ammoMultiplier));
}
if(!Mathf.equal(type.reloadMultiplier, 1f)){
sep(bt, Core.bundle.format("bullet.reload", Strings.autoFixed(type.reloadMultiplier, 2)));
}
if(type.knockback > 0){
sep(bt, Core.bundle.format("bullet.knockback", Strings.autoFixed(type.knockback, 2)));
}
if(type.healPercent > 0f){
sep(bt, Core.bundle.format("bullet.healpercent", (int)type.healPercent));
}
if(type.pierce || type.pierceCap != -1){
sep(bt, type.pierceCap == -1 ? "@bullet.infinitepierce" : Core.bundle.format("bullet.pierce", type.pierceCap));
}
if(type.incendAmount > 0){
sep(bt, "@bullet.incendiary");
}
if(type.status != StatusEffects.none){
sep(bt, (type.minfo.mod == null ? type.status.emoji() : "") + "[stat]" + type.status.localizedName);
}
if(type.homingPower > 0.01f){
sep(bt, "@bullet.homing");
}
if(type.lightning > 0){
sep(bt, Core.bundle.format("bullet.lightning", type.lightning, type.lightningDamage < 0 ? type.damage : type.lightningDamage));
}
if(type.fragBullet != null){
sep(bt, "@bullet.frag");
}
}).padTop(unit ? 0 : -9).left().get().background(unit ? null : Tex.underline);
table.row();
}
}
void sep(Table table, String text){
table.row();
table.add(text);
}
TextureRegion icon(T t){
return t.icon(Cicon.medium);
}
}

View File

@@ -1,37 +0,0 @@
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

@@ -1,33 +0,0 @@
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();
}
}
});
}
}

View File

@@ -1,17 +0,0 @@
package mindustry.world.meta.values;
import arc.scene.ui.layout.*;
import mindustry.world.meta.*;
public class BooleanValue implements StatValue{
private final boolean value;
public BooleanValue(boolean value){
this.value = value;
}
@Override
public void display(Table table){
table.add(!value ? "@no" : "@yes");
}
}

View File

@@ -1,56 +0,0 @@
package mindustry.world.meta.values;
import arc.*;
import arc.func.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class BoosterListValue implements StatValue{
protected float reload, maxUsed, multiplier;
protected boolean baseReload;
protected Boolf<Liquid> filter;
public BoosterListValue(float reload, float maxUsed, float multiplier, boolean baseReload, Boolf<Liquid> filter){
this.reload = reload;
this.maxUsed = maxUsed;
this.baseReload = baseReload;
this.multiplier = multiplier;
this.filter = filter;
}
@Override
public void display(Table table){
table.row();
table.table(c -> {
for(Liquid liquid : content.liquids()){
if(!filter.get(liquid)) continue;
c.image(liquid.icon(Cicon.medium)).size(3 * 8).padRight(4).right().top();
c.add(liquid.localizedName).padRight(10).left().top();
c.table(Tex.underline, bt -> {
bt.left().defaults().padRight(3).left();
float reloadRate = (baseReload ? 1f : 0f) + maxUsed * multiplier * liquid.heatCapacity;
float standardReload = baseReload ? reload : reload / (maxUsed * multiplier * 0.4f);
float result = standardReload / (reload / reloadRate);
bt.add(Core.bundle.format("bullet.reload", Strings.autoFixed(result, 2)));
}).left().padTop(-9);
c.row();
}
}).colspan(table.getColumns());
table.row();
}
void sep(Table table, String text){
table.row();
table.add(text);
}
}

View File

@@ -1,27 +0,0 @@
package mindustry.world.meta.values;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.ui.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.meta.*;
public class FloorEfficiencyValue implements StatValue{
private final Floor floor;
private final float multiplier;
private final boolean startZero;
public FloorEfficiencyValue(Floor floor, float multiplier, boolean startZero){
this.floor = floor;
this.multiplier = multiplier;
this.startZero = startZero;
}
@Override
public void display(Table table){
table.stack(new Image(floor.icon(Cicon.medium)).setScaling(Scaling.fit), new Table(t -> {
t.top().right().add((multiplier < 0 ? "[scarlet]" : startZero ? "[accent]" : "[accent]+") + (int)((multiplier) * 100) + "%").style(Styles.outlineLabel);
}));
}
}

View File

@@ -1,21 +0,0 @@
package mindustry.world.meta.values;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import mindustry.ui.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.meta.*;
public class FloorValue implements StatValue{
private final Floor floor;
public FloorValue(Floor floor){
this.floor = floor;
}
@Override
public void display(Table table){
table.add(new Image(floor.icon(Cicon.small))).padRight(3);
table.add(floor.localizedName).padRight(3);
}
}

View File

@@ -1,33 +0,0 @@
package mindustry.world.meta.values;
import arc.func.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class ItemFilterValue implements StatValue{
private final Boolf<Item> filter;
public ItemFilterValue(Boolf<Item> filter){
this.filter = filter;
}
@Override
public void display(Table table){
Seq<Item> list = content.items().select(filter);
for(int i = 0; i < list.size; i++){
Item item = list.get(i);
table.add(new ItemDisplay(item)).padRight(5);
if(i != list.size - 1){
table.add("/");
}
}
}
}

View File

@@ -1,27 +0,0 @@
package mindustry.world.meta.values;
import arc.scene.ui.layout.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.meta.*;
public class ItemListValue implements StatValue{
private final ItemStack[] stacks;
private final boolean displayName;
public ItemListValue(ItemStack... stacks){
this(true, stacks);
}
public ItemListValue(boolean displayName, ItemStack... stacks){
this.stacks = stacks;
this.displayName = displayName;
}
@Override
public void display(Table table){
for(ItemStack stack : stacks){
table.add(new ItemDisplay(stack.item, stack.amount, displayName)).padRight(5);
}
}
}

View File

@@ -1,39 +0,0 @@
package mindustry.world.meta.values;
import arc.func.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class LiquidFilterValue implements StatValue{
private final Boolf<Liquid> filter;
private final float amount;
private final boolean perSecond;
public LiquidFilterValue(Boolf<Liquid> filter, float amount, boolean perSecond){
this.filter = filter;
this.amount = amount;
this.perSecond = perSecond;
}
@Override
public void display(Table table){
Seq<Liquid> list = new Seq<>();
for(Liquid item : content.liquids()){
if(!item.isHidden() && filter.get(item)) list.add(item);
}
for(int i = 0; i < list.size; i++){
table.add(new LiquidDisplay(list.get(i), amount, perSecond)).padRight(5);
if(i != list.size - 1){
table.add("/");
}
}
}
}

View File

@@ -1,23 +0,0 @@
package mindustry.world.meta.values;
import arc.scene.ui.layout.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.meta.*;
public class LiquidValue implements StatValue{
private final Liquid liquid;
private final float amount;
private final boolean perSecond;
public LiquidValue(Liquid liquid, float amount, boolean perSecond){
this.liquid = liquid;
this.amount = amount;
this.perSecond = perSecond;
}
@Override
public void display(Table table){
table.add(new LiquidDisplay(liquid, amount, perSecond));
}
}

View File

@@ -1,27 +0,0 @@
package mindustry.world.meta.values;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.world.meta.*;
/**
* A stat that is a number with a unit attacked.
* The number is rounded to 2 decimal places by default.
*/
public class NumberValue implements StatValue{
private final StatUnit unit;
private final float value;
public NumberValue(float value, StatUnit unit){
this.unit = unit;
this.value = value;
}
@Override
public void display(Table table){
int precision = Math.abs((int)value - value) <= 0.001f ? 0 : Math.abs((int)(value * 10) - value * 10) <= 0.001f ? 1 : 2;
table.add(Strings.fixed(value, precision));
table.add((unit.space ? " " : "") + unit.localized());
}
}

View File

@@ -1,18 +0,0 @@
package mindustry.world.meta.values;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.world.meta.*;
public class StringValue implements StatValue{
private final String value;
public StringValue(String value, Object... args){
this.value = Strings.format(value, args);
}
@Override
public void display(Table table){
table.add(value);
}
}

View File

@@ -1,55 +0,0 @@
package mindustry.world.meta.values;
import arc.graphics.g2d.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.meta.*;
public class WeaponListValue implements StatValue{
private final Seq<Weapon> weapons;
private final UnitType unit;
public WeaponListValue(UnitType unit, Seq<Weapon> weapons){
this.weapons = weapons;
this.unit = unit;
}
@Override
public void display(Table table){
table.row();
for(int i = 0; i < weapons.size;i ++){
Weapon weapon = weapons.get(i);
if(weapon.flipSprite){
//flipped weapons are not given stats
continue;
}
TextureRegion region = !weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : unit.icon(Cicon.full);
table.image(region).size(60).scaling(Scaling.bounded).right().top();
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));
var bullet = new AmmoListValue<UnitType>(OrderedMap.of(unit, weapon.bullet));
bullet.display(w);
}).padTop(-9).left();
table.row();
}
}
void sep(Table table, String text){
table.row();
table.add(text);
}
}