Skip to content

Commit e1b50de

Browse files
committed
Don't allow door coordinate for pet path
1 parent d896b9e commit e1b50de

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Diff for: Kepler-Server/src/main/java/org/alexdev/kepler/game/room/mapping/RoomMapping.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.alexdev.kepler.game.room.mapping;
22

3+
import org.alexdev.kepler.game.entity.EntityType;
34
import org.alexdev.kepler.game.player.Player;
45
import org.alexdev.kepler.game.entity.Entity;
56
import org.alexdev.kepler.game.item.Item;
@@ -489,10 +490,7 @@ public RoomTile getTile(int x, int y) {
489490
return this.roomMap[x][y];
490491
}
491492

492-
public Position getRandomWalkableBound(Entity entity) {
493-
Position position = null;
494-
495-
boolean isWalkable = false;
493+
public Position getRandomWalkableBound(Entity entity, boolean allowDoorBound) {
496494
int attempts = 0;
497495
int maxAttempts = 10;
498496

@@ -501,7 +499,13 @@ public Position getRandomWalkableBound(Entity entity) {
501499

502500
int randomX = this.room.getModel().getRandomBound(0);
503501
int randomY = this.room.getModel().getRandomBound(1);
504-
position = new Position(randomX, randomY);
502+
503+
var position = new Position(randomX, randomY);
504+
505+
if (!allowDoorBound) {
506+
if (position.equals(this.room.getModel().getDoorLocation()))
507+
continue;
508+
}
505509

506510
if (RoomTile.isValidTile(this.room, entity, position)) {
507511
return position;

Diff for: Kepler-Server/src/main/java/org/alexdev/kepler/game/room/tasks/EntityTask.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private void processPet(Pet pet) {
296296
}
297297

298298

299-
Position availableTile = this.room.getMapping().getRandomWalkableBound(pet);
299+
Position availableTile = this.room.getMapping().getRandomWalkableBound(pet, false);
300300

301301
if (availableTile != null) {
302302
pet.getRoomUser().walkTo(availableTile.getX(), availableTile.getY());

0 commit comments

Comments
 (0)