diff --git a/core/src/io/anuke/mindustry/ai/OptimizedPathFinder.java b/core/src/io/anuke/mindustry/ai/OptimizedPathFinder.java index 006d63a546..8cb177b051 100644 --- a/core/src/io/anuke/mindustry/ai/OptimizedPathFinder.java +++ b/core/src/io/anuke/mindustry/ai/OptimizedPathFinder.java @@ -2,12 +2,14 @@ package io.anuke.mindustry.ai; import com.badlogic.gdx.ai.pfa.*; import com.badlogic.gdx.utils.BinaryHeap; +import com.badlogic.gdx.utils.IntMap; import com.badlogic.gdx.utils.TimeUtils; /**An IndexedAStarPathfinder that uses an OptimizedGraph, and therefore has less allocations.*/ public class OptimizedPathFinder implements PathFinder { OptimizedGraph graph; - NodeRecord[] nodeRecords; + //NodeRecord[] nodeRecords; //TODO remove. + IntMap> records = new IntMap<>(); BinaryHeap> openList; NodeRecord current; @@ -23,22 +25,13 @@ public class OptimizedPathFinder implements PathFinder { @SuppressWarnings("unchecked") public OptimizedPathFinder(OptimizedGraph graph) { this.graph = graph; - this.nodeRecords = (NodeRecord[]) new NodeRecord[graph.getNodeCount()]; + //this.nodeRecords = (NodeRecord[]) new NodeRecord[graph.getNodeCount()]; this.openList = new BinaryHeap<>(); } @Override public boolean searchConnectionPath(N startNode, N endNode, Heuristic heuristic, GraphPath> outPath) { - - // Perform AStar - boolean found = search(startNode, endNode, heuristic); - - if (found) { - // Create a path made of connections - generateConnectionPath(startNode, outPath); - } - - return found; + return false; } @Override @@ -196,27 +189,13 @@ public class OptimizedPathFinder implements PathFinder { } - protected void generateConnectionPath(N startNode, GraphPath> outPath) { - //do ABSOLUTELY NOTHING - /* - // Work back along the path, accumulating connections - // outPath.clear(); - while (current.node != startNode) { - outPath.add(current.connection); - current = nodeRecords[graph.getIndex(current.connection.getFromNode())]; - } - - // Reverse the path - outPath.reverse();*/ - } - protected void generateNodePath(N startNode, GraphPath outPath) { // Work back along the path, accumulating nodes // outPath.clear(); while (current.from != null) { outPath.add(current.node); - current = nodeRecords[graph.getIndex(current.from)]; + current = records.get(graph.getIndex(current.from)); } outPath.add(startNode); @@ -230,6 +209,16 @@ public class OptimizedPathFinder implements PathFinder { } protected NodeRecord getNodeRecord(N node) { + if(!records.containsKey(graph.getIndex(node))){ + NodeRecord record = new NodeRecord<>(); + record.node = node; + record.searchId = searchId; + records.put(graph.getIndex(node), record); + return record; + }else{ + return records.get(graph.getIndex(node)); + } + /* int index = graph.getIndex(node); NodeRecord nr = nodeRecords[index]; if (nr != null) { @@ -242,7 +231,7 @@ public class OptimizedPathFinder implements PathFinder { nr = nodeRecords[index] = new NodeRecord<>(); nr.node = node; nr.searchId = searchId; - return nr; + return nr;*/ } /** diff --git a/core/src/io/anuke/mindustry/ai/Pathfind.java b/core/src/io/anuke/mindustry/ai/Pathfind.java index 61e8356444..1bdeec41b7 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfind.java +++ b/core/src/io/anuke/mindustry/ai/Pathfind.java @@ -127,6 +127,7 @@ public class Pathfind{ if(point.finder.search(point.request, maxTime)){ smoother.smoothPath(point.path); point.pathTiles = point.path.nodes.toArray(Tile.class); + point.finder = null; } }catch (ArrayIndexOutOfBoundsException e){ //no path diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index 0ae9e87f2a..58583fb4f4 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -421,11 +421,9 @@ public class Control extends Module{ Timers.run(i*2, ()-> Effects.effect(Fx.explosion, core.worldx()+Mathf.range(40), core.worldy()+Mathf.range(40))); } Effects.effect(Fx.coreexplosion, core.worldx(), core.worldy()); - - Timers.run(60, () -> { - ui.restart.show(); - if(Net.active() && Net.server()) netServer.handleGameOver(); - }); + + ui.restart.show(); + if(Net.active() && Net.server()) netServer.handleGameOver(); } public boolean isGameOver(){ @@ -613,7 +611,7 @@ public class Control extends Module{ } if(Inputs.keyTap(Keys.G)){ - addItem(Item.stone, 1000); + Vars.world.pathfinder().benchmark(); } if(Inputs.keyDown(Keys.I)){ @@ -645,6 +643,10 @@ public class Control extends Module{ if(!GameState.is(State.menu)){ input.update(); + + if(core.block() != ProductionBlocks.core && !ui.restart.isShown()){ + coreDestroyed(); + } if(Inputs.keyTap("pause") && !ui.restart.isShown() && !Net.active() && (GameState.is(State.paused) || GameState.is(State.playing))){ GameState.set(GameState.is(State.playing) ? State.paused : State.playing); diff --git a/core/src/io/anuke/mindustry/game/EnemySpawn.java b/core/src/io/anuke/mindustry/game/EnemySpawn.java index 632f027a61..bd44b16520 100644 --- a/core/src/io/anuke/mindustry/game/EnemySpawn.java +++ b/core/src/io/anuke/mindustry/game/EnemySpawn.java @@ -20,7 +20,7 @@ public class EnemySpawn{ /**The tier this spawn starts at.*/ protected int tier = 1; /**Maximum amount of enemies that spawn*/ - protected int max = 17; + protected int max = 60; /**How many waves need to pass before the amount of enemies increases by 1*/ protected float scaling = 9999f; /**Amount of enemies spawned initially, with no scaling*/ diff --git a/core/src/io/anuke/mindustry/world/Map.java b/core/src/io/anuke/mindustry/world/Map.java index ab71636812..e07ccd8205 100644 --- a/core/src/io/anuke/mindustry/world/Map.java +++ b/core/src/io/anuke/mindustry/world/Map.java @@ -11,6 +11,7 @@ public class Map{ public boolean visible = true; public boolean flipBase = false; public boolean custom = false; + public boolean oreGen = true; public Color backgroundColor = Color.valueOf("646464"); public transient Pixmap pixmap; diff --git a/core/src/io/anuke/mindustry/world/WorldGenerator.java b/core/src/io/anuke/mindustry/world/WorldGenerator.java index 048519d6b4..2140c46d4c 100644 --- a/core/src/io/anuke/mindustry/world/WorldGenerator.java +++ b/core/src/io/anuke/mindustry/world/WorldGenerator.java @@ -57,8 +57,8 @@ public class WorldGenerator { block = rocks.get(floor); } - if(floor == Blocks.stone || floor == Blocks.grass || floor == Blocks.blackstone || - floor == Blocks.snow || floor == Blocks.sand){ + if(Vars.world.getMap().oreGen && (floor == Blocks.stone || floor == Blocks.grass || floor == Blocks.blackstone || + floor == Blocks.snow || floor == Blocks.sand)){ if(Noise.nnoise(x, y, 8, 1) > 0.21){ floor = Blocks.iron; }