diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index b48e0ccc96..5b005dae89 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -1297,6 +1297,7 @@ public class Blocks implements ContentList{ drillEffect = Fx.mineHuge; rotateSpeed = 6f; warmupSpeed = 0.01f; + itemCapacity = 20; //more than the laser drill liquidBoostIntensity = 1.8f; diff --git a/core/src/mindustry/game/SectorInfo.java b/core/src/mindustry/game/SectorInfo.java index 4d2b20b9cc..45af10f817 100644 --- a/core/src/mindustry/game/SectorInfo.java +++ b/core/src/mindustry/game/SectorInfo.java @@ -1,5 +1,6 @@ package mindustry.game; +import arc.func.*; import arc.math.*; import arc.struct.*; import arc.util.*; @@ -21,6 +22,7 @@ public class SectorInfo{ private static final int valueWindow = 60; /** refresh period of export in ticks */ private static final float refreshPeriod = 60; + private static float returnf; /** Core input statistics. */ public ObjectMap production = new ObjectMap<>(); @@ -265,23 +267,29 @@ public class SectorInfo{ 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. */ //TODO this can be a float map - public ObjectMap importStats(){ + public ObjectMap importStats(Planet planet){ ObjectMap imports = new ObjectMap<>(); - //for all sectors on all planets that have bases and export to this sector - for(Planet planet : content.planets()){ - for(Sector sector : planet.sectors){ - Sector dest = sector.info.getRealDestination(); - if(sector.hasBase() && sector.info != this && dest != null && dest.info == this){ - //add their exports to our imports - sector.info.export.each((item, stat) -> { - imports.get(item, ExportStat::new).mean += stat.mean; - }); - } + eachImport(planet, sector -> sector.info.export.each((item, stat) -> imports.get(item, ExportStat::new).mean += stat.mean)); + return imports; + } + + /** Iterates through every sector this one imports from. */ + public void eachImport(Planet planet, Cons cons){ + for(Sector sector : planet.sectors){ + 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{ diff --git a/core/src/mindustry/io/JsonIO.java b/core/src/mindustry/io/JsonIO.java index 9f51b32cb0..3e6beb26e8 100644 --- a/core/src/mindustry/io/JsonIO.java +++ b/core/src/mindustry/io/JsonIO.java @@ -214,7 +214,8 @@ public class JsonIO{ String str = jsonData.asString(); Item item = Vars.content.getByName(ContentType.item, 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; } }); diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 7aea305426..da5ca2229a 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -11,6 +11,7 @@ import arc.util.*; import mindustry.*; import mindustry.game.Saves.*; import mindustry.game.*; +import mindustry.gen.*; import mindustry.graphics.g3d.PlanetGrid.*; import mindustry.ui.*; 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); } + @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(){ return save != null && !info.waves; } diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 6ec88d38af..7dfae6246a 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -371,6 +371,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ } if(selectAlpha > 0.001f){ + + for(Sector sec : planet.sectors){ if(sec.hasBase()){ 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); } } + + + 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 stats, String name){ + displayItems(c, scl, stats, name, t -> {}); + } + + void displayItems(Table c, float scl, ObjectMap stats, String name, Cons builder){ Table t = new Table().left(); int i = 0; @@ -622,8 +640,10 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ } if(t.getChildren().any()){ - c.add(name).left().row(); - c.add(t).padLeft(10f).left().row(); + c.defaults().left(); + 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"); //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 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(); diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index b81f6a34f8..04684a2b70 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -15,6 +15,7 @@ import mindustry.core.*; import mindustry.entities.*; import mindustry.entities.units.*; import mindustry.game.EventType.*; +import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.input.*; @@ -38,6 +39,7 @@ public class PlacementFragment extends Fragment{ Block menuHoverBlock; Displayable hover; Object lastDisplayState; + Team lastTeam; boolean wasHovered; Table blockTable, toggler, topTable; ScrollPane blockPane; @@ -283,13 +285,14 @@ public class PlacementFragment extends Fragment{ //don't refresh unnecessarily //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.top().left().margin(5); lastDisplayState = displayState; wasHovered = isHovered; + lastTeam = player.team(); //show details of selected block, with costs if(displayBlock != null){