Fixed some loading bugs

This commit is contained in:
Anuken 2017-11-26 22:53:41 -05:00
parent d9a66278ff
commit cb9acb7a52
6 changed files with 13 additions and 47 deletions

View File

@ -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<Tile>(graph);
}
point.finder = new IndexedAStarPathFinder<Tile>(graph);
point.path.clear();
@ -103,47 +103,10 @@ public class Pathfind{
point.request = new PathFinderRequest<Tile>(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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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 ++){

View File

@ -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;

Binary file not shown.