Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ stat.reactive = Reacts
stat.immunities = Immunities
stat.healing = Healing
stat.efficiency = [stat]{0}% Efficiency
stat.meltdownoutput = Meltdown output

ability.forcefield = Force Field
ability.forcefield.description = Projects a force shield that absorbs bullets
Expand Down Expand Up @@ -1251,6 +1252,7 @@ bar.strength = [stat]{0}[lightgray]x strength
bar.regenerationrate = [stat]{0}/sec[lightgray] regen rate
bar.activationtimer = Activates in {0}
bar.activated = Activated
bar.upto = Up to {0}

units.processorcontrol = [lightgray]Processor Controlled

Expand Down Expand Up @@ -1302,6 +1304,7 @@ unit.liquidunits = liquid units
unit.powerunits = power units
unit.powerequilibrium = power equilibrium
unit.heatunits = heat units
unit.heatunitsperside = heat units per side
unit.degrees = degrees
unit.seconds = seconds
unit.minutes = mins
Expand Down
8 changes: 5 additions & 3 deletions core/src/mindustry/ui/dialogs/ContentInfoDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.input.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.meta.*;

Expand All @@ -34,6 +35,7 @@ public ContentInfoDialog(){
public void show(UnlockableContent content){
cont.clear();

Planet curPlanet = ui.planet.isShown() ? ui.planet.state.planet : state.isGame() ? state.getPlanet() : null;
Table table = new Table();
table.margin(10);

Expand All @@ -57,7 +59,7 @@ public void show(UnlockableContent content){
}

if(content.description != null){
var any = content.stats.toMap().size > 0;
var any = content.stats.toMap(curPlanet).size > 0;

if(any){
table.add("@category.purpose").color(Pal.accent).fillX().padTop(10);
Expand All @@ -75,8 +77,8 @@ public void show(UnlockableContent content){

Stats stats = content.stats;

for(StatCat cat : stats.toMap().keys()){
OrderedMap<Stat, Seq<StatValue>> map = stats.toMap().get(cat);
for(StatCat cat : stats.toMap(curPlanet).keys()){
OrderedMap<Stat, Seq<StatValue>> map = stats.toMap(curPlanet).get(cat);

if(map.size == 0) continue;

Expand Down
8 changes: 8 additions & 0 deletions core/src/mindustry/world/blocks/power/NuclearReactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ public void setStats(){
if(hasItems){
stats.add(Stat.productionTime, itemDuration / 60f, StatUnit.seconds);
}
if(heatOutput > 0f){
stats.add(Stat.meltdownOutput, table -> {
//using StatUnit.localized() strips the icon
String unit = "[red]" + Iconc.waves + "[] " + Strings.fixed(heatOutput, 0) + " " + Core.bundle.get("unit.heatunitsperside");

table.add(Core.bundle.format("bar.upto", unit));
}, Planets.erekir);
}
}

@Override
Expand Down
1 change: 1 addition & 0 deletions core/src/mindustry/world/meta/Stat.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class Stat implements Comparable<Stat>{
drillSpeed = new Stat("drillSpeed", StatCat.crafting),
linkRange = new Stat("linkRange", StatCat.crafting),
instructions = new Stat("instructions", StatCat.crafting),
meltdownOutput = new Stat("meltdownoutput", StatCat.crafting),

weapons = new Stat("weapons", StatCat.function),
bullet = new Stat("bullet", StatCat.function),
Expand Down
1 change: 1 addition & 0 deletions core/src/mindustry/world/meta/StatUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class StatUnit{
powerUnits = new StatUnit("powerUnits", "[accent]" + Iconc.power + "[]"),
powerEquilibrium = new StatUnit("powerEquilibrium"),
heatUnits = new StatUnit("heatUnits", "[red]" + Iconc.waves + "[]"),
heatUnitsPerSide = new StatUnit("heatUnitsPerSide", "[red]" + Iconc.waves + "[]"),
degrees = new StatUnit("degrees"),
seconds = new StatUnit("seconds"),
minutes = new StatUnit("minutes"),
Expand Down
65 changes: 65 additions & 0 deletions core/src/mindustry/world/meta/Stats.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import arc.struct.ObjectMap.*;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.mod.*;
import mindustry.type.*;

Expand All @@ -21,6 +22,7 @@ public class Stats{
public float timePeriod = -1;

private @Nullable OrderedMap<StatCat, OrderedMap<Stat, Seq<StatValue>>> map;
private @Nullable ObjectMap<Stat, Seq<Planet>> statPlanets;
private boolean dirty;

/** Adds a single float value with this stat, formatted to 2 decimal places. */
Expand Down Expand Up @@ -108,6 +110,42 @@ public void add(Stat stat, StatValue value){
dirty = true;
}

/** Adds a single float value with this stat, formatted to 2 decimal places, and filtered to a planet. */
public void add(Stat stat, float value, StatUnit unit, Planet planet){
add(stat, StatValues.number(value, unit), planet);
}

/** Adds a stat value that only displays on specific planets. */
public void add(Stat stat, StatValue value, Planet planet){
add(stat, value, Seq.with(planet));
}

/** Adds a stat value that only displays on specific planets. */
public void add(Stat stat, StatValue value, Seq<Planet> planets){
add(stat, value);

if(statPlanets == null) statPlanets = new ObjectMap<>();
if(!statPlanets.containsKey(stat)){
statPlanets.put(stat, new Seq<>());
}

statPlanets.get(stat).addAll(planets);
}

/** Checks if a stat should be displayed on the given planet. */
public boolean shouldDisplay(Stat stat, @Nullable Planet planet){
if(statPlanets == null || !statPlanets.containsKey(stat)){
return true;
}

//in <any> environment display all, and in the main menu dont display
if(planet == Planets.sun) return true;
if(planet == null) return false;

Seq<Planet> planets = statPlanets.get(stat);
return planets.contains(planet);
}

/** Removes a stat, if it exists. */
public void remove(Stat stat){
if(map == null) map = new OrderedMap<>();
Expand Down Expand Up @@ -136,6 +174,33 @@ public OrderedMap<StatCat, OrderedMap<Stat, Seq<StatValue>>> toMap(){
return map;
}

/** Returns a map of stats for a specific planet. */
public OrderedMap<StatCat, OrderedMap<Stat, Seq<StatValue>>> toMap(@Nullable Planet planet){
OrderedMap<StatCat, OrderedMap<Stat, Seq<StatValue>>> full = toMap();

if(statPlanets == null || statPlanets.isEmpty()){
return full;
}

OrderedMap<StatCat, OrderedMap<Stat, Seq<StatValue>>> filter = new OrderedMap<>();

for(Entry<StatCat, OrderedMap<Stat, Seq<StatValue>>> catEntry : full.entries()){
OrderedMap<Stat, Seq<StatValue>> catMap = new OrderedMap<>();

for(Entry<Stat, Seq<StatValue>> entry : catEntry.value.entries()){
if(shouldDisplay(entry.key, planet)){
catMap.put(entry.key, entry.value);
}
}

if(!catMap.isEmpty()){
filter.put(catEntry.key, catMap);
}
}

return filter;
}

public void statInfo(Cell<?> cell, Stat stat){
if(cell == null || stat == null) return;

Expand Down
Loading