Starsector API
Loading...
Searching...
No Matches
Range.java
Go to the documentation of this file.
1package com.fs.starfarer.api.util;
2
3import java.util.Random;
4
5import com.fs.starfarer.api.Global;
6
7public class Range {
8
9 public float min, max, range;
10
16
17 public float rollFloat(Random random) {
18 if (random == null) random = Misc.random;
19 return min + random.nextFloat() * range;
20 }
21 public int rollInt(Random random) {
22 if (random == null) random = Misc.random;
23 return (int) min + random.nextInt((int) range + 1);
24 }
25
26 public float interpFloat(float t) {
27 return min + range * t;
28 }
29
30 public int interpInt(float t) {
31 return (int) min + (int) Math.round(t * range);
32 }
33}
static SettingsAPI getSettings()
Definition Global.java:51
int rollInt(Random random)
Definition Range.java:21
float rollFloat(Random random)
Definition Range.java:17
Range(String settingsKey)
Definition Range.java:11
float getFloatFromArray(String key, int index)