Skip to content

Commit 045ec59

Browse files
committed
feature: Add ChainGridPositionGenerator
1 parent 57a9594 commit 045ec59

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.noxcrew.interfaces.grid
2+
3+
/** A grid position generator that chains together two other generators. */
4+
public data class ChainGridPositionGenerator(
5+
/** The first generator. */
6+
private val first: GridPositionGenerator,
7+
/** The second generator. */
8+
private val second: GridPositionGenerator,
9+
) : GridPositionGenerator {
10+
11+
public companion object {
12+
/** Adds two grid position generators together. */
13+
public operator fun GridPositionGenerator.plus(second: GridPositionGenerator): ChainGridPositionGenerator =
14+
ChainGridPositionGenerator(this, second)
15+
}
16+
17+
override fun generate(): List<GridPoint> {
18+
return first.generate() + second.generate()
19+
}
20+
}

0 commit comments

Comments
 (0)