Do not cancel navigation if overriding path is non-existent

This commit is contained in:
Alejandro 2020-02-06 01:06:49 +02:00
parent 4389d7e18f
commit b87cbd398b
2 changed files with 7 additions and 5 deletions

View File

@ -317,7 +317,7 @@ public class RoomLayout {
return this.findPath(oldTile, newTile, goalLocation, roomUnit, true); return this.findPath(oldTile, newTile, goalLocation, roomUnit, true);
} }
return new LinkedList<>(); return null;
} }
private RoomTile findTile(List<RoomTile> tiles, short x, short y) { private RoomTile findTile(List<RoomTile> tiles, short x, short y) {

View File

@ -177,6 +177,9 @@ public class RoomUnit {
} }
Deque<RoomTile> peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this); Deque<RoomTile> peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this);
if (peekPath == null) peekPath = new LinkedList<>();
if (peekPath.size() >= 3) { if (peekPath.size() >= 3) {
if (path.isEmpty()) return true; if (path.isEmpty()) return true;
@ -543,10 +546,9 @@ public class RoomUnit {
public void findPath() public void findPath()
{ {
if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) {
{ Deque<RoomTile> path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
if (path != null) this.path = path;
this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
} }
} }