fix: prevent getFreeNeighbour from choosing positions outside of the map
This commit is contained in:
parent
a7b0514bd8
commit
70529f04d8
@ -711,8 +711,12 @@ public class GameLogic {
|
||||
}
|
||||
|
||||
for(IntVector2 dir: IntVector2.CardinalDirections) {
|
||||
if(state.entities.findByPosition(start.add(dir)).size() == 0) {
|
||||
options.add(start.add(dir));
|
||||
IntVector2 pos = start.add(dir);
|
||||
if(pos.getX() < 0 || pos.getX() >= state.mapSize.getX() || pos.getY() < 0 || pos.getY() >= state.mapSize.getY()) {
|
||||
return options;
|
||||
}
|
||||
if(state.entities.findByPosition(pos).size() == 0) {
|
||||
options.add(pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user