Table of Contents

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 float
variance float
distribution EnumDistribution

Fields

avg

The average value for the random float.

public float avg

Field Value

float

dist

The type of distribution to use that determines the commodity of values.

public EnumDistribution dist

Field Value

EnumDistribution

offset

A full offset to apply to any values returned.

public float offset

Field Value

float

var

The variation for the random float.

public float var

Field Value

float

Properties

One

Always 1

public static NatFloat One { get; }

Property Value

NatFloat

Zero

Always 0

public static NatFloat Zero { get; }

Property Value

NatFloat

Methods

ClampToRange(float)

Clamps supplied value to avg-var and avg+var

public float ClampToRange(float value)

Parameters

value float

Returns

float

Clone()

public NatFloat Clone()

Returns

NatFloat

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

NatFloat

copyWithOffset(float)

public NatFloat copyWithOffset(float value)

Parameters

value float

Returns

NatFloat

create(EnumDistribution, float, float)

public static NatFloat create(EnumDistribution distribution, float averagevalue, float variance)

Parameters

distribution EnumDistribution
averagevalue float
variance float

Returns

NatFloat

createDirac(float, float)

public static NatFloat createDirac(float averagevalue, float variance)

Parameters

averagevalue float
variance float

Returns

NatFloat

createFromBytes(BinaryReader)

public static NatFloat createFromBytes(BinaryReader reader)

Parameters

reader BinaryReader

Returns

NatFloat

createGauss(float, float)

public static NatFloat createGauss(float averagevalue, float variance)

Parameters

averagevalue float
variance float

Returns

NatFloat

createInvGauss(float, float)

public static NatFloat createInvGauss(float averagevalue, float variance)

Parameters

averagevalue float
variance float

Returns

NatFloat

createInvexp(float, float)

public static NatFloat createInvexp(float averagevalue, float variance)

Parameters

averagevalue float
variance float

Returns

NatFloat

createNarrowGauss(float, float)

public static NatFloat createNarrowGauss(float averagevalue, float variance)

Parameters

averagevalue float
variance float

Returns

NatFloat

createStrongInvexp(float, float)

public static NatFloat createStrongInvexp(float averagevalue, float variance)

Parameters

averagevalue float
variance float

Returns

NatFloat

createStrongerInvexp(float, float)

public static NatFloat createStrongerInvexp(float averagevalue, float variance)

Parameters

averagevalue float
variance float

Returns

NatFloat

createTri(float, float)

public static NatFloat createTri(float averagevalue, float variance)

Parameters

averagevalue float
variance float

Returns

NatFloat

createUniform(float, float)

public static NatFloat createUniform(float averagevalue, float variance)

Parameters

averagevalue float
variance float

Returns

NatFloat

nextFloat()

public float nextFloat()

Returns

float

nextFloat(float)

public float nextFloat(float multiplier)

Parameters

multiplier float

Returns

float

nextFloat(float, Random)

public float nextFloat(float multiplier, Random rand)

Parameters

multiplier float
rand Random

Returns

float

nextFloat(float, IRandom)

public float nextFloat(float multiplier, IRandom rand)

Parameters

multiplier float
rand IRandom

Returns

float

setOffset(float)

public NatFloat setOffset(float offset)

Parameters

offset float

Returns

NatFloat