Improves getNeighbours greatly

This commit is contained in:
2018-03-14 14:00:48 +01:00
parent 6a21332877
commit d4c7d08df7
9 changed files with 153 additions and 138 deletions

View File

@@ -397,7 +397,9 @@ public class Game implements IGame {
}
public void draw() {
map.draw(painter, printer);
//map.draw(painter, printer);
GameMap aMap = (GameMap) map;
aMap.drawVisible(painter, printer, this);
}
@Override
@@ -471,20 +473,17 @@ public class Game implements IGame {
@Override
public List<ILocation> getVisible() {
List<ILocation> neighbours = map.getNeighbourhood(currentLocation, currentActor.getVision());
List<ILocation> valid = new ArrayList<>();
List<ILocation> invalid = new ArrayList<>();
for (ILocation neighbour : neighbours) {
boolean blocked = false;
for (ILocation tile : currentLocation.gridLineTo(neighbour)) {
if (map.hasWall(tile)) {
blocked = true;
invalid.add(neighbour);
break;
}
}
if (!blocked) {
valid.add(neighbour);
}
}
return valid;
neighbours.removeAll(invalid);
return neighbours;
}
@Override