Skip to content

Commit

Permalink
feature: Add ChainGridPositionGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
kezz committed Sep 18, 2024
1 parent 57a9594 commit 045ec59
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.noxcrew.interfaces.grid

/** A grid position generator that chains together two other generators. */
public data class ChainGridPositionGenerator(
/** The first generator. */
private val first: GridPositionGenerator,
/** The second generator. */
private val second: GridPositionGenerator,
) : GridPositionGenerator {

public companion object {
/** Adds two grid position generators together. */
public operator fun GridPositionGenerator.plus(second: GridPositionGenerator): ChainGridPositionGenerator =
ChainGridPositionGenerator(this, second)
}

override fun generate(): List<GridPoint> {
return first.generate() + second.generate()
}
}

0 comments on commit 045ec59

Please sign in to comment.