diff --git a/core/src/io/anuke/mindustry/ai/Pathfind.java b/core/src/io/anuke/mindustry/ai/Pathfind.java index e239913791..c8199f1e23 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfind.java +++ b/core/src/io/anuke/mindustry/ai/Pathfind.java @@ -22,12 +22,15 @@ public class Pathfind{ Vector2 vector = new Vector2(); public Vector2 find(Enemy enemy){ - if(enemy.node == -1){ + if(enemy.node == -1 || enemy.node == -2){ findNode(enemy); } if(enemy.path == null){ return vector.set(enemy.x, enemy.y); + }else if(enemy.node == -2){ + enemy.node = -1; + enemy.findClosestNode(); } //-1 is only possible here if both pathfindings failed, which should NOT happen @@ -35,7 +38,6 @@ public class Pathfind{ Tile[] path = enemy.path; - //REPRODUCE BUG: load in test map, then load save 1? Tile prev = path[enemy.node - 1]; Tile target = path[enemy.node]; @@ -92,9 +94,7 @@ public class Pathfind{ public void updatePath(){ for(SpawnPoint point : Vars.control.getSpawnPoints()){ - if(point.finder == null){ - point.finder = new IndexedAStarPathFinder(graph); - } + point.finder = new IndexedAStarPathFinder(graph); point.path.clear(); @@ -103,47 +103,10 @@ public class Pathfind{ point.request = new PathFinderRequest(point.start, Vars.control.getCore(), heuristic, point.path); point.request.statusChanged = true; //IMPORTANT! } - - /* - if(paths.size == 0 || paths.size != World.spawnpoints.size){ - paths.clear(); - finders.clear(); - pathSequences = new Tile[World.spawnpoints.size][0]; - for(int i = 0; i < World.spawnpoints.size; i ++){ - SmoothGraphPath path = new SmoothGraphPath(); - paths.add(path); - finders.add(new IndexedAStarPathFinder(graph)); - } - } - - for(int i = 0; i < paths.size; i ++){ - SmoothGraphPath path = paths.get(i); - - path.clear(); - finders.get(i).searchNodePath( - World.spawnpoints.get(i), - World.core, heuristic, path); - - smoother.smoothPath(path); - - pathSequences[i] = new Tile[path.getCount()]; - - for(int node = 0; node < path.getCount(); node ++){ - Tile tile = path.get(node); - - pathSequences[i][node] = tile; - } - - - if(Vars.debug && Vars.showPaths) - for(Tile tile : path){ - Effects.effect(Fx.ind, tile.worldx(), tile.worldy()); - } - - }*/ } void findNode(Enemy enemy){ + if(Vars.control.getSpawnPoints().get(enemy.spawn).pathTiles == null){ return; } diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index c93d7add2d..507a847371 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -444,6 +444,10 @@ public class Control extends Module{ enemyGroup.clear(); } + if(Inputs.keyUp(Keys.F)){ + wavetime = 0f; + } + if(Inputs.keyUp(Keys.O)){ Vars.noclip = !Vars.noclip; } diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java index 91ba5b1e25..cf29ef468c 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java @@ -139,8 +139,6 @@ public class Enemy extends DestructibleEntity{ } public void findClosestNode(){ - Vars.world.pathfinder().find(this); - int index = 0; int cindex = -1; float dst = Float.MAX_VALUE; diff --git a/core/src/io/anuke/mindustry/io/SaveIO.java b/core/src/io/anuke/mindustry/io/SaveIO.java index 990ae1fac7..8358224742 100644 --- a/core/src/io/anuke/mindustry/io/SaveIO.java +++ b/core/src/io/anuke/mindustry/io/SaveIO.java @@ -372,7 +372,7 @@ public class SaveIO{ Vars.renderer.clearTiles(); for(Enemy enemy : enemiesToUpdate){ - enemy.findClosestNode(); + enemy.node = -2; } for(int x = 0; x < Vars.world.width(); x ++){ diff --git a/core/src/io/anuke/mindustry/world/World.java b/core/src/io/anuke/mindustry/world/World.java index 34a80075d6..3d92e17c57 100644 --- a/core/src/io/anuke/mindustry/world/World.java +++ b/core/src/io/anuke/mindustry/world/World.java @@ -155,12 +155,13 @@ public class World extends Module{ createTiles(); }else{ - tiles = new Tile[map.width][map.height]; createTiles(); } + Vars.control.getSpawnPoints().clear(); + Entities.resizeTree(0, 0, map.width * tilesize, map.height * tilesize); this.seed = seed; diff --git a/desktop/mindustry-saves/3.mins b/desktop/mindustry-saves/3.mins index 2b036dbabe..6b1bf4bd41 100644 Binary files a/desktop/mindustry-saves/3.mins and b/desktop/mindustry-saves/3.mins differ