[orx-noise] isolated method for non-stateful rng (#155)

This commit is contained in:
Ricardo Matias
2021-01-03 11:45:17 +01:00
committed by GitHub
parent b6dcfde772
commit c12a5015e0

View File

@@ -54,6 +54,18 @@ object Random {
seed = "${seedBase}-${seedTracking}"
}
fun isolated(fn: Random.() -> Unit) {
val state = rnd
val currentSeed = seed
resetState()
this.fn()
seed = currentSeed
rnd = state
}
fun double(min: Double = -1.0, max: Double = 1.0): Double {
return Double.uniform(min, max, rnd)
}