Added a river coordinate system - it's just far enough from the tile oordinate system to be incredibly annoying

This commit is contained in:
Yair Morgenstern 2020-05-31 17:05:35 +03:00
parent e81e048169
commit 844cdcb821

View file

@ -741,3 +741,28 @@ class MapGenerator(val ruleset: Ruleset) {
// endregion
}
}
class RiverGenerator(){
public class RiverCoordinate(val position: Vector2, val bottomRightOrLeft:BottomRightOrLeft){
enum class BottomRightOrLeft{
BottomLeft, BottomRight
}
fun getAdjacentPositions(): Sequence<RiverCoordinate> {
// What's nice is that adjacents are always the OPPOSITE in terms of right-left - rights are adjacent to only lefts, and vice-versa
// This means that a lot of obviously-wrong assignments are simple to spot
if (bottomRightOrLeft == BottomRightOrLeft.BottomLeft) {
return sequenceOf(RiverCoordinate(position, BottomRightOrLeft.BottomRight), // same tile, other side
RiverCoordinate(position.cpy().add(1f,0f), BottomRightOrLeft.BottomRight), // tile to MY top-left, take its bottom right corner
RiverCoordinate(position.cpy().add(0f,-1f), BottomRightOrLeft.BottomRight) // Tile to MY bottom-left, take its bottom right
)
} else {
return sequenceOf(RiverCoordinate(position, BottomRightOrLeft.BottomLeft), // same tile, other side
RiverCoordinate(position.cpy().add(0f,1f), BottomRightOrLeft.BottomLeft), // tile to MY top-right, take its bottom left
RiverCoordinate(position.cpy().add(-1f,0f), BottomRightOrLeft.BottomLeft) // tile to MY bottom-right, take its bottom left
)
}
}
}
}