File tree 2 files changed +10
-6
lines changed
Kepler-Server/src/main/java/org/alexdev/kepler/game/room
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 1
1
package org .alexdev .kepler .game .room .mapping ;
2
2
3
+ import org .alexdev .kepler .game .entity .EntityType ;
3
4
import org .alexdev .kepler .game .player .Player ;
4
5
import org .alexdev .kepler .game .entity .Entity ;
5
6
import org .alexdev .kepler .game .item .Item ;
@@ -489,10 +490,7 @@ public RoomTile getTile(int x, int y) {
489
490
return this .roomMap [x ][y ];
490
491
}
491
492
492
- public Position getRandomWalkableBound (Entity entity ) {
493
- Position position = null ;
494
-
495
- boolean isWalkable = false ;
493
+ public Position getRandomWalkableBound (Entity entity , boolean allowDoorBound ) {
496
494
int attempts = 0 ;
497
495
int maxAttempts = 10 ;
498
496
@@ -501,7 +499,13 @@ public Position getRandomWalkableBound(Entity entity) {
501
499
502
500
int randomX = this .room .getModel ().getRandomBound (0 );
503
501
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
+ }
505
509
506
510
if (RoomTile .isValidTile (this .room , entity , position )) {
507
511
return position ;
Original file line number Diff line number Diff line change @@ -296,7 +296,7 @@ private void processPet(Pet pet) {
296
296
}
297
297
298
298
299
- Position availableTile = this .room .getMapping ().getRandomWalkableBound (pet );
299
+ Position availableTile = this .room .getMapping ().getRandomWalkableBound (pet , false );
300
300
301
301
if (availableTile != null ) {
302
302
pet .getRoomUser ().walkTo (availableTile .getX (), availableTile .getY ());
You can’t perform that action at this time.
0 commit comments