From f77cf29567debc29d12574977ce517b80fd0570f Mon Sep 17 00:00:00 2001 From: DBotThePony <dbotthepony@yandex.ru> Date: Sat, 10 Aug 2024 19:07:45 +0700 Subject: [PATCH] nextRange for floats --- .../ru/dbotthepony/kstarbound/util/random/RandomUtils.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/util/random/RandomUtils.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/util/random/RandomUtils.kt index 45b064c1..39de2880 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/util/random/RandomUtils.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/util/random/RandomUtils.kt @@ -5,6 +5,7 @@ import com.google.gson.JsonElement import it.unimi.dsi.fastutil.bytes.ByteConsumer import org.classdump.luna.ByteString import ru.dbotthepony.kommons.util.IStruct2d +import ru.dbotthepony.kommons.util.IStruct2f import ru.dbotthepony.kommons.util.IStruct2i import ru.dbotthepony.kommons.util.XXHash32 import ru.dbotthepony.kommons.util.XXHash64 @@ -263,6 +264,10 @@ fun RandomGenerator.nextRange(range: IStruct2d): Double { return if (range.component1() == range.component2()) return range.component1() else nextDouble(range.component1(), range.component2()) } +fun RandomGenerator.nextRange(range: IStruct2f): Float { + return if (range.component1() == range.component2()) return range.component1() else nextFloat(range.component1(), range.component2()) +} + fun <T> MutableList<T>.shuffle(random: RandomGenerator) { for (i in 0 until size) { val rand = random.nextInt(size)