Sector bugfixes / More sector info
This commit is contained in:
@@ -1297,6 +1297,7 @@ public class Blocks implements ContentList{
|
|||||||
drillEffect = Fx.mineHuge;
|
drillEffect = Fx.mineHuge;
|
||||||
rotateSpeed = 6f;
|
rotateSpeed = 6f;
|
||||||
warmupSpeed = 0.01f;
|
warmupSpeed = 0.01f;
|
||||||
|
itemCapacity = 20;
|
||||||
|
|
||||||
//more than the laser drill
|
//more than the laser drill
|
||||||
liquidBoostIntensity = 1.8f;
|
liquidBoostIntensity = 1.8f;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package mindustry.game;
|
package mindustry.game;
|
||||||
|
|
||||||
|
import arc.func.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
@@ -21,6 +22,7 @@ public class SectorInfo{
|
|||||||
private static final int valueWindow = 60;
|
private static final int valueWindow = 60;
|
||||||
/** refresh period of export in ticks */
|
/** refresh period of export in ticks */
|
||||||
private static final float refreshPeriod = 60;
|
private static final float refreshPeriod = 60;
|
||||||
|
private static float returnf;
|
||||||
|
|
||||||
/** Core input statistics. */
|
/** Core input statistics. */
|
||||||
public ObjectMap<Item, ExportStat> production = new ObjectMap<>();
|
public ObjectMap<Item, ExportStat> production = new ObjectMap<>();
|
||||||
@@ -265,23 +267,29 @@ public class SectorInfo{
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean anyExports(){
|
||||||
|
if(export.size == 0) return false;
|
||||||
|
returnf = 0f;
|
||||||
|
export.each((i, e) -> returnf += e.mean);
|
||||||
|
return returnf >= 0.01f;
|
||||||
|
}
|
||||||
|
|
||||||
/** @return a newly allocated map with import statistics. Use sparingly. */
|
/** @return a newly allocated map with import statistics. Use sparingly. */
|
||||||
//TODO this can be a float map
|
//TODO this can be a float map
|
||||||
public ObjectMap<Item, ExportStat> importStats(){
|
public ObjectMap<Item, ExportStat> importStats(Planet planet){
|
||||||
ObjectMap<Item, ExportStat> imports = new ObjectMap<>();
|
ObjectMap<Item, ExportStat> imports = new ObjectMap<>();
|
||||||
//for all sectors on all planets that have bases and export to this sector
|
eachImport(planet, sector -> sector.info.export.each((item, stat) -> imports.get(item, ExportStat::new).mean += stat.mean));
|
||||||
for(Planet planet : content.planets()){
|
return imports;
|
||||||
for(Sector sector : planet.sectors){
|
}
|
||||||
Sector dest = sector.info.getRealDestination();
|
|
||||||
if(sector.hasBase() && sector.info != this && dest != null && dest.info == this){
|
/** Iterates through every sector this one imports from. */
|
||||||
//add their exports to our imports
|
public void eachImport(Planet planet, Cons<Sector> cons){
|
||||||
sector.info.export.each((item, stat) -> {
|
for(Sector sector : planet.sectors){
|
||||||
imports.get(item, ExportStat::new).mean += stat.mean;
|
Sector dest = sector.info.getRealDestination();
|
||||||
});
|
if(sector.hasBase() && sector.info != this && dest != null && dest.info == this){
|
||||||
}
|
cons.get(sector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return imports;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ExportStat{
|
public static class ExportStat{
|
||||||
|
|||||||
@@ -214,7 +214,8 @@ public class JsonIO{
|
|||||||
String str = jsonData.asString();
|
String str = jsonData.asString();
|
||||||
Item item = Vars.content.getByName(ContentType.item, str);
|
Item item = Vars.content.getByName(ContentType.item, str);
|
||||||
Liquid liquid = Vars.content.getByName(ContentType.liquid, str);
|
Liquid liquid = Vars.content.getByName(ContentType.liquid, str);
|
||||||
return item != null ? item : liquid;
|
Block block = Vars.content.getByName(ContentType.block, str);
|
||||||
|
return item != null ? item : liquid == null ? block : liquid;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import arc.util.*;
|
|||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.game.Saves.*;
|
import mindustry.game.Saves.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.modules.*;
|
import mindustry.world.modules.*;
|
||||||
@@ -126,6 +127,13 @@ public class Sector{
|
|||||||
return info.contentIcon != null ? info.contentIcon.uiIcon : info.icon == null ? null : Fonts.getLargeIcon(info.icon);
|
return info.contentIcon != null ? info.contentIcon.uiIcon : info.icon == null ? null : Fonts.getLargeIcon(info.icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String iconChar(){
|
||||||
|
if(info.contentIcon != null) return info.contentIcon.emoji();
|
||||||
|
if(info.icon != null) return Iconc.codes.get(info.icon) + "";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCaptured(){
|
public boolean isCaptured(){
|
||||||
return save != null && !info.waves;
|
return save != null && !info.waves;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,6 +371,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(selectAlpha > 0.001f){
|
if(selectAlpha > 0.001f){
|
||||||
|
|
||||||
|
|
||||||
for(Sector sec : planet.sectors){
|
for(Sector sec : planet.sectors){
|
||||||
if(sec.hasBase()){
|
if(sec.hasBase()){
|
||||||
for(Sector enemy : sec.near()){
|
for(Sector enemy : sec.near()){
|
||||||
@@ -378,6 +380,18 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
planets.drawArc(planet, enemy.tile.v, sec.tile.v, Team.crux.color.write(Tmp.c2).a(selectAlpha), Color.clear, 0.24f, 110f, 25);
|
planets.drawArc(planet, enemy.tile.v, sec.tile.v, Team.crux.color.write(Tmp.c2).a(selectAlpha), Color.clear, 0.24f, 110f, 25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(selected != null && selected != sec && selected.hasBase()){
|
||||||
|
//imports
|
||||||
|
if(sec.info.getRealDestination() == selected && sec.info.anyExports()){
|
||||||
|
planets.drawArc(planet, sec.tile.v, selected.tile.v, Color.gray.write(Tmp.c2).a(selectAlpha), Pal.accent, 0.4f, 90f, 25);
|
||||||
|
}
|
||||||
|
//exports
|
||||||
|
if(selected.info.getRealDestination() == sec && selected.info.anyExports()){
|
||||||
|
planets.drawArc(planet, selected.tile.v, sec.tile.v, Pal.place.write(Tmp.c2).a(selectAlpha), Pal.accent, 0.4f, 90f, 25);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -605,6 +619,10 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void displayItems(Table c, float scl, ObjectMap<Item, ExportStat> stats, String name){
|
void displayItems(Table c, float scl, ObjectMap<Item, ExportStat> stats, String name){
|
||||||
|
displayItems(c, scl, stats, name, t -> {});
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayItems(Table c, float scl, ObjectMap<Item, ExportStat> stats, String name, Cons<Table> builder){
|
||||||
Table t = new Table().left();
|
Table t = new Table().left();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -622,8 +640,10 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(t.getChildren().any()){
|
if(t.getChildren().any()){
|
||||||
c.add(name).left().row();
|
c.defaults().left();
|
||||||
c.add(t).padLeft(10f).left().row();
|
c.add(name).row();
|
||||||
|
builder.get(c);
|
||||||
|
c.add(t).padLeft(10f).row();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,11 +680,21 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
displayItems(c, sector.getProductionScale(), sector.info.production, "@sectors.production");
|
displayItems(c, sector.getProductionScale(), sector.info.production, "@sectors.production");
|
||||||
|
|
||||||
//export
|
//export
|
||||||
displayItems(c, sector.getProductionScale(), sector.info.export, "@sectors.export");
|
displayItems(c, sector.getProductionScale(), sector.info.export, "@sectors.export", t -> {
|
||||||
|
if(sector.info.destination != null){
|
||||||
|
String ic = sector.info.destination.iconChar();
|
||||||
|
t.add(Iconc.rightOpen + " " + (ic == null || ic.isEmpty() ? "" : ic + " ") + sector.info.destination.name()).padLeft(10f).row();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//import
|
//import
|
||||||
if(sector.hasBase()){
|
if(sector.hasBase()){
|
||||||
displayItems(c, 1f, sector.info.importStats(), "@sectors.import");
|
displayItems(c, 1f, sector.info.importStats(sector.planet), "@sectors.import", t -> {
|
||||||
|
sector.info.eachImport(sector.planet, other -> {
|
||||||
|
String ic = other.iconChar();
|
||||||
|
t.add(Iconc.rightOpen + " " + (ic == null || ic.isEmpty() ? "" : ic + " ") + other.name()).padLeft(10f).row();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemSeq items = sector.items();
|
ItemSeq items = sector.items();
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import mindustry.core.*;
|
|||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.input.*;
|
import mindustry.input.*;
|
||||||
@@ -38,6 +39,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
Block menuHoverBlock;
|
Block menuHoverBlock;
|
||||||
Displayable hover;
|
Displayable hover;
|
||||||
Object lastDisplayState;
|
Object lastDisplayState;
|
||||||
|
Team lastTeam;
|
||||||
boolean wasHovered;
|
boolean wasHovered;
|
||||||
Table blockTable, toggler, topTable;
|
Table blockTable, toggler, topTable;
|
||||||
ScrollPane blockPane;
|
ScrollPane blockPane;
|
||||||
@@ -283,13 +285,14 @@ public class PlacementFragment extends Fragment{
|
|||||||
|
|
||||||
//don't refresh unnecessarily
|
//don't refresh unnecessarily
|
||||||
//refresh only when the hover state changes, or the displayed block changes
|
//refresh only when the hover state changes, or the displayed block changes
|
||||||
if(wasHovered == isHovered && lastDisplayState == displayState) return;
|
if(wasHovered == isHovered && lastDisplayState == displayState && lastTeam == player.team()) return;
|
||||||
|
|
||||||
topTable.clear();
|
topTable.clear();
|
||||||
topTable.top().left().margin(5);
|
topTable.top().left().margin(5);
|
||||||
|
|
||||||
lastDisplayState = displayState;
|
lastDisplayState = displayState;
|
||||||
wasHovered = isHovered;
|
wasHovered = isHovered;
|
||||||
|
lastTeam = player.team();
|
||||||
|
|
||||||
//show details of selected block, with costs
|
//show details of selected block, with costs
|
||||||
if(displayBlock != null){
|
if(displayBlock != null){
|
||||||
|
|||||||
Reference in New Issue
Block a user