-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
317 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
src/main/kotlin/io/github/addoncommunity/galactifun/scripting/dsl/gen/AbstractPerlin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
package io.github.addoncommunity.galactifun.scripting.dsl.gen | ||
|
||
import io.github.addoncommunity.galactifun.scripting.PlanetDsl | ||
import io.github.addoncommunity.galactifun.scripting.RequiredProperty | ||
|
||
abstract class AbstractPerlin : GeneratorBuilder() { | ||
var generateBedrock = true | ||
|
||
var averageHeight: Int by RequiredProperty() | ||
var maxDeviation: Int by RequiredProperty() | ||
var minHeight: Int by RequiredProperty() | ||
var minY = Int.MIN_VALUE | ||
var surfaceHeight = 10 | ||
|
||
@PlanetDsl | ||
class PerlinConfig { | ||
var octaves: Int = 8 | ||
var scale: Double by RequiredProperty() | ||
var amplitude: Double by RequiredProperty() | ||
var frequency: Double by RequiredProperty() | ||
|
||
var flattenFactor: Double = 1.0 | ||
var smoothen: Boolean = false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/kotlin/io/github/addoncommunity/galactifun/scripting/dsl/gen/SimpleBlocksBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.github.addoncommunity.galactifun.scripting.dsl.gen | ||
|
||
import io.github.addoncommunity.galactifun.scripting.PlanetDsl | ||
import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.RandomizedSet | ||
import org.bukkit.Material | ||
|
||
|
||
typealias BlockProvider = SimplePerlinBuilder.GenInfo.() -> Material | ||
|
||
@PlanetDsl | ||
class SimpleBlocksBuilder { | ||
|
||
var top = mutableListOf<BlockProvider>() | ||
var bottom = mutableListOf<BlockProvider>() | ||
var middle: BlockProvider = { Material.AIR } | ||
|
||
private fun addN(n: Int, list: MutableList<BlockProvider>, block: BlockProvider) { | ||
repeat(n) { | ||
list.add(block) | ||
} | ||
} | ||
|
||
infix fun BlockProvider.top(n: Int) = addN(n, top, this) | ||
|
||
infix fun Material.top(n: Int) = addN(n, top) { this@top } | ||
|
||
infix fun BlockProvider.bottom(n: Int) = addN(n, bottom, this) | ||
|
||
infix fun Material.bottom(n: Int) = addN(n, bottom) { this@bottom } | ||
|
||
@PlanetDsl | ||
class RandomBuilder { | ||
internal val selector = RandomizedSet<Material>() | ||
|
||
infix fun Material.withWeight(weight: Float) { | ||
selector.add(this, weight) | ||
} | ||
} | ||
} | ||
|
||
fun SimpleBlocksBuilder.fillInRestWith(block: BlockProvider) { | ||
middle = block | ||
} | ||
|
||
fun SimpleBlocksBuilder.fillInRestWith(material: Material) { | ||
middle = { material } | ||
} | ||
|
||
fun SimpleBlocksBuilder.random(block: SimpleBlocksBuilder.RandomBuilder.() -> Unit): BlockProvider { | ||
val builder = SimpleBlocksBuilder.RandomBuilder() | ||
builder.block() | ||
return { | ||
builder.selector.getRandom(random) | ||
} | ||
} |
Oops, something went wrong.