fix: fix terrible vector handling

This commit is contained in:
punchready 2021-07-19 14:36:18 +02:00
parent e9b4bc5f58
commit 996addcaf8
2 changed files with 5 additions and 3 deletions

View File

@ -79,7 +79,9 @@ public class IntVector2 implements Serializable {
}
public IntVector2 sub(int x, int y) {
return new IntVector2(this.x - x, this.y - y);
this.x -= x;
this.y -= y;
return this;
}
public IntVector2 sub(IntVector2 v) {

View File

@ -711,7 +711,7 @@ public class GameLogic {
}
for(IntVector2 dir: IntVector2.CardinalDirections) {
IntVector2 pos = start.add(dir);
IntVector2 pos = start.copy().add(dir);
if(pos.getX() < 0 || pos.getX() >= state.mapSize.getX() || pos.getY() < 0 || pos.getY() >= state.mapSize.getY()) {
return options;
}
@ -721,7 +721,7 @@ public class GameLogic {
}
if(options.size() == 0) {
return getFreeNeighbour(state, start.add(IntVector2.CardinalDirections[rand.nextInt(IntVector2.CardinalDirections.length)]));
return getFreeNeighbour(state, start.copy().add(IntVector2.CardinalDirections[rand.nextInt(IntVector2.CardinalDirections.length)]));
}else {
return options;
}