Skip to main content

Distribution

A class in Root.Township, Alta.Caves.

Weighted random table of assets (prefabs, presets, liquids) under the hashed path Distributions. Item weights can depend on spawn attributes, and festivity groups add items while a festivity is active.

Constructors​

MemberWhat it is
Distribution()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Methods​

MemberWhat it is
T GetRandomAs<T>(AttributeSet attributes = null)Picks a random entry, weighted by the given attributes, and casts it. Null on the null chance, no match or wrong type.
T GetRandomAs<T>(Func<double> randomValue, AttributeSet attributes = null)Picks a random entry, weighted by the given attributes, and casts it. Null on the null chance, no match or wrong type.
protected override void OnValidate()Logs errors for empty entries and empty festivity groups.

Used in​

Members of other types that take, return or hold a Distribution: