diff --git a/core/src/com/unciv/logic/map/MapGenerator.kt b/core/src/com/unciv/logic/map/MapGenerator.kt index 5da27f68eb..b5b04500a5 100644 --- a/core/src/com/unciv/logic/map/MapGenerator.kt +++ b/core/src/com/unciv/logic/map/MapGenerator.kt @@ -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 { + // 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 + ) + } + } + } +} \ No newline at end of file