From d72153c67a17d547d3ddc8f247a59a732d649a09 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 13 Feb 2022 11:09:27 -0500 Subject: [PATCH] Logic fixes / Bigger erekir sectors --- android/build.gradle | 7 +- .../sprites/blocks/logic/world-cell.png | Bin 0 -> 373 bytes core/src/mindustry/ai/ControlPathfinder.java | 6 +- core/src/mindustry/content/Blocks.java | 10 ++- core/src/mindustry/core/World.java | 2 +- .../mindustry/graphics/MinimapRenderer.java | 2 +- core/src/mindustry/logic/LExecutor.java | 16 ++-- .../maps/generators/PlanetGenerator.java | 16 ++-- .../maps/planet/ErekirPlanetGenerator.java | 76 +++++++++++++++++- .../ui/dialogs/LaunchLoadoutDialog.java | 10 ++- .../mindustry/ui/dialogs/PlanetDialog.java | 2 +- core/src/mindustry/world/Block.java | 2 + core/src/mindustry/world/Tile.java | 10 +++ .../world/blocks/logic/LogicBlock.java | 3 +- .../world/blocks/logic/MemoryBlock.java | 16 ++++ 15 files changed, 147 insertions(+), 31 deletions(-) create mode 100644 core/assets-raw/sprites/blocks/logic/world-cell.png diff --git a/android/build.gradle b/android/build.gradle index 586efca310..5792f9a7de 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -94,11 +94,12 @@ android{ buildTypes{ all{ + //TODO without these lines (r8 enabled), Mindustry crashes with missing default interface method errors. + //WHY THE HELL ARE DEFAULT INTERFACES NOT BEING DESUGARED? WHY DID UPDATING AGP MAKE THIS HAPPEN? + //When I ENABLE shrinking, r8 goes and REMOVES ALL DEFAULT INTERFACE CLASSES, which breaks mods. Why? + //-keep class mindustry.** { *; } should *keep the classes* - WHY IS R8 REMOVING THEM? minifyEnabled = true shrinkResources = true - //this is the ONLY WAY I could find to force r8 to keep its filthy hands off of my default interfaces. - //may have undesirable side effects - debuggable = true proguardFiles("proguard-rules.pro") } } diff --git a/core/assets-raw/sprites/blocks/logic/world-cell.png b/core/assets-raw/sprites/blocks/logic/world-cell.png new file mode 100644 index 0000000000000000000000000000000000000000..67aba657a790277eafc79187eadd126ea25d7690 GIT binary patch literal 373 zcmV-*0gC>KP)Px$FG)l}R9J;$%qwX4&wvNqxqTU*G(n)Es*6{ii6Yaf07f0af=|-P%Yng(!2w0g zUvfWQ12;Z*#1PxJ?Ep^oI77h6%K?`Z$pD{OSRFu3%L$o@;Q(4#j?Zis^n8vU=P)p9 z;$#R-(3&d@3=9kmY5BQWWzp>;Di^>kCj}6z2X8JwH)v~z4xH^>aRo&kHn~|7C*uqW z7$CYFK(>IIYB54U<@jo%H4_8S%MJ82G~gxSr~^hFFzNt|a^Q%hC7Q^3iY&lvAE1_? zM27%+(Mv701nUAn|3HRK8`l#w7@HiSdVqm}$Pn=J4= 0 && y >= 0 && x < ww && y < wh){ if(solid(type, x + y * wwidth)) return true; @@ -455,7 +456,7 @@ public class ControlPathfinder{ } lastId = curId; - //re-do everything when world updates + //re-do everything when world updates, but keep the old path around if(Time.timeSinceMillis(lastTime) > 1000 * 3 && (worldUpdateId != lastWorldUpdate || !destination.epsilonEquals(lastDestination, 2f))){ lastTime = Time.millis(); lastWorldUpdate = worldUpdateId; @@ -466,7 +467,6 @@ public class ControlPathfinder{ long ns = Time.nanos(); int counter = 0; - //Log.info("running; @ in frontier", frontier.size); while(frontier.size > 0){ int current = frontier.poll(); diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index cc02c347eb..22ad2db42f 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -150,7 +150,7 @@ public class Blocks{ //logic message, switchBlock, microProcessor, logicProcessor, hyperProcessor, largeLogicDisplay, logicDisplay, memoryCell, memoryBank, - worldProcessor, + worldProcessor, worldCell, //campaign //TODO launch pad on erekir, 5x5, uses nuclear(?) fuel @@ -3853,7 +3853,6 @@ public class Blocks{ }}; worldProcessor = new LogicBlock("world-processor"){{ - //currently incomplete, debugOnly for now requirements(Category.logic, BuildVisibility.editorOnly, with()); //TODO customizable IPT @@ -3864,6 +3863,13 @@ public class Blocks{ size = 1; }}; + worldCell = new MemoryBlock("world-cell"){{ + requirements(Category.logic, BuildVisibility.editorOnly, with()); + + privileged = true; + memoryCapacity = 128; + }}; + //endregion } } \ No newline at end of file diff --git a/core/src/mindustry/core/World.java b/core/src/mindustry/core/World.java index 199d7c8195..8359dbcc18 100644 --- a/core/src/mindustry/core/World.java +++ b/core/src/mindustry/core/World.java @@ -504,7 +504,7 @@ public class World{ } if(state.hasSector() && state.getSector().preset == null){ - int circleBlend = 14; + int circleBlend = 7; //quantized angle float offset = state.getSector().rect.rotation + 90; float angle = Angles.angle(x, y, tiles.width/2, tiles.height/2) + offset; diff --git a/core/src/mindustry/graphics/MinimapRenderer.java b/core/src/mindustry/graphics/MinimapRenderer.java index bebc9ef035..c445842fe6 100644 --- a/core/src/mindustry/graphics/MinimapRenderer.java +++ b/core/src/mindustry/graphics/MinimapRenderer.java @@ -163,7 +163,7 @@ public class MinimapRenderer{ TextureRegion icon = Icon.units.getRegion(); - Lines.stroke(3f); + Lines.stroke(Scl.scl(3f)); Draw.color(state.rules.waveTeam.color, Tmp.c2.set(state.rules.waveTeam.color).value(1.2f), Mathf.absin(Time.time, 16f, 1f)); diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index 81563ad375..c01f993f83 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -1208,19 +1208,21 @@ public class LExecutor{ @Override public void run(LExecutor exec){ + if(net.client()) return; + Tile tile = world.tile(exec.numi(x), exec.numi(y)); if(tile != null && exec.obj(block) instanceof Block b){ //TODO this can be quite laggy... switch(layer){ case ore -> { - if(b instanceof OverlayFloor o) tile.setOverlay(o); + if(b instanceof OverlayFloor o) tile.setOverlayNet(o); } case floor -> { - if(b instanceof Floor f) tile.setFloor(f); + if(b instanceof Floor f) tile.setFloorNet(f); } case block -> { Team t = exec.obj(team) instanceof Team steam ? steam : Team.derelict; - tile.setBlock(b, t, Mathf.clamp(exec.numi(rotation), 0, 3)); + tile.setNet(b, t, Mathf.clamp(exec.numi(rotation), 0, 3)); } //building case not allowed } @@ -1230,7 +1232,6 @@ public class LExecutor{ public static class SpawnUnitI implements LInstruction{ public int type, x, y, rotation, team, result; - public boolean effect; public SpawnUnitI(int type, int x, int y, int rotation, int team, boolean effect, int result){ this.type = type; @@ -1238,7 +1239,6 @@ public class LExecutor{ this.y = y; this.rotation = rotation; this.team = team; - this.effect = effect; this.result = result; } @@ -1247,13 +1247,13 @@ public class LExecutor{ @Override public void run(LExecutor exec){ + if(net.client()) return; + if(exec.obj(type) instanceof UnitType type && !type.hidden && exec.obj(team) instanceof Team team && Units.canCreate(team, type)){ //random offset to prevent stacking var unit = type.spawn(team, World.unconv(exec.numf(x)) + Mathf.range(0.01f), World.unconv(exec.numf(y)) + Mathf.range(0.01f)); unit.rotation = exec.numf(rotation); - if(effect){ - spawner.spawnEffect(unit); - } + spawner.spawnEffect(unit); exec.setobj(result, unit); } } diff --git a/core/src/mindustry/maps/generators/PlanetGenerator.java b/core/src/mindustry/maps/generators/PlanetGenerator.java index cbf2ee44ff..18ea8a35eb 100644 --- a/core/src/mindustry/maps/generators/PlanetGenerator.java +++ b/core/src/mindustry/maps/generators/PlanetGenerator.java @@ -141,16 +141,20 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe this.tiles = tiles; this.seed = seed + baseSeed; this.sector = sec; + this.width = tiles.width; + this.height = tiles.height; this.rand.setSeed(sec.id + seed + baseSeed); TileGen gen = new TileGen(); - tiles.each((x, y) -> { - gen.reset(); - Vec3 position = sector.rect.project(x / (float)tiles.width, y / (float)tiles.height); + for(int y = 0; y < height; y++){ + for(int x = 0; x < width; x++){ + gen.reset(); + Vec3 position = sector.rect.project(x / (float)tiles.width, y / (float)tiles.height); - genTile(position, gen); - tiles.set(x, y, new Tile(x, y, gen.floor, gen.overlay, gen.block)); - }); + genTile(position, gen); + tiles.set(x, y, new Tile(x, y, gen.floor, gen.overlay, gen.block)); + } + } generate(tiles); } diff --git a/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java b/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java index 6f8f09ca3f..4fe328d18a 100644 --- a/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java +++ b/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java @@ -56,7 +56,8 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ @Override public float getSizeScl(){ - return 2000 * 1.06f; + //TODO should sectors be 600, or 500 blocks? + return 2000 * 1.07f * 6f / 5f; } @Override @@ -139,8 +140,50 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ } } + private @Nullable String lastSec; + + private void sec(String name){ + if(lastSec != null){ + float elapsed = Time.elapsed(); + Log.info("@: @ (@ sec)", lastSec.toUpperCase(), elapsed, Strings.fixed(elapsed / 1000f, 2)); + } + if(name != null){ + Time.mark(); + } + lastSec = name; + } + + //TODO remove + @Override + public void generate(Tiles tiles, Sector sec, int seed){ + this.tiles = tiles; + this.seed = seed + baseSeed; + this.sector = sec; + this.width = tiles.width; + this.height = tiles.height; + this.rand.setSeed(sec.id + seed + baseSeed); + + long begin = Time.millis(); + sec("genTile"); + + TileGen gen = new TileGen(); + for(int y = 0; y < height; y++){ + for(int x = 0; x < width; x++){ + gen.reset(); + Vec3 position = sector.rect.project(x / (float)tiles.width, y / (float)tiles.height); + + genTile(position, gen); + tiles.set(x, y, new Tile(x, y, gen.floor, gen.overlay, gen.block)); + } + } + + generate(tiles); + Log.info("TOTAL TILE: @ (@ sec)", Time.timeSinceMillis(begin), Strings.fixed(Time.timeSinceMillis(begin) / 1000f, 2)); + } + @Override protected void generate(){ + sec("tempPass"); float temp = rawTemp(sector.tile.v); if(temp > 0.7){ @@ -165,6 +208,8 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ }); } + sec("cells1"); + cells(4); //regolith walls for more dense terrain @@ -175,7 +220,6 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ }); //TODO: yellow regolith biome tweaks - //TODO: crystal biome on the dark side w/ terrain tweaks //TODO ice biome float length = width/3f; @@ -185,10 +229,14 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ endX = (int)(-trns.x + width/2f), endY = (int)(-trns.y + height/2f); float maxd = Mathf.dst(width/2f, height/2f); + sec("pathfinding"); + erase(spawnX, spawnY, 15); brush(pathfind(spawnX, spawnY, endX, endY, tile -> (tile.solid() ? 300f : 0f) + maxd - tile.dst(width/2f, height/2f)/10f, Astar.manhattan), 9); erase(endX, endY, 15); + sec("arkycite"); + //arkycite pass((x, y) -> { if(floor != Blocks.beryllicStone) return; @@ -211,19 +259,26 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ blend(Blocks.arkyciteFloor, Blocks.arkyicStone, 4); + sec("slag"); + //TODO may overwrite floor blocks under walls and look bad blend(Blocks.slag, Blocks.yellowStonePlates, 4); - distort(10f, 12f); + sec("distort"); + distort(10f, 12f); distort(5f, 7f); + sec("arkycite-slag-median"); + //does arkycite need smoothing? median(2, 0.6, Blocks.arkyciteFloor); //smooth out slag to prevent random 1-tile patches median(3, 0.6, Blocks.slag); + sec("details 1"); + pass((x, y) -> { //rough rhyolite if(noise(x, y + 600 + x, 5, 0.86f, 60f, 1f) < 0.41f && floor == Blocks.rhyolite){ @@ -240,6 +295,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ float max = 0; for(Point2 p : Geometry.d8){ + //TODO I think this is the cause of lag max = Math.max(max, world.getDarkness(x + p.x, y + p.y)); } if(max > 0){ @@ -256,11 +312,17 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ } }); + sec("inverse flood fill"); + inverseFloodFill(tiles.getn(spawnX, spawnY)); + sec("redStone"); + //TODO veins, blend after inverse flood fill? blend(Blocks.redStoneWall, Blocks.denseRedStone, 4); + sec("ores"); + //make sure enemies have room erase(endX, endY, 6); @@ -321,6 +383,8 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ //} }); + sec("trim dark"); + //remove props near ores, they're too annoying pass((x, y) -> { if(ore.asFloor().wallOre || block.itemDrop != null || (block == Blocks.air && ore != Blocks.air)){ @@ -330,6 +394,8 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ trimDark(); + sec("vents"); + int minVents = rand.random(6, 9); int ventCount = 0; @@ -437,6 +503,8 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ } } + sec("decoration"); + for(Tile tile : tiles){ if(tile.overlay().needsSurface && !tile.floor().hasSurface()){ tile.setOverlay(Blocks.air); @@ -456,5 +524,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ //all sectors are wave sectors state.rules.waves = true; state.rules.showSpawns = true; + + sec(""); } } diff --git a/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java b/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java index ded82fb471..0ec4b613d5 100644 --- a/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java +++ b/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java @@ -101,12 +101,20 @@ public class LaunchLoadoutDialog extends BaseDialog{ }); }).width(204); - buttons.button("@launch.text", Icon.ok, () -> { + boolean rows = Core.graphics.isPortrait() && mobile; + + if(rows) buttons.row(); + + var cell = buttons.button("@launch.text", Icon.ok, () -> { universe.updateLoadout(core, selected); confirm.run(); hide(); }).disabled(b -> !valid); + if(rows){ + cell.colspan(2).size(160f + 204f + 4f, 64f); + } + int cols = Math.max((int)(Core.graphics.getWidth() / Scl.scl(230)), 1); ButtonGroup