mirror of
https://github.com/Quackster/Havana.git
synced 2025-07-04 05:37:47 +00:00
add door flag for not allowing pet to walk to the door
This commit is contained in:
parent
a39cef9507
commit
67b8686257
3 changed files with 11 additions and 8 deletions
|
@ -51,7 +51,7 @@ public class BotCommand extends Command {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Position bound = room.getMapping().getRandomWalkableBound(bot);
|
Position bound = room.getMapping().getRandomWalkableBound(bot, false);
|
||||||
|
|
||||||
if (bound != null)
|
if (bound != null)
|
||||||
room.getEntityManager().enterRoom(bot, bound);
|
room.getEntityManager().enterRoom(bot, bound);
|
||||||
|
@ -59,7 +59,7 @@ public class BotCommand extends Command {
|
||||||
|
|
||||||
room.getTaskManager().scheduleTask("BotCommandTask", ()-> {
|
room.getTaskManager().scheduleTask("BotCommandTask", ()-> {
|
||||||
for (Bot bot : room.getEntityManager().getEntitiesByClass(Bot.class)) {
|
for (Bot bot : room.getEntityManager().getEntitiesByClass(Bot.class)) {
|
||||||
Position newBound = room.getMapping().getRandomWalkableBound(bot);
|
Position newBound = room.getMapping().getRandomWalkableBound(bot, false);
|
||||||
|
|
||||||
if (newBound != null) {
|
if (newBound != null) {
|
||||||
bot.getRoomUser().walkTo(newBound.getX(), newBound.getY());
|
bot.getRoomUser().walkTo(newBound.getX(), newBound.getY());
|
||||||
|
|
|
@ -593,10 +593,7 @@ public class RoomMapping {
|
||||||
return this.roomMap[x][y];
|
return this.roomMap[x][y];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position getRandomWalkableBound(Entity entity) {
|
public Position getRandomWalkableBound(Entity entity, boolean allowDoorBound) {
|
||||||
Position position = null;
|
|
||||||
|
|
||||||
boolean isWalkable = false;
|
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
int maxAttempts = 10;
|
int maxAttempts = 10;
|
||||||
|
|
||||||
|
@ -605,7 +602,13 @@ public class RoomMapping {
|
||||||
|
|
||||||
int randomX = this.room.getModel().getRandomBound(0);
|
int randomX = this.room.getModel().getRandomBound(0);
|
||||||
int randomY = this.room.getModel().getRandomBound(1);
|
int randomY = this.room.getModel().getRandomBound(1);
|
||||||
position = new Position(randomX, randomY);
|
|
||||||
|
var position = new Position(randomX, randomY);
|
||||||
|
|
||||||
|
if (!allowDoorBound) {
|
||||||
|
if (position.equals(this.room.getModel().getDoorLocation()))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (RoomTile.isValidTile(this.room, entity, position)) {
|
if (RoomTile.isValidTile(this.room, entity, position)) {
|
||||||
return position;
|
return position;
|
||||||
|
|
|
@ -304,7 +304,7 @@ public class EntityTask implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Position availableTile = this.room.getMapping().getRandomWalkableBound(pet);
|
Position availableTile = this.room.getMapping().getRandomWalkableBound(pet, false);
|
||||||
|
|
||||||
if (availableTile != null) {
|
if (availableTile != null) {
|
||||||
pet.getRoomUser().walkTo(availableTile.getX(), availableTile.getY());
|
pet.getRoomUser().walkTo(availableTile.getX(), availableTile.getY());
|
||||||
|
|
Loading…
Add table
Reference in a new issue