Improves getNeighbours greatly
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user