Class NatFloat
- Namespace
- Vintagestory.API.MathTools
- Assembly
- VintagestoryAPI.dll
A more natural random number generator (nature usually doesn't grow by the exact same numbers nor does it completely randomly)
public class NatFloat
- Inheritance
-
NatFloat
- Inherited Members
- Extension Methods
Examples
"quantity": {
"dist": "strongerinvexp",
"avg": 6,
"var": 4
}
"quantity": {
"avg": 4,
"var": 2
}
Constructors
NatFloat(float, float, EnumDistribution)
public NatFloat(float averagevalue, float variance, EnumDistribution distribution)
Parameters
averagevalue
floatvariance
floatdistribution
EnumDistribution
Fields
avg
The average value for the random float.
public float avg
Field Value
dist
The type of distribution to use that determines the commodity of values.
public EnumDistribution dist
Field Value
offset
A full offset to apply to any values returned.
public float offset
Field Value
var
The variation for the random float.
public float var
Field Value
Properties
One
Always 1
public static NatFloat One { get; }
Property Value
Zero
Always 0
public static NatFloat Zero { get; }
Property Value
Methods
ClampToRange(float)
Clamps supplied value to avg-var and avg+var
public float ClampToRange(float value)
Parameters
value
float
Returns
Clone()
public NatFloat Clone()
Returns
FromBytes(BinaryReader)
public void FromBytes(BinaryReader reader)
Parameters
reader
BinaryReader
ToBytes(BinaryWriter)
public void ToBytes(BinaryWriter writer)
Parameters
writer
BinaryWriter
addOffset(float)
public NatFloat addOffset(float value)
Parameters
value
float
Returns
copyWithOffset(float)
public NatFloat copyWithOffset(float value)
Parameters
value
float
Returns
create(EnumDistribution, float, float)
public static NatFloat create(EnumDistribution distribution, float averagevalue, float variance)
Parameters
distribution
EnumDistributionaveragevalue
floatvariance
float
Returns
createDirac(float, float)
public static NatFloat createDirac(float averagevalue, float variance)
Parameters
Returns
createFromBytes(BinaryReader)
public static NatFloat createFromBytes(BinaryReader reader)
Parameters
reader
BinaryReader
Returns
createGauss(float, float)
public static NatFloat createGauss(float averagevalue, float variance)
Parameters
Returns
createInvGauss(float, float)
public static NatFloat createInvGauss(float averagevalue, float variance)
Parameters
Returns
createInvexp(float, float)
public static NatFloat createInvexp(float averagevalue, float variance)
Parameters
Returns
createNarrowGauss(float, float)
public static NatFloat createNarrowGauss(float averagevalue, float variance)
Parameters
Returns
createStrongInvexp(float, float)
public static NatFloat createStrongInvexp(float averagevalue, float variance)
Parameters
Returns
createStrongerInvexp(float, float)
public static NatFloat createStrongerInvexp(float averagevalue, float variance)
Parameters
Returns
createTri(float, float)
public static NatFloat createTri(float averagevalue, float variance)
Parameters
Returns
createUniform(float, float)
public static NatFloat createUniform(float averagevalue, float variance)
Parameters
Returns
nextFloat()
public float nextFloat()
Returns
nextFloat(float)
public float nextFloat(float multiplier)
Parameters
multiplier
float
Returns
nextFloat(float, Random)
public float nextFloat(float multiplier, Random rand)
Parameters
Returns
nextFloat(float, IRandom)
public float nextFloat(float multiplier, IRandom rand)
Parameters
Returns
setOffset(float)
public NatFloat setOffset(float offset)
Parameters
offset
float